-
Notifications
You must be signed in to change notification settings - Fork 30
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
Segfault while compiling rustc_codegen_spirv
#29
Comments
Here's how far I got with
|
It builds in |
I have the same issue, |
Interesting, CI only appears to check x86_64 on Mac:
Though the docs say latest is arm? 🤔 And it looks like CI only uses |
I was able to update rust-gpu to Many of the tests fail with hacks to get around the |
@eddyb found the cause:
|
Likely culprit: llvm/llvm-project@70579c9 This leaves Feb 14th - May 20th as the range with the bug, i.e. between: Looking at the report (rust-lang/rust#125053), it is weirdly specific. I wonder if it's in code we control.
@schell if you have the time, it might be useful to try to add |
Found a relatively low-effort way to inject $ echo '"$@" || (lldb -b -o "process launch" -- "$@" && exit 99)' > wrapper.sh
$ chmod +x wrapper.sh
$ RUSTC_WRAPPER=./wrapper.sh cargo rustc -p rustc_codegen_spirv --no-default-features --features use-installed-tools -- -C save-temps
Compiling rustc_codegen_spirv v0.9.0 (/Users/eddyb/Code/rust-gpu/crates/rustc_codegen_spirv)
/Users/eddyb/Code/rust-gpu/./wrapper.sh: line 1: 12630 Segmentation fault: 11 "$@"
(lldb) target create "/Users/eddyb/.rustup/toolchains/nightly-2024-04-24-aarch64-apple-darwin/bin/rustc"
Current executable set to '/Users/eddyb/.rustup/toolchains/nightly-2024-04-24-aarch64-apple-darwin/bin/rustc' (arm64).
(lldb) settings set -- target.run-args "--crate-name" "rustc_codegen_spirv" "--edition=2021" "crates/rustc_codegen_spirv/src/lib.rs" "--error-format=json" "--json=diagnostic-rendered-ansi,artifacts,future-incompat" "--diagnostic-width=147" "--crate-type" "dylib" "--emit=dep-info,link" "-C" "embed-bitcode=no" "-C" "debuginfo=2" "-C" "split-debuginfo=unpacked" "-C" "save-temps" "--cfg" "feature=\"use-installed-tools\"" "-C" "metadata=d3f81d8f7c25b8cf" "--out-dir" "/Users/eddyb/Code/rust-gpu/target/debug/deps" "-C" "incremental=/Users/eddyb/Code/rust-gpu/target/debug/incremental" "-L" "dependency=/Users/eddyb/Code/rust-gpu/target/debug/deps" "--extern" "ar=/Users/eddyb/Code/rust-gpu/target/debug/deps/libar-e3ad7146ff683a59.rlib" "--extern" "either=/Users/eddyb/Code/rust-gpu/target/debug/deps/libeither-b182a76c8248f318.rlib" "--extern" "hashbrown=/Users/eddyb/Code/rust-gpu/target/debug/deps/libhashbrown-d17b05ac8765534d.rlib" "--extern" "indexmap=/Users/eddyb/Code/rust-gpu/target/debug/deps/libindexmap-5721173ffd4b737f.rlib" "--extern" "itertools=/Users/eddyb/Code/rust-gpu/target/debug/deps/libitertools-91ee06ba4bd713a5.rlib" "--extern" "lazy_static=/Users/eddyb/Code/rust-gpu/target/debug/deps/liblazy_static-4bc53d643ec30e40.rlib" "--extern" "libc=/Users/eddyb/Code/rust-gpu/target/debug/deps/liblibc-1fb46c3556945141.rlib" "--extern" "num_traits=/Users/eddyb/Code/rust-gpu/target/debug/deps/libnum_traits-893caca608ed540b.rlib" "--extern" "once_cell=/Users/eddyb/Code/rust-gpu/target/debug/deps/libonce_cell-e9b1da7b0201a63a.rlib" "--extern" "regex=/Users/eddyb/Code/rust-gpu/target/debug/deps/libregex-b32f0d5f03e3e84d.rlib" "--extern" "rspirv=/Users/eddyb/Code/rust-gpu/target/debug/deps/librspirv-99fce9813432e2d2.rlib" "--extern" "rustc_demangle=/Users/eddyb/Code/rust-gpu/target/debug/deps/librustc_demangle-61ad1dd711dcb489.rlib" "--extern" "rustc_codegen_spirv_types=/Users/eddyb/Code/rust-gpu/target/debug/deps/librustc_codegen_spirv_types-b835e0468acc55e4.rlib" "--extern" "sanitize_filename=/Users/eddyb/Code/rust-gpu/target/debug/deps/libsanitize_filename-86f3198c840fea75.rlib" "--extern" "smallvec=/Users/eddyb/Code/rust-gpu/target/debug/deps/libsmallvec-503084d070b4a84a.rlib" "--extern" "spirt=/Users/eddyb/Code/rust-gpu/target/debug/deps/libspirt-ce67463698cb406c.rlib" "--extern" "spirv_tools=/Users/eddyb/Code/rust-gpu/target/debug/deps/libspirv_tools-1edd2bdab4924908.rlib" "-Dunsafe_code" "-Wclippy::all" "-Wclippy::await_holding_lock" "-Wclippy::char_lit_as_u8" "-Wclippy::checked_conversions" "-Wclippy::dbg_macro" "-Wclippy::debug_assert_with_mut_call" "-Wclippy::doc_markdown" "-Wclippy::empty_enum" "-Wclippy::enum_glob_use" "-Wclippy::exit" "-Wclippy::expl_impl_clone_on_copy" "-Wclippy::explicit_deref_methods" "-Wclippy::explicit_into_iter_loop" "-Wclippy::fallible_impl_from" "-Wclippy::filter_map_next" "-Wclippy::flat_map_option" "-Wclippy::float_cmp_const" "-Wclippy::fn_params_excessive_bools" "-Wclippy::from_iter_instead_of_collect" "-Wclippy::if_let_mutex" "-Wclippy::implicit_clone" "-Wclippy::imprecise_flops" "-Wclippy::inefficient_to_string" "-Wclippy::invalid_upcast_comparisons" "-Wclippy::large_digit_groups" "-Wclippy::large_stack_arrays" "-Wclippy::large_types_passed_by_value" "-Wclippy::let_unit_value" "-Wclippy::linkedlist" "-Wclippy::lossy_float_literal" "-Wclippy::macro_use_imports" "-Wclippy::manual_ok_or" "-Wclippy::map_err_ignore" "-Wclippy::map_flatten" "-Wclippy::map_unwrap_or" "-Wclippy::match_on_vec_items" "-Wclippy::match_same_arms" "-Wclippy::match_wild_err_arm" "-Wclippy::match_wildcard_for_single_variants" "-Wclippy::mem_forget" "-Wclippy::mismatched_target_os" "-Wclippy::missing_enforced_import_renames" "-Wclippy::mut_mut" "-Wclippy::mutex_integer" "-Wclippy::needless_borrow" "-Wclippy::needless_continue" "-Wclippy::needless_for_each" "-Wclippy::option_option" "-Wclippy::path_buf_push_overwrite" "-Wclippy::ptr_as_ptr" "-Wclippy::rc_mutex" "-Wclippy::ref_option_ref" "-Wclippy::rest_pat_in_fully_bound_structs" "-Wclippy::same_functions_in_if_condition" "-Wclippy::semicolon_if_nothing_returned" "-Wclippy::single_match_else" "-Wclippy::string_add_assign" "-Wclippy::string_add" "-Wclippy::string_lit_as_bytes" "-Wclippy::string_to_string" "-Wclippy::todo" "-Wclippy::trait_duplication_in_bounds" "-Wclippy::unimplemented" "-Wclippy::unnested_or_patterns" "-Wclippy::unused_self" "-Wclippy::useless_transmute" "-Wclippy::verbose_file_reads" "-Wclippy::zero_sized_map_values" "-Wfuture_incompatible" "-Wnonstandard_style" "-Wrust_2018_idioms" "-Aunsafe_code"
(lldb) process launch
{"$message_type":"diagnostic","message":"failed to connect to jobserver from environment variable `CARGO_MAKEFLAGS=\"-j --jobserver-fds=8,9 --jobserver-auth=8,9\"`: cannot open file descriptor 8 from the jobserver environment variable value: Bad file descriptor (os error 9)","code":null,"level":"warning","spans":[],"children":[{"message":"the build environment is likely misconfigured","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: failed to connect to jobserver from environment variable `CARGO_MAKEFLAGS=\"-j --jobserver-fds=8,9 --jobserver-auth=8,9\"`: cannot open file descriptor 8 from the jobserver environment variable value: Bad file descriptor (os error 9)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: the build environment is likely misconfigured\u001b[0m\n\n"}
{"$message_type":"artifact","artifact":"/Users/eddyb/Code/rust-gpu/target/debug/deps/rustc_codegen_spirv.d","emit":"dep-info"}
Process 12653 stopped
* thread #8, name = 'opt 4q5ivfep7qt5yoow', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x000000010d2edd04 librustc_driver-ca847c7e3a88e281.dylib`llvm::AArch64RegisterBankInfo::isLoadFromFPType(llvm::MachineInstr const&) const + 212
librustc_driver-ca847c7e3a88e281.dylib`llvm::AArch64RegisterBankInfo::isLoadFromFPType:
-> 0x10d2edd04 <+212>: ldr x9, [x8]
0x10d2edd08 <+216>: ldrb w8, [x9, #0x8]
0x10d2edd0c <+220>: cmp w8, #0x10
0x10d2edd10 <+224>: ccmp x9, #0x0, #0x4, eq
Target 0: (rustc) stopped.
Process 12653 launched: '/Users/eddyb/.rustup/toolchains/nightly-2024-04-24-aarch64-apple-darwin/bin/rustc' (arm64)
error: could not compile `rustc_codegen_spirv` (lib) Then: $ env $(rustc --print=sysroot)/lib/rustlib/aarch64-apple-darwin/bin/llvm-dis \
target/debug/deps/rustc_codegen_spirv.4q5ivfep7qt5yoow.rcgu.no-opt.bc
$ rg '[^,{]( \{ )+\{\}, ' target/debug/deps/rustc_codegen_spirv.4q5ivfep7qt5yoow.rcgu.no-opt.ll
12:@_RNvNvMsh_NtNtCsbqr1HCq8ilm_12rustc_middle2ty4listINtB7_7RawListupE5empty5EMPTY = external global { {}, i64, [7 x i64], [0 x {}] }
$ cargo install rustfilt
$ rg '[^,{]( \{ )+\{\}, ' target/debug/deps/rustc_codegen_spirv.4q5ivfep7qt5yoow.rcgu.no-opt.ll | rustfilt
@<rustc_middle::ty::list::RawList<(), _>>::empty::EMPTY = external global { {}, i64, [7 x i64], [0 x {}] } (note the Now, if it is that symbol, that's bad news because it's in $ nm ~/.rustup/toolchains/nightly-2024-04-24-aarch64-apple-darwin/lib/librustc_driver-ca847c7e3a88e281.dylib \
| rg _RNvNvMsh_NtNtCsbqr1HCq8ilm_12rustc_middle2ty4listINtB7_7RawListupE5empty5EMPTY
000000000506c680 S __RNvNvMsh_NtNtCsbqr1HCq8ilm_12rustc_middle2ty4listINtB7_7RawListupE5empty5EMPTY Does this mean nobody on M1 could've contributed to EDIT: the real culprit is a load from that global variable: $ rg 'load.*@_RNvNvMsh_NtNtCsbqr1HCq8ilm_12rustc_middle2ty4listINtB7_7RawListupE5empty5EMPTY' target/debug/deps/rustc_codegen_spirv.4q5ivfep7qt5yoow.rcgu.ll
17832: %119 = load i64, ptr @_RNvNvMsh_NtNtCsbqr1HCq8ilm_12rustc_middle2ty4listINtB7_7RawListupE5empty5EMPTY, align 8, !dbg !68816 (not sure yet if we can avoid it, but optimizations simply replace it with |
We have two options to deal with this:
|
Expected Behaviour
cargo build
should finish without error.Example & Steps To Reproduce
Run
cargo build
after a clean clone of the repo.System Info
Output
The text was updated successfully, but these errors were encountered: