Skip to content

Add support for building a static libobjc2 for WebAssembly - #422

Open
HendrikHuebner wants to merge 1 commit into
gnustep:masterfrom
HendrikHuebner:wasm-static-runtime
Open

Add support for building a static libobjc2 for WebAssembly#422
HendrikHuebner wants to merge 1 commit into
gnustep:masterfrom
HendrikHuebner:wasm-static-runtime

Conversation

@HendrikHuebner

Copy link
Copy Markdown

This PR does a few things:

  1. For WASM, libobjc2 and any other system library should be built as a static archive by default.
  2. This PR also allows users to disable a shared library build (disabled for WASM by default)
  3. For WASM, OLDABI_COMPAT must be disabled
  4. For WASM, block-to-IMP and assembly fast-paths are disabled
  5. WASM exception handling is configured

Point 2 is not strictly necessary, so let me know if we should keep it.
We should ideally only land this after all of my other open PRs have been merged. On the Clang side the only thing missing is @finally support.

@davidchisnall davidchisnall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look fine, but is there a way to make the tests work in some command-line wasm runner?

@HendrikHuebner

Copy link
Copy Markdown
Author

These changes look fine, but is there a way to make the tests work in some command-line wasm runner?

I have not run the tests yet. For testing I created this repo, since tying everything together with the source build emscripten, clang etc is a bit cumbersome: https://github.com/HendrikHuebner/objc-wasm-tooling/tree/main/tests

The repo contains a couple of tests and a (vibe-coded) Obj-C + Qt + libs-base demo.

I can try running the tests and finding out what still fails. There are still many things I have not tested, and of course a few features are disabled for now.

@HendrikHuebner

HendrikHuebner commented Aug 26, 2026

Copy link
Copy Markdown
Author

I was able to get the libobjc2 test suite running with all my patches applied. The tests are compiled into .js/.wasm pairs and ran with node.js

There are a couple of failures:

  • SuperMethodMissing, PropertyIntrospectionTest2_arc fail because of function pointer signature mismatches
  • alignTest, FastPathAlloc, BlockImpTest fail because of missing fast paths
  • ManyManySelectors OOMs? Probably misconfigured NodeJS/wasm runtime?
  • All the tests containing @finally fail because its not supported in clang yet

So the function pointer mismatches still need to be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants