phase 5
This commit is contained in:
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# Phase 3: build a core reactor plus one generated-shape PIC side module.
|
||||
# Runs on k-uce; artifacts go under /tmp/uce/wasm-phase3.
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
SDK=/opt/wasi-sdk
|
||||
ROOT=$(cd ../.. && pwd)
|
||||
OUT=/tmp/uce/wasm-phase3
|
||||
SHIM="$OUT/shim"
|
||||
mkdir -p "$OUT" "$SHIM"
|
||||
|
||||
cat > "$SHIM/uce_lib.h" <<'EOF'
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
String html_escape(String s);
|
||||
EOF
|
||||
cp "$ROOT/src/lib/types.h" "$SHIM/types.h"
|
||||
python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
p = Path('/tmp/uce/wasm-phase3/shim/types.h')
|
||||
s = p.read_text()
|
||||
start = s.index('void * operator new(decltype(sizeof(0)) n) noexcept(false)')
|
||||
end = s.index('void operator delete(void * p) throw()')
|
||||
end = s.index('\n}', end) + 3
|
||||
replacement = '''// WASM side-module shim: allocator is owned by the core module.\nvoid * operator new(decltype(sizeof(0)) n) noexcept(false);\nvoid operator delete(void * p) throw();\nvoid operator delete(void * p, decltype(sizeof(0)) n) noexcept;\n'''
|
||||
p.write_text(s[:start] + replacement + s[end:])
|
||||
PY
|
||||
cat > "$SHIM/signal.h" <<'EOF'
|
||||
#pragma once
|
||||
typedef int sig_atomic_t;
|
||||
typedef void (*sighandler_t)(int);
|
||||
#define SIGTERM 15
|
||||
int raise(int);
|
||||
sighandler_t signal(int, sighandler_t);
|
||||
EOF
|
||||
|
||||
"$SDK/bin/clang++" --target=wasm32-wasip1 -mexec-model=reactor \
|
||||
-O1 -fno-exceptions \
|
||||
-I../.. -I../../src/lib \
|
||||
core.cpp -o "$OUT/core.wasm" \
|
||||
-Wl,--export-all \
|
||||
-Wl,--import-table \
|
||||
-Wl,--export=__stack_pointer \
|
||||
-Wl,--export=__heap_base \
|
||||
-Wl,--allow-undefined-file=hostcalls.syms \
|
||||
-Wl,--undefined=_ZTVN10__cxxabiv117__class_type_infoE
|
||||
|
||||
"$SDK/bin/clang++" --target=wasm32-wasip1 -fPIC -fvisibility=default \
|
||||
-fvisibility-inlines-hidden \
|
||||
-O1 -fno-exceptions \
|
||||
-I"$SHIM" -I"$ROOT/src/lib" \
|
||||
-c generated/page.uce.cpp -o "$OUT/page.o"
|
||||
|
||||
"$SDK/bin/clang++" --target=wasm32-wasip1 -fPIC -fvisibility=default \
|
||||
-fvisibility-inlines-hidden \
|
||||
-O1 -fno-exceptions \
|
||||
-I"$SHIM" -I"$ROOT/src/lib" \
|
||||
-c generated/helper.cpp -o "$OUT/helper.o"
|
||||
|
||||
"$SDK/bin/wasm-ld" -shared --experimental-pic \
|
||||
--unresolved-symbols=import-dynamic \
|
||||
"$OUT/page.o" "$OUT/helper.o" -o "$OUT/page.wasm" \
|
||||
--export=__uce_set_current_request \
|
||||
--export=__uce_render
|
||||
|
||||
echo "--- phase3 core.wasm ---"
|
||||
ls -la "$OUT/core.wasm"
|
||||
echo "--- phase3 page.wasm ---"
|
||||
ls -la "$OUT/page.wasm"
|
||||
Reference in New Issue
Block a user