I’m trying to build my own libraries in a (bare metal) 32-bit installation (works great on an old Netbook, by the way). Now, I am a bit confused about gcc and… gcc there. The system “defaults” to gcc2 (and I think I understand why), but a way more recent gcc version is also available. Just invoking gcc, link after link it points to gcc 2.95.3. However there is also gcc-x86, which points to gcc 13.3.0 (not exactly the latest, but good enough for my needs). By default there is only gfortran-x86. I can either add a link, gfortran, that points to gfortran 13.3.0. Or just add the more recent version to $PATH:
I could also modify my Makefiles slightly instead of messing with $PATH, but I prefer the same Makefiles work in both 64 and 32 bit. So I added the “correct” directory in the beginning of $PATH. That way gcc also points to gcc 13.3.0 instead of 2.95.3:
PATH=/boot/system/develop/tools/x86/bin:$PATH
With that, all my Makefiles work as expected. However I’m not sure that’s the “proper” way to do it. If two versions of gcc are supported, I assume the system already has a way to make the recent gcc version being the “default”. Am I missing something here?
There are many ways to compile in Haiku 32 while keeping the Makefile intact (same as in Haiku 64-bit). For example you can also compile with make CXX=g++-x86 or something similar. But I think setarch x86 is the most elegant, clean way.
No because I mainly work with Fortran (and C/C++ when I have to, which is the exception rather than the rule). LLVM actually has Flang for that (in fact, there are two Flangs — it’s a mess). There is also the very promising LFortran compiler (based on LLVM as well), but it’s not production-ready.
GCC’s gfortran is the only reliable Fortran compiler for Haiku right now. On GNU/Linux there are several other options (by Intel, NVidia etc), but there is no Haiku support for them. And I’m not sure they can directly compete with gfortan anyway.
It is, that’s why I used make FC=gfortran-x86 in the beginning, and it worked fine. I could even modify the Makefile (which has a Haiku section anyway) so that it detects 32-bit and sets FC accordingly, e.g.
ifeq ($(shell uname), Haiku)
ifeq ($(shell getconf LONG_MAX), 2147483647)
FC=gfortran-x86
endif
< other settings here, such as setting Haiku include and lib dirs >
endif
In GNU/Linux and BSDs I use LONG_BIT to detet 32-bit in Makefiles — which is more elegant, because getconf LONG_BIT returns 32 or 64. However LONG_BIT doesn’t seem to exist in Haiku, so LONG_MAX instead will do just fine. Still, setting architecture to x86 and leave the Makefile intact still seems better to me.