Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 700234 - sys-libs/glibc-2.30-r2 USE=custom-cflags appends make.conf CFLAGS to environment CFLAGS
Summary: sys-libs/glibc-2.30-r2 USE=custom-cflags appends make.conf CFLAGS to environm...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-16 10:48 UTC by Klaus Kusche
Modified: 2019-11-16 16:48 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge-info,8.63 KB, text/plain)
2019-11-16 11:24 UTC, Klaus Kusche
Details
emerge --info glibc (with -custom-cflags, hence not really relevant) (emerge-info-glibc,9.69 KB, text/plain)
2019-11-16 11:25 UTC, Klaus Kusche
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Klaus Kusche 2019-11-16 10:48:28 UTC
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.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-11-16 10:57:20 UTC
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
Comment 2 Klaus Kusche 2019-11-16 11:23:23 UTC
(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"
Comment 3 Klaus Kusche 2019-11-16 11:24:28 UTC
Created attachment 596350 [details]
emerge --info
Comment 4 Klaus Kusche 2019-11-16 11:25:24 UTC
Created attachment 596352 [details]
emerge --info glibc (with -custom-cflags, hence not really relevant)
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2019-11-16 15:23:33 UTC
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.
Comment 6 Klaus Kusche 2019-11-16 16:31:37 UTC
(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.
Comment 7 Klaus Kusche 2019-11-16 16:48:56 UTC
(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...