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

Upgrade Rust, remove LLVM patches #1

Closed
lrettig opened this issue Jun 8, 2024 · 3 comments · Fixed by #2
Closed

Upgrade Rust, remove LLVM patches #1

lrettig opened this issue Jun 8, 2024 · 3 comments · Fixed by #2
Labels
help wanted Extra attention is needed

Comments

@lrettig
Copy link

lrettig commented Jun 8, 2024

See athenavm/athena#3 (comment)

@lrettig
Copy link
Author

lrettig commented Jun 8, 2024

   Compiling compiler_builtins v0.1.108
The following warnings were emitted during compilation:

warning: [email protected]: Compiler version doesn't include clang or GCC: "cc" "--version"
warning: [email protected]: Compiler version doesn't include clang or GCC: "cc" "--version"
warning: [email protected]: Compiler version doesn't include clang or GCC: "cc" "--version"
warning: [email protected]: cc: error: unrecognized argument in option ‘-mabi=ilp32’
warning: [email protected]: cc: note: valid arguments to ‘-mabi=’ are: ms sysv
warning: [email protected]: cc: error: unrecognized argument in option ‘-mabi=ilp32’
warning: [email protected]: cc: note: valid arguments to ‘-mabi=’ are: ms sysv
warning: [email protected]: cc: error: unrecognized argument in option ‘-mcmodel=medany’
warning: [email protected]: cc: note: valid arguments to ‘-mcmodel=’ are: 32 kernel large medium small

error: failed to run custom build command for `compiler_builtins v0.1.108`

Caused by:
  process didn't exit successfully: `/home/lane/git/rustc-rv32e-toolchain/rust/build/x86_64-unknown-linux-gnu/stage2-std/release/build/compiler_builtins-48937ba6ff658e6a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:compiler-rt=/home/lane/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.108/compiler-rt
  cargo:rustc-cfg=feature="unstable"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/absvdi2.c
  cargo:rustc-cfg=__absvdi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/absvsi2.c
  cargo:rustc-cfg=__absvsi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/absvti2.c
  cargo:rustc-cfg=__absvti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/addvdi3.c
  cargo:rustc-cfg=__addvdi3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/addvsi3.c
  cargo:rustc-cfg=__addvsi3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/addvti3.c
  cargo:rustc-cfg=__addvti3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/bswapsi2.c
  cargo:rustc-cfg=__bswapsi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/clzdi2.c
  cargo:rustc-cfg=__clzdi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/clzsi2.c
  cargo:rustc-cfg=__clzsi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/clzti2.c
  cargo:rustc-cfg=__clzti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/cmpdi2.c
  cargo:rustc-cfg=__cmpdi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/cmpti2.c
  cargo:rustc-cfg=__cmpti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/ctzdi2.c
  cargo:rustc-cfg=__ctzdi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/ctzsi2.c
  cargo:rustc-cfg=__ctzsi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/ctzti2.c
  cargo:rustc-cfg=__ctzti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/divdc3.c
  cargo:rustc-cfg=__divdc3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/divsc3.c
  cargo:rustc-cfg=__divsc3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/extendhfsf2.c
  cargo:rustc-cfg=__extendhfsf2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/ffsti2.c
  cargo:rustc-cfg=__ffsti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/int_util.c
  cargo:rustc-cfg=__int_util="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/muldc3.c
  cargo:rustc-cfg=__muldc3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/mulsc3.c
  cargo:rustc-cfg=__mulsc3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/mulvdi3.c
  cargo:rustc-cfg=__mulvdi3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/mulvsi3.c
  cargo:rustc-cfg=__mulvsi3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/mulvti3.c
  cargo:rustc-cfg=__mulvti3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/negdf2.c
  cargo:rustc-cfg=__negdf2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/negdi2.c
  cargo:rustc-cfg=__negdi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/negsf2.c
  cargo:rustc-cfg=__negsf2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/negti2.c
  cargo:rustc-cfg=__negti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/negvdi2.c
  cargo:rustc-cfg=__negvdi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/negvsi2.c
  cargo:rustc-cfg=__negvsi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/negvti2.c
  cargo:rustc-cfg=__negvti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/paritydi2.c
  cargo:rustc-cfg=__paritydi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/paritysi2.c
  cargo:rustc-cfg=__paritysi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/parityti2.c
  cargo:rustc-cfg=__parityti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/popcountdi2.c
  cargo:rustc-cfg=__popcountdi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/popcountsi2.c
  cargo:rustc-cfg=__popcountsi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/popcountti2.c
  cargo:rustc-cfg=__popcountti2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/subvdi3.c
  cargo:rustc-cfg=__subvdi3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/subvsi3.c
  cargo:rustc-cfg=__subvsi3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/subvti3.c
  cargo:rustc-cfg=__subvti3="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/truncdfhf2.c
  cargo:rustc-cfg=__truncdfhf2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/truncsfhf2.c
  cargo:rustc-cfg=__truncsfhf2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/ucmpdi2.c
  cargo:rustc-cfg=__ucmpdi2="optimized-c"
  cargo:rerun-if-changed=/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/ucmpti2.c
  cargo:rustc-cfg=__ucmpti2="optimized-c"
  TARGET = Some("riscv32em-athena-zkvm-elf")
  OPT_LEVEL = Some("3")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_riscv32em-athena-zkvm-elf
  CC_riscv32em-athena-zkvm-elf = None
  cargo:rerun-if-env-changed=CC_riscv32em_athena_zkvm_elf
  CC_riscv32em_athena_zkvm_elf = Some("cc")
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:warning=Compiler version doesn't include clang or GCC: "cc" "--version"
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("e,m")
  cargo:rerun-if-env-changed=CFLAGS_riscv32em-athena-zkvm-elf
  CFLAGS_riscv32em-athena-zkvm-elf = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32em_athena_zkvm_elf
  CFLAGS_riscv32em_athena_zkvm_elf = Some("-ffunction-sections -fdata-sections -fPIC -march=rv32em -mabi=ilp32 -mcmodel=medany")
  cargo:rerun-if-env-changed=CC_riscv32em-athena-zkvm-elf
  CC_riscv32em-athena-zkvm-elf = None
  cargo:rerun-if-env-changed=CC_riscv32em_athena_zkvm_elf
  CC_riscv32em_athena_zkvm_elf = Some("cc")
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:warning=Compiler version doesn't include clang or GCC: "cc" "--version"
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("e,m")
  cargo:rerun-if-env-changed=CFLAGS_riscv32em-athena-zkvm-elf
  CFLAGS_riscv32em-athena-zkvm-elf = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32em_athena_zkvm_elf
  CFLAGS_riscv32em_athena_zkvm_elf = Some("-ffunction-sections -fdata-sections -fPIC -march=rv32em -mabi=ilp32 -mcmodel=medany")
  cargo:rerun-if-env-changed=CC_riscv32em-athena-zkvm-elf
  CC_riscv32em-athena-zkvm-elf = None
  cargo:rerun-if-env-changed=CC_riscv32em_athena_zkvm_elf
  CC_riscv32em_athena_zkvm_elf = Some("cc")
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:warning=Compiler version doesn't include clang or GCC: "cc" "--version"
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("e,m")
  cargo:rerun-if-env-changed=CFLAGS_riscv32em-athena-zkvm-elf
  CFLAGS_riscv32em-athena-zkvm-elf = None
  cargo:rerun-if-env-changed=CFLAGS_riscv32em_athena_zkvm_elf
  CFLAGS_riscv32em_athena_zkvm_elf = Some("-ffunction-sections -fdata-sections -fPIC -march=rv32em -mabi=ilp32 -mcmodel=medany")
  cargo:warning=cc: error: unrecognized argument in option ‘-mabi=ilp32’
  cargo:warning=cc: note: valid arguments to ‘-mabi=’ are: ms sysv
  cargo:warning=cc: error: unrecognized argument in option ‘-mabi=ilp32’
  cargo:warning=cc: note: valid arguments to ‘-mabi=’ are: ms sysv
  cargo:warning=cc: error: unrecognized argument in option ‘-mcmodel=medany’
  cargo:warning=cc: note: valid arguments to ‘-mcmodel=’ are: 32 kernel large medium small

  --- stderr


  error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=rv32em" "-mabi=ilp32" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=rv32em" "-mabi=ilp32" "-mcmodel=medany" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding" "-DVISIBILITY_HIDDEN" "-o" "/home/lane/git/rustc-rv32e-toolchain/rust/build/x86_64-unknown-linux-gnu/stage2-std/riscv32em-athena-zkvm-elf/release/build/compiler_builtins-29b9a173143622a0/out/376c17df37744b3d-absvdi2.o" "-c" "/home/lane/git/rustc-rv32e-toolchain/rust/src/llvm-project/compiler-rt/lib/builtins/absvdi2.c" with args "cc" did not execute successfully (status code exit status: 1).

