每轮只推进合理适量的上下文、禁止顺手扩功能 smoke:源码链接构建约束

This commit is contained in:
cnc
2026-06-01 19:54:04 +08:00
parent 6f9431a389
commit 5ec10abf38
41 changed files with 3301 additions and 670 deletions

View File

@@ -3,63 +3,33 @@ set -euo pipefail
cd "$(dirname "$0")"
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
cxx=${CXX:-g++}
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_runtime_link.XXXXXX")
manifest=${1:-linuxcnc-rs274-wasm-source-files.txt}
trap 'rm -rf "$build_dir"' EXIT
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs.sh "$manifest"
preflight_cache_dir=${CNC_SIM_PREFLIGHT_CACHE_DIR:-build/wasm-probe-preflight-cache}
probe=$(CNC_SIM_PREFLIGHT_CACHE_DIR="$preflight_cache_dir" ./build-linuxcnc-wasm-link-probe.sh --mode runtime "$manifest")
probe_dir=$(dirname "$probe")
symbol_file="$probe_dir/runtime.symbols"
symbol_signature="$probe_dir/runtime.symbols.signature"
symbol_next_signature="$probe_dir/runtime.symbols.signature.next"
{
printf 'PROBE=%s\n' "$probe"
printf 'SYMBOL_RULE_VERSION=1\n'
stat -c 'PROBE_STAT=%n:%s:%y' "$probe"
} > "$symbol_next_signature"
if [[ ! -f "$symbol_file" || ! -f "$symbol_signature" ]] || ! cmp -s "$symbol_signature" "$symbol_next_signature"; then
nm -C "$probe" > "$symbol_file"
mv "$symbol_next_signature" "$symbol_signature"
else
rm -f "$symbol_next_signature"
fi
grep -F "cnc_sim_parse_program" "$symbol_file" >/dev/null
grep -F "parse_linuxcnc_rs274_backend" "$symbol_file" >/dev/null
grep -F "parse_gcode_with_backend" "$symbol_file" >/dev/null
grep -F "Interp::read(char const*)" "$symbol_file" >/dev/null
grep -F "Interp::init()" "$symbol_file" >/dev/null
grep -E '(^| )wordexp($| )' "$symbol_file" >/dev/null
grep -E '(^| )wordfree($| )' "$symbol_file" >/dev/null
common_flag_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-wasm-common-cxxflags.sh --profile core20-sections)
mapfile -t common_flags <<<"$common_flag_output"
common_flags+=(-DCNC_SIM_ENABLE_LINUXCNC_RS274_BACKEND)
shim_output=$(./list-linuxcnc-wasm-safe-shims.sh)
mapfile -t sources <<<"$shim_output"
core_source_output=$(./list-cmake-set-sources.sh cnc_sim_core_sources core/)
mapfile -t core_sources <<<"$core_source_output"
sources+=("${core_sources[@]}")
backend_source_output=$(./list-cmake-set-sources.sh cnc_sim_linuxcnc_rs274_backend_sources core/)
mapfile -t backend_sources <<<"$backend_source_output"
sources+=("${backend_sources[@]}")
source_output=$(LINUXCNC_ROOT="$linuxcnc_root" ./list-linuxcnc-wasm-manifest-sources.sh "$manifest" core full)
mapfile -t linuxcnc_sources <<<"$source_output"
sources+=("${linuxcnc_sources[@]}")
sources+=(core/wasm_shims/cnc_sim_wasm_runtime_probe_main.cc)
objects=()
object_index=0
for source in "${sources[@]}"; do
obj="$build_dir/source_${object_index}.o"
source_flags=()
case "$source" in
core/src/linuxcnc_genserfuncs_adapter.c|core/src/linuxcnc_xyzab_tdr_kins_adapter.c)
source_flags+=(-fpermissive)
;;
esac
"$cxx" "${common_flags[@]}" "${source_flags[@]}" -c "$source" -o "$obj"
objects+=("$obj")
object_index=$((object_index + 1))
done
"$cxx" "${objects[@]}" \
-Wl,--gc-sections \
-lfmt \
-o "$build_dir/cnc_sim_wasm_runtime_probe"
nm -C "$build_dir/cnc_sim_wasm_runtime_probe" > "$build_dir/runtime.symbols"
grep -F "cnc_sim_parse_program" "$build_dir/runtime.symbols" >/dev/null
grep -F "parse_linuxcnc_rs274_backend" "$build_dir/runtime.symbols" >/dev/null
grep -F "parse_gcode_with_backend" "$build_dir/runtime.symbols" >/dev/null
grep -F "Interp::read(char const*)" "$build_dir/runtime.symbols" >/dev/null
grep -F "Interp::init()" "$build_dir/runtime.symbols" >/dev/null
grep -E '(^| )wordexp($| )' "$build_dir/runtime.symbols" >/dev/null
grep -E '(^| )wordfree($| )' "$build_dir/runtime.symbols" >/dev/null
"$build_dir/cnc_sim_wasm_runtime_probe"
"$probe"
echo "linuxcnc wasm runtime link probe passed"