dtolnay / dtolnay/linkme

Linker error on Windows with lld-link: relocation against symbol in discarded section

Open
#70 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
890
Forks
46
PR merge metrics
No merged PRs in 30d

Description

it actually ends up crashing lld-link, but the errors come first, so I think it's also doing something wrong.

I tried with and without `used_linker` and get the same thing either way, whereas `used_linker` fixed lld on other platforms.

The `GTESTS` here is the distributed_slice, in the `rust_gtest_interop` crate.

```
[2/2] LINK rust_gtest_interop_unittests.exe rust_gtest_interop_unittests.exe.pdb
FAILED: rust_gtest_interop_unittests.exe rust_gtest_interop_unittests.exe.pdb
..\..\third_party\llvm-build\Release+Asserts\bin\lld-link.exe "/OUT:./rust_gtest_interop_unittests.exe" /nologo -libpath:..\..\third_party\llvm-build\Release+Asserts\lib\clang\17\lib\windows /winsysroot:../../third_party/depot_tools/win_toolchain/vs_files/27370823e7 /MACHINE:X64 "/PDB:./rust_gtest_interop_unittests.exe.pdb" "@./rust_gtest_interop_unittests.exe.rsp"
lld-link: error: relocation against symbol in discarded section: _ZN18rust_gtest_interop6GTESTS12LINKME_START17h75470cf2db5c947aE
>>> referenced by librust_gtest_interop.rlib(librust_gtest_interop.rust_gtest_interop.11482080eb92b0cf-cgu.0.rcgu.o):(rust_gtest_interop::GTESTS::h78f8c0ca7ebcfebd)
>>> referenced by librust_gtest_interop.rlib(librust_gtest_interop.rust_gtest_interop.11482080eb92b0cf-cgu.0.rcgu.o):(__declspec(dllimport) rust_gtest_interop::GTESTS::LINKME_START::h75470cf2db5c947a)

lld-link: error: relocation against symbol in discarded section: _ZN18rust_gtest_interop6GTESTS11LINKME_STOP17h3f94993507f6c1d0E
>>> referenced by librust_gtest_interop.rlib(librust_gtest_interop.rust_gtest_interop.11482080eb92b0cf-cgu.0.rcgu.o):(rust_gtest_interop::GTESTS::h78f8c0ca7ebcfebd)
>>> referenced by librust_gtest_interop.rlib(librust_gtest_interop.rust_gtest_interop.11482080eb92b0cf-cgu.0.rcgu.o):(__declspec(dllimport) rust_gtest_interop::GTESTS::LINKME_STOP::h3f94993507f6c1d0)
```

This should be reproducible on Windows outside of Chromium with `--target=x86_64-pc-windows-msvc -Clinker=clang-cl -Clink-arg=-fuse-ld=lld`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.