Skip to content

Conversation

@sanity
Copy link
Contributor

@sanity sanity commented Oct 20, 2025

Summary

Fixes freenet/river#39

Windows MSVC linker errors when building contracts because it requires all external symbols to be resolved, even for cdylib crates. The WASM import symbols are only valid for the wasm32-unknown-unknown target.

Root Cause

The external symbols __frnt__logger__info, __frnt__rand__rand_bytes, and __frnt__time__utc_now are declared as WASM imports using #[link(wasm_import_module = "...")]. These symbols are provided by the Freenet WASM runtime at load time.

When compiling contracts on Windows for the native target (x86_64-pc-windows-msvc), the MSVC linker (link.exe) is strict and requires all external symbols to be resolved during linking, causing LNK2019 errors. Linux/Mac linkers are more lenient.

Changes

  • Guards WASM import declarations with #[cfg(target_family = "wasm")]
  • Provides stub implementations for non-WASM targets with #[cfg(not(target_family = "wasm"))]
  • Allows contracts to compile on Windows native target without linker errors

Testing

  • ✅ Builds successfully on Linux for native target
  • ✅ Builds successfully for wasm32-unknown-unknown target
  • ✅ All tests pass

Impact

The stub implementations are never used at runtime since contracts only execute in the Freenet WASM runtime. This change only affects compilation, not runtime behavior.

Next Steps

After this PR is merged:

  1. Release freenet-stdlib v0.1.23
  2. Update freenet-core to use new version
  3. Update river to use new version

[AI-assisted debugging and comment]

sanity and others added 4 commits September 28, 2025 02:22
Adds three Claude workflows:
- claude.yml: Responds to @claude mentions in issues/PRs
- claude-code-review.yml: Automated PR code reviews
- claude-ci-analysis job in ci.yml: Analyzes CI failures when 'claude-debug' label is present

Features:
- Opt-in debugging with 'claude-debug' label
- Automatic code review on PR creation
- Interactive @claude support for questions and debugging
- Reads CI logs and provides root cause analysis

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Changed all Claude workflows to use ANTHROPIC_API_KEY environment
variable instead of claude_code_oauth_token parameter.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Composite actions need environment variables at job level,
not step level, to properly access them during validation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixes freenet/river#39

Windows MSVC linker requires all external symbols to be resolved, even for
cdylib crates. The WASM import symbols (__frnt__logger__info,
__frnt__rand__rand_bytes, __frnt__time__utc_now) are only valid when
compiling to wasm32-unknown-unknown target.

This change:
- Guards WASM imports with #[cfg(target_family = "wasm")]
- Provides stub implementations for non-WASM targets
- Allows contracts to compile on Windows native target

The stub implementations are never used at runtime since contracts only
execute in the Freenet WASM runtime.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sanity sanity merged commit 94e38d5 into main Oct 20, 2025
9 checks passed
@sanity sanity deleted the fix/windows-linking-issue-39 branch October 20, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows test_contract compile link errors

2 participants