Skip to content

Commit

Permalink
Initial (still only trivial) integration of Risc0.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurik committed Dec 15, 2024
1 parent bcc277c commit 5c20b13
Show file tree
Hide file tree
Showing 12 changed files with 3,595 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,9 @@
[submodule "liboqs"]
path = lib-protocol/liboqs
url = https://github.com/open-quantum-safe/liboqs.git
[submodule "risc0"]
path = eth-sender/risc0
url = https://github.com/risc0/risc0.git
[submodule "risc0-ethereum"]
path = eth-sender/risc0-ethereum
url = https://github.com/risc0/risc0-ethereum.git
8 changes: 5 additions & 3 deletions env/output.mk
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ $(output)/%/librust.a: $$(specific) $$(folder)/Cargo.toml $(output)/rustup-targe
@# or if using rustc: rustc --version --verbose | sed -e '/^host: /!d;s///'

@# https://github.com/buildroot/buildroot/commit/4b2be770b8a853a7dd97b5788d837f0d84923fa1
cd $(folder) && RUST_BACKTRACE=1 $(rust):$(dir $(word 1,$(cc))) \
$(ccrs)_CC='$(cc) $(more/$(arch)) $(qflags)' $(ccrs)_AR='$(ar/$(arch))' \
cd $(folder) && ENV_RUST=$(notdir $(folder)) RUST_BACKTRACE=1 $(rust):$(dir $(word 1,$(cc))) \
$(ccrs)_CC='$(cc) $(more/$(arch))' $(ccrs)_CFLAGS='$(qflags)' \
$(ccrs)_CXX='$(cxx) $(more/$(arch))' $(ccrs)_CXXFLAGS='$(qflags) $(xflags)' \
$(ccrs)_AR='$(ar/$(arch))' \
PKG_CONFIG_ALLOW_CROSS=1 PKG_CONFIG="$(CURDIR)/env/pkg-config.sh" ENV_ARCH="$(arch)" \
CARGO_HOME='$(call path,$(CURDIR)/$(output)/cargo)' CARGO_INCREMENTAL=0 \
__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS=nightly CARGO_TARGET_APPLIES_TO_HOST=false \
Expand All @@ -185,7 +187,7 @@ $(output)/%/librust.a: $$(specific) $$(folder)/Cargo.toml $(output)/rustup-targe
cargo +$(rustc) build --verbose --lib --release --features "$(features/$(folder))" \
--target $(triple/$(arch)) -Z target-applies-to-host \
--target-dir $(call path,$(CURDIR)/$(output)/$(arch)/$(folder))
cp -f $(output)/$(arch)/$(folder)/$(triple/$(arch))/release/deps/lib$(subst -,_,$(notdir $(folder))).a $@
cp -f $(output)/$(arch)/$(folder)/$(triple/$(arch))/release/lib$(subst -,_,$(notdir $(folder))).a $@

.PHONY: clean
clean:
Expand Down
4 changes: 3 additions & 1 deletion env/rustc-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ set -e
# XXX: this only exists due to this Cargo bug :(
# https://github.com/rust-lang/cargo/issues/8140

# XXX: well, I also mix in the project name now?

file=
for arg in "$@"; do
if [[ ${arg} == ${CARGO_HOME}/* && -z ${file} ]]; then
file=${arg##${CARGO_HOME}}
file=${ENV_RUST}/${arg##${CARGO_HOME}/}
fi
done

Expand Down
5 changes: 5 additions & 0 deletions eth-sender/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ cflags += -I$(pwd)/source
checks/$(pwd)/source/main.cpp += -bugprone-unchecked-optional-access

$(call include,lib/target.mk)

linked += $(pwd)/riscy/librust.a
cflags += -I$(pwd)/riscy
$(call depend,$(pwd)/riscy/librust.a,$(pwd)/riscy/riscy.rs)

include env/output.mk

$(output)/%/cj$(exe): $(patsubst %,$(output)/$$*/%,$(object) $(linked))
Expand Down
1 change: 1 addition & 0 deletions eth-sender/risc0
Submodule risc0 added at baf81c
1 change: 1 addition & 0 deletions eth-sender/risc0-ethereum
Submodule risc0-ethereum added at 3722b3
Loading

0 comments on commit 5c20b13

Please sign in to comment.