# Open CASCADE Technology (OCCT) in Zolid Precision CAD Zolid's Precision CAD kernel uses Open CASCADE Technology, a third-party library, as a separate, replaceable WebAssembly module. - Library: Open CASCADE Technology (OCCT) - Version: 7.9.3 (tag `V7_9_3`, commit `a016080bf6738d6aeae020badee4e888ad1540a5`) - Official source: https://github.com/Open-Cascade-SAS/OCCT (also https://dev.opencascade.org) - Licence: GNU LGPL 2.1 with the Open CASCADE exception (`LICENSE_LGPL_21.txt`, `OCCT_LGPL_EXCEPTION.txt`, copied verbatim from the source tree). - Modifications: none. OCCT is built from the unmodified upstream tag; the build recipe refuses a source tree with local changes unless you name your own with `OCCT_SRC`. Only build options are chosen (static libraries, selected toolkits, wasm exceptions, size optimisation). ## Written offer For at least three years from when we last distribute this version, we will provide the complete corresponding source code of OpenCascade 7.9.3 (the library in `occt.wasm`) on request: email support@zolid.dev. This offer covers only OpenCascade, not Zolid's own code. ## How the kernel is put together The kernel is two files, linked when they are loaded, never before: | File | Contains | Licence | |---|---|---| | `occt.wasm` | OCCT, compiled from the source above, plus the Emscripten C/C++ runtime (musl libc, libc++, libc++abi; permissive licences) | LGPL 2.1 + exception (OCCT) | | `cad.wasm` | Zolid's bridge, which uses OCCT only through the interface below. It contains no OCCT code. | Zolid, proprietary | The JavaScript loader (`loadCad()`, `lib/dylink.mjs`) links `cad.wasm` against whichever `occt.wasm` it is given, using the standard WebAssembly dynamic-linking convention (https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md). This is a shared library mechanism in the sense of LGPL 2.1 section 6(b): it uses the copy of the library present at run time and works with a modified version of it, as long as that version is interface-compatible. OCCT is never linked into `engine.wasm`. ## Where it lives In the built engine: `wasm/cad/occt.wasm`, next to `cad.wasm`, this file, the licence texts and the build recipe (`build_occt.sh`, `occt.env`). In the source repository the recipe is in `third_party/occt/`. ## The interface `occt.wasm` is an Emscripten "main module" (`-sMAIN_MODULE=2 -sSTANDALONE_WASM`). It must: - export `memory`, `__indirect_function_table`, `__stack_pointer`, the C++ exception tag `__cpp_exception` and `calloc`; - export every symbol `cad.wasm` imports from `env`, `GOT.mem` and `GOT.func`: OCCT's public C++ API (mangled names) and the C/C++ runtime functions it uses. The build recipe derives this list from `cad.wasm` itself, so you never maintain it by hand, and fails the link if your OCCT lacks one; you can print it with `WebAssembly.Module.imports(new WebAssembly.Module(bytes))`. `occt.wasm` itself imports no OCCT code from `cad.wasm`; - use the same C++ ABI: OCCT 7.9.3's public headers (class layouts, virtual tables), compiled with the Emscripten release `EMSCRIPTEN_VERSION` and the code-generation flags `OCCT_CFLAGS` from `occt.env` (relocatable code, native wasm exceptions). If a replacement lacks a symbol, `loadCad()` fails at load time and names the missing symbols. ## Replacing occt.wasm 1. Install Emscripten (the release in `occt.env`), CMake, Ninja and Node.js (binaryen's `wasm-opt` is optional). 2. Build: from the folder holding `cad.wasm` (`wasm/cad/` in the package), run ```sh bash build_occt.sh # pinned official source; writes occt.wasm here OCCT_SRC=/path/to/your/occt bash build_occt.sh # your own, possibly modified, OCCT source ``` `build_occt.sh [cad.wasm] [occt.wasm]` also takes explicit paths. It builds the OCCT toolkits listed in `occt.env` as static libraries and links them into `occt.wasm`, keeping exactly the symbols `cad.wasm` imports. Work files go to `OCCT_WORK` (default `~/.cache/zolid-occt`). 3. Use it: an `occt.wasm` next to `cad.wasm` is picked up by `loadCad()`; one kept elsewhere is passed in with `loadCad({ occt: "/path/to/occt.wasm" })` (also a URL, bytes, a `Response` or a compiled `WebAssembly.Module`). The unmodified `cad.wasm` then runs on your OCCT.