linker failure when using ASAN in a project with inventory on macOS
- Dominant language
- Rust
- Stars
- 1.3k
- Forks
- 59
- PR merge metrics
- No merged PRs in 30d
Description
Address sanitizer instrumentation causes linker failures on macos, when building a project with ASAN if inventory is used.
Note: So far I have only tested this on macOS, so I'm not sure if this affects other platforms too or not.
Error:
```
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "/Users/jschwender/Dev/servo/target/aarch64-apple-darwin/debug/deps/rustcZlEnU0/symbols.o" "-Wl,-rpath,/lib/rustlib/aarch64-apple-darwin/lib" "-lrustc-nightly_rt.asan" "<12 object files omitted>" "/Users/jschwender/Dev/servo/target/aarch64-apple-darwin/debug/deps/{libpanic_unwind-e2cbe8a37bf8031d,libinventory-eb75aedd0a5e10b3,libstd-a905e430b68cd1eb,libobject-063f8701cb9da335,libmemchr-af83b2092bd01733,libaddr2line-6a77301e61ece6e7,libgimli-9c44d6d37bcaf012,libcfg_if-525f1fc3152666cb,librustc_demangle-5003910a324fd2b2,libstd_detect-6374965ea5a4209f,libhashbrown-bd83babaeedf7ad2,librustc_std_workspace_alloc-7605b59b0554276b,libminiz_oxide-dfa5f37a9f9b6cd5,libadler2-338aea64e3e9747a,libunwind-6c9639723d1b68fe,liblibc-1caab95a0d8c0c5a,librustc_std_workspace_core-9006be5192f25403,liballoc-f895105505615930,libcore-70bc5bc7d3a78b09,libcompiler_builtins-a822e9e3e666f863}.rlib" "-lSystem" "-lc" "-lm" "-arch" "arm64" "-mmacosx-version-min=11.0.0" "-L" "/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/jschwender/Dev/servo/target/aarch64-apple-darwin/debug/deps/inventory_asan_reproducer-435ea13176d07177" "-Wl,-dead_strip" "-nodefaultlibs"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: ld: initializer pointer has no target in '/Users/jschwender/Dev/servo/target/aarch64-apple-darwin/debug/deps/inventory_asan_reproducer-435ea13176d07177.1olrms82pacaq7h911owi7jfn.0vwfdr0.rcgu.o'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
Minimum reproducer
main.rs:
```rust
struct Plugin(&'static str);
inventory::collect!(Plugin);
inventory::submit! {
Plugin("hello")
}
fn main() {
for plugin in inventory::iter:: {
std::hint::black_box(plugin.0);
}
}
```
Cargo.toml
```toml
[package]
name = "inventory-asan-reproducer"
version = "0.1.0"
edition = "2024"
[dependencies]
inventory = "0.3.24"
```
build command:
```sh
RUSTFLAGS="-Zsanitizer=address -C force-frame-pointers=yes" \
cargo +nightly build -Zbuild-std --target aarch64-apple-darwin
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.