Files
wasm-simulator/docs/linuxcnc-rs274-source-map.md
2026-05-22 04:43:21 +08:00

126 lines
3.8 KiB
Markdown

# LinuxCNC rs274 source map
This is the working map for moving from native `librs274` linking to source-level compilation and then to wasm.
## Compile assumptions
Native user-space syntax checks require:
- `-DULAPI`
- LinuxCNC include roots:
- `linuxcnc/src`
- `linuxcnc/src/emc`
- `linuxcnc/src/emc/nml_intf`
- `linuxcnc/src/emc/rs274ngc`
- `linuxcnc/src/emc/motion`
- `linuxcnc/src/emc/pythonplugin`
- `linuxcnc/include`
- Python development headers for current upstream sources, because the interpreter still embeds Python/Boost.Python paths.
## Source groups
### Interpreter core
These are the first group to keep compiling while we peel away native-only dependencies:
- `interp_arc.cc`
- `interp_array.cc`
- `interp_base.cc`
- `interp_check.cc`
- `interp_convert.cc`
- `interp_cycles.cc`
- `interp_execute.cc`
- `interp_find.cc`
- `interp_g7x.cc`
- `interp_inspection.cc`
- `interp_internal.cc`
- `interp_inverse.cc`
- `interp_namedparams.cc`
- `interp_o_word.cc`
- `interp_python.cc`
- `interp_queue.cc`
- `interp_read.cc`
- `interp_remap.cc`
- `interp_setup.cc`
- `interp_write.cc`
- `modal_state.cc`
- `nurbs_additional_functions.cc`
- `rs274ngc_pre.cc`
### Python binding modules
These are not needed for the browser simulator ABI and should not be part of the wasm core:
- `canonmodule.cc`
- `gcodemodule.cc`
- `interpmodule.cc`
- `pyarrays.cc`
- `pyblock.cc`
- `pyemctypes.cc`
- `pyinterp1.cc`
- `pyparamclass.cc`
### Browser-hostile dependencies to replace
- Python/Boost.Python remap and named parameter hooks.
- `dlopen`/`dlsym` interpreter loading in `interp_base.cc`.
- mmap-backed `tooldata_mmap.cc`.
- persistent parameter file writes.
- dynamic INI/HAL queries.
## Current syntax probe
Run:
```bash
./test-linuxcnc-source-syntax.sh
```
The probe checks a representative subset of source files with `-DULAPI`. It is not a full source build yet; it is a guardrail before the full source backend is introduced.
## Current object probe
Run:
```bash
./test-linuxcnc-source-objects.sh
```
This compiles every `core:` entry in `linuxcnc-rs274-source-files.txt` into object files. As of this step, the core interpreter sources compile to `.o` in the native environment with `-DULAPI`.
The next boundary is linking. Expected link risks:
- `PythonPlugin` and Boost.Python symbols from remap/named parameter paths.
- Python module initialization symbols if the source backend reuses the existing builtin module setup.
- `tooldata_*` implementations, currently mmap-backed in native LinuxCNC and unsuitable for wasm.
- dynamic loader code in `interp_base.cc`.
- parameter file persistence in `rs274ngc_pre.cc`.
## Current source-link probe
Run:
```bash
./test-linuxcnc-source-link.sh
```
This compiles every `core:` interpreter source into local objects and links the
native runner without `librs274`. It still uses built LinuxCNC support objects
and libraries for the dependencies that have not been replaced yet:
- Boost.Python binding module initializers required by the current interpreter constructor.
- `libpyplugin` for Python remap and named-parameter hooks.
- `liblinuxcncini` and `liblinuxcnchal` for INI/HAL named parameter paths.
- `liblinuxcnc-uspace-posix` for `rtapi_*` user-space helpers.
- `libtooldata` for the current mmap-backed native tool table.
This is not wasm-ready yet, but it proves the simulator can own and compile the
RS274 interpreter core sources directly. The next source-port boundary is to
replace each support dependency with browser-safe shims instead of pulling in
the LinuxCNC task, motion, HAL, and Python runtime layers.
The native runner used by this probe now recognizes simulator-owned control
lines before handing code to LinuxCNC: `M428`, `M429`, `M430`, `G43.4`,
`G43.5`, and `G49`. This keeps the direct runner aligned with the public
`linuxcnc-rs274` API backend for RTCP and kinematics switch tests.