Re: /usr/bin/ld: [...] undefined reference to _D3std6format6internal6write...

2022-12-22 Thread Siarhei Siamashka via Digitalmars-d-learn

On Thursday, 22 December 2022 at 15:32:28 UTC, Anonymouse wrote:

I'm not sure what to do.


If it links on Ubuntu, but not on Manjaro/Arch, then is it 
possible that the GDC package from Manjaro/Arch is somehow 
provided with a missing, misconfigured or broken Phobos library?


Maybe try to compile GDC from sources yourself?


Re: /usr/bin/ld: [...] undefined reference to _D3std6format6internal6write...

2022-12-22 Thread Anonymouse via Digitalmars-d-learn

On Tuesday, 20 December 2022 at 20:55:08 UTC, Paul Backus wrote:

Apologies for the late reply.


On Tuesday, 20 December 2022 at 20:01:04 UTC, Anonymouse wrote:

What does `-allinst` even do


`-allinst` tells the compiler to generate code for all 
instantiated templates, even if it thinks that code has already 
been generated in a different object file.

[...]

I see. That makes sense. When things fail (requiring `-allinst`), 
is that a bug I should report or a fact of life to lament?



and why does it seem to be insufficient here?


Hard to say without more information. Are you compiling with 
`-preview=dip1000`? If not, does adding that flag fix the error?


I'm not compiling with `dip1000`. Adding it just adds some extra 
lines to the top of the linker errors.


Full demangled non-`dip1000` error, slightly formatted for 
readability;


```
/usr/bin/ld: 
../../.dub/packages/requests-2.0.9/requests/.dub/build/[...]/librequests.a: in function `pure @safe void std.format.internal.write.formatValueImpl!(void delegate(scope const(char)[]) pure nothrow @safe, ulong, char).formatValueImpl(ref void delegate(scope const(char)[]) pure nothrow @safe, const(ulong), scope ref const(std.format.spec.FormatSpec!(char).FormatSpec))':

/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/std/format/internal/write.d:171:
 undefined reference to `pure nothrow @nogc @trusted const(char)[] 
std.format.internal.write.formatValueImpl!(void delegate(scope const(char)[]) 
pure nothrow @safe, ulong, char).formatValueImpl(ref void delegate(scope 
const(char)[]) pure nothrow @safe, const(ulong), scope ref 
const(std.format.spec.FormatSpec!(char).FormatSpec)).__lambda5!(ulong).__lambda5(ref
 ulong)'

/usr/bin/ld: 
../../.dub/packages/requests-2.0.9/requests/.dub/build/[...]/librequests.a: in function `pure @safe immutable(char)[] std.algorithm.searching.find!(std.algorithm.mutation.stripLeft!(immutable(char)[], char).stripLeft(immutable(char)[], char).__lambda3, immutable(char)[]).find(immutable(char)[])':

/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/d/std/algorithm/searching.d:1858:
 undefined reference to `pure nothrow @nogc @safe bool 
std.algorithm.mutation.stripLeft!(immutable(char)[], 
char).stripLeft(immutable(char)[], char).__lambda3!(dchar).__lambda3(dchar)'

collect2: error: ld returned 1 exit status
Error gdc failed with exit code 1.
```

In this case it's even in an external dependency (`requests`), 
which compiles by itself but not when dub builds my thing with it.


I'm not sure what to do.


Re: /usr/bin/ld: [...] undefined reference to _D3std6format6internal6write...

2022-12-20 Thread Paul Backus via Digitalmars-d-learn

On Tuesday, 20 December 2022 at 20:01:04 UTC, Anonymouse wrote:

What does `-allinst` even do


`-allinst` tells the compiler to generate code for all 
instantiated templates, even if it thinks that code has already 
been generated in a different object file.


Why would the compiler think that? Sometimes, which templates get 
instantiated can depend on which flags the code is compiled with. 
If you compile your code with one set of flags, and link it 
against a library compiled with a different set of flags, then 
the different invocations of the compiler may disagree on which 
templates should end up in which object files.



and why does it seem to be insufficient here?


Hard to say without more information. Are you compiling with 
`-preview=dip1000`? If not, does adding that flag fix the error?