-devel-static for LDC (D compiler) runtime and phobos
The OBS build of LDC does not currently package libdruntime.a or libphobos2.a in any (sub)package. This means that there isn't a way of building a statically-linked D program with LDC short of building a new runtime and phobos to link against. Since static libs can be a delicate topic and static lib bloat best avoided for obvious reasons, I decided it'd be best to ask on the mailing list first instead of just putting together a pull request. Has there been any discussion on it as it applies to LDC (or other applicable compilers)? My position would be that the core runtime and stdlib for a compiler clearly count as an "exceptional case" to offer a -devel-static.
On Fri, 15 Dec 2023, Jake Drahos wrote:
The OBS build of LDC does not currently package libdruntime.a or libphobos2.a in any (sub)package. This means that there isn't a way of building a statically-linked D program with LDC short of building a new runtime and phobos to link against.
Since static libs can be a delicate topic and static lib bloat best avoided for obvious reasons, I decided it'd be best to ask on the mailing list first instead of just putting together a pull request. Has there been any discussion on it as it applies to LDC (or other applicable compilers)? My position would be that the core runtime and stdlib for a compiler clearly count as an "exceptional case" to offer a -devel-static.
The GCC based D compiler has those available. Richard. -- Richard Biener <rguenther@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
On 12/18/23 01:35, Richard Biener wrote:
On Fri, 15 Dec 2023, Jake Drahos wrote:
The OBS build of LDC does not currently package libdruntime.a or libphobos2.a in any (sub)package. This means that there isn't a way of building a statically-linked D program with LDC short of building a new runtime and phobos to link against.
Since static libs can be a delicate topic and static lib bloat best avoided for obvious reasons, I decided it'd be best to ask on the mailing list first instead of just putting together a pull request. Has there been any discussion on it as it applies to LDC (or other applicable compilers)? My position would be that the core runtime and stdlib for a compiler clearly count as an "exceptional case" to offer a -devel-static.
The GCC based D compiler has those available.
Richard.
It looks like -static is also broken for GDC, at least on Tumbleweed (__tls_get_addr undefined), but I haven't dug into it in detail. I spent some time over the weekend trying to put together a -devel-static for LDC, and it's not a pretty situation. I couldn't get it working without either completely disabling LTO for the whole build, or hacking together some ugly multi-stage build to disable LTO only when building the runtime. The combination of clang for C components, ldc for D components, and LTO just results in broken static libraries at the end. ldc-build-runtime gets installed with ldc and runs with default arguments to build a (working) static runtime/phobos. It's not as clean as having a -devel-static package, but it's a straightforward workaround. I did find out while working on this that phobos actually vendors in its own (source) copy of zlib, which seems... odd. Even the default shared builds of phobos shipped with LDC (and presumably the other compilers, it's from upstream) builds its own in-tree zlib instead of using system zlib. I'll try to figure out what's going on with that, since it actually seems to be the source of most of the problems. It's quite possible that linking against system zlib might make static phobos magically start working. Jake
On Mon, 18 Dec 2023, Jake Drahos wrote:
On 12/18/23 01:35, Richard Biener wrote:
On Fri, 15 Dec 2023, Jake Drahos wrote:
The OBS build of LDC does not currently package libdruntime.a or libphobos2.a in any (sub)package. This means that there isn't a way of building a statically-linked D program with LDC short of building a new runtime and phobos to link against.
Since static libs can be a delicate topic and static lib bloat best avoided for obvious reasons, I decided it'd be best to ask on the mailing list first instead of just putting together a pull request. Has there been any discussion on it as it applies to LDC (or other applicable compilers)? My position would be that the core runtime and stdlib for a compiler clearly count as an "exceptional case" to offer a -devel-static.
The GCC based D compiler has those available.
Richard.
It looks like -static is also broken for GDC, at least on Tumbleweed (__tls_get_addr undefined), but I haven't dug into it in detail.
Indeed, I can see that. __tls_get_addr is supposed to be resolved via relaxation, not sure why that doesn't work here. Ah, there's an explicit call in libdruntime and not a TLS relocation - that's not going to work. I filed a bugreport upstream, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113081 Now, I can see that -static-libphobos works (with a Hello World), this leaves a dynamic executable but the D runtime linked statically (there isn't a -static-libdruntime but the executable doesn't seem to reference that). Not sure if you need a fully static executable. Richard. -- Richard Biener <rguenther@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
participants (2)
-
Jake Drahos
-
Richard Biener