[Bug bootstrap/60160] Building with -flto in CFLAGS_FOR_TARGET / CXXFLAGS_FOR_TARGET
a.heider at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Feb 2 08:39:10 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60160
Andre Heider <a.heider at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |a.heider at gmail dot com
--- Comment #8 from Andre Heider <a.heider at gmail dot com> ---
I tried this too, and so far I ran into this build failure:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108630
With --enable-symvers=no as a workaround the build succeeds with a shared
libstdc++.
If I build the target's toolchain libraries with LTO (using
{C,CXX,LD}FLAGS_FOR_TARGET), some userland apps fail to link with mold:
mold: error: undefined symbol: __EH_FRAME_BEGIN__.lto_priv.0
Where as bfd links without errors.
As per this bug's description "1. crtstuff.c: perhaps it'd be better to compile
it with -fno-lto." I tried this patch:
diff -ur a/libgcc/Makefile.in b/libgcc/Makefile.in
--- a/libgcc/Makefile.in 2022-08-19 10:09:54.664689148 +0200
+++ b/libgcc/Makefile.in 2023-02-01 21:56:50.561528520 +0100
@@ -301,7 +301,7 @@
CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
$(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
-fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
- -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
+ -fbuilding-libgcc -fno-stack-protector -fno-lto
$(FORCE_EXPLICIT_EH_REGISTRY) \
$(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY)
And then the mold linker can build the userland apps in question too.
I only saw this later, but that's one hunk of the patch in comment #4. Is that
patch correct and worth commiting?
More information about the Gcc-bugs
mailing list