August 11

On Sunday, 11 August 2024 at 13:16:16 UTC, Denis Feklushkin wrote:

> >

What you could e.g. do with a dedicated ldc2.conf is specifying the paths to druntime and Phobos as regular default switches.

This will break a lot of things, it's easier to manually add a similar hack into the build scripts

Yeah I'd probably prefer and go with that myself too. E.g., for the LDC CMake build, you can use the C++ compiler as linker driver (or the D host compiler); in that case, we need to pass the linker flags for host druntime+Phobos too, and do so by building a dummy-executable with the D host compiler and -v, and then parsing the printed linker cmdline.

Wrt. available options for linking D parts statically into a project in another language, I'd go in this order:

  1. Use the D compiler as linker driver.
  2. With a non-D compiler as linker driver, inject the required linker flags for the D parts, something like -L<path to libs dir> -lphobos2-ldc -ldruntime-ldc, in the correct position.
  3. Otherwise merge all static D libs incl. druntime+Phobos to a single monolithic static lib (still depending on libc etc.) as an extra step.

Solution 3 could potentially be implemented in build systems like dub, which would then e.g. also allow you to create a 'standalone' fat static lib for a dub project with regular static-lib dub dependencies, merging all of them, not just druntime and Phobos.

What I wrote earlier wasn't 100% exact:

> >

the -defaultlib libraries need to be in one of the lib-dirs in ldc2.conf, it's the linker that resolves them

They don't need to be in one of the lib-dirs, but can also be specified in the cmdline/config file via -L-L<dir>. So the compiler really doesn't know the exact location the linker would use (potentially even skipping dirs with libs for another target architecture etc.).

August 12
On 12/08/2024 2:04 AM, kinke wrote:
> Wrt. available options for linking D parts /statically/ into a project in another language, I'd go in this order:
> 
>  1. Use the D compiler as linker driver.
>  2. With a non-D compiler as linker driver, inject the required linker
>     flags for the D parts, something like |-L<path to libs dir>
>     -lphobos2-ldc -ldruntime-ldc|, in the correct position.
>  3. Otherwise merge all static D libs incl. druntime+Phobos to a single
>     monolithic static lib (still depending on libc etc.) as an extra step.
> 
> Solution 3 could potentially be implemented in build systems like dub, which would then e.g. also allow you to create a 'standalone' fat static lib for a dub project with regular static-lib dub dependencies, merging all of them, not just druntime and Phobos.

This touches upon something I've been wanting for a while now, which is essentially a platform probe switch for D compilers.

It would replace dub's platform probe file, but would aid in cases like this where you don't want to be guessing locations of files.

But it could also offer:

All target triples, their linker flags (with respect to shared + static builds), file paths to druntime/phobos, and if the triple is default or supported by host.

August 11
On Sunday, 11 August 2024 at 14:27:11 UTC, Richard (Rikki) Andrew Cattermole wrote:

> This touches upon something I've been wanting for a while now, which is essentially a platform probe switch for D compilers.
>
> It would replace dub's platform probe file, but would aid in cases like this where you don't want to be guessing locations of files.
>
> But it could also offer:
>
> All target triples, their linker flags (with respect to shared + static builds), file paths to druntime/phobos, and if the triple is default or supported by host.

https://github.com/ldc-developers/ldc/pull/4717

Maybe this is what you need? Just need to specify correct `--conf=` path

August 12
On 12/08/2024 6:06 AM, Denis Feklushkin wrote:
> On Sunday, 11 August 2024 at 14:27:11 UTC, Richard (Rikki) Andrew Cattermole wrote:
> 
>> This touches upon something I've been wanting for a while now, which is essentially a platform probe switch for D compilers.
>>
>> It would replace dub's platform probe file, but would aid in cases like this where you don't want to be guessing locations of files.
>>
>> But it could also offer:
>>
>> All target triples, their linker flags (with respect to shared + static builds), file paths to druntime/phobos, and if the triple is default or supported by host.
> 
> https://github.com/ldc-developers/ldc/pull/4717
> 
> Maybe this is what you need? Just need to specify correct `--conf=` path

No, that changes the configuration file location (you want to use the one that came with the compiler).

What I suggested was for introspecting how the compiler is configured so tasks like linking against druntime/phobos separately didn't involve guess work.
1 2
Next ›   Last »