Closed
Description
Background: I was trying to integrate libfoo.a
(compiled as crate-type = "staticlib"
) as a static depencency of libbar.so
library (written in C++). Turned out that bazel
was passing -whole-archive libfoo.a
to the linker, which caused problems:
Steps to reproduce
This is a slightly different scenario, but produces the same error:
touch foo.rs
rustc --crate-type staticlib foo.rs
ld -r -whole-archive libfoo.a -o foo.o
Fails with (both with ld
and ld.gold
):
libfoo.a(clzsi2.o): In function `__clzsi2':
clzsi2.c:(.text.__clzsi2+0x0): multiple definition of `__clzsi2'
libfoo.a(compiler_builtins-05f9079cfd1746c1.compiler_builtins.5xigqg70-cgu.0.rcgu.o):/cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.5/src/int/mod.rs:332: first defined here
Failing version
rustc 1.34.0-nightly (4b1e39b7b 2019-02-05)
GNU ld (GNU Binutils for Ubuntu) 2.30
GNU gold (GNU Binutils for Ubuntu 2.30) 1.15
Ubuntu 18.04
Last working versions
This scenario works without errors on stable (1.32) and beta (1.33.0-beta.6).
I don't actually understand linkers enough to even say if that's a bug or expected behaviour, but at least for me it's a regression, because a scenario that was working on stable has stopped to work on nightly.