FreeBASIC OpenBSD package

For other topics related to the FreeBASIC project or its community.
ibara
Posts: 7
Joined: Oct 23, 2017 23:08

FreeBASIC OpenBSD package

Postby ibara » Oct 24, 2017 1:05

Apologies first and foremost if this is the wrong subsection of the forum to write this. I chose here because I saw the Mac OS X unofficial build thread here.

I am writing to let the community know that there is now a package of FreeBASIC 1.05.0 for OpenBSD. It has been committed to the official OpenBSD package repository (by me), so all our users can benefit from all your hard work.

Thanks!

http://openports.se/lang/freebasic
TeeEmCee
Posts: 259
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: FreeBASIC OpenBSD package

Postby TeeEmCee » Oct 25, 2017 10:22

Thank you! I was just looking into creating a FreeBSD portfile yesterday, and will base it off of yours.

# All they seem to support.
ONLY_FOR_ARCHS = amd64 i386


arm and aarch64 targets are supported. I'm not really clear how different ARM CPUs and ABIs are handled (fbc only understands the names armv6, armv7a, arm, aarch64, which is rather weird), but since it compiles to C rather than assembly, fbc shouldn't be exposed to those details anyway... hopefully. It's kind of messy.

I see you worked around the missing headers by doing a search-replace for __FB_LINUX__ with __FB_OPENBSD__. I think that's reasonable (I used the same workaround), though of course will sometimes be broken. In the rare case that someone actually depends on something really system-specific in there. Which is probably never.

Code: Select all

# Can't use upstream; no OpenBSD bootstrap.


Unfortunately. OpenBSD and other targets ought to be added to the official bootstrap package.
See also my comments at https://github.com/freebasic/fbc/issues ... -334758862

Many of your fixes should be incorporated back into fbc, for anyone wishing to compile for OpenBSD from source. But I don't understand all of the changes.

Why should egcc be used instead of gcc? Should it always be?
And why default to att asm syntax instead of intel? What assembler is used with gcc on OpenBSD, gas provided with gcc, or a native BSD one, or a BSD fork of gas (like Apple used)? I know that most assemblers aside from true FSF gas have broken or missing support for intel syntax.

Why was overriding the prefix like that necessary? fbc defaults to using the parent of the directory containing the fbc binary as the prefix. However on openbsd, that path is determined by looking at argv[0], while on most other systems the OS is queried for the true path (see rtlib/openbsd/sys_getexepath.c).
Anyway, even if autodetection doesn't work, why not use the ENABLE_PREFIX makefile flag to set a different prefix?

Code: Select all

+ALLCFLAGS += -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables

Isn't this redundant, because these flags are in CFLAGS, and later on "ALLCFLAGS += $(CFLAGS)"? I see they're missing from BOOTSTRAP_CFLAGS, though.
ibara
Posts: 7
Joined: Oct 23, 2017 23:08

Re: FreeBASIC OpenBSD package

Postby ibara » Oct 25, 2017 15:03

TeeEmCee wrote:Thank you! I was just looking into creating a FreeBSD portfile yesterday, and will base it off of yours.

I have no idea if that's a good idea. FreeBSD ports are not OpenBSD ports; I'm sure FreeBSD has different expectations.

TeeEmCee wrote:arm and aarch64 targets are supported. I'm not really clear how different ARM CPUs and ABIs are handled (fbc only understands the names armv6, armv7a, arm, aarch64, which is rather weird), but since it compiles to C rather than assembly, fbc shouldn't be exposed to those details anyway... hopefully. It's kind of messy.

Then perhaps upstream would consider changing this line, displayed prominently on the freebasic.net frontpage:
FreeBASIC.net frontpage wrote:The compiler, fbc, currently supports building for i386-based architectures on the DOS, Linux, Windows and Xbox platforms.


TeeEmCee wrote:I see you worked around the missing headers by doing a search-replace for __FB_LINUX__ with __FB_OPENBSD__. I think that's reasonable (I used the same workaround), though of course will sometimes be broken. In the rare case that someone actually depends on something really system-specific in there. Which is probably never.

Isn't that exactly the point of having FreeBASIC in more package repositories? So that if this "rare case" ever occurs, people will use it and test it and discover it's broken and then file bug reports/pull requests?

TeeEmCee wrote:Unfortunately. OpenBSD and other targets ought to be added to the official bootstrap package.
See also my comments at https://github.com/freebasic/fbc/issues ... -334758862

*shrug*
Generating a bootstrap is trivially easy, actually it's a testament to them just how simple they made it. If upstream wants to add OpenBSD as a target, great. If not, I'm not going to lose any sleep over it.
I'd be much more appreciative if upstream added OpenBSD (or, perhaps when you're done with FreeBSD, *BSD) to their list of supported operating systems on their website frontpage and code repository. That to me speaks much more loudly than whether or not they generate bootstraps.

TeeEmCee wrote:Many of your fixes should be incorporated back into fbc, for anyone wishing to compile for OpenBSD from source. But I don't understand all of the changes.

I don't think there is anything worthwhile to upstream. They're just OpenBSD ports-specific tweaks.

TeeEmCee wrote:Why should egcc be used instead of gcc? Should it always be?
And why default to att asm syntax instead of intel? What assembler is used with gcc on OpenBSD, gas provided with gcc, or a native BSD one, or a BSD fork of gas (like Apple used)? I know that most assemblers aside from true FSF gas have broken or missing support for intel syntax.

Why was overriding the prefix like that necessary? fbc defaults to using the parent of the directory containing the fbc binary as the prefix. However on openbsd, that path is determined by looking at argv[0], while on most other systems the OS is queried for the true path (see rtlib/openbsd/sys_getexepath.c).
Anyway, even if autodetection doesn't work, why not use the ENABLE_PREFIX makefile flag to set a different prefix?

It's not my responsibility to teach you how OpenBSD works on another community's forum. That's inappropriate. Get a hold of me by email if you want to talk about these things.

Anyhow, to everyone else, sorry for the above noise. I'm happy to report a number of OpenBSD users thanked me for creating an OpenBSD package of FreeBASIC, and they're already using it. I hope our users can be helpful to all of you.
counting_pine
Site Admin
Posts: 6170
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: FreeBASIC OpenBSD package

Postby counting_pine » Oct 26, 2017 11:48

Hi ibara, welcome to the forum, and thanks for taking the time to make this package!
I personally have only really had any exposure to BSD through pfSense recently, but it seems like a potentially interesting discussion, and you're welcome to have it here if you want.

Maybe it would be worth adding a Mac/BSD subforum, if you think it will generate enough traffic. Or I could rename the Linux subforum and expand its intended scope.
marcov
Posts: 2762
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: FreeBASIC OpenBSD package

Postby marcov » Oct 26, 2017 17:50

TeeEmCee wrote:Why should egcc be used instead of gcc? Should it always be?

And why default to att asm syntax instead of intel? What assembler is used with gcc on OpenBSD, gas provided with gcc, or a native BSD one, or a BSD fork of gas (like Apple used)? I know that most assemblers aside from true FSF gas have broken or missing support for intel syntax.


The BSDs decided not to allow GPLv3 in the base of the distro. But maybe it is still installable from ports.

For compiler they went in different directions (FreeBSD went to LLVM), and binutils and gdb are fixated on old versions.

Newer GPLv3 versions will not be adapted, and most are seeking maintained alternatives to gcc with a suitable license.
ibara
Posts: 7
Joined: Oct 23, 2017 23:08

Re: FreeBASIC OpenBSD package

Postby ibara » Oct 26, 2017 22:25

marcov wrote:The BSDs decided not to allow GPLv3 in the base of the distro. But maybe it is still installable from ports.

This is exactly the reason I don't like having these types of discussions outside our own community. This statement is just wrong, because it elides all the different *BSD projects into one thing. And if left unchecked, it sows FUD into our community. We're not Linux; all the BSDs are separate operating systems with separate goals and choices. The fact of the matter is that both NetBSD and DragonFly BSD have GPLv3 licensed versions of gcc and binutils and gdb in their code repositories available as in-base compilers.

FreeBSD and OpenBSD do not do this, as they have opted to go the route of LLVM+clang+lld+lldb as their primary toolchain. However, all the BSDs have GPLv3 licensed versions of gcc in their respective package repositories which are maintained and easily obtainable, and often we work with upstream to get patches and fixes in. On OpenBSD, this compiler happens to be named egcc, as to not conflict with some architectures that have not or cannot make the switch to the LLVM toolchain (the Motorola 88000 architecture comes to mind as one such cannot), which then have an in-base compiler named gcc.

marcov wrote:Newer GPLv3 versions will not be adapted, and most are seeking maintained alternatives to gcc with a suitable license.

I don't go around spreading misinformation about your projects. I kindly ask that you cease doing so about mine.
ibara
Posts: 7
Joined: Oct 23, 2017 23:08

Re: FreeBASIC OpenBSD package

Postby ibara » Oct 26, 2017 22:32

counting_pine wrote:Hi ibara, welcome to the forum, and thanks for taking the time to make this package!

Thanks! You're welcome. But you should really be thanking our users, who alerted me to FreeBASIC because they wanted to use it on OpenBSD:
http://daemonforums.org/showthread.php?t=10141

counting_pine wrote:I personally have only really had any exposure to BSD through pfSense recently, but it seems like a potentially interesting discussion, and you're welcome to have it here if you want.

Maybe it would be worth adding a Mac/BSD subforum, if you think it will generate enough traffic. Or I could rename the Linux subforum and expand its intended scope.

Thanks. I'm not sure if a Mac/BSD subforum would garner enough traffic to be worthwhile. We can probably happily stick to the Linux(/Unix) subforum.

The thing that is salient to me, like I said an earlier post, is that upstream recognition that we made the effort to work with you and be helpful. Oftentimes that comes in the addition of *BSD to the "supported platforms" list. And I'm happy to work with you to get at least OpenBSD to a point where you would feel comfortable enough to make that claim.
caseih
Posts: 1369
Joined: Feb 26, 2007 5:32

Re: FreeBASIC OpenBSD package

Postby caseih » Oct 26, 2017 23:16

ibara wrote:
marcov wrote:Newer GPLv3 versions will not be adapted, and most are seeking maintained alternatives to gcc with a suitable license.

I don't go around spreading misinformation about your projects. I kindly ask that you cease doing so about mine.

What are you referring to? Marcov wasn't spreading misinformation about your projects. In fact he wasn't even talking about your projects at all. He was speaking about the various BSD operating systems. And what he said is exactly correct. What's wrong about saying that? I think you misread what he said.
ibara
Posts: 7
Joined: Oct 23, 2017 23:08

Re: FreeBASIC OpenBSD package

Postby ibara » Oct 26, 2017 23:30

caseih wrote:
ibara wrote:
marcov wrote:Newer GPLv3 versions will not be adapted, and most are seeking maintained alternatives to gcc with a suitable license.

I don't go around spreading misinformation about your projects. I kindly ask that you cease doing so about mine.

What are you referring to? Marcov wasn't spreading misinformation about your projects. In fact he wasn't even talking about your projects at all. He was speaking about the various BSD operating systems. And what he said is exactly correct. What's wrong about saying that? I think you misread what he said.

It is not correct. GPLv3 versions of gcc are being adapted into all the BSDs. Including, for half of the BSDs, directly into their base code repositories.
caseih
Posts: 1369
Joined: Feb 26, 2007 5:32

Re: FreeBASIC OpenBSD package

Postby caseih » Oct 27, 2017 0:11

I see. That contradicts what I read over the last few years then. Back in 2012, for example, FreeBSD deprecated GCC in favor of Clang. As far as I know FreeBSD is currently built by CLANG/LLVM, except where that's not possible. This is wrong?
ibara
Posts: 7
Joined: Oct 23, 2017 23:08

Re: FreeBASIC OpenBSD package

Postby ibara » Oct 27, 2017 2:39

caseih wrote:I see. That contradicts what I read over the last few years then. Back in 2012, for example, FreeBSD deprecated GCC in favor of Clang. As far as I know FreeBSD is currently built by CLANG/LLVM, except where that's not possible. This is wrong?

For FreeBSD and OpenBSD, it is correct that LLVM+clang are the new default, in-base compilers. But you cannot say "FreeBSD is doing x, therefore *BSD is doing x." The BSDs are not like Linux. And there is not one *BSD. There are four main projects (FreeBSD, OpenBSD, NetBSD, DragonFly BSD). Each are their own, different, independent operating system with different kernels, userlands, package repositories, developers, etc. They happen to have the same historical origin (BSD from UC Berkeley) and happen to share code occasionally and even share a meta-community of users. But you have to treat each *BSD in technical respects in relation to each other as you would treat Mac OS X in relation to Linux. You certainly can't run binaries compiled for one *BSD on another!

However, just because LLVM+clang are the in-base compilers for FreeBSD and OpenBSD does not mean that gcc is being actively shunned, or not being adapted (adopted?), by either FreeBSD or OpenBSD. It just means you have to go to the package repository to get it, just like you would have to go to the package repository to get gcc on Debian (for example). In all the *BSD package repositories, you will find up-to-date, GPLv3 licensed versions of gcc (and gdb and, with the exception of OpenBSD, binutils) ready to be installed and used. And if you happen to be a NetBSD or DragonFly BSD user, you will find an up-to-date, GPLv3 licensed version of gcc and gdb and binutils right there in the base install and can skip the package repository step.

However, and especially with this thread being (in theory, if not in practice) about the announcement of an OpenBSD package of FreeBASIC (and hopefully in the future, announcements of the package being kept up-to-date with upstream), discussions of technical decisions that any of the BSDs make seem rather off-topic. Those decisions, especially decisions made by other operating systems that are not OpenBSD, don't affect the availability or usability of the OpenBSD package of FreeBASIC. I'm happy to discuss those topics elsewhere, such as by email or a *BSD-centered forum, or even in a new thread, preferably in the Linux(/Unix) section of this forum. I am also not fond of discussing the technical decisions behind the creation of the package (which is what I think might have caused this whirlwind) in an announcement thread. I wouldn't like it if someone showed up in a *BSD-centered forum and started wasting other people's time with long-winded discussions of the intricate technical details of FreeBASIC (just for example, no offense meant). And I take that tact when I am the newcomer into someone else's community (like this one). But since a moderator already said go for it, I'll be happy to discuss those things if someone would like to open a new thread about the technical details about how to make packages for FreeBASIC so we can all benefit from that discussion, whether you're making a package for OpenBSD or another *BSD or a Linux or Homebrew for Mac OS X or Haiku or any other OS.

But perhaps I am a radical, and believe that one thread should serve one purpose. And other threads should serve other purposes.
marcov
Posts: 2762
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: FreeBASIC OpenBSD package

Postby marcov » Oct 27, 2017 11:22

ibara wrote:This is exactly the reason I don't like having these types of discussions outside our own community. This statement is just wrong, because it elides all the different *BSD projects into one thing. And if left unchecked, it sows FUD into our community. We're not Linux; all the BSDs are separate operating systems with separate goals and choices. The fact of the matter is that both NetBSD and DragonFly BSD have GPLv3 licensed versions of gcc and binutils and gdb in their code repositories available as in-base compilers.


This is exactly why this is a bad idea. At least give some outlook, so that people are not left to wonder when OpenBSD will adopt new as and gcc in base/by default.
If you think new versions in ports are the way to go, say so and say that is the difference between gcc and egcc, and clarify (g)as.

I only stepped in with a global outlook to fix that. Leaving it vague only increases confusion. If you want to avoid discussion, describe it as it is, whatever your opinion about the reasons.

FreeBSD and OpenBSD do not do this, as they have opted to go the route of LLVM+clang+lld+lldb as their primary toolchain.


I was mostly speaking from FreeBSD experience, and knew it from OpenBSD. I never used dragonfly much, but of course knew FreeBSD4 well.

However, all the BSDs have GPLv3 licensed versions of gcc in their respective package repositories which are maintained and easily obtainable, and often we work with upstream to get patches and fixes in.


Which I already noted was probably the case.

I don't go around spreading misinformation about your projects. I kindly ask that you cease doing so about mine.


So you own the BSD projects now? I didn't get that memo.

p.s. if you don't want people to comment, don't use public discussion lists/forums.
ibara
Posts: 7
Joined: Oct 23, 2017 23:08

Re: FreeBASIC OpenBSD package

Postby ibara » Oct 27, 2017 13:52

At least the block button still works.
TeeEmCee
Posts: 259
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: FreeBASIC OpenBSD package

Postby TeeEmCee » Oct 27, 2017 15:17

OK, I created a new thread for discussing the porting details. Better to discuss in the open rather than email, as there are other people working on related FB ports like Mac and FreeBSD, aside from you and I.

FB does intend to officially support OpenBSD. The fact that OpenBSD and other OSes aren't usually listed as one of the platforms supported by FB is because the ports aren't really finished, so don't actually work, as you noticed, even though they're really close to working. It seems a little dishonest to say platform X is supported when it can't be used and probably noone has ever run FB on it. But now, OpenBSD could be listed as supported even though it's via a 3rd-party package, and upstream FB is still broken. I suggest that that incredibly out-of-date description on the FB homepage be changed to something like:
FreeBASIC supports Windows, DOS, Xbox, Linux and other Unix platforms. The compiler, fbc, currently supports direct code generation for i386-based architectures, and x86_64 and 32/64-bit ARM via emitting C compiled with GCC.


counting_pine wrote:Maybe it would be worth adding a Mac/BSD subforum, if you think it will generate enough traffic. Or I could rename the Linux subforum and expand its intended scope.


I'd like to see either a new subforum for all other OSes, or rename the Linux forum to include everything under the sun. (Including non-Unix? I'd like to see a Haiku port!) Many topics in the Linux forum are probably general to all Unices. However Mac issues may often be quite independent, and there are plenty of differences between BSDs and Linux.
St_W
Posts: 1470
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FreeBASIC OpenBSD package

Postby St_W » Oct 27, 2017 16:05

Nice to see that there's a OpenBSD package for FB now. Are you going to maintain that package in case new versions of FB will be released or is this intended as a proof of concept for the FB developers to help them getting started building OpenBSD packages?

Currently there are build jobs for FreeBSD x86/x64 on the CI server, maybe there should also be ones for OpenBSD. However, the jobs are mostly unmaintained as there seem to be nearly no FreeBasic users on FreeBSD and I guess there are not many FB users on OpenBSD either.

ibara wrote:At least the block button still works.
Please get off your high horse and consider that most people here do not know as much about *BSD as you do. So IMHO it's totally fine to also ask more general questions about the OpenBSD package and OpenBSD specifics here.

I had a quick look at the files available on the site you've referred to and saw that you're using your own copy of FreeBasic sources (and some patches) and building the compiler from precompiled C code. I was wondering whether there are also binary packages containing a pre-built copy of fbc instead of having to compile from (partially compiled) source?
A change you made was modifying the default inline assembler syntax. As this breaks source compatibility with existing code for x86 resp. x86_64 platforms this should probably fixed. So the question is: what are the technical reasons for not defaulting to Intel syntax?

IMHO the goal should be to integrate the changes into the compiler, that are currently implemented as patches, to allow compiling on OpenBSD more easily. Ideally there also should be a binary packages for OpenBSD generated for each official FB release.

//edit: just saw there's a new thread for porting dicussions meanwhile. Some of the questions above should probably be continued to discuss there.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest