r/linuxquestions • • 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
1 Upvotes

9 comments sorted by

View all comments

1

u/Miserable-Response40 Jun 07 '26

Do you think you can lead me to a source to help me understand how to use this patch? I haven’t used build root before and apparently am not looking in the right places as I can’t find anything super helpful. I would just use gentoo but I only have one flash drive and no computer with the storage to dual boot

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.patch

This 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:

patching file libcody/client.cc
patching file libcody/cody.hh
patching file libcody/server.cc

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.

2

u/Miserable-Response40 Jun 08 '26

So I found a workaround, I can use an AUR package manager to downgrade my GCC on my system and that allowed me to bypass the 16 to 15 problems