From 39636acf2ece94a1a71ef796768b195d7e79ecb5 Mon Sep 17 00:00:00 2001 From: udo Date: Sat, 18 Jul 2026 14:31:53 +0000 Subject: [PATCH] Keep precompile PCH generation-local --- docs/wasi-sdk-toolchain.md | 6 ++++++ docs/wasm-runtime-architecture.md | 2 +- scripts/compile_wasm_unit | 3 ++- src/lib/compiler.cpp | 3 ++- src/wasm/abi.h | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/wasi-sdk-toolchain.md b/docs/wasi-sdk-toolchain.md index 4448ccb..a429ce6 100644 --- a/docs/wasi-sdk-toolchain.md +++ b/docs/wasi-sdk-toolchain.md @@ -39,6 +39,12 @@ UCE expects these executables on each deployment host: source map before debug sections are stripped from the runtime artifact. The map is consulted only on a wasm trap. +The native compiler passes the ABI-generation root to +`scripts/compile_wasm_unit`. Unless `UCE_WASM_PCH_DIR` is explicitly set, the +unit PCH lives beneath that writable generation rather than a +process-user-dependent `/tmp` path. Managed precompile therefore behaves the +same inside and outside the service unit. + ## Upgrade policy Treat WASI SDK upgrades like runtime dependency upgrades: diff --git a/docs/wasm-runtime-architecture.md b/docs/wasm-runtime-architecture.md index 25b3d06..833a7ee 100644 --- a/docs/wasm-runtime-architecture.md +++ b/docs/wasm-runtime-architecture.md @@ -233,7 +233,7 @@ whose compilation outlasted the guest CPU budget would immediately trap in the following allocator/relocation call even though no guest loop consumed it. Unit artifacts live beneath an ABI-generation directory such as -`BIN_DIRECTORY/units-c12-w7`: `c12` is the compiler/unit-metadata ABI and `w7` +`BIN_DIRECTORY/units-c13-w7`: `c13` is the compiler/unit-metadata ABI and `w7` is the runtime core ABI. Old and new service binaries therefore never publish or read the same unit path during an ABI transition. The managed restart builds and serializes the complete next generation before stopping the old service; diff --git a/scripts/compile_wasm_unit b/scripts/compile_wasm_unit index 675bccb..e0a1820 100755 --- a/scripts/compile_wasm_unit +++ b/scripts/compile_wasm_unit @@ -9,6 +9,7 @@ DEST_DIR="$2" SRC_FN="$3" PP_FN="$4" WASM_FN="$5" +UNIT_CACHE_DIR="${6:-$DEST_DIR}" SDK=${WASI_SDK:-/opt/wasi-sdk} ABI_VERSION=${UCE_UNIT_ABI_VERSION:-$(awk '/^#define UCE_WASM_CORE_ABI_VERSION / {print $3; exit}' src/wasm/abi.h)} @@ -19,7 +20,7 @@ MODULE_TMP="$DEST_DIR/$PP_FN.uce-module.txt" WASM_TMP="$DEST_DIR/$WASM_FN.tmp.$$" MAP_TMP="$DEST_DIR/$WASM_FN.source-map.tmp.$$" PCH_ENABLED=${UCE_WASM_UNIT_PCH:-1} -PCH_DIR=${UCE_WASM_PCH_DIR:-/tmp/uce/wasm-w2/pch} +PCH_DIR=${UCE_WASM_PCH_DIR:-$UNIT_CACHE_DIR/.pch} COMMON_FLAGS=( --target=wasm32-wasip1 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden diff --git a/src/lib/compiler.cpp b/src/lib/compiler.cpp index fbce0b2..07aecd0 100644 --- a/src/lib/compiler.cpp +++ b/src/lib/compiler.cpp @@ -992,7 +992,8 @@ void compile_shared_unit(Request* context, SharedUnit* su) shell_escape(su->bin_path)+" "+ shell_escape(su->file_name)+" "+ shell_escape(su->pre_file_name)+" "+ - shell_escape(su->wasm_file_name) + shell_escape(su->wasm_file_name)+" "+ + shell_escape(compiler_unit_bin_directory(context)) )); if(su->compiler_messages.length() == 0 && !file_exists(su->wasm_name)) diff --git a/src/wasm/abi.h b/src/wasm/abi.h index ee71219..40b7d2d 100644 --- a/src/wasm/abi.h +++ b/src/wasm/abi.h @@ -1,4 +1,4 @@ #pragma once #define UCE_WASM_CORE_ABI_VERSION 7 -#define UCE_COMPILER_UNIT_ABI_VERSION 12 +#define UCE_COMPILER_UNIT_ABI_VERSION 13