[PR #1446] [MERGED] Mod SDK: export_mod! exports only in WebAssembly, so the guests link on macOS #3526

Closed
opened 2026-11-03 04:10:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1446
Author: @ludovic111
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @ludovic111

Base: main ← Head: fix/macos-guest-cdylib-link


📝 Commits (1)

  • eeb4cdb Mod SDK: export_mod! exports only in WebAssembly, so the guests link on macOS

📊 Changes

1 file changed (+6 additions, -0 deletions)

View changed files

📝 crates/horizon-mod-sdk/src/lib.rs (+6 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

cargo build --workspace / cargo test --workspace on macOS failed to link the two wasm guest cdylibs (coords-hud, horizon-mods-test-guest), so Mac agents had to --exclude them (review-plan.md §1 Build, workstream 6).

Cause: on a host build the SDK's export_mod! emits the component's exports (horizon:mods/events@0.1.0#init, cabi_post_…#command, …) and rustc lists them in the cdylib's exported-symbols file; ld64 treats # there as a comment, so it looks for _horizon:mods/events@0.1.0, which doesn't exist:

Undefined symbols for architecture arm64:
  "_cabi_post_horizon:mods/events@0.1.0", referenced from: <initial-undefines>
  "_horizon:mods/events@0.1.0", referenced from: <initial-undefines>

(-undefined dynamic_lookup doesn't help.)

Fix (6 lines in crates/horizon-mod-sdk/src/lib.rs): the exports are only generated for wasm32, the only target that uses them. On the host the macro still type-checks the mod and references Export::init, so the mod's type and methods aren't dead code (without that line clippy reports struct CoordsHud is never constructed). The wasm32 expansion is unchanged.

Before / after (Mac mini)

before after
cargo build -p coords-hud link error above builds
cargo build --workspace fails on the two guests builds (3 m 49 s, only the existing __eh_frame linker note)
cargo test -p coords-hud -p horizon-mods-test-guest -p horizon-mod-sdk link error 3 passed

Self-check

  • cargo fmt --all -- --check: OK
  • cargo clippy --workspace --all-targets -- -D warnings (macOS host): OK
  • cargo clippy -p coords-hud -p horizon-mods-test-guest --target wasm32-unknown-unknown -- -D warnings: OK
  • cargo test -p horizon-mods (sandbox tests: builds both guests for wasm32, loads them in wasmtime): 11 + 12 passed, 1 ignored (the benchmark)
  • tools/parity.py --changed origin/main --list: 0 of 329 harnesses depend on the SDK.

Needs Ludovic

Nothing. Mod authors see no change (their wasm32 builds expand the same).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1446 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/macos-guest-cdylib-link` --- ### 📝 Commits (1) - [`eeb4cdb`](https://github.com/horizon-rust/horizon/commit/eeb4cdb680bb16739a1f4c85e3bea24ad2097052) Mod SDK: export_mod! exports only in WebAssembly, so the guests link on macOS ### 📊 Changes **1 file changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-mod-sdk/src/lib.rs` (+6 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `cargo build --workspace` / `cargo test --workspace` on macOS failed to link the two wasm guest cdylibs (coords-hud, horizon-mods-test-guest), so Mac agents had to `--exclude` them (review-plan.md §1 Build, workstream 6). Cause: on a host build the SDK's `export_mod!` emits the component's exports (`horizon:mods/events@0.1.0#init`, `cabi_post_…#command`, …) and rustc lists them in the cdylib's exported-symbols file; ld64 treats `#` there as a comment, so it looks for `_horizon:mods/events@0.1.0`, which doesn't exist: ``` Undefined symbols for architecture arm64: "_cabi_post_horizon:mods/events@0.1.0", referenced from: <initial-undefines> "_horizon:mods/events@0.1.0", referenced from: <initial-undefines> ``` (`-undefined dynamic_lookup` doesn't help.) Fix (6 lines in `crates/horizon-mod-sdk/src/lib.rs`): the exports are only generated for `wasm32`, the only target that uses them. On the host the macro still type-checks the mod and references `Export::init`, so the mod's type and methods aren't dead code (without that line clippy reports `struct CoordsHud is never constructed`). The wasm32 expansion is unchanged. ## Before / after (Mac mini) | | before | after | |---|---|---| | `cargo build -p coords-hud` | link error above | builds | | `cargo build --workspace` | fails on the two guests | builds (3 m 49 s, only the existing `__eh_frame` linker note) | | `cargo test -p coords-hud -p horizon-mods-test-guest -p horizon-mod-sdk` | link error | 3 passed | ## Self-check - `cargo fmt --all -- --check`: OK - `cargo clippy --workspace --all-targets -- -D warnings` (macOS host): OK - `cargo clippy -p coords-hud -p horizon-mods-test-guest --target wasm32-unknown-unknown -- -D warnings`: OK - `cargo test -p horizon-mods` (sandbox tests: builds both guests for wasm32, loads them in wasmtime): 11 + 12 passed, 1 ignored (the benchmark) - `tools/parity.py --changed origin/main --list`: 0 of 329 harnesses depend on the SDK. ## Needs Ludovic Nothing. Mod authors see no change (their wasm32 builds expand the same). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:10:11 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3526
No description provided.