In my make.conf, I have CFLAGS="-march=native -mtune=native -msahf -flto -fuse-linker-plugin -O3 -fomit-frame-pointer ..." (no ${CFLAGS} right of =, i.e. no reference to any CFLAGS defined before!) In my /etc/portage/env file for glibc, I have CFLAGS="-march=native -mtune=native -msahf -O3 -fomit-frame-pointer ... -fno-lto -fno-use-linker-plugin" With USE=custom-cflags, glibc actually uses ... -m64 -mtune=native -msahf -O3 -fomit-frame-pointer ... -fno-lto -fno-use-linker-plugin -mtune=native -msahf -flto -fuse-linker-plugin -O3 -fomit-frame-pointer ... Hence, my default make.conf CFLAGS are *appended* to the package-specific env CFLAGS, so I have no way to override my default CFLAGS (in this case, -flto) with package-specific CFLAGS (-fno-lto). (and configure fails, because glibc can't be configured with -flto). If package-specific CFLAGS are given, they must *replace* the make.conf CFLAGS, i.e. the make.conf CFLAGS must not be used in any way in this case.
I don't think glibc does anything special here. CFLAGS should be one variable (well, maybe there is CXXFLAGS as well). It's up to portage to pass final CFLAGS on. Please post your: 1. emerge --info 2. emerge --info sys-libs/glibc 3. relevant /etc/portage/env/ entries 4. relevant /etc/portage/package.env/ files
(In reply to Sergei Trofimovich from comment #1) > I don't think glibc does anything special here. CFLAGS should be one > variable (well, maybe there is CXXFLAGS as well). It's up to portage to pass > final CFLAGS on. Please post your: > 1. emerge --info > 2. emerge --info sys-libs/glibc > 3. relevant /etc/portage/env/ entries > 4. relevant /etc/portage/package.env/ files Both emerge --info attached (too long for a comment). emerge-info-glibc is for a build with USE=-custom-cflags, because building with USE=custom-cflags fails. Relevant line in /etc/portage/package.env: sys-libs/glibc debuginfo.conf Contents of /etc/portage/env/debuginfo.conf (I have removed -fno-lto and -fno-use-linker-plugin, because they don't work for glibc, and because they should not be needed at all if only these CFLAGS are used and not those in make.conf): # -flto removed, -ggdb added CFLAGS="-march=native -mtune=native -msahf -O3 -fomit-frame-pointer -fsched-pressure -fgcse-after-reload -flive-range-shrinkage -fweb -ftracer -fivopts -ftree-loop-im -frename-registers -fstdarg-opt -ggdb -maccumulate-outgoing-args -pipe" CXXFLAGS="-march=native -mtune=native -msahf -O3 -fomit-frame-pointer -fsched-pressure -fgcse-after-reload -flive-range-shrinkage -fweb -ftracer -fivopts -ftree-loop-im -frename-registers -fstdarg-opt -ggdb -maccumulate-outgoing-args -pipe" FEATURES="${FEATURES} nostrip"
Created attachment 596350 [details] emerge --info
Created attachment 596352 [details] emerge --info glibc (with -custom-cflags, hence not really relevant)
In /etc/portage/env/debuginfo.conf you override CFLAGS, CXXFLAGS but not LDFLAGS. Is it on purpose? I don't think it will yield result you seek. If after fixing LDFLAGS you still have a problem please attach the build.log. It should show any misconfiguration in a more clear way.
(In reply to Sergei Trofimovich from comment #5) > In /etc/portage/env/debuginfo.conf you override CFLAGS, CXXFLAGS but not > LDFLAGS. Is it on purpose? I don't think it will yield result you seek. No, it's not on purpose, the missing LDFLAGS are a mistake on my side. But it is irrelevant for this bug, because the configure test which fails due to -flto only checks the assembler source generated for a .c file. It does not invoke the linker and does not use LDFLAGS. I will test again and upload the logs.
(In reply to Sergei Trofimovich from comment #5) > If after fixing LDFLAGS you still have a problem please attach the > build.log. It should show any misconfiguration in a more clear way. Surprise, with LDFLAGS fixed, the problem is gone: The configure test succeeds, and the whole build succeeds. I double-checked the configure log and tried different flags: My assumption that the flags I see in the configure log are "env CFLAGS" + "make.conf CFLAGS" was wrong. The flags are actually "env CFLAGS" + "env LDFLAGS". I did not expect at all that configure includes the LDFLAGS in its CC variable for a "compile-to-asm-source" test without linking...