Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ install: install-bash install-nginx install-git install-curl install-grep instal
clean:
$(MAKE) -C '$(APPS_ROOT)/lmbench/src' clean || true
-rm -rf '$(APPS_BIN_DIR)/lmbench'
-rm -rf '$(APPS_BUILD)/lmbench'
-rm -rf '$(APPS_BIN_DIR)/nginx'
-$(MAKE) -C '$(APPS_ROOT)/nginx' clean || true
-rm -rf '$(APPS_OVERLAY)' '$(MERGED_SYSROOT)' '$(APPS_BIN_DIR)' '$(APPS_LIB_DIR)' '$(TOOL_ENV)'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Artifacts land under`build/`:
- `build/sysroot_overlay/` – staged headers/libs (e.g., libtirpc)
- `build/sysroot_merged/` – base sysroot + overlay
- `build/lib/` – helper archives (e.g., `liblmb_stubs.a`, combined `libc.a`)
- `build/bin/lmbench/wasm32-wasi/` – lmbench binaries
- `build/lmbench/bin/` – lmbench binaries (canonical)
- `build/bin/lmbench/wasm32-wasi/` – lmbench binaries (legacy mirror)
- `build/bin/bash/wasm32-wasi/` – bash outputs

==List produced binaries:==
Expand All @@ -42,7 +43,7 @@ Artifacts land under`build/`:
- `make stubs`
Creates small compatibility stubs needed for lmbench (temporary workaround; see TODOs in Makefile).
- `make lmbench`
Builds lmbench via `lmbench/src/compile_lmbench.sh` and stages into `build/bin/lmbench/wasm32-wasi/`.
Builds lmbench via `lmbench/src/compile_lmbench.sh`, stages into `build/lmbench/bin/`, and mirrors to `build/bin/lmbench/wasm32-wasi/`.
- `make bash`
Builds bash via `bash/compile_bash.sh` and stages into `build/bin/bash/wasm32-wasi/`.
- `make clean
Expand All @@ -53,4 +54,3 @@ Artifacts land under`build/`:
- `LIND_WASM_ROOT` – path to `lind-wasm` (default: `~/lind-wasm`)
- `WASMTIME_PROFILE` – `debug` or `release` (scripts fall back to `release` if missing)
- `WASM_OPT`, `WASMTIME` – override tool paths if needed

21 changes: 17 additions & 4 deletions lmbench/src/compile_lmbench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ set -euo pipefail
# High level:
# 1) Reuse the merged `libc.a` augmentation unless its inputs changed.
# 2) Rebuild lmbench only when the toolchain or build inputs changed.
# 3) Stage raw wasm outputs first.
# 3) Stage outputs under build/lmbench/bin (canonical location).
# 4) Treat optimization and precompilation as optional, heavier follow-up
# work instead of always doing them on the default path.
# 5) Mirror canonical outputs to build/bin/lmbench/wasm32-wasi (legacy path).

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
Expand All @@ -20,7 +21,8 @@ fi
APPS_BUILD="$REPO_ROOT/build"
APPS_OVERLAY="$APPS_BUILD/sysroot_overlay"
MERGED_SYSROOT="$APPS_BUILD/sysroot_merged"
APPS_BIN_ROOT="$APPS_BUILD/bin/lmbench"
APPS_LMBENCH_CANON_ROOT="$APPS_BUILD/lmbench/bin"
APPS_LMBENCH_LEGACY_ROOT="$APPS_BUILD/bin/lmbench"
TOOL_ENV="$APPS_BUILD/.toolchain.env"
MAX_WASM_MEMORY="${MAX_WASM_MEMORY:-67108864}"
ENABLE_WASI_THREADS="${ENABLE_WASI_THREADS:-1}"
Expand Down Expand Up @@ -127,6 +129,15 @@ run_wasm_opt_replace() {
fi
}

mirror_legacy_outputs() {
local legacy_out="$APPS_LMBENCH_LEGACY_ROOT/wasm32-wasi"
rm -rf "$legacy_out"
mkdir -p "$legacy_out"
cp -a "$OUT_DIR/." "$legacy_out/"
echo "[lmbench] mirrored artifacts to legacy path: $legacy_out"
}


BASE_LIBC="$MERGED_SYSROOT/lib/wasm32-wasi/libc.a"
TIRPC_MERGE_DIR="$APPS_OVERLAY/usr/lib/wasm32-wasi/merge_tmp"

Expand Down Expand Up @@ -299,8 +310,8 @@ echo "[lmbench] building suite with REAL_CC='$REAL_CC'"
)
printf '%s\n' "$current_build_sig" >"$BUILD_SIG_FILE"

mkdir -p "$APPS_BIN_ROOT"
OUT_DIR="$APPS_BIN_ROOT/wasm32-wasi"
mkdir -p "$APPS_LMBENCH_CANON_ROOT"
OUT_DIR="$APPS_LMBENCH_CANON_ROOT"

echo "[lmbench] staging binaries from $LM_BENCH_BIN_DIR -> $OUT_DIR"

Expand Down Expand Up @@ -374,6 +385,7 @@ wait_for_background_jobs
##################
if [[ "$ARTIFACT_MODE" != "full" ]]; then
echo "[lmbench] artifact mode is fast; keeping default lmbench program names runnable and skipping cwasm generation."
mirror_legacy_outputs
exit 0
fi

Expand Down Expand Up @@ -413,4 +425,5 @@ else
echo "[lmbench] NOTE: lind-boot not found at '$LIND_BOOT'; skipping cwasm generation."
fi

mirror_legacy_outputs
echo "[lmbench] post-processing complete."