Closed
Description
I tried this code:
git clone https://github.com/DianQK/rust-109821-reproducible.git
cd rust-109821-reproducible/stable
cargo build --release
I expected to see this happen: Build Success.
Instead, this happened: undefined reference to 'bar::add'.
Meta
rustc --version --verbose
:
rustc 1.68.2 (9eb3afe9e 2023-03-27)
binary: rustc
commit-hash: 9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0
commit-date: 2023-03-27
host: x86_64-unknown-linux-gnu
release: 1.68.2
LLVM version: 15.0.6
Error output
= note: /usr/bin/ld: /home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps/libfoo-43f9aa8deb6de355.rlib(foo-43f9aa8deb6de355.foo.dc68fc3e-cgu.0.rcgu.o): in function `foo::add':
foo.dc68fc3e-cgu.0:(.text._ZN3foo3add17h49dc1e6624cb3836E+0x3): undefined reference to `bar::add'
collect2: error: ld returned 1 exit status
Backtrace
Running `rustc --crate-name tool --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=212 --crate-type bin --emit=dep-info,link -C opt-level=1 -C lto=fat -C codegen-units=1 -C metadata=eb743437eba5f3e9 -C extra-filename=-eb743437eba5f3e9 --out-dir /home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps -L dependency=/home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps --extern foo=/home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps/libfoo-43f9aa8deb6de355.rlib`
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/home/dianqk/.rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/dianqk/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/platform-tools:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" VSLANG="1033" "cc" "-m64" "/tmp/rustckARHcS/symbols.o" "/home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps/tool-eb743437eba5f3e9.tool.5d7473d5-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps" "-L" "/home/dianqk/.rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps/libfoo-43f9aa8deb6de355.rlib" "/home/dianqk/.rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-10f041ff25bad5f3.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/dianqk/.rustup/toolchains/1.68.2-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps/tool-eb743437eba5f3e9" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
= note: /usr/bin/ld: /home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps/libfoo-43f9aa8deb6de355.rlib(foo-43f9aa8deb6de355.foo.dc68fc3e-cgu.0.rcgu.o): in function `foo::add':
foo.dc68fc3e-cgu.0:(.text._ZN3foo3add17h49dc1e6624cb3836E+0x3): undefined reference to `bar::add'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
error: could not compile `tool` due to previous error
Caused by:
process didn't exit successfully: `rustc --crate-name tool --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=212 --crate-type bin --emit=dep-info,link -C opt-level=1 -C lto=fat -C codegen-units=1 -C metadata=eb743437eba5f3e9 -C extra-filename=-eb743437eba5f3e9 --out-dir /home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps -L dependency=/home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps --extern foo=/home/dianqk/Projects/rust-109821-reproducible/stable/target/release/deps/libfoo-43f9aa8deb6de355.rlib` (exit status: 1)
I filed this because it is different from #108853. And can be reproduced in a stable version.