rust-lang / rust-lang/rustc_codegen_gcc
Host vs target confusion for `bfin-elf` target
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 105
- Avg merge
- 8h 20m
- Merged PRs (30d)
- 14
Description
Heya!
I've been trying to get Rust to build against a small embedded device which runs on a Blackfin processor. Unfortunately LLVM no longer has support for Blackfin (dropped in ~LLVM 3.0) and thus I would have to use GCC.
I've built a toolchain using the following:
binutils b275570803cefba388595bc42b75b68403eb86f1
../binutils-gdb/configure --prefix=/opt/bfin --target=bfin-elf --disable-multilib
gcc (your repo) 5a50919bab958687c76f61cc1a1f52345ba2c3bc
../gcc/configure --enable-host-shared --disable-multilib --enable-languages=c,jit --disable-bootstrap --enable-checking=release --prefix=/opt/bfin --target=bfin-elf --without-headers
I never built a libc or used kernel headers (bare-metal target), but I don't think the issue I ran into is related.
Finished release [optimized] target(s) in 0.04s
[BUILD] sysroot
Updating crates.io index
Compiling core v0.0.0 (/home/pleb/rustc_codegen_gcc/build_sysroot/sysroot_src/library/core)
Compiling libc v0.2.119
Compiling compiler_builtins v0.1.70
Compiling memchr v2.4.1
Compiling unwind v0.0.0 (/home/pleb/rustc_codegen_gcc/build_sysroot/sysroot_src/library/unwind)
Compiling miniz_oxide v0.4.4
Compiling std v0.0.0 (/home/pleb/rustc_codegen_gcc/build_sysroot/sysroot_src/library/std)
Compiling rustc-std-workspace-core v1.99.0 (/home/pleb/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-core)
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)39 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)39 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)39 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)40 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)1 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_ofhEB4_ (return type: __uint32_t)
libgccjit.so: error: unterminated block in _RINvNtCsbWodogVmn9l_4core3mem7size_ofhEB4_: start
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)4 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_ofjEB4_ (return type: __uint32_t)
libgccjit.so: error: unterminated block in _RINvNtCsbWodogVmn9l_4core3mem7size_ofjEB4_: start
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)32 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_ofNtNvNtB4_3ptr25swap_nonoverlapping_bytes5BlockEB4_ (return type: __uint32_t)
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)1 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_ofhEB4_ (return type: __uint32_t)
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)4 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_ofjEB4_ (return type: __uint32_t)
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)8 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_ofyEB4_ (return type: __uint32_t)
libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: bitcast((__int32_t)1, __uint32_t) (type: __uint32_t) b: (unsigned long long)16 (type: unsigned long long)
gcc_jit_rvalue_get_type: NULL rvalue
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x4b5733)[0x7fc05a5dd733]
/lib64/libpthread.so.0(+0x121d0)[0x7fc059d821d0]
/opt/bfin/lib/libgccjit.so(_ZN3gcc3jit9recording19memento_of_get_type19accepts_writes_fromEPNS1_4typeE+0x79)[0x7fc051d4ab39]
/opt/bfin/lib/libgccjit.so(gcc_jit_compatible_types+0x52)[0x7fc051d2cea2]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(+0x15149e)[0x7fc052fbe49e]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(_ZN106_$LT$rustc_codegen_gcc..builder..Builder$u20$as$u20$rustc_codegen_ssa..traits..builder..BuilderMethods$GT$6memcpy17h688530f54ac74998E+0x44)[0x7fc052f048a4]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(+0xd34fb)[0x7fc052f404fb]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(+0x13ef4a)[0x7fc052fabf4a]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(+0x16725d)[0x7fc052fd425d]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(+0xe87ce)[0x7fc052f557ce]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(+0x10c402)[0x7fc052f79402]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(+0xe7e0b)[0x7fc052f54e0b]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(_ZN112_$LT$rustc_codegen_gcc..GccCodegenBackend$u20$as$u20$rustc_codegen_ssa..traits..backend..ExtraBackendMethods$GT$20compile_codegen_unit17hd9d70887dd3c8690E+0x61)[0x7fc052fc21d1]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(+0x141a3b)[0x7fc052faea3b]
/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so(_ZN107_$LT$rustc_codegen_gcc..GccCodegenBackend$u20$as$u20$rustc_codegen_ssa..traits..backend..CodegenBackend$GT$13codegen_crate17h036443feb60a072eE+0x110)[0x7fc052fc1e10]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x22feb67)[0x7fc05c426b67]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x22e6a46)[0x7fc05c40ea46]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(_RNvMs0_NtCs8JPLtiCPH45_15rustc_interface7queriesNtB5_7Queries15ongoing_codegen+0xaf)[0x7fc05c404edf]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x22b4fdd)[0x7fc05c3dcfdd]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x22b7196)[0x7fc05c3df196]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x22b49b1)[0x7fc05c3dc9b1]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x22a0372)[0x7fc05c3c8372]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x229fc2d)[0x7fc05c3c7c2d]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-920796763ff499ad.so(+0x229e419)[0x7fc05c3c6419]
/home/pleb/.rustup/toolchains/nightly-2022-02-25-x86_64-unknown-linux-gnu/bin/../lib/libstd-1b64d5fe7a3c3d7f.so(rust_metadata_std_2a6da251afaa3124+0xa8183)[0x7fc059e61183]
/lib64/libpthread.so.0(+0x7d4e)[0x7fc059d77d4e]
/lib64/libc.so.6(clone+0x3f)[0x7fc059ca1faf]
error: could not compile `core`
Caused by:
process didn't exit successfully: `rustc --crate-name core --edition=2021 sysroot_src/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=3f89901f5ca6a5d5 -C extra-filename=-3f89901f5ca6a5d5 --out-dir /home/pleb/rustc_codegen_gcc/build_sysroot/target/mips-unknown-linux-gnu/debug/deps --target mips-unknown-linux-gnu -L dependency=/home/pleb/rustc_codegen_gcc/build_sysroot/target/mips-unknown-linux-gnu/debug/deps -L dependency=/home/pleb/rustc_codegen_gcc/build_sysroot/target/debug/deps -Clinker=bfin-elf-gcc -Cpanic=abort -Csymbol-mangling-version=v0 -Cdebuginfo=2 -Clto=off -Zpanic-abort-tests -Zcodegen-backend=/home/pleb/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so --sysroot /home/pleb/rustc_codegen_gcc/build_sysroot/sysroot -Z force-unstable-if-unmarked -Cpanic=abort` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)1 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_ofhECsiwW3a5wxMRb_17compiler_builtins (return type: __uint32_t)
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)4 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_ofmECsiwW3a5wxMRb_17compiler_builtins (return type: __uint32_t)
libgccjit.so: error: gcc_jit_block_end_with_return: mismatching types: return of (unsigned long long)2 (type: unsigned long long) in function _RINvNtCsbWodogVmn9l_4core3mem7size_oftECsiwW3a5wxMRb_17compiler_builtins (return type: __uint32_t)
libgccjit.so: error: unterminated block in _RINvNtCsbWodogVmn9l_4core3mem7size_ofhECsiwW3a5wxMRb_17compiler_builtins: start
libgccjit.so: error: unterminated block in _RINvNtCsbWodogVmn9l_4core3mem7size_ofmECsiwW3a5wxMRb_17compiler_builtins: start
libgccjit.so: error: unterminated block in _RINvNtCsbWodogVmn9l_4core3mem7size_oftECsiwW3a5wxMRb_17compiler_builtins: start
/tmp/libgccjit-Vbp6EG/fake.s: Assembler messages:
/tmp/libgccjit-Vbp6EG/fake.s:11: Error: no such instruction: `link 16'
/tmp/libgccjit-Vbp6EG/fake.s:13: Error: junk at end of line, first unrecognized character is `['
/tmp/libgccjit-Vbp6EG/fake.s:16: Error: no such instruction: `p2 +=-4'
/tmp/libgccjit-Vbp6EG/fake.s:18: Error: junk at end of line, first unrecognized character is `['
/tmp/libgccjit-Vbp6EG/fake.s:28: Error: no such instruction: `link 36'
/tmp/libgccjit-Vbp6EG/fake.s:31: Error: junk at end of line, first unrecognized character is `['
/tmp/libgccjit-Vbp6EG/fake.s:34: Error: no such instruction: `p2 +=-36'
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported rustc invocation, especially the mismatch between --target mips-unknown-linux-gnu and -Clinker=bfin-elf-gcc, then inspect build_sysroot/sysroot_src/library/core/src/lib.rs and the rustc_codegen_gcc backend. Reproduce the sysroot build with the bfin-elf toolchain and determine whether host/target selection causes the libgccjit type and assembler errors. Done means the target configuration is understood and the build either succeeds or fails with the correct target-specific diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100