Apply the EMCC_WASM_LD patch to the emscripten install. Idempotent — does nothing if the patch is already in place. Required so that ``shared.py`` honors the ``EMCC_WASM_LD`` env var we set below, routing emcc's internal wasm-ld invocation through our ctc-wasm-ld native launcher. Ad
()
| 520 | |
| 521 | |
| 522 | def _ensure_emscripten_wasm_ld_patch() -> None: |
| 523 | """Apply the EMCC_WASM_LD patch to the emscripten install. |
| 524 | |
| 525 | Idempotent — does nothing if the patch is already in place. Required |
| 526 | so that ``shared.py`` honors the ``EMCC_WASM_LD`` env var we set below, |
| 527 | routing emcc's internal wasm-ld invocation through our ctc-wasm-ld |
| 528 | native launcher. Added in clang-tool-chain 1.5.1 (closes #22). |
| 529 | """ |
| 530 | global _emscripten_patch_applied |
| 531 | if _emscripten_patch_applied: |
| 532 | return |
| 533 | try: |
| 534 | import platform as _platform_mod |
| 535 | |
| 536 | from clang_tool_chain.installers.emscripten import ensure_emscripten_available |
| 537 | |
| 538 | system = _platform_mod.system().lower() |
| 539 | platform_name = ( |
| 540 | "win" |
| 541 | if system == "windows" |
| 542 | else ("darwin" if system == "darwin" else "linux") |
| 543 | ) |
| 544 | machine = _platform_mod.machine().lower() |
| 545 | arch = "x86_64" if machine in ("x86_64", "amd64") else "arm64" |
| 546 | ensure_emscripten_available(platform_name, arch) |
| 547 | _emscripten_patch_applied = True |
| 548 | except KeyboardInterrupt: |
| 549 | raise |
| 550 | except Exception as e: |
| 551 | # Patch is best-effort. Without it, EMCC_WASM_LD is ignored and emcc |
| 552 | # falls back to the bundled wasm-ld — the build still works, just |
| 553 | # without the ctc-wasm-ld speedup on link. |
| 554 | print(f"[WASM] EMCC_WASM_LD patch attempt failed (non-fatal): {e}") |
| 555 | |
| 556 | |
| 557 | def _render_wasm_cross_file(build_dir: Path) -> Path: |