@@ -5,16 +5,64 @@ set -euo pipefail
5
5
source config.sh
6
6
7
7
# Fail fast if these tools aren't properly installed and in the path
8
- need_cmd riscv64 -unknown-elf-gcc
9
- need_cmd riscv64 -unknown-elf-g ++
8
+ need_cmd riscv32 -unknown-elf-clang
9
+ need_cmd riscv32 -unknown-elf-clang ++
10
10
11
11
# Rust requires a custom target file to exist for our custom target as part of the bootstrap build,
12
12
# but it doesn't actually look at the contents.
13
- touch /tmp/riscv32em-athena-zkvm-elf.json
13
+ cat > /tmp/riscv32em-athena-zkvm-elf.json << EOF
14
+ {
15
+ "arch": "riscv32",
16
+ "cpu": "generic-rv32",
17
+ "crt-objects-fallback": "false",
18
+ "data-layout": "e-m:e-p:32:32-i64:64-n32-S32",
19
+ "eh-frame-header": false,
20
+ "emit-debug-gdb-scripts": false,
21
+ "features": "+e,+m",
22
+ "linker": "rust-lld",
23
+ "linker-flavor": "gnu-lld",
24
+ "llvm-abiname": "ilp32e",
25
+ "llvm-target": "riscv32",
26
+ "max-atomic-width": 32,
27
+ "os": "zkvm",
28
+ "panic-strategy": "abort",
29
+ "relocation-model": "static",
30
+ "singlethread": true,
31
+ "target-pointer-width": "32",
32
+ "vendor": "athena",
33
+ "options": {
34
+ "c-flags": "-march=rv32e -mabi=ilp32e",
35
+ "pre-link-args": {
36
+ "gcc": [
37
+ "-march=rv32e",
38
+ "-mabi=ilp32e"
39
+ ]
40
+ }
41
+ }
42
+ }
43
+ EOF
44
+
45
+ # Set environment variables to override compiler flags
46
+ export CC_riscv32em_athena_zkvm_elf=" riscv32-unknown-elf-clang"
47
+ export CXX_riscv32em_athena_zkvm_elf=" riscv32-unknown-elf-clang++"
48
+ export AR_riscv32em_athena_zkvm_elf=" riscv32-unknown-elf-ar"
49
+
50
+ # Explicitly set CFLAGS without the problematic flags
51
+ export CFLAGS_riscv32em_athena_zkvm_elf=" -ffunction-sections -fdata-sections -fPIC -target riscv32-unknown-elf"
52
+ export CXXFLAGS_riscv32em_athena_zkvm_elf=" $CFLAGS_riscv32em_athena_zkvm_elf "
53
+
54
+ # Set Rust flags
55
+ export CARGO_TARGET_RISCV32EM_ATHENA_ZKVM_ELF_RUSTFLAGS=" -Cpasses=loweratomic -Clink-arg=-march=rv32em -Clink-arg=-mabi=ilp32e"
56
+
57
+ # Override the default target for compiler-rt
58
+ export COMPILER_RT_DEFAULT_TARGET_TRIPLE=" riscv32-unknown-elf"
59
+
60
+ # Force the use of our custom target spec
61
+ export RUST_TARGET_PATH=" /tmp"
62
+
63
+ # Prevent the build system from adding --target flag
64
+ export RUSTC_TARGET_ARG=" "
14
65
15
66
# Will create component archives (dists) ./rust/build/dist
16
67
cd rust
17
- RUST_TARGET_PATH=" /tmp" \
18
- CARGO_TARGET_RISCV32EM_ATHENA_ZKVM_ELF_RUSTFLAGS=" -Cpasses=loweratomic" \
19
- CFLAGS_riscv32em_athena_zkvm_elf=" -ffunction-sections -fdata-sections -fPIC -march=rv32em -mabi=ilp32e" \
20
68
./x build --stage 2
0 commit comments