Skip to content

Issue bootstrapping x86_64-unknown-linux-musl - using -static when linking llvm dynamic library #103199

@lancethepants

Description

@lancethepants

I'm using Debian 10 trying to bootstrap x86_64-unknown-linux-musl.
https://github.com/lancethepants/rust-bootstrap-x86_64-unknown-linux-musl

I've bootstrapped other platforms using musl libc but haven't encountered this issue. Near the end of compiling llvm for the target when everything is linking I get this and other issues like this. The issue seems to be that -static is being passed to the link invocation when creating a dynamic library which is pulling in several static libraries. The -static shouldn't be in there and when I manually run the command without it it links just fine. The -static is causing the linker to want to pull in crtbeginT.o when what we really need is crtbeginS.o. -shared is also provided later on in the link, but that doesn't seem to counter the -static.

Looking through the source I'm not sure where the -static is being pulled in.
In compiler/rustc_codegen_ssa/src/back/linker.rs there is a reference to StaticDylib that invokes -static. I've tried removing that but that didn't seem to work, though I don't know if it's using the pre-compiled toolchain downloaded when bootstrapping or the newly created x86_64-unknown-linux-gnu version that is built during this bootstrap process. The x86_64-unknown-linux-gnu toolchain it creates in the bootstrap process doesn't have -static when llvm is being linked for that target, so seems like a musl thing maybe.

/opt/tomatoware/x86_64-musl-mmc/bin/x86_64-linux-g++ -fPIC -ffunction-sections -fdata-sections -fPIC -m64 -static -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG  -Wl,-Bsymbolic -static-libstdc++ -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/lance/rust-bootstrap-x86_64-unknown-linux-musl/src/rust/rust/build/x86_64-unknown-linux-musl/llvm/build/./lib  -Wl,--gc-sections  -Wl,--version-script,"/home/lance/rust-bootstrap-x86_64-unknown-linux-musl/src/rust/rust/build/x86_64-unknown-linux-musl/llvm/build/tools/remarks-shlib/Remarks.exports" -shared -Wl,-soname,libRemarks.so.14-rust-1.64.0-stable -o lib/libRemarks.so.14-rust-1.64.0-stable tools/remarks-shlib/CMakeFiles/Remarks.dir/libremarks.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMRemarks.a lib/libLLVMBitstreamReader.a lib/libLLVMSupport.a -lrt -ldl -lm lib/libLLVMDemangle.a && :
/opt/tomatoware/x86_64-musl-mmc/lib/gcc/x86_64-tomatoware-linux-musl/12.2.0/../../../../x86_64-tomatoware-linux-musl/bin/ld: /opt/tomatoware/x86_64-musl-mmc/lib/gcc/x86_64-tomatoware-linux-musl/12.2.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
/opt/tomatoware/x86_64-musl-mmc/lib/gcc/x86_64-tomatoware-linux-musl/12.2.0/../../../../x86_64-tomatoware-linux-musl/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.O-muslTarget: The musl libc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions