Skip to content

LLVM ERROR: Not supported instr" on 'mips64-poky-linux-gnun32-gnu' target #100687

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
sundeep-kokkonda opened this issue Aug 17, 2022 · 4 comments
Closed
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-MIPS Target: MIPS processors T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sundeep-kokkonda
Copy link
Contributor

I am getting this error when compiling the rust application for mips n32 arch abi on Yocto project.

Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: Using rust targets from /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rust-targets/
| NOTE: cargo = /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot-native/usr/bin/cargo
| NOTE: rustc =
| NOTE: cargo build -v --target mips64-poky-linux-gnun32-gnu --release --manifest-path=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rustc-1.62.1-src/library/std//Cargo.toml --features 'panic-unwind backtrace'
| warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
| package:   /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rustc-1.62.1-src/src/tools/rls/racer/Cargo.toml
| workspace: /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rustc-1.62.1-src/Cargo.toml
|    Compiling core v0.0.0 (/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rustc-1.62.1-src/library/core)
|        Fresh cc v1.0.69
| warning: target json file contains unused fields: has-elf-tls
....
....
....
|      Running `rustc --crate-name rustc_demangle /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rustc-1.62.1-src/vendor/rustc-demangle/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="compiler_builtins"' --cfg 'feature="core"' --cfg 'feature="rustc-dep-of-std"' -C metadata=b0744d1bbf6f1c66 -C extra-filename=-b0744d1bbf6f1c66 --out-dir /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps --target mips64-poky-linux-gnun32-gnu -C linker=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/wrapper/target-rust-ccld -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/release/deps --extern compiler_builtins=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps/libcompiler_builtins-3cb14fed722f45eb.rmeta --extern core=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps/librustc_std_workspace_core-1588482532069bec.rmeta --cap-lints allow -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32/rustlib/mips64-poky-linux-gnun32-gnu/lib --remap-path-prefix=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0=/usr/src/debug/libstd-rs/1.62.1-r0 -Cembed-bitcode=yes -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32 -C link-arg=-Wl,-soname,libstd.so`
| warning: `cfg-if` (lib) generated 2 warnings (2 duplicates)
|     Building [==========>                ] 13/31: libc, compiler_builtins, ...
| LLVM ERROR: Not supported instr: <MCInst 0 <MCOperand Reg:30> <MCOperand Reg:1>>
| warning: `adler` (lib) generated 2 warnings (2 duplicates)
| error: could not compile `adler`; 2 warnings emitted
|
| Caused by:
|   process didn't exit successfully: `rustc --crate-name adler /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rustc-1.62.1-src/vendor/adler-0.2.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 --cfg 'feature="compiler_builtins"' --cfg 'feature="core"' --cfg 'feature="rustc-dep-of-std"' -C metadata=49e9881f5b101600 -C extra-filename=-49e9881f5b101600 --out-dir /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps --target mips64-poky-linux-gnun32-gnu -C linker=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/wrapper/target-rust-ccld -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/release/deps --extern compiler_builtins=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps/libcompiler_builtins-3cb14fed722f45eb.rmeta --extern core=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps/librustc_std_workspace_core-1588482532069bec.rmeta --cap-lints allow -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32/rustlib/mips64-poky-linux-gnun32-gnu/lib --remap-path-prefix=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0=/usr/src/debug/libstd-rs/1.62.1-r0 -Cembed-bitcode=yes -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32 -C link-arg=-Wl,-soname,libstd.so` (exit status: 101)
| warning: build failed, waiting for other jobs to finish...
|     Building [===========>               ] 14/31: libc, compiler_builtins, ...
| LLVM ERROR: Not supported instr: <MCInst 0 <MCOperand Reg:433> <MCOperand Reg:338>>
| warning: `core` (lib) generated 2 warnings (2 duplicates)
| error: could not compile `core`; 2 warnings emitted
|
| Caused by:
|   process didn't exit successfully: `rustc --crate-name core --edition=2021 library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C metadata=e2fb70f62d4d21c6 -C extra-filename=-e2fb70f62d4d21c6 --out-dir /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps --target mips64-poky-linux-gnun32-gnu -C linker=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/wrapper/target-rust-ccld -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/release/deps -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32/rustlib/mips64-poky-linux-gnun32-gnu/lib --remap-path-prefix=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0=/usr/src/debug/libstd-rs/1.62.1-r0 -Cembed-bitcode=yes -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32 -C link-arg=-Wl,-soname,libstd.so` (exit status: 101)
|     Building [============>              ] 15/31: libc, compiler_builtins, ...
| LLVM ERROR: Not supported instr: <MCInst 0 <MCOperand Reg:380> <MCOperand Reg:22>>
| LLVM ERROR: Not supported instr: <MCInst 0 <MCOperand Reg:30> <MCOperand Reg:1>>
| /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot-native/usr/lib/librustc_driver-f73c9c7b2d50741f.so(+0xa85d12)[0x7f19a2a85d12]
| /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/sysroots-uninative/x86_64-linux/lib/libc.so.6(+0x36e20)[0x7f19a9f17e20]
| /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/sysroots-uninative/x86_64-linux/lib/libc.so.6(__cxa_finalize+0x40)[0x7f19a9f19960]
| /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot-native/usr/lib/librustc_driver-f73c9c7b2d50741f.so(+0xa17bc3)[0x7f19a2a17bc3]
| warning: `compiler_builtins` (lib) generated 2 warnings (2 duplicates)
| error: could not compile `compiler_builtins`; 2 warnings emitted
|
| Caused by:
|   process didn't exit successfully: `rustc --crate-name compiler_builtins /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rustc-1.62.1-src/vendor/compiler_builtins/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C codegen-units=10000 --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=3cb14fed722f45eb -C extra-filename=-3cb14fed722f45eb --out-dir /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps --target mips64-poky-linux-gnun32-gnu -C linker=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/wrapper/target-rust-ccld -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/release/deps --extern core=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps/librustc_std_workspace_core-1588482532069bec.rmeta --cap-lints allow -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32/rustlib/mips64-poky-linux-gnun32-gnu/lib --remap-path-prefix=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0=/usr/src/debug/libstd-rs/1.62.1-r0 -Cembed-bitcode=yes -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32 -C link-arg=-Wl,-soname,libstd.so --cfg 'feature="unstable"'` (signal: 11, SIGSEGV: invalid memory reference)
|     Building [============>              ] 16/31: libc, alloc, memchr, rust...
| LLVM ERROR: Not supported instr: <MCInst 0 <MCOperand Reg:440> <MCOperand Reg:1>>
| warning: `libc` (lib) generated 2 warnings (2 duplicates)
| error: could not compile `libc`; 2 warnings emitted
|
| Caused by:
|   process didn't exit successfully: `rustc --crate-name libc /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/rustc-1.62.1-src/vendor/libc/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="align"' --cfg 'feature="rustc-dep-of-std"' --cfg 'feature="rustc-std-workspace-core"' -C metadata=0bb8cd4dab13899e -C extra-filename=-0bb8cd4dab13899e --out-dir /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps --target mips64-poky-linux-gnun32-gnu -C linker=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/wrapper/target-rust-ccld -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps -L dependency=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/release/deps --extern rustc_std_workspace_core=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/build/mips64-poky-linux-gnun32-gnu/release/deps/librustc_std_workspace_core-1588482532069bec.rmeta --cap-lints allow -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32/rustlib/mips64-poky-linux-gnun32-gnu/lib --remap-path-prefix=/ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0=/usr/src/debug/libstd-rs/1.62.1-r0 -Cembed-bitcode=yes -L /ala-lpggp31/skokkonda/14877/poky/buildA/tmp/work/mips64-n32-poky-linux-gnun32/libstd-rs/1.62.1-r0/recipe-sysroot/usr/lib32 -C link-arg=-Wl,-soname,libstd.so --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_int128 --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor --cfg libc_non_exhaustive --cfg libc_ptr_addr_of --cfg libc_underscore_const_names --cfg libc_thread_local` (exit status: 101)
|     Building [=============>             ] 17/31: alloc, memchr, rustc-dema...
| LLVM ERROR: LLVM ERROR: Not supported instr: <MCInst 0 <MCOperand Reg:440> <MCOperand Reg:1>>Not supported instr: <MCInst 0 <MCOperand Reg:30> <MCOperand Reg:1>>
...
...
...

What could be the reason for this error and how to fix it? I suspect the data layout causing this issue. Below is the data layout used.

## mips64-n32-unknown-linux-{gnu, musl}
DATA_LAYOUT[mips64-n32] = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
TARGET_ENDIAN[mips64-n32] = "big"
TARGET_POINTER_WIDTH[mips64-n32] = "32"
TARGET_C_INT_WIDTH[mips64-n32] = "32"
MAX_ATOMIC_WIDTH[mips64-n32] = "64"

How do I derive a correct data layout for a specific arch? (Like the one given in rust-lang/compiler-builtins#400 (comment))

I tried changing the DATA_LAYOUT by referring https://llvm.org/docs/LangRef.html#data-layout & https://irix7.com/techpubs/007-2816-004.pdf docs but the error is still there.

My build is for mips64-n32 abi. I could not see this abi on the rust supported target list in https://doc.rust-lang.org/nightly/rustc/platform-support.html. Does this error because of n32 is a not supported target arch of rust?

@sundeep-kokkonda
Copy link
Contributor Author

Can I get some help here?

1 similar comment
@sundeep-kokkonda
Copy link
Contributor Author

Can I get some help here?

@workingjubilee workingjubilee added O-MIPS Target: MIPS processors A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Mar 3, 2023
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@workingjubilee
Copy link
Member

Sorry, I don't believe we support N32 ABI targets. We're having trouble supporting even other MIPS targets lately.

@workingjubilee workingjubilee added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jul 3, 2023
@workingjubilee
Copy link
Member

I have recently discovered that yocto removes the very code that exists to check our data layouts against LLVM's, so that there is no drift or inaccuracy in ABI or code generation. This was done in yoctoproject/poky@c08c522

"What this code was doing" was preventing things like this issue from occurring. That patch allows rustc's code generation to become unreliable. It allows usage of yocto's patched rustc by unwitting programmers against targets which we do not know the data layout for, thus cannot generate correct code for.

The code patched out disables the check if it determines a build-time variable to use a variant LLVM was set, to assist distros that wish to force rustc to link against an LLVM of their choosing. That was all. Setting the variable to a boolean might have been adequate, and might have been accepted upstream. But that patch simply disables the check unconditionally.

I am thus closing this issue, because even if we supported this target, the appropriate place to file issues for problems in yocto's Rust compiler not handling ABI or data layouts correctly is now with yocto.

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-MIPS Target: MIPS processors T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants