dmd's linking order

Jonathan M Davis jmdavisProg at gmx.com
Wed Apr 11 01:37:48 PDT 2012


On Wednesday, April 11, 2012 10:25:37 Jacob Carlborg wrote:
> On 2012-04-11 03:46, Jonathan M Davis wrote:
> > This stackoverflow question raises an interesting issue with linking order
> > and dmd:
> > 
> > http://stackoverflow.com/questions/10095150/std-net-curl-linker-errors-in-
> > linux
> > 
> > I don't know if it's this way on Linux machines in general, but the OP had
> > to link his program manually to be able to use std.curl. dmd appears to
> > put the - L argument before any of its own linker arguments, and in this
> > case, the linking argument for curl needs to go on the end.
> > 
> > So, my question is whether dmd should be changed to put any -L arguments
> > passed to it after the arguments that it passes to the linker itself. I'm
> > far from an expert on this and am quite surprised that the order of
> > arguments to the linker matters, but since it does, it seems to me that
> > we should find the optimal order for dmd to use if we can, since it's not
> > terribly user friendly to force people to call gcc or ld directly rather
> > than using dmd to link just because they want to pass an argument to the
> > linker. That's what the -L flag is supposed to be for.
> > 
> > - Jonathan M Davis
> 
> Could it happen that the linker arguments need to be placed first
> sometimes ?

I have no idea. If they always need to be in a particular order, then we can 
just make dmd put the user provide ones in the correct spot, but if it varies 
depending on the flags, then either dmd is going to have to know which flags go 
in which order (assuming that it can), or there's no way to solve the problem 
without introducing new flags to dmd to give you more control over linking 
order or just using the linker directly.

Unfortunately, I have no idea why the linking order even matters in the first 
place, so I can't really say what we need to do here. Hopefully, someone else 
around here _does_ know. But the issue does seem to need to be brought up.

- Jonathan M Davis


More information about the Digitalmars-d mailing list