Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 883451

Summary: sys-libs/compiler-rt[clang] sys-libs/compiler-rt-sanitizers[clang] sys-libs/libcxx[clang] sys-libs/libcxxabi[clang] sys-libs/llvm-libunwind[clang] strips -unwindlib=libunwind
Product: Gentoo Linux Reporter: unhappy-ending <unhappy-ending>
Component: Current packagesAssignee: LLVM support project <llvm>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=881579
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: libcxxabi example stripping flags
libcxxabi example bypassing flag stripping

Description unhappy-ending 2022-11-28 18:41:39 UTC
When using the clang USE flag, portage will strip out -unwindlib=libunwind which causes linking error ld.lld: error: undefined symbol: _Unwind_Resume.

Default behavior outputs the following in the build log:

-- <<< Gentoo configuration >>>
Build type      RelWithDebInfo
Install path    /usr
Compiler flags:
C               -march=native -O2 -pipe -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-comment -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections
C++             -march=native -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color
Linker flags:
Executable      -fuse-ld=lld -rtlib=compiler-rt -Wl,--color-diagnostics
Module          -fuse-ld=lld -rtlib=compiler-rt -Wl,-z,nodelete -Wl,--color-diagnostics
Shared          -fuse-ld=lld -rtlib=compiler-rt -Wl,-z,defs -Wl,-z,nodelete -Wl,--color-diagnostics

Adding _FLAG_O_MATIC_ECLASS=1 to workaround the issue shows:

-- <<< Gentoo configuration >>>
Build type      RelWithDebInfo
Install path    /usr
Compiler flags:
C               -march=native -O2 -pipe -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-comment -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections
C++             -march=native -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color
Linker flags:
Executable      -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--color-diagnostics
Module          -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,-z,nodelete -Wl,--color-diagnostics
Shared          -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,-z,defs -Wl,-z,nodelete -Wl,--color-diagnostics


Reproducible: Always

Steps to Reproduce:
1. Compile the LLVM toolchain
2. Build libcxxabi with the clang USE flag and LDFLAGS="-rtlib=compiler-rt -unwindlib=libunwind"
3. Portage strips -unwindlib=libunwind
Actual Results:  
In LLVM 15.0.2 resulted in failure with unresolved symbols to GCC's unwinder but I can't reproduce the failure since I bootstrapped the toolchain circa 15.0.2.

Expected Results:  
Success with resolved symbols to LLVM's unwinder

Behavior still persists, but no build failures since bootstrapping. I'm assuming an initial LLVM built by GCC and then attempt to bootstrap would retain the link time failure.
Comment 1 unhappy-ending 2022-11-28 18:42:53 UTC
Created attachment 838007 [details]
libcxxabi example stripping flags

Portage strips -unwindlib=libunwind and libcxxabi fails to build.
Comment 2 unhappy-ending 2022-11-28 18:44:33 UTC
Created attachment 838009 [details]
libcxxabi example bypassing flag stripping

Bypassing the stripping results in a proper build with -unwindlib=libunwind intact.