Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 917089 - sys-libs/musl-1.2.3-r8: mimalloc segfaults if built with sys-devel/mold
Summary: sys-libs/musl-1.2.3-r8: mimalloc segfaults if built with sys-devel/mold
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Matthew Smith
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: systemwide-mold
  Show dependency tree
 
Reported: 2023-11-09 20:25 UTC by hugegameartgd
Modified: 2023-11-13 02:11 UTC (History)
6 users (show)

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


Attachments
build.log (build.log,7.38 KB, text/x-log)
2023-11-09 20:32 UTC, hugegameartgd
Details
make.conf (make.conf,599 bytes, text/plain)
2023-11-09 20:33 UTC, hugegameartgd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hugegameartgd 2023-11-09 20:25:44 UTC
Compiling sys-libs/libcxx (or any c++ project) fails with clang, mold and -flto if sys-libs/musl has been built with ld.mold.

Reproducible: Always

Steps to Reproduce:
Steps to reproduce:
1. Download musl+llvm stage3 tarball
https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-musl-llvm/ (arch-chroot /mnt/gentoo)
2. emerge --sync
3. add `sys-devel/llvm binutils-plugin` to /etc/portage/package.use/custom
4. emerge -1 =sys-devel/llvm-16.0.6 --exclude=llvm:17
5. emerge -1 sys-libs/mold
6. replace /etc/portage/make.conf

COMMON_FLAGS="-O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto"
CC="clang"
CXX="clang++"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS} -stdlib=libc++"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
LDFLAGS="${COMMON_FLAGS} ${LDLIBS} -Wl,-O3 -Wl,--as-needed -Wl,--strip-debug -Wl,--undefined-version -Wl,--icf=safe -Wl,--threads=4 -Wl,--compress-debug-sections=none -fuse-ld=mold -rtlib=c>
CHOST="x86_64-gentoo-linux-musl"
ACCEPT_KEYWORDS="amd64 ~amd64"
LD="ld.mold"
LC_MESSAGES=C
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS}"
MAKEOPTS="-j4"

7. emerge -1 =sys-libs/musl-1.2.3* sys-libs/libcxx --exclude=sys-devel/llvm
Actual Results:  
-- Found assembler: /usr/lib/llvm/16/bin/x86_64-gentoo-linux-musl-clang
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/lib/llvm/16/bin/x86_64-gentoo-linux-musl-clang
-- Check for working C compiler: /usr/lib/llvm/16/bin/x86_64-gentoo-linux-musl-clang - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/usr/lib/llvm/16/bin/x86_64-gentoo-linux-musl-clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /var/tmp/portage/sys-libs/libcxx-16.0.6/work/runtimes_build-abi_x86_64.amd64/CMakeFiles/CMakeScratch/TryCompile-ankcJC
    
    Run Build Command(s):/usr/bin/ninja -v cmTC_391b2 && [1/2] /usr/lib/llvm/16/bin/x86_64-gentoo-linux-musl-clang    -O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto -MD -MT CMakeFiles/cmTC_391b2.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_391b2.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_391b2.dir/testCCompiler.c.o -c /var/tmp/portage/sys-libs/libcxx-16.0.6/work/runtimes_build-abi_x86_64.amd64/CMakeFiles/CMakeScratch/TryCompile-ankcJC/testCCompiler.c
    [2/2] : && /usr/lib/llvm/16/bin/x86_64-gentoo-linux-musl-clang -O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto -O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -Wl,-O3 -Wl,--as-needed -Wl,--strip-debug -Wl,--undefined-version -Wl,--icf=safe -Wl,--threads=4 -Wl,--compress-debug-sections=none -fuse-ld=mold -rtlib=compiler-rt -unwindlib=libunwind CMakeFiles/cmTC_391b2.dir/testCCompiler.c.o -o cmTC_391b2   && :
    FAILED: cmTC_391b2 
    : && /usr/lib/llvm/16/bin/x86_64-gentoo-linux-musl-clang -O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto -O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -Wl,-O3 -Wl,--as-needed -Wl,--strip-debug -Wl,--undefined-version -Wl,--icf=safe -Wl,--threads=4 -Wl,--compress-debug-sections=none -fuse-ld=mold -rtlib=compiler-rt -unwindlib=libunwind CMakeFiles/cmTC_391b2.dir/testCCompiler.c.o -o cmTC_391b2   && :
    mimalloc: error: mi_free: pointer does not point to a valid heap space: 0x7f1fbad089b0
    clang-16: error: unable to execute command: Segmentation fault (core dumped)
    clang-16: error: linker command failed due to signal (use -v to see invocation)
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:10 (project)


-- Configuring incomplete, errors occurred!


Expected Results:  
Compiling sys-libs/musl with ld.mold should not break mimalloc.

!!! No gcc found. You probably need to 'source /etc/profile'
!!! to update the environment of this terminal and possibly
!!! other terminals also.
Portage 3.0.51 (python 3.11.5-final-0, default/linux/amd64/17.0/musl/clang, [unavailable], musl-1.2.3-r8, 6.5.10-gentoo-dist x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-6.5.10-gentoo-dist-x86_64-Intel-R-_Core-TM-_i5-7200U_CPU_@_2.50GHz-with-libc
KiB Mem:     8003608 total,   3515028 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 09 Nov 2023 00:30:01 +0000
Head commit of repository gentoo: 0411910f6a20c1da3b37ed2fc86ab2b43ae56766
sh bash 5.1_p16-r6
ld LLD 16.0.6 (compatible with GNU linkers)
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.1_p16-r6::gentoo
dev-lang/perl:             5.38.0-r1::gentoo
dev-lang/python:           3.11.5::gentoo
dev-util/cmake:            3.26.5-r2::gentoo
dev-util/meson:            1.2.1-r1::gentoo
sys-apps/baselayout:       2.14::gentoo
sys-apps/openrc:           0.48::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/autoconf:        2.71-r6::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           16.0.6::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             16.0.6::gentoo
sys-devel/llvm:            16.0.6::gentoo
sys-devel/make:            4.4.1-r1::gentoo
sys-kernel/linux-headers:  6.1::gentoo (virtual/os-headers)
sys-libs/musl:             1.2.3-r8::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-extra-opts: 
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1

Binary Repositories:

gentoobinhost
    priority: 1
    sync-uri: https://gentoo.osuosl.org/releases/amd64/binpackages/17.1/x86-64_musl_llvm

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
ADDR2LINE="llvm-addr2line"
AR="llvm-ar"
AS="clang -c"
CBUILD="x86_64-gentoo-linux-musl"
CC="clang"
CFLAGS="-O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto"
CHOST="x86_64-gentoo-linux-musl"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CPP="clang-cpp"
CXX="clang++"
CXXFLAGS="-O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto -stdlib=libc++"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS=""
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="charset.alias /usr/share/locale/locale.alias"
LANG="C.UTF8"
LD="ld.mold"
LDFLAGS="-O2 -pipe -march=native -mtune=native -D_FORTIFY_SOURCE=3 -g0 -flto  -Wl,-O3 -Wl,--as-needed -Wl,--strip-debug -Wl,--undefined-version -Wl,--icf=safe -Wl,--threads=4 -Wl,--compress-debug-sections=none -fuse-ld=mold -rtlib=compiler-rt -unwindlib=libunwind"
LEX="flex"
MAKEOPTS="-j4"
NM="llvm-nm"
OBJCOPY="llvm-objcopy"
OBJDUMP="llvm-objdump"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
RANLIB="llvm-ranlib"
READELF="llvm-readelf"
SHELL="/bin/bash"
STRINGS="llvm-strings"
STRIP="llvm-strip"
USE="acl amd64 bzip2 clang cli crypt dri fortran iconv ipv6 libtirpc llvm-libunwind ncurses nls nptl openmp pam pcre pic readline seccomp split-usr ssl test-rust unicode xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby31" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ARFLAGS, ASFLAGS, CCLD, CONFIG_SHELL, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS, SIZE, YACC, YFLAGS

=================================================================
                        Package Settings
=================================================================

sys-libs/libcxx-16.0.6::gentoo was built with the following:
USE="(clang) (libcxxabi) static-libs -test -verify-sig"
FEATURES="distlocks qa-unresolved-soname-deps binpkg-docompress binpkg-dostrip assume-digests network-sandbox strict parallel-fetch binpkg-multi-instance merge-sync sandbox sfperms binpkg-logs unmerge-orphans userfetch userpriv preserve-libs unmerge-logs buildpkg-live ipc-sandbox fixlafiles usersync news unknown-features-warn usersandbox xattr config-protect-if-modified pid-sandbox ebuild-locks protect-owned"
Comment 1 hugegameartgd 2023-11-09 20:32:25 UTC
Created attachment 874389 [details]
build.log

build.log
Comment 2 hugegameartgd 2023-11-09 20:33:26 UTC
Created attachment 874390 [details]
make.conf
Comment 3 hugegameartgd 2023-11-09 21:33:40 UTC
Similar upstream bug report:
https://github.com/rui314/mold/issues/1071
Comment 4 hugegameartgd 2023-11-12 15:06:18 UTC
Fixed by https://github.com/rui314/mold/commit/da3f5dd4ecf4faaba466ba41c7c30ba4f8f73bfd (mold-9999.ebuild)
Comment 5 Larry the Git Cow gentoo-dev 2023-11-13 02:11:22 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2fc10cbc98bebe136012849b28f6969327d6613b

commit 2fc10cbc98bebe136012849b28f6969327d6613b
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-11-13 02:10:14 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-11-13 02:10:14 +0000

    sys-devel/mold: backport symbol interposition fix (e.g. mimalloc/musl segfault)
    
    Closes: https://bugs.gentoo.org/917089
    Signed-off-by: Sam James <sam@gentoo.org>

 ...d-2.3.2-mimalloc-visibility-interposition.patch | 495 +++++++++++++++++++++
 sys-devel/mold/mold-2.3.2-r1.ebuild                |  96 ++++
 2 files changed, 591 insertions(+)
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-13 02:11:39 UTC
(In reply to hugegameartgd from comment #3)
> Similar upstream bug report:
> https://github.com/rui314/mold/issues/1071

Thank you for persuing it upstream and getting it sorted.