r/linuxquestions • u/Miserable-Response40 • Jun 06 '26
Linux From Scratch GCC Compilation Error
Hi all, I am currently trying to build Linux From Scratch using the newest book. I am getting stuck on chapter 5 where I have to compile GCC compiler. I keep getting an error when I try to make using the command: make CFLAGS="" CXXFLAGS="" LDFLAGS="" (I was getting this error before the extra arguments. I just thought that would fix it, it did not). The error I get is make: *** [Makefile:1048: all] Error 2. I am using arch Linux. My config.log file is below.
config file: https://pastebin.com/X8z6m0H0
log file (Too large for pastebin): https://ctxt.io/2/AAD4657OFA
When running make with "SHELL='sh -x'" the last few lines show as this
+ _G_arg='( cd \"$output_objdir\" && $RM \"$outputname\" && $LN_S \"../$outputname\" \"$outputname\" )'
+ case $_G_arg in
+ _G_arg='"( cd \"$output_objdir\" && $RM \"$outputname\" && $LN_S \"../$outputname\" \"$outputname\" )"'
+ func_quote_for_expand_result='"( cd \"$output_objdir\" && $RM \"$outputname\" && $LN_S \"../$outputname\" \"$outputname\" )"'
+ eval 'func_notquiet "( cd \"$output_objdir\" && $RM \"$outputname\" && $LN_S \"../$outputname\" \"$outputname\" )"'
++ func_notquiet '( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )'
++ :
++ false
++ func_echo '( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )'
++ :
++ _G_message='( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )'
++ func_echo_IFS=$' \t\n'
++ IFS=$'\n'
++ for _G_line in $_G_message
++ IFS=$' \t\n'
++ printf '%s\n' 'libtool: link: ( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )'
libtool: link: ( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )
++ IFS=$' \t\n'
++ :
+ false
+ eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )'
++ cd .libs
++ rm -f libgmp.la
++ ln -s ../libgmp.la libgmp.la
+ _G_status=0
+ test 0 -ne 0
+ exit 0
make[4]: Leaving directory '/mnt/lfs/sources/gcc-15.2.0/build/gmp'
+ test -z ''
make[3]: Leaving directory '/mnt/lfs/sources/gcc-15.2.0/build/gmp'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-15.2.0/build/gmp'
make[1]: Leaving directory '/mnt/lfs/sources/gcc-15.2.0/build'
make: *** [Makefile:1048: all] Error 2
View all comments
Show parent comment
1
u/AiwendilH Jun 08 '26 edited Jun 08 '26
First off...source code patches are often for specific versions so no guarantees that this one will apply to the gcc version the LFS book wants you to use.
From the link copy everything after " Signed-off-by: Bernd Kuhls <bernd at kuhls.net>" in a text file "Make-it-buildable-by-C-11-to-C-26.patch" (name doesn't really matter) and put that file in the directory you extracted the gcc source code to (so inside the gcc-15.2.0 or whatever-the-version-is directory)
Usually you would apply such a patch now directly to the sourcecode...but this one seems to be a patch for the "buildroot" build system so we have to do it in two steps.
First use tha patch file you saved. Go to the directory with gcc and run
patch < Make-it-buildable-by-C-11-to-C-26.patchThis will create a "0001-libcody-Make-it-buildable-by-C-11-to-C-26.patch" file in your gcc directory with the actual source code patch (That's the buildroot part that is usually not necessary...the patch from the mail creates an patch that needs to be applied. Usually the patch is already directly applied to the source code)
So now apply this patch to the source code with
patch -p1 < 0001-libcody-Make-it-buildable-by-C-11-to-C-26.patch. The "-p1" is needed to strip the "first directory" from the patch file....if you look inside the patch file it tries to change files "a/libcody/client.cc b/libcody/client.cc". The -p1 strips the leading "a" directory" which is a result of creating a patch between two different git versions.Should give you output like this:
And that's it...with some luck and if there are no other issues you can build gcc15 with gcc16 now...hopefully.
But really, you can easily avoid this by using a liveUSB with gcc15 to build the first stage of your LFS system. You only need to liveUSB until you chroot in the system...that step you can do with your normal system again as from this point on everything will be compiled with the gcc you build yourself andn ot the one from the host system anymore.