Open
Description
As seen when testing #122456
I tried this code:
pub fn main() {
let f: &fn() = &((|| ()) as _);
f();
}
compiled with rustc --crate-type=bin -C prefer-dynamic=off -Clto -Zsanitizer=cfi -C target-feature=-crt-static -C codegen-units=1 -C opt-level=0
on OSX
I expected to see this happen: Builds successfully
Instead, this happened: Relocation issues:
command: RUSTC_ICE="0" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2/bin/rustc" "/Users/runner/work/rust/rust/tests/ui/sanitizer/cfi-closure-fn-ptr-cast.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/Users/runner/.cargo" "--sysroot" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/stage2" "--target=x86_64-apple-darwin" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/sanitizer/cfi-closure-fn-ptr-cast/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/Users/runner/work/rust/rust/build/x86_64-apple-darwin/native/rust-test-helpers" "-L" "/Users/runner/work/rust/rust/build/x86_64-apple-darwin/test/ui/sanitizer/cfi-closure-fn-ptr-cast/auxiliary" "--crate-type=bin" "-Cprefer-dynamic=off" "-Clto" "-Zsanitizer=cfi" "-C" "target-feature=-crt-static" "-C" "codegen-units=1" "-C" "opt-level=0"
--- stderr -------------------------------
error: unsupported symbol modifier in branch relocation
|
note: instantiated into assembly here
note: instantiated into assembly here
--> <inline asm>:1:2
|
LL | jmp __ZN4core3ops8function6FnOnce9call_once17hbd679098001308bdE.cfi@plt
error: unsupported symbol modifier in branch relocation
|
note: instantiated into assembly here
note: instantiated into assembly here
--> <inline asm>:5:1
|
LL | jmp __ZN23cfi_closure_fn_ptr_cast4main17hec6d7c750d93313aE.cfi@plt
error: aborting due to 2 previous errors
------------------------------------------
The patch being tested only adjusts labels, so this bug is about fixing actually producing CFI executables on OSX - all the previously existing tests were codegen only.
It is likely that a much smaller program (possibly anything with an indirect call? any function?) will trigger this issue without needing the FnPtrShim
, but I don't personally have a mac to test with.