Skip to content

Address sanitizer fails to link on nightly-x86_64-apple-darwin toolchain #74571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bonsairobo opened this issue Jul 20, 2020 · 2 comments · Fixed by #74793
Closed

Address sanitizer fails to link on nightly-x86_64-apple-darwin toolchain #74571

bonsairobo opened this issue Jul 20, 2020 · 2 comments · Fixed by #74793
Labels
A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug.

Comments

@bonsairobo
Copy link

I tried to build my project here with address sanitizer:

RUSTFLAGS="-Z sanitizer=address" cargo +nightly run --target x86_64-apple-darwin --bin editor

and I got a link error about a bunch of undefined symbols:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.0.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.1.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.10.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.11.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.12.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.13.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.14.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.15.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.2.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.3.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.4.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.5.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.6.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.7.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.8.rcgu.o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.9.rcgu.o" "-o" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/liblexical_core-28f3ff8c62cdf737.dylib" "-Wl,-exported_symbols_list,/var/folders/hq/9pr5dhj171b8dznlltq6h4yh00022_/T/rustcPV8Jog/list" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/lexical_core-28f3ff8c62cdf737.1mo5b0mlxxhyrlwt.rcgu.o" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs" "-L" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps" "-L" "/Users/duncan/handsome-voxels/target/debug/deps" "-L" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/libryu-7e1b0f2e9d48330a.rlib" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/libarrayvec-9cd2750906caba3e.rlib" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/libnodrop-900e3a7f2f7679f1.rlib" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/libstatic_assertions-04dbb6ec8e2f4e31.rlib" "/Users/duncan/handsome-voxels/target/x86_64-apple-darwin/debug/deps/libcfg_if-dcde3996e9a47bd5.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-473bfa6649025a67.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-8e1c1c2f3b88fa26.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-73b777ace327e6f8.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-b666c9c30cd05ed8.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-13799bdb379be2ce.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-63abd5899e0d7e6b.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-1b07ed0286619776.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-89188c3232051162.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-caece456e5f78fce.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-628a35dcde52dad2.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-a0fac8d46f97ec7a.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-ef5998790eeac756.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-3fe78a4d2924ae43.rlib" "/Users/duncan/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-e166c2d904273814.rlib" "-lSystem" "-lresolv" "-lc" "-lm"
  = note: Undefined symbols for architecture x86_64:
            "___asan_memmove", referenced from:
                core::intrinsics::copy::h982d3f2a1a608020 in lexical_core-28f3ff8c62cdf737.lexical_core.94sp2ta6-cgu.3.rcgu.o
                core::intrinsics::copy::hd2f8d6f0e2a1b9bc in libryu-7e1b0f2e9d48330a.rlib(ryu-7e1b0f2e9d48330a.ryu.364h1osy-cgu.14.rcgu.o)

...etc...

Meta

$ rustc +nightly --version
rustc 1.46.0-nightly (346aec9b0 2020-07-11)
@bonsairobo bonsairobo added the C-bug Category: This is a bug. label Jul 20, 2020
@jonas-schievink jonas-schievink added the A-sanitizers Area: Sanitizers for correctness and code quality label Jul 20, 2020
@MaulingMonkey
Copy link
Contributor

Based on this conversation in the Rust Community discord's #dev-tools channel, it sounds like this might be a matter of rustc trying to use a different version of address sanitizer than is available on the system?

Normally I'd expect some kind of error about failing to find an appropriate library, but perhaps address sanitizer involves a little too much special case magic pixie dust...?

(I could also be completely off-basis, I don't know the inner workings of address sanitizer very well)

@tmiasko
Copy link
Contributor

tmiasko commented Jul 20, 2020

Note that cc is linking a dylib and there is no sanitizer runtime on the link command line.

Probably this condition needs to be changed: https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_ssa/back/link.rs#L781-L783. It should be also possible to enable tests in src/test/run-make-fulldeps/sanitizer-*-link/Makefile afterwards (remove only-linux directive).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants