Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 914478 - sys-devel/gcc-13.2.1 - compile with hardened profiles fails when using fully llvm based system
Summary: sys-devel/gcc-13.2.1 - compile with hardened profiles fails when using fully...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-20 23:16 UTC by Rahul Sandhu
Modified: 2024-02-18 06:28 UTC (History)
1 user (show)

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


Attachments
config.log (config.log,40.02 KB, text/x-log)
2023-09-20 23:16 UTC, Rahul Sandhu
Details
build.log (build.log.xz,201.53 KB, application/x-xz)
2023-09-20 23:16 UTC, Rahul Sandhu
Details
emerge --info sys-devel/gcc (emerge-info.log,18.79 KB, text/x-log)
2023-09-20 23:17 UTC, Rahul Sandhu
Details
make.conf (make.conf,1.77 KB, text/plain)
2023-09-20 23:17 UTC, Rahul Sandhu
Details
successful sys-devel:gcc-13.2.1_p20240113-r1:20240212-033941.log (gzip) (sys-devel:gcc-13.2.1_p20240113-r1:20240212-033941.log.gz,610.70 KB, application/gzip)
2024-02-17 09:36 UTC, Haelwenn (lanodan) Monnier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rahul Sandhu 2023-09-20 23:16:15 UTC
gcc fails to compile on a clang based system when using the hardened profile with "Bootstrap comparison failure!". After testing, I can confirm this bug on 2 different processors (Xeon E5-2698 and i3-4130). Attached is the build.log (compressed), config.log, emerge --info and make.conf of my xeon system. gcc was compiled with the following env:
CFLAGS="${CFLAGS} -ggdb3"
CXXFLAGS="${CXXFLAGS} -ggdb3"
FEATURES="${FEATURES} compressdebug installsources splitdebug -nostrip"

It should also be noted I am *not* using the clang/llvm profile. The profile being used is in my repo with these parents:
gentoo:default/linux/amd64/17.1/hardened
gentoo:targets/desktop
gentoo:targets/systemd
gentoo:features/merged-usr

Reproducible: Always

Steps to Reproduce:
1. Use a hardened systemd profile on one of the cpu's mentioned
2. Use clang as system compiler
3. emerge -auvDN1 sys-devel/gcc
Actual Results:  
Fails to compile
Comment 1 Rahul Sandhu 2023-09-20 23:16:41 UTC
Created attachment 871015 [details]
config.log
Comment 2 Rahul Sandhu 2023-09-20 23:16:55 UTC
Created attachment 871016 [details]
build.log
Comment 3 Rahul Sandhu 2023-09-20 23:17:19 UTC
Created attachment 871017 [details]
emerge --info sys-devel/gcc
Comment 4 Rahul Sandhu 2023-09-20 23:17:32 UTC
Created attachment 871018 [details]
make.conf
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-21 12:47:19 UTC
Is this the same as bug 904426 or not? Does it happen w/ USE=-cet?
Comment 6 Rahul Sandhu 2023-09-24 14:09:24 UTC
(In reply to Sam James from comment #5)
> Is this the same as bug 904426 or not? Does it happen w/ USE=-cet?

Unfortunately both of those don't seem to be the case. Same thing for both of them.
Comment 7 Rahul Sandhu 2023-12-17 05:13:05 UTC
(In reply to Sam James from comment #5)
> Is this the same as bug 904426 or not? Does it happen w/ USE=-cet?

After a bit of digging, USE=-hardened results in gcc compiling successfully.
Comment 8 Rahul Sandhu 2023-12-17 05:19:04 UTC
(In reply to Sam James from comment #5)
> Is this the same as bug 904426 or not? Does it happen w/ USE=-cet?

Also important to note that it doesn't occur before completely rebuilding my system. For context, this is normally how things goes:
- Stage3 (Normal systemd merged-usr stage3)
- Switch to hardened profile
- emerge -va1 sys-devel/gcc (happily builds with all appropriate use flags, including USE=hardened (set by hardened profile))
- emerge -va1 sys-devel/binutils sys-libs/glibc
- emerge -va sys-devel/{clang,llvm,lld} sys-libs/llvm-libunwind
- echo "sys-devel/clang-common default-lld" >> /etc/portage/package.use/sys-devel
- emerge -va1 sys-devel/clang-common
- emerge -e @world
At any point after this, gcc will no longer build and will fail with the aforementioned boostrap comparison error. Also of note is the use of thinLTO on the system:
CFLAGS="${COMMON_FLAGS} -flto=thin"
CXXFLAGS="${COMMON_FLAGS} -flto=thin"

I also use -O3 however I did test this on a -O2 box with the same result. Since I first filed the bug report I switched the the nomultilib stage + profile as well with the exact same error.
Comment 9 Rahul Sandhu 2023-12-17 06:35:09 UTC
More news. If using gcc to build with an env *and* setting USE="graphite lto" on sys-devel/gcc, it builds with USE="hardened". I used this environment to achieve these results:
CC="gcc"
CXX="g++"

AR="${CHOST}-ar"
NM="${CHOST}-nm"
RANLIB="${CHOST}-ranlib"

COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
LDFLAGS="-Wl,--as-needed"

OBJCOPY="objcopy"
OBJDUMP="objdump"
Comment 10 Haelwenn (lanodan) Monnier 2024-02-17 09:36:13 UTC
Created attachment 885212 [details]
successful sys-devel:gcc-13.2.1_p20240113-r1:20240212-033941.log (gzip)

Got this bug as well, interestingly I managed to build =sys-devel/gcc-13.2.1_p20240113-r1 on one box even after a lot of failed ones and with USE=hardened.
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-02-18 06:28:40 UTC
Can someone hitting this please upload all the bad+good objects mentioned in the error? (in separate directories for bad/good)