Open AsafFisher opened 2 years ago
@rustbot label A-linkage O-musl O-linux
I believe this happens because rustc explicitly passes the crt object files to the linker rather than letting the linker select them. The later option would cause the glibc crt object files to be used on glibc based systems. I'm not sure this can be fixed without letting rustc parse -nostartfiles
, but doing so will likely go wrong in edge cases.
I tried this code:
I expected to see this happen: A static+pie binary with no main.
Instead, this happened:
Meta
rustc --version --verbose
:Backtrace
``` note: /usr/bin/ld: /workspace/dbg/target/x86_64-unknown-linux-musl/release/deps/standard_linuxgdb-b39958c4e33e1b5c.standard_linuxgdb.a819e94f-cgu.0.rcgu.o: in function `_start': standard_linuxgdb.a819e94f-cgu.0:(.text._start+0x0): multiple definition of `_start'; /home/gitpod/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/rcrt1.o:rcrt1.c:(.text+0x0): first defined here /usr/bin/ld: /home/gitpod/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/rcrt1.o: in function `__dls2': /build/musl-cross-make/build/local/x86_64-linux-musl/obj_musl/../src_musl/crt/rcrt1.c:13: undefined reference to `main' /usr/bin/ld: /build/musl-cross-make/build/local/x86_64-linux-musl/obj_musl/../src_musl/crt/rcrt1.c:13: undefined reference to `__libc_start_main' collect2: error: ld returned 1 exit status ```