Skip to content

mold fails to build with musl libc with undefined references to getcontext, swapcontext and makecontext #281

@stefson

Description

@stefson

hey, I tried to compile mold source code on a linux that uses musl as the libc. Its a very lean and fast alternative to the bloaty and unhealthy glibc. Here is the error, during linking:

g++-10.3.0 -DMOLD_VERSION=\"1.0.1\" -DLIBDIR="\"/usr/lib\"" -O2 -pipe -pthread -fPIE -fno-unwind-tables -fno-asynchronous-unwind-tables -std=c++20 -fno-exceptions -Wl,-O1 -Wl,--as-needed  out/compress.o out/demangle.o out/filepath.o out/hyperloglog.o out/main.o out/perf.o out/tar.o out/elf/arch-arm64.o out/elf/arch-i386.o out/elf/arch-x86-64.o out/elf/cmdline.o out/elf/gc-sections.o out/elf/icf.o out/elf/input-sections.o out/elf/linker-script.o out/elf/main.o out/elf/mapfile.o out/elf/object-file.o out/elf/output-chunks.o out/elf/output-file.o out/elf/passes.o out/elf/relocatable.o out/elf/subprocess.o out/macho/arch-arm64.o out/macho/arch-x86-64.o out/macho/cmdline.o out/macho/dead-strip.o out/macho/dumper.o out/macho/input-sections.o out/macho/main.o out/macho/mapfile.o out/macho/object-file.o out/macho/output-chunks.o out/macho/output-file.o out/macho/tapi.o out/macho/yaml.o -o mold -pthread -lz -ldl -lm -lmimalloc -ltbb -lxxhash -lrt -lcrypto
/usr/lib/gcc/aarch64-gentoo-linux-musl/10.3.0/../../../../aarch64-gentoo-linux-musl/bin/ld: /usr/lib/gcc/aarch64-gentoo-linux-musl/10.3.0/../../../../lib/libtbb.so: undefined reference to `getcontext'
/usr/lib/gcc/aarch64-gentoo-linux-musl/10.3.0/../../../../aarch64-gentoo-linux-musl/bin/ld: /usr/lib/gcc/aarch64-gentoo-linux-musl/10.3.0/../../../../lib/libtbb.so: undefined reference to `swapcontext'
/usr/lib/gcc/aarch64-gentoo-linux-musl/10.3.0/../../../../aarch64-gentoo-linux-musl/bin/ld: /usr/lib/gcc/aarch64-gentoo-linux-musl/10.3.0/../../../../lib/libtbb.so: undefined reference to `makecontext'
collect2: error: ld returned 1 exit status
make: *** [Makefile:118: mold] Error 1

mold was build using these commands:

make -j1 SYSTEM_TBB=1 SYSTEM_MIMALLOC=1 SYSTEM_XXHASH=1 STRIP=true LIBDIR=/usr/lib

do you have an idea where this is coming from? is it a bug in libtbb.so?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions