You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While DMD and its druntime support a shared libphobos2.so for most ELF platforms, there's no Mach-O support for macOS yet. LDC does support shared druntime/Phobos on macOS/iOS, and upstreaming shouldn't be very hard.
The main adaptations are required in druntime's `rt.sections_elf_shared` module, extending it to work with Mach-O binaries too. LDC's version is here: https://github.com/ldc-developers/ldc/blob/master/runtime/druntime/src/rt/sections_elf_shared.d. In LDC, we've already extended it to Windows too, so the file/diff is unfortunately pretty messy, and the whole module could very much use a refactoring (and a better name!!!). LDC uses `rt.sections_elf_shared` for all major platforms, for static *and* shared druntime; all the other upstream rt.sections* implementations are unused and could probably be dropped upstream too in time.
Then each binary needs to register itself with druntime, calling `_d_dso_registry`. DMD does this by emitting a `d_dso_init` function into every compiled object file, like LDC used to. We then switched to doing this in druntime directly (no magic compiler-generated code anymore, which for Mach-O would need an extra helper variable + function), via some special little module: https://github.com/ldc-developers/ldc/blob/master/runtime/druntime/src/rt/dso.d. If adopting that approach, make sure to read the comments to understand what needs to be done, like bundling that precompiled object file with the compiler installation packages, and linking it automatically into every binary linked against *shared* druntime. And note that DMD would then need to adopt some `@hidden` UDA too; `dso.d` absolutely needs that functionality (of making symbols binary-internal only).
I'd propose adopting LDC's `-link-defaultlib-shared` too, instead of DMD's platform-specific `-defaultlib={libphobos2.so,libphobos2.dylib,phobos2.dll}`. Linking in the bundled `dso.o` would become easier then too.
After that, adapting variable `SHARED` in druntime's Makefile (setting it to 1 on macOS) might be enough.
The text was updated successfully, but these errors were encountered:
kinke reported this on 2024-05-17T17:48:39Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=24555
Description
The text was updated successfully, but these errors were encountered: