How to build a statically linked executable, before i loose my mind
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sun Jul 14 06:34:54 UTC 2024
On 14/07/2024 5:06 AM, ryuukk_ wrote:
> On Saturday, 13 July 2024 at 16:44:22 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
>> On 14/07/2024 4:37 AM, ryuukk_ wrote:
>>> On Saturday, 13 July 2024 at 16:16:20 UTC, Richard (Rikki) Andrew
>>> Cattermole wrote:
>>>> Seeing ``_d_arraybounds_slice`` missing sounds like druntime isn't
>>>> being linked against.
>>>>
>>>> It is possible that your distribution of ldc doesn't include a
>>>> static build of druntime/phobos. You need to verify that ld is
>>>> trying to link against a static build and that static build exists.
>>>
>>> `curl -fsS https://dlang.org/install.sh | bash -s ldc`
>>
>> Okay yup, looks like its all there in latest release.
>>
>> Have to dump out what ld is getting passed to it, and what it thinks
>> it is doing next.
>
>
> ```
> /usr/bin/ld -plugin /usr/lib/gcc/x86_64-linux-gnu/11/liblto_plugin.so
> -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
> -plugin-opt=-fresolution=/tmp/ccBV7TjM.res
> -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
> -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc
> -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m
> elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker
> /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o bin/dls
> /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o
> /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crti.o
> /usr/lib/gcc/x86_64-linux-gnu/11/crtbeginS.o
> -L/home/runner/dlang/ldc-1.39.0/bin/../lib
> -L/home/runner/dlang/ldc-1.39.0/lib/../lib
> -L/usr/lib/gcc/x86_64-linux-gnu/11
> -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu
> -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib
> -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu
> -L/usr/lib/../lib -L/home/runner/dlang/ldc-1.39.0/lib -L/usr/lib/gcc/x
> ```
>
>
> https://github.com/ryuukk/dls/actions/runs/9921536908/job/27409615370
>
>
> It works locally, but not their machine, ubuntu apparently
Boom, got it working!
https://github.com/rikkimax/dls/blob/master/makefile#L39
It's a link order issue.
```
ldc2 -of=bin/dlsobj.o -c --output-o $(OPTIMIZE) $(PREVIEWS) -Iserver/ -i
server/cjson/cJSON.c server/dls/main.d
ldc2 -of=bin/dls$(exe) bin/dlsobj.o server/dls/libdcd.a
```
More information about the Digitalmars-d-learn
mailing list