From 0fa9457c989423b5246fe29bdbd257f371c2190d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Thu, 26 Sep 2024 14:49:33 +0200 Subject: [PATCH 1/5] chore: update time to be compatible with rust 1.81 --- core/Cargo.lock | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/Cargo.lock b/core/Cargo.lock index 45e29c7..84d92e6 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -1129,6 +1129,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.45" @@ -1807,11 +1813,12 @@ dependencies = [ [[package]] name = "time" -version = "0.3.30" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", + "num-conv", "powerfmt", "serde", "time-core", @@ -1826,10 +1833,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] From acffb94c2c72b7e67903ecd4df47dbc7306e2d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Thu, 26 Sep 2024 14:50:02 +0200 Subject: [PATCH 2/5] chore: update wasm target name --- Makefile | 18 +++++++++--------- core/.cargo/config.toml | 4 ++-- scripts/build-a-core/template.py | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 4d4b3e8..7a6074a 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ git_hooks: ## CORE ## ########## deps_core: ${WASI_SDK_FOLDER} - rustup target add wasm32-wasi + rustup target add wasm32-wasip1 curl https://wasmtime.dev/install.sh -sSf | bash ${CORE_DIST}: ${WASI_SDK_FOLDER} ${CORE_JS_ASSETS_MAP_STD} ${CORE_JS_ASSETS_PROFILE_VALIDATOR} ${CORE_SCHEMA_ASSETS_SECURITY_VALUES} ${CORE_SCHEMA_ASSETS_PARAMETERS_VALUES} @@ -83,13 +83,13 @@ ${CORE_DIST}: ${WASI_SDK_FOLDER} ${CORE_JS_ASSETS_MAP_STD} ${CORE_JS_ASSETS_PROF touch ${CORE_DIST} ${CORE_WASM}: ${CORE_DIST} - cd core; cargo build --package oneclient_core --target wasm32-wasi ${CARGO_FLAGS} + cd core; cargo build --package oneclient_core --target wasm32-wasip1 ${CARGO_FLAGS} @echo 'Optimizing wasm...' - wasm-opt -Oz ${WASM_OPT_FLAGS} core/target/wasm32-wasi/${CARGO_PROFILE}/oneclient_core.wasm --output ${CORE_WASM} + wasm-opt -Oz ${WASM_OPT_FLAGS} core/target/wasm32-wasip1/${CARGO_PROFILE}/oneclient_core.wasm --output ${CORE_WASM} ${TEST_CORE_WASM}: ${CORE_DIST} - cd core; cargo build --package oneclient_core --target wasm32-wasi --features "core_mock" ${CARGO_FLAGS} - cp core/target/wasm32-wasi/${CARGO_PROFILE}/oneclient_core.wasm ${TEST_CORE_WASM} + cd core; cargo build --package oneclient_core --target wasm32-wasip1 --features "core_mock" ${CARGO_FLAGS} + cp core/target/wasm32-wasip1/${CARGO_PROFILE}/oneclient_core.wasm ${TEST_CORE_WASM} ${CORE_ASYNCIFY_WASM}: ${CORE_WASM} @echo 'Running asyncify...' @@ -100,18 +100,18 @@ ${TEST_CORE_ASYNCIFY_WASM}: ${TEST_CORE_WASM} ${CORE_COMLINK_WASM}: mkdir -p ${CORE_DIST} - cd core; cargo build --package comlink_wasm --target wasm32-wasi ${CARGO_FLAGS} - wasm-opt -Os ${WASM_OPT_FLAGS} core/target/wasm32-wasi/${CARGO_PROFILE}/comlink_wasm.wasm --output ${CORE_COMLINK_WASM} + cd core; cargo build --package comlink_wasm --target wasm32-wasip1 ${CARGO_FLAGS} + wasm-opt -Oz ${WASM_OPT_FLAGS} core/target/wasm32-wasip1/${CARGO_PROFILE}/comlink_wasm.wasm --output ${CORE_COMLINK_WASM} ${WASI_SDK_FOLDER}: wget -qO - ${WASI_SDK_URL} | tar xzvf - -C core test_core: ${WASI_SDK_FOLDER} ${CORE_JS_ASSETS_MAP_STD} ${CORE_JS_ASSETS_PROFILE_VALIDATOR} ${CORE_SCHEMA_ASSETS_SECURITY_VALUES} ${CORE_SCHEMA_ASSETS_PARAMETERS_VALUES} - cd core && cargo test -- --nocapture + cd core && cargo test build_core: ${CORE_WASM} ${TEST_CORE_WASM} ${CORE_ASYNCIFY_WASM} ${TEST_CORE_ASYNCIFY_WASM} build_core_json_schemas: - cd core/json_schemas && cargo build && wasmtime run --dir=. ../target/wasm32-wasi/debug/json_schemas.wasm + cd core/json_schemas && cargo build && wasmtime run --dir=. ../target/wasm32-wasip1/debug/json_schemas.wasm ${CORE_JS_ASSETS_MAP_STD}: ${MAP_STD} mkdir -p ${CORE_JS_ASSETS} diff --git a/core/.cargo/config.toml b/core/.cargo/config.toml index 84902f5..bda5e34 100644 --- a/core/.cargo/config.toml +++ b/core/.cargo/config.toml @@ -3,7 +3,7 @@ QUICKJS_WASM_SYS_WASI_SDK_PATH = { value = "wasi-sdk-20.0", relative = true } WASMTIME_NEW_CLI = "1" [build] -target = "wasm32-wasi" +target = "wasm32-wasip1" -[target.wasm32-wasi] +[target.wasm32-wasip1] runner = "wasmtime" diff --git a/scripts/build-a-core/template.py b/scripts/build-a-core/template.py index 275f2b9..0f03ac2 100644 --- a/scripts/build-a-core/template.py +++ b/scripts/build-a-core/template.py @@ -16,9 +16,9 @@ def dockerfile_template( cargo_profile = cargo_profile.replace("\n", "\\n").replace('"', '\\"') if wasm_opt_flags != "": - post_process = f"{OPT_BINARYEN}/bin/wasm-opt {wasm_opt_flags} {CARGO_TARGET_DIR}/wasm32-wasi/build-a-core/oneclient_core.wasm --output /opt/build-a-core/core.wasm" + post_process = f"{OPT_BINARYEN}/bin/wasm-opt {wasm_opt_flags} {CARGO_TARGET_DIR}/wasm32-wasip1/build-a-core/oneclient_core.wasm --output /opt/build-a-core/core.wasm" else: - post_process = f"cp {CARGO_TARGET_DIR}/wasm32-wasi/build-a-core/oneclient_core.wasm /opt/build-a-core/core.wasm" + post_process = f"cp {CARGO_TARGET_DIR}/wasm32-wasip1/build-a-core/oneclient_core.wasm /opt/build-a-core/core.wasm" return f""" FROM debian:bookworm as wasi-sdk-builder @@ -68,7 +68,7 @@ def dockerfile_template( apt clean rm -rf /var/lib/apt/lists/* EOF -RUN rustup default {toolchain_version} && rustup component add rust-src && rustup target add wasm32-wasi +RUN rustup default {toolchain_version} && rustup component add rust-src && rustup target add wasm32-wasip1 WORKDIR /opt/build-a-core RUN git clone https://github.com/superfaceai/one-sdk.git . && git checkout {core_ref} @@ -97,7 +97,7 @@ def dockerfile_template( ENV CARGO_HOME=/var/cache/cargo ENV CARGO_TARGET_DIR={CARGO_TARGET_DIR} RUN echo "{cargo_profile}" >>Cargo.toml -RUN --mount=type=cache,target=/var/cache/cargo cargo build --target wasm32-wasi --package oneclient_core --profile build-a-core {build_std_flags} +RUN --mount=type=cache,target=/var/cache/cargo cargo build --target wasm32-wasip1 --package oneclient_core --profile build-a-core {build_std_flags} COPY --from=binaryen-builder /opt/binaryen/bin {OPT_BINARYEN}/bin COPY --from=binaryen-builder /opt/binaryen/lib {OPT_BINARYEN}/lib From 8b6c5ebb10ea68d6a512dd45d3ba1a253c95e6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Fri, 27 Sep 2024 10:44:08 +0200 Subject: [PATCH 3/5] chore: uptimise code to fix wasm-opt error with too many locals --- core/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/Cargo.toml b/core/Cargo.toml index 1340da9..e19cfd7 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -15,6 +15,9 @@ thiserror = { version = "1" } url = { version = "2" } tracing = { version = "0.1" } +[profile.dev] +opt-level = 1 # + [profile.release] opt-level = "s" lto = true From 481c879144c2d3cc4210322a734a9ba9ce9603d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Mon, 30 Sep 2024 09:40:51 +0200 Subject: [PATCH 4/5] chore: update cicd target --- .github/actions/build_core/action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/build_core/action.yml b/.github/actions/build_core/action.yml index 79b5862..7223b6d 100644 --- a/.github/actions/build_core/action.yml +++ b/.github/actions/build_core/action.yml @@ -5,19 +5,19 @@ inputs: CARGO_PROFILE: description: "Cargo profile name to use for cargo cache key" required: false - default: 'release' + default: "release" CORE_WASM: description: "Whether to build core.wasm and core-async.wasm, oneOf `none, build, upload`" required: false - default: 'none' + default: "none" TEST_CORE_WASM: description: "Whether to build test-core.wasm and test-core-async.wasm, oneOf `none, build, upload`" required: false - default: 'none' + default: "none" COMLINK_WASM: description: "Whether to build comlink.wasm, oneOf `none, build, upload`" required: false - default: 'none' + default: "none" runs: using: "composite" @@ -52,7 +52,7 @@ runs: sudo apt-get install binaryen - name: Install rust target shell: bash - run: rustup target add wasm32-wasi + run: rustup target add wasm32-wasip1 # build and store core.wasm, core-async.wasm - name: Run make to build core.wasm if: ${{ inputs.CORE_WASM != 'none' }} From b6e02d5b8de9fd96f608ff32db15745251ad0c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Tue, 17 Dec 2024 15:35:48 +0100 Subject: [PATCH 5/5] chore: ignore unused profile property --- core/core/src/sf_core/cache.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/core/src/sf_core/cache.rs b/core/core/src/sf_core/cache.rs index 698ed90..47e7c9f 100644 --- a/core/core/src/sf_core/cache.rs +++ b/core/core/src/sf_core/cache.rs @@ -20,6 +20,7 @@ pub enum ProfileCacheEntryError { } #[derive(Debug)] pub struct ProfileCacheEntry { + #[allow(dead_code)] pub profile: String, // TODO: parsed so we can extract the version pub content_hash: String, }