https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96752
Bug ID: 96752 Summary: -fwhopr feature - is it available in gcc 9.2.0 Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: djuki.car.kv at gmail dot com CC: marxin at gcc dot gnu.org Target Milestone: --- Created attachment 49104 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49104&action=edit Patch for LTO during building gcc in MinGW Dear GCC team, I was very curious to explore Link-Time-Optimization in a GCC and I though it can improve my project. I found that during linking I also need to provide the same option which I have used during compiling. And it makes sense. But I can't use standard LTO because my project contains C and CPP files which is compiled with different configuration flags. So Linker complains every time when I try to build my project. After that I found that instead of LTO, I can use Whole Program Optimization (-fwhopr). From my point of view, it will really solve my problem, because the compiler will do all optimization during compiling and at the end it will just link object files. Please look at the image which I found in the GCC documentation. But when I tried to compile just simple project with flag -fwhopr, the compiler complained that -fwhopr is unknown option for its. Is this feature still part of GCC? Maybe I didn't build my compiler well. The configuration which I have used is: $SRCDIR/configure --host=$host --build=$build --prefix=$prefix --target=$target --disable-nls --enable-multilib --with-multilib-list=lp64,ilp32 --enable-languages=c,c++ --disable-decimal-float --with-sysroot=$prefix --without-headers --disable-shared --disable-threads --enable-lto --enable-plugin --disable-libmudflap --disable-libssp --disable-libgomp --disable-libffi --disable-libstdcxx-pch --disable-win32-registry '--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-newlib --with-gcc --with-gnu-as --with-gnu-ld --with-gmp=$prefixlocal --with-mpfr=$prefixlocal --with-mpc=$prefixlocal --with-isl=$prefixlocal --with-zstd=$prefixlocal But before configuration, you will need to apply the patch, which you can find in attachment. This is only if you want to build it in Windows 10 using MinGW 9.2.0. On Linux Debian 10, I think everything is working as expected. I have tried to build gcc for aarch64, but I think for all other targets it is the same. Also, you have noticed I use ld.bfd instead ld.gold. Generally LTO is related to the gold linker, but I found information that BFD linker also supports LTO. I had some issues when I tried to use gold linker. I was able to compile my project, but it didn't work. I didn't have a time to investigate more in it, but I saw memory sections look different although I used the same linker script. For this reason, I have tried to use BFD linker for LTO. Thanks for considering this message and I hope you will have some solution for Whole Program Optimization option. Please let me know if I can assist any further. With best regards, M.Eng. Filip Bascarevic