Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten LTO: Linking two modules of different target triples #81

Open
kassane opened this issue Sep 15, 2024 · 2 comments
Open

Emscripten LTO: Linking two modules of different target triples #81

kassane opened this issue Sep 15, 2024 · 2 comments

Comments

@kassane
Copy link
Contributor

kassane commented Sep 15, 2024

Actually Zig isn't enabling LTO on release targets ( wasm32 in particular). Enabling it manually gives this warning during linking.

$ zig build run-clear -Dtarget=wasm32-emscripten -Doptimize=ReleaseSmall
run-clear
└─ run /home/kassane/.cache/zig/p/1220146d92ca77f3cabb151fd035f6fa2ea03481ea07f3358ec912f17acdba791a8a/upstream/emscripten/emrun
   └─ install generated/
      └─ emcc stderr
wasm-ld: warning: Linking two modules of different target triples: '/home/kassane/sokol-zig/.zig-cache/o/b17f1f6a7714e069fb53b8a52b736ac9/libsokol_clib.a(sokol_app.o at 20300)' is 'wasm32-unknown-emscripten-musl' whereas 'ld-temp.o' is 'wasm32-unknown-emscripten'
wasm-ld: warning: Linking two modules of different target triples: '/home/kassane/sokol-zig/.zig-cache/o/b17f1f6a7714e069fb53b8a52b736ac9/libsokol_clib.a(sokol_glue.o at 379232)' is 'wasm32-unknown-emscripten-musl' whereas 'ld-temp.o' is 'wasm32-unknown-emscripten'
wasm-ld: warning: Linking two modules of different target triples: '/home/kassane/sokol-zig/.zig-cache/o/b17f1f6a7714e069fb53b8a52b736ac9/libsokol_clib.a(sokol_gfx.o at 95292)' is 'wasm32-unknown-emscripten-musl' whereas 'ld-temp.o' is 'wasm32-unknown-emscripten'
wasm-ld: warning: Linking two modules of different target triples: '/home/kassane/sokol-zig/.zig-cache/o/b17f1f6a7714e069fb53b8a52b736ac9/libsokol_clib.a(sokol_log.o at 11768)' is 'wasm32-unknown-emscripten-musl' whereas 'ld-temp.o' is 'wasm32-unknown-emscripten'

Similar issue in sokol-d: kassane/sokol-d#3 (comment)

How to fix?

Replace wasm32-emscripten (default is musl) to wasm32-emscripten-none!

# first clean .zig-cache and zig-out
$ zig build run-clear -Dtarget=wasm32-emscripten-none -Doptimize=ReleaseSmall
Now listening at http://0.0.0.0:6931/
@floooh
Copy link
Owner

floooh commented Sep 16, 2024

Hmm good to know but strange, I would actually have expected that MUSL is the correct C library to use (since Emscripten is also using MUSL).

@kassane
Copy link
Contributor Author

kassane commented Sep 16, 2024

This is probably because zig ensures its self-dependencies by default.
Unlike other toolchains (ldc2, rustc, ...) that depend on emscripten libc.

During the tests I had no complications in running the applications, only the warnings issued. (same target data-layout)

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

No branches or pull requests

2 participants