Files
wasm-simulator/analyze-linuxcnc-wasm-blockers.sh
cnc fb9561ccc7 按源标记Python绑定编译覆盖
结论:依据 LinuxCNC RS274 Python/Boost.Python 绑定源 canonmodule.cc、gcodemodule.cc、interpmodule.cc 与 py*.cc,blocker 分析新增 python-compile-covered 分组,锁定这些 blocker 已由 inert Python C API symbol probe 编译覆盖;Python/remap 执行仍保持禁用,未扩展 smoke。

检查:./test-linuxcnc-wasm-python-c-api-symbols.sh;./test-linuxcnc-wasm-blockers.sh linuxcnc-rs274-wasm-source-files.txt;CNC_SIM_WASM_BLOCKERS_SELF_CHECKS=1 ./test-linuxcnc-wasm-blockers.sh linuxcnc-rs274-wasm-source-files.txt;./check-linuxcnc-wasm-blockers-source-map.sh;./test-native.sh;./test-linuxcnc-source-link.sh。
2026-06-06 12:27:22 +08:00

215 lines
6.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
# LinuxCNC source basis: this blocker scan is constrained to the RS274/WASM
# manifest. Python and Boost.Python blockers come from
# src/emc/rs274ngc/gcodemodule.cc, interp_namedparams.cc, interp_o_word.cc,
# and the py*.cc module bindings; tooldata/native-backend blockers come from
# src/emc/tooldata/tooldata_mmap.cc and tooldata_db.cc; native filesystem
# coverage comes from LinuxCNC RS274 sources such as interp_o_word.cc
# directory traversal and rs274ngc_pre.cc parameter-file replacement.
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
manifest=${1:-linuxcnc-rs274-wasm-source-files.txt}
LINUXCNC_ROOT="$linuxcnc_root" ./check-linuxcnc-inputs-cached.sh "$manifest"
linuxcnc_root=$(cd "$linuxcnc_root" && pwd)
python_blockers=()
python_compile_covered=()
core_python_sources=()
dlopen_blockers=()
core_dlopen_sources=()
tooldata_blockers=()
core_tooldata_sources=()
shimmed_tooldata_users=()
core_tooldata_users=()
native_backend_blockers=()
native_fs_blockers=()
core_native_fs_sources=()
core_count=0
blocked_count=0
blocked_replacements=()
shim_source_output=$(./list-linuxcnc-wasm-safe-shims.sh)
mapfile -t wasm_safe_shims <<<"$shim_source_output"
blocked_replacement_for() {
case "$1" in
src/emc/tooldata/tooldata_mmap.cc)
./list-linuxcnc-wasm-safe-shims.sh tooldata_mmap_backend.cc
;;
src/emc/rs274ngc/canonmodule.cc|src/emc/rs274ngc/gcodemodule.cc|src/emc/rs274ngc/interpmodule.cc)
./list-linuxcnc-wasm-safe-shims.sh linuxcnc_runtime_shim.cc
;;
src/emc/rs274ngc/pyarrays.cc|src/emc/rs274ngc/pyblock.cc|src/emc/rs274ngc/pyemctypes.cc|src/emc/rs274ngc/pyinterp1.cc|src/emc/rs274ngc/pyparamclass.cc)
./list-linuxcnc-wasm-safe-shims.sh python_c_api_shim.cc
;;
*)
return 1
;;
esac
}
wasm_safe_shim_in_build() {
local shim=$1
local candidate
for candidate in "${wasm_safe_shims[@]}"; do
if [[ "$candidate" == "$shim" ]]; then
return 0
fi
done
return 1
}
python_compile_probe_covers() {
grep -F "$1" test-linuxcnc-wasm-python-c-api-symbols.sh >/dev/null
}
core_sources=()
blocked_sources=()
manifest_line_number=0
while IFS= read -r manifest_line || [[ -n "$manifest_line" ]]; do
manifest_line_number=$((manifest_line_number + 1))
case "$manifest_line" in
""|\#*)
continue
;;
esac
IFS=: read -r group path note extra <<<"$manifest_line"
if [[ -z "$group" || -z "$path" || -z "$note" || -n "${extra:-}" ]]; then
echo "bad manifest line $manifest_line_number: $manifest_line" >&2
exit 1
fi
case "$group" in
core)
core_sources+=("$path")
;;
blocked)
blocked_sources+=("$path")
;;
header|metadata|blocked-header)
;;
*)
echo "unknown manifest group: $group" >&2
exit 1
;;
esac
done < "$manifest"
core_count=${#core_sources[@]}
blocked_count=${#blocked_sources[@]}
scan_source() {
local group=$1
local path=$2
full_path="$linuxcnc_root/$path"
if [[ ! -f "$full_path" ]]; then
echo "missing manifest source: $path" >&2
exit 1
fi
if [[ "$group" == "blocked" ]]; then
if ! replacement=$(blocked_replacement_for "$path"); then
echo "missing blocked replacement mapping: $path" >&2
exit 1
fi
if [[ ! -f "$replacement" ]]; then
echo "missing blocked replacement source: $replacement" >&2
exit 1
fi
if ! wasm_safe_shim_in_build "$replacement"; then
echo "blocked replacement is not in wasm shim build set: $path -> $replacement" >&2
exit 1
fi
blocked_replacements+=("$path -> $replacement")
fi
if [[ "$path" == src/emc/tooldata/* ]]; then
if [[ "$group" == "blocked" ]]; then
tooldata_blockers+=("$path")
else
core_tooldata_sources+=("$path")
fi
fi
if [[ "$path" == "src/emc/tooldata/tooldata_mmap.cc" ]]; then
native_backend_blockers+=("$path")
fi
if grep -Eq 'Python\.h|boost/python|pythonplugin|PyObject|PyInit_' "$full_path"; then
if [[ "$group" == "blocked" ]]; then
python_blockers+=("$path")
if python_compile_probe_covers "$path"; then
python_compile_covered+=("$path")
fi
else
core_python_sources+=("$path")
fi
fi
if grep -Eq 'dlopen|dlsym|RTLD_' "$full_path"; then
if [[ "$group" == "blocked" ]]; then
dlopen_blockers+=("$path")
else
core_dlopen_sources+=("$path")
fi
fi
if grep -Eq 'mkstemp|mkstemps|dirent\.h|opendir|readdir|unistd\.h' "$full_path"; then
if [[ "$group" == "blocked" ]]; then
native_fs_blockers+=("$path")
else
core_native_fs_sources+=("$path")
fi
fi
if [[ "$path" != src/emc/tooldata/* ]] && grep -Eq 'tooldata/tooldata.hh|tooldata_' "$full_path"; then
if [[ "$group" == "blocked" ]]; then
shimmed_tooldata_users+=("$path")
else
core_tooldata_users+=("$path")
fi
fi
}
for path in "${core_sources[@]}"; do
[[ -z "$path" ]] && continue
scan_source core "$path"
done
for path in "${blocked_sources[@]}"; do
[[ -z "$path" ]] && continue
scan_source blocked "$path"
done
print_group() {
local title=$1
shift
echo "[$title]"
if [[ $# -eq 0 ]]; then
echo "(none)"
else
printf '%s\n' "$@" | LC_ALL=C sort -u
fi
echo
}
echo "[manifest]"
echo "core=$core_count"
echo "blocked=$blocked_count"
echo
print_group "python" "${python_blockers[@]}"
print_group "python-compile-covered" "${python_compile_covered[@]}"
print_group "dlopen" "${dlopen_blockers[@]}"
print_group "tooldata" "${tooldata_blockers[@]}"
print_group "tooldata-users" "${shimmed_tooldata_users[@]}"
print_group "native-backend" "${native_backend_blockers[@]}"
print_group "native-fs" "${native_fs_blockers[@]}"
print_group "blocked-replacements" "${blocked_replacements[@]}"
print_group "core-python-shimmed" "${core_python_sources[@]}"
print_group "core-dlopen-shimmed" "${core_dlopen_sources[@]}"
print_group "core-tooldata-shimmed" "${core_tooldata_sources[@]}"
print_group "core-tooldata-users-shimmed" "${core_tooldata_users[@]}"
print_group "core-native-fs-shimmed" "${core_native_fs_sources[@]}"