Possible gcc installation problem?
I am making a custom minimal toolchain builder
C3750 /projects/devchain-baremetal-2023/mybuilder# ./mybuild info all
BC success: m6811-elf, binutils v2.23, gcc v3.3.6-s12x, mini mode
BC success: m68k-elf, binutils v2.34, gcc v9.3.0, mini mode
BC success: m88k-coff, binutils v2.16.1, gcc v3.1.1, mini mode
BC success: mips-elf, binutils v2.24, gcc v9.3.0, mini mode
BC success: mips64-elf, binutils v2.24, gcc v9.3.0, mini mode
BC success: powerpc-elf, binutils v2.24, gcc v9.3.0, mini mode
BC success: powerpc-eabi, binutils v2.24, gcc v9.3.0, mini mode
BC success: arm-eabi, binutils v2.24, gcc v9.3.0, mini mode
BC success: sh2-elf, binutils v2.24, gcc v9.3.0, mini mode
BC success: riscv32-elf, binutils v2.39, gcc v9.3.0, mini mode
BC success: hppa-unknown-linux-gnu, binutils v2.24, gcc v9.3.0, mini mode
mini mode means that only these files are installed
/usr/idp/bin/$arch-addr2line
/usr/idp/bin/$arch-ar
/usr/idp/bin/$arch-as
/usr/idp/bin/$arch-cc1
/usr/idp/bin/$arch-cpp
/usr/idp/bin/$arch-gcc
/usr/idp/bin/$arch-gcov
/usr/idp/bin/$arch-ld
/usr/idp/bin/$arch-nm
/usr/idp/bin/$arch-objcopy
/usr/idp/bin/$arch-objdump
/usr/idp/bin/$arch-protoize
/usr/idp/bin/$arch-ranlib
/usr/idp/bin/$arch-readelf
/usr/idp/bin/$arch-size
/usr/idp/bin/$arch-strings
/usr/idp/bin/$arch-strip
/usr/idp/bin/$arch-unprotoize
The binutils and gcc sources have been hacked and patched to have cc1 in the wished place.
All the minimal (gcc -S, gcc -c, link with minimal link script) test-benches pass
C3750 /projects/devchain-baremetal-2023/mybuilder test all
testing m6811-elf-gcc ... success
testing m68k-elf-gcc ... success
testing m88k-coff-gcc ... success
testing mips-elf-gcc ... success
testing mips64-elf-gcc ... success
testing powerpc-elf-gcc ... success
testing powerpc-eabi-gcc ... success
testing arm-eabi-gcc ... success
testing sh2-elf-gcc ... success
testing riscv32-elf-gcc ... success
testing hppa-unknown-linux-gnu-gcc ... success
Essentially this stuff is able to compile a simple bootloader written in C, but not a complex project like an Operating System.
I still have to understand the above error, because, essentially, -fuse-linker-plugin "should be" no longer necessary.
These differences are subtle. First, understand what -flto actually does. It essentially creates an output that can be optimized later (at "link-time").
What -fwhole-program does is assumes "that the current compilation unit represents the whole program being compiled" whether or not that is actually the case. Therefore, GCC will assume that it knows all of the places that call a particular function. As it says, it might use more aggressive inter-procedural optimizers. I'll explain that in a bit.
Lastly, what -fuse-linker-plugin does is actually perform the optimizations at link time that would normally be done as each compilation unit is performed. So, this one is designed to pair with -flto because -flto means save enough information to do optimizations later and -fuse-linker-plugin means actually do those optimizations.
So, where do they differ? Well, as GCC doc suggests, there is no advantage in principle of using -fwhole-program because that option assumes something that you then have to ensure is true. To break it, simply define a function in one .cpp file and use it in another. You will get a linker error.
Is there any advantage to -fwhole-program? Well, if you only have one compilation unit then you can use it, but honestly, it won't be any better. I was able to get different sized executables by using equivalent programs, but when checking the actual generated machine code, they were identical. In fact, the only differences that I saw were that line numbers with debugging information were different.
(from
here, stackoverflow.com, questions#15606993)