@lrettig lrettig added the help wanted Extra attention is needed label Jun 8, 2024
@lrettig
Copy link
Author

lrettig commented Jun 8, 2024

As mentioned in athenavm/athena#3 (comment) it should be possible to upgrade to a newer mainline Rust which includes a newer LLVM which includes CodeGen support for RV32E (llvm/llvm-project@3ac9fe6). This work is partially done in #2. Unfortunately I'm running into the above error trying to build the toolchain. I made sure to try this using an identical config and environment, which doesn't help. Something must've changed in the Rust/LLVM build process between the two releases but I can't figure out what it is. Some possibly useful notes and resources:

The particular compile command that fails works when I run it using cpp from https://github.com/riscv-collab/riscv-gnu-toolchain. But when I set CC= to that compiler, it fails with a different error:

> CC=/home/lane/opt/riscv/bin/riscv32-unknown-linux-gnu-gcc ./x build --stage 1 --host x86_64-unknown-linux-gnu --target ../riscv32em-athena-zkvm-elf.json compiler/rustc library/std
warning: [email protected]: riscv32-unknown-linux-gnu-gcc: error: unrecognized command-line option '-m64'
warning: [email protected]: riscv32-unknown-linux-gnu-gcc: error: unrecognized command-line option '-m64'

I tried differentiating the host and guest compilers to no avail:

HOST_CC=gcc CC_riscv64_unknown_linux_gnu=/home/lane/opt/riscv/bin/riscv64-unknown-linux-gnu-gcc CARGO_TARGET_RISCV64_UNKNOWN_LINUX_GNU_LINKER=/home/lane/opt/riscv/bin/riscv64-unknown-linux-gnu-gcc ./build.sh

I'm also having trouble compiling riscv-gnu-toolchain. It seems to partially compile and install when configured as such, but then later to run into errors:

./configure --prefix=$HOME/opt/riscv --with-arch=rv32e --with-abi=ilp32e

In any case it shouldn't be required to build Rust since the build script in this repo works just fine on older Rust without it.

@lrettig
Copy link
Author

lrettig commented Jun 9, 2024

Found the issue: rust-lang/compiler-builtins#563. See also rust-lang/rust#121371. Worked around this in 2ac5f67. Also included two required Rust patches that haven't been released yet:

Another option here might be to use a dockerized build, using the compilers referenced here: rust-lang/rust#117654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant