Skip to content
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

Fix riscv64gc-unknown-linux-gnu #1423

Closed
Emilgardis opened this issue Jan 31, 2024 · 5 comments · Fixed by #1525
Closed

Fix riscv64gc-unknown-linux-gnu #1423

Emilgardis opened this issue Jan 31, 2024 · 5 comments · Fixed by #1525
Labels
Milestone

Comments

@Emilgardis
Copy link
Member

CI fails for this target:

riscv64gc-unknown-linux-gnu - ❌

error: linking with `riscv64-linux-gnu-gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" VSLANG="1033" "riscv64-linux-gnu-gcc" "/tmp/rustcL5EYAM/symbols.o" "/target/riscv64gc-unknown-linux-gnu/debug/deps/hello-8b4240f02115318c.hello.4898b753e7bb93fe-cgu.0.rcgu.o" "/target/riscv64gc-unknown-linux-gnu/debug/deps/hello-8b4240f02115318c.3tghmwzgt5h6j3k.rcgu.o" "-Wl,--as-needed" "-L" "/target/riscv64gc-unknown-linux-gnu/debug/deps" "-L" "/target/debug/deps" "-L" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libstd-61f5b1021fe67be9.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libpanic_unwind-b7d64cf61360ba90.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libobject-5944d8c055f61b94.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libmemchr-911cfe7bb937393f.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libaddr2line-47c99826792c3442.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libgimli-d1395a1ebcdb89a9.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/librustc_demangle-c0b84cd4909ede05.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libstd_detect-94ffaeed1fd8f191.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libhashbrown-d7d27d49c4ab78d7.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/librustc_std_workspace_alloc-fbafa950c308ed6b.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libminiz_oxide-bd0474a7cc295b06.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libadler-b339f046f1fd4366.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libunwind-26adcace73305118.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libcfg_if-e81f5ac9dda42ff6.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/liblibc-b16acf89b22a1706.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/liballoc-bae0c14b28b06671.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/librustc_std_workspace_core-3c106561728d9a61.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libcore-ce7ae382ac0ff6ce.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libcompiler_builtins-ac5d42bf3e358089.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib" "-o" "/target/riscv64gc-unknown-linux-gnu/debug/deps/hello-8b4240f02115318c" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /target/riscv64gc-unknown-linux-gnu/debug/deps/hello-8b4240f02115318c.3tghmwzgt5h6j3k.rcgu.o
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libstd-61f5b1021fe67be9.rlib(std-61f5b1021fe67be9.std.bde20bb6bfa1c42-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libpanic_unwind-b7d64cf61360ba90.rlib(panic_unwind-b7d64cf61360ba90.panic_unwind.dc53addc679bf0ba-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libobject-5944d8c055f61b94.rlib(object-5944d8c055f61b94.object.9940abbe183ae2a0-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libmemchr-911cfe7bb937393f.rlib(memchr-911cfe7bb937393f.memchr.e9cc1d998c88d27d-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libaddr2line-47c99826792c3442.rlib(addr2line-47c99826792c3442.addr2line.afe00be04daafd1d-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libgimli-d1395a1ebcdb89a9.rlib(gimli-d1395a1ebcdb89a9.gimli.1b380625c2a4faf0-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/librustc_demangle-c0b84cd4909ede05.rlib(rustc_demangle-c0b84cd4909ede05.rustc_demangle.22b1241fcec5c3b9-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libminiz_oxide-bd0474a7cc295b06.rlib(miniz_oxide-bd0474a7cc295b06.miniz_oxide.3dd1cd58e6ed6f5a-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libadler-b339f046f1fd4366.rlib(adler-b339f046f1fd4366.adler.12789116cf2a7aeb-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/liballoc-bae0c14b28b06671.rlib(alloc-bae0c14b28b06671.alloc.7d144d07b4c17fea-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libcore-ce7ae382ac0ff6ce.rlib(core-ce7ae382ac0ff6ce.core.a88923a368bb68cc-cgu.0.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libcompiler_builtins-ac5d42bf3e358089.rlib(compiler_builtins-ac5d42bf3e358089.compiler_builtins.2dbade20c842dffe-cgu.083.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libcompiler_builtins-ac5d42bf3e358089.rlib(compiler_builtins-ac5d42bf3e358089.compiler_builtins.2dbade20c842dffe-cgu.100.rcgu.o)
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: -march=rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0: unsupported ISA subset `z'
          /usr/lib/gcc-cross/riscv64-linux-gnu/9/../../../../riscv64-linux-gnu/bin/ld: failed to merge target specific data of file /home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib/libcompiler_builtins-ac5d42bf3e358089.rlib(compiler_builtins-ac5d42bf3e358089.compiler_builtins.2dbade20c842dffe-cgu.004.rcgu.o)
          collect2: error: ld returned 1 exit status
@Emilgardis Emilgardis modified the milestones: v0.3.1, v0.3.0 Jan 31, 2024
@Emilgardis Emilgardis added the bug label Jan 31, 2024
@Emilgardis
Copy link
Member Author

Emilgardis commented Feb 1, 2024

This seems to be rust-lang/rust#117101, caused by the update to llvm 17 and us using a too old ld.

I'll use a lower rustc for riscv for now

github-merge-queue bot pushed a commit that referenced this issue Feb 6, 2024
@endocrimes
Copy link

Building my own cross-rs image (https://github.com/users/endocrimes/packages/container/package/cross-rs%2Friscv64gc-unknown-linux-gnu) based on Ubuntu 23.04 rather than 20.04 got builds working successfully for me with Rust 1.76 (bc newer ld) in case anyone else ends up here after running into this 😅

Happy to PR the version bump, but I'm not really aware enough of broader cross-rs use to know if that's likely to break elsewhere.

@YOU54F
Copy link
Contributor

YOU54F commented Apr 18, 2024

I came across this cross-compiling on macos, and managed to build correctly with binutils updated to 2.38

@believeinlain
Copy link

I'm running into this issue and I can't seem to get any of the workarounds people have posted here to work. I don't understand how to get cross to use binutils 2.38 or Ubuntu 23.04 or use an older rustc version. So I'm just unable to cross-compile for RISCV at all using cross. If someone could point me towards a solution with a list of steps I can follow to get cross working for RISCV I would greatly appreciate it.

If it's relevant, I'm on Ubuntu 22.04 using rustc 1.78 and I'm trying to compile a cdylib. Cross works fine for me for aarch64 but not for riscv. The error output is just a long list of unsupported ISA subset 'z' like above, so I'm pretty sure this is the correct issue to post in.

@YOU54F
Copy link
Contributor

YOU54F commented May 22, 2024

Hey @believeinlain,

I wasn't able to use it with cross due to the above error, I use a mac m1 as a my main dev machine at the moment.

I got the same error with the macos toolchain

long list of unsupported ISA subset 'z'

before using the updated formula with a later binutils (2.38)

YOU54F/homebrew-musl-cross-multilib@ed5ebfd

that is compiling here for multi-targets (albeit a binary and not a cdylib)

https://github.com/YOU54F/hello_world_cross_rust/actions/runs/8741493783/job/23987644136#step:11:17

I do however recall manage to build a cdylib for riscv64gc-unknown-linux-gnu target in this run, with cross

https://github.com/YOU54F/pact_cli/actions/runs/8483936405/job/23245943624

I was trying to build slim binaries, but I wasn't able to build-std

https://github.com/YOU54F/pact_cli/blob/74b23c4f00c1d2b3065d5683f571815ca89a267b/Makefile#L79

Just kicked off the build again today for riscv64gc-unknown-linux-gnu target, will see if it passes 🤞🏾

https://github.com/YOU54F/pact_cli/actions/runs/9198478216/job/25301286790

I don't understand how to get cross to use binutils 2.38 or Ubuntu 23.04 or use an older rustc version.

I believe @endocrimes used an updated image by modifying the cross dockerfile to 23.04 and building it locally

https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.riscv64gc-unknown-linux-gnu

You could give that a try, and you can reference custom images in your Cross.toml

https://github.com/cross-rs/cross/blob/main/docs/custom_images.md#custom-image

kxxt added a commit to kxxt/cross that referenced this issue Jul 10, 2024
kxxt added a commit to kxxt/cross that referenced this issue Jul 10, 2024
Lzzzzzt added a commit to Lzzzzzt/monoio that referenced this issue Aug 2, 2024
using main branch of cross-rs and disable the tests on riscv64gc due to the llvm bug cross-rs/cross#1423

Signed-off-by: lzzzt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants