Link tests are not allowed after GCC_NO_EXECUTABLES: A possible reason
Posted: Sun Jan 19, 2025 2:46 pm
Hello OSDEVers,
This is not a question but more of an answer to a problem I had a few days ago concerning making a GCC hosted cross compiler. There are already some threads with this but in the interest of not necrobumping one/all of those, I'm making a quick post detailing my experience and why it happened.
This wasn't my first time doing this charade and I decided I wanted to get a hosted cross compiler ASAP instead of fudging the paths needed to start building ports. Me being me, I also decided to re-roll my own libc. Thus, I filled in the exact bare minimum required to get GCC compiling for my target so that I could have the hosted cross compiler working and ready and I wouldn't have to come back to it when my libc was already mature.
GCC and libgcc compiled and installed without issue once I had the needed functions implemented/prototyped. The issue came when I wanted to quickly get libcstc++ built and installed. When I ran `make all-target-libstc++-v3` (GCC 11.1.0), I got the following cryptic error message:
To say I was puzzled would be an understatement. I spent a while scratching my head and trying to figure out why it wasn't working. Perhaps it was my poor knowledge of how autoconf works but after kludging configure to not do link tests (Forcefully set gcc_no_link to no), I finally got the C compiler to just error out so I could start adding the required functions of libstdc++ as the compiler needed them (Weird workflow, I know).
I came back later and reconfigured out of curiosity once I had the needed libc functions and lo and behold, it configured fine. No kludges, no nonsense.
The reason I didn't try this first is because:
1. The wiki enrty for hosted cross compiler (https://wiki.osdev.org/Hosted_GCC_Cross-Compiler) lists the minimum requirements needed to get GCC to compile. I then later interpreted the article to imply that if GCC compiled fine, libstdc++ would compile fine too. At least for GCC 11.1.0, this is not the case. libstdc++ needs one hell of a lot more support and seems to refuse to configure unless you have that support.
2. Googling the issue led to a dead-end of Bugzilla reports and unanswered osdev.org threads. The one thread that had the answer that was correct was actually viewtopic.php?t=29983. I misconstrued the answer given by the user 'heat' as saying that I needed a libc of some sort. To make this crystal clear to the next poor soul who gets trapped by this: You need more than just a libc! You need a libc that is complete enough to compile libstdc++ to some extent (To exactly what extent, I don't know). Otherwise, it will not configure and you will get that cryptic error message. You can kludge it using the hack I listed above to get the compiler to show you what functions you need but you will need to go into the configure script and set that by hand.
This also explains why I did not encounter this charade 2 years ago. When I built my first ever hosted cross compiler, my libc was already good enough to compile libstdc++ without a hitch.
Perhaps someone could edit the wiki entry to reflect this. I am sure I'd mess up some or other standard that the wiki seeks so I'll leave it to anyone experienced to do that if they so please.
Hope this is of some use to someone.
Happy programming,
CaydendW
This is not a question but more of an answer to a problem I had a few days ago concerning making a GCC hosted cross compiler. There are already some threads with this but in the interest of not necrobumping one/all of those, I'm making a quick post detailing my experience and why it happened.
This wasn't my first time doing this charade and I decided I wanted to get a hosted cross compiler ASAP instead of fudging the paths needed to start building ports. Me being me, I also decided to re-roll my own libc. Thus, I filled in the exact bare minimum required to get GCC compiling for my target so that I could have the hosted cross compiler working and ready and I wouldn't have to come back to it when my libc was already mature.
GCC and libgcc compiled and installed without issue once I had the needed functions implemented/prototyped. The issue came when I wanted to quickly get libcstc++ built and installed. When I ran `make all-target-libstc++-v3` (GCC 11.1.0), I got the following cryptic error message:
Code: Select all
checking for shl_load... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES
make: *** [Makefile:12073: configure-target-libstc++-v3] Error 1
I came back later and reconfigured out of curiosity once I had the needed libc functions and lo and behold, it configured fine. No kludges, no nonsense.
The reason I didn't try this first is because:
1. The wiki enrty for hosted cross compiler (https://wiki.osdev.org/Hosted_GCC_Cross-Compiler) lists the minimum requirements needed to get GCC to compile. I then later interpreted the article to imply that if GCC compiled fine, libstdc++ would compile fine too. At least for GCC 11.1.0, this is not the case. libstdc++ needs one hell of a lot more support and seems to refuse to configure unless you have that support.
2. Googling the issue led to a dead-end of Bugzilla reports and unanswered osdev.org threads. The one thread that had the answer that was correct was actually viewtopic.php?t=29983. I misconstrued the answer given by the user 'heat' as saying that I needed a libc of some sort. To make this crystal clear to the next poor soul who gets trapped by this: You need more than just a libc! You need a libc that is complete enough to compile libstdc++ to some extent (To exactly what extent, I don't know). Otherwise, it will not configure and you will get that cryptic error message. You can kludge it using the hack I listed above to get the compiler to show you what functions you need but you will need to go into the configure script and set that by hand.
This also explains why I did not encounter this charade 2 years ago. When I built my first ever hosted cross compiler, my libc was already good enough to compile libstdc++ without a hitch.
Perhaps someone could edit the wiki entry to reflect this. I am sure I'd mess up some or other standard that the wiki seeks so I'll leave it to anyone experienced to do that if they so please.
Hope this is of some use to someone.
Happy programming,
CaydendW