Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 938949 - <sys-devel/gcc-15: link failures with -fuse-ld=mold on musl
Summary: <sys-devel/gcc-15: link failures with -fuse-ld=mold on musl
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: systemwide-mold
  Show dependency tree
 
Reported: 2024-09-02 23:16 UTC by Michael Orlitzky
Modified: 2025-05-01 01:33 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Orlitzky gentoo-dev 2024-09-02 23:16:10 UTC
When trying to use mold on a (USE=hardened?) musl system, I always get link failures:

  $ gcc -fuse-ld=mold main.c 
  mimalloc: warning: unable to allocate aligned OS memory directly, fall back
  to over-allocation (size: 0x2000000 bytes, address: 0x003F7F000000, alignment: 
  0x2000000, commit: 1)
  mold: fatal: library not found: ssp_nonshared
  collect2: error: ld returned 1 exit status

(the mimalloc warning is unimportant).

If I dump the linker command, it looks like this comes from the musl-specific addition of -lssp_nonshared by 50_all_libssp_unconditionally.patch. Problem is, mold doesn't have a default search path, and gcc doesn't pass its own default path (/usr/lib, in this case) as part of the link command. So while /usr/lib/libssp_nonshared.a exists, -lssp_nonshared fails with mold.

My first guess would be to include -L${libdir} in the link command, but maybe there's a better solution.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-02 23:18:05 UTC
By remarkable coincidence, this might have been fixed on trunk a few days ago: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=3fb90724cec7e76b60fb910fa98b4ebec9912a31.
Comment 2 zyxhere 2025-03-22 13:01:39 UTC
Yep can't reproduce on hardened musl
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-05-01 01:33:20 UTC
This is fixed in 15. I may backport it.