Closed kassane closed 1 month ago
All flags: https://github.com/ldc-developers/ldc/blob/master/driver%2Fcl_options.cpp https://github.com/dlang/dub/blob/master/source%2Fdub%2Fcompilers%2Fldc.d
Based on some information, it is expected to improve support for nogc and/or betterC.
Currently the user_data
example requires GC because of AA (associative array)
The latest changes are intended to remove support for custom-Druntime (obsolete and incomplete). Only wasm32-target as betterC will be allowed. #20 This needs to be re-tested and improved.
However, for a higher priority, it is still necessary to resolve the linking conflicts of the objects generated by ldmd2/ldc2
Note: ldmd2 is just the wrapper for the ldc2 compiler, using the dmd flags (ldc2 -ldmd
- w/ dmd library).
wasm32-unknown-unknwon-wasm
is wasm32-freestanding
]
wasm-unknown-emscripten
get Warning: unknown target OS: emscripten
wasm32-emscripten
]*.wasm
). [wasm32-unknown-emscripten
]In the following, I have tested it manually (no zig build system).
Note 2: LTO between ldc2 and emcc cause warnings. Prefer enable LTO in ldc2 only (no or minimum warnings)!!
wasm-ld: warning: Linking two modules of different data layouts: '/home/kassane/.cache/zig/p/122083537ec3463ee4b2d520bf86a36b1057ab05abfe712c32bae1048f9b0c6e2a13/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libc.a(llrintl.o at 2994444)' is 'e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20' whereas 'ld-temp.o' is 'e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20'
cc: @floooh
Just FIY, I'll be travelling until Thursday and will probably be unresponsive during that time.
Just FIY, I'll be travelling until Thursday and will probably be unresponsive during that time.
No trouble! Enjoy your travels.
Note 2: LTO between ldc2 and emcc cause warnings. Prefer enable LTO in ldc2 only (no or minimum warnings)!!
After fix ldc2 (master) issue (add wasm32-unknown-emscripten
)...
I have discovered a strange situation, in that when enabling LTO on all in release mode.
warning: Linking two modules of different target triples: '/home/kassane/sokol-d/zig-cache/o/11f2f18f48ea24e538f790ad4c0e12f8/libsokol.a(sokol_gfx.o at 101382)' is 'wasm32-unknown-emscripten-musl' whereas 'ld-temp.o' is 'wasm32-unknown-emscripten'
wasm32-unknown-emscripten-musl
?? Maybe based on wasi target.
The issue is fixed (without warnings) when passing -Dtarget=wasm32-emscripten-none
.
After new updates and the possible inclusion of imgui support. As you can see, build.zig
is quite long and complicated.
Unlike the sokol-zig approach (by @floooh), sokol-d has everything included, which requires extending the support in build.zig
.
So far, the port of pacman.c/pacman.zig to pacman.d is in progress, as a first external solution using sokol-d.
Any suggestions for other approaches to reduce such complexity?
Maybe pacman.d can serve as a reference.
After some testing with zig-master regarding external package management, I will need to postpone porting the build system modularization.
Also, it requires looking into the issues with shaded examples in wasm32, while knowing ldc2's poor support for the target.
Also evaluate the possibility of updating imgui support (replacing cimgui to dear-bindings).
Another alternative to try is to add nuklear support.
The next ldc2 version brings improved wasm32-emscripten-musl
support.
Emscripten: The compiler now mimicks a musl Linux platform wrt. extra predefined versions.
More info: https://forum.dlang.org/post/xmrqpocmcfwpajxvzfal@forum.dlang.org
Remember: Currently, the wasm32 target in this project has LTO enabled (ldc2/zig cc/emcc) in release mode.
However, wasm32-emscripten
and wasm32-wasi
in Zig links musl-libc by default. Causing conflict on the part of the object generated by ldc2 and sokol
library. Add -none
in wasm triple-target to bypass linker error.
This compiler improvement, it might help linking with musl-libc on LTO enabled. In debug mode (LTO off) emit warnings yet!
Previous test
Note 2: LTO between ldc2 and emcc cause warnings. Prefer enable LTO in ldc2 only (no or minimum warnings)!!
wasm-ld: warning: Linking two modules of different data layouts: '/home/kassane/.cache/zig/p/122083537ec3463ee4b2d520bf86a36b1057ab05abfe712c32bae1048f9b0c6e2a13/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/lto/libc.a(llrintl.o at 2994444)' is 'e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20' whereas 'ld-temp.o' is 'e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20'
Current test
The next ldc2 version brings improved
wasm32-emscripten-musl
support.Emscripten: The compiler now mimicks a musl Linux platform wrt. extra predefined versions.
$ 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-d/.zig-cache/o/10eb24f94f096a2b4bc05693912b8a55/libsokol.a(sokol_log.o at 11906)' 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-d/.zig-cache/o/10eb24f94f096a2b4bc05693912b8a55/libsokol.a(sokol_app.o at 20434)' 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-d/.zig-cache/o/10eb24f94f096a2b4bc05693912b8a55/libsokol.a(sokol_gfx.o at 95426)' 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-d/.zig-cache/o/10eb24f94f096a2b4bc05693912b8a55/libsokol.a(sokol_glue.o at 404594)' is 'wasm32-unknown-emscripten-musl' whereas 'ld-temp.o' is 'wasm32-unknown-emscripten'
ldc2
+ emcc
(LTO enabled) no have different target triples.
Try use wasm32-unknown-emscripten-musl
in zig cc
+ ldc2
:
Conflicts between zig cc
and emcc
different triple-targets!
Documentation(autogenerated code does not keep comments)External Reference