dmd link mystery on linux

John Belmonte john at neggie.net
Sun May 20 19:14:30 PDT 2012


On Sunday, 20 May 2012 at 13:53:21 UTC, Mike Wey wrote:
> On my system it looks like the order of the commands passed on 
> to ld differ depending on if -Xlinker is used.
> gcc passes some default paths to the linker like: -L/lib/ and 
> -L/usr/lib/, now commands passed on to the linker with -Xlinker 
> are added after these paths, while if you don't use -Xlinker 
> the path is passed before the default paths.
>
> So if your global phobos lib is installed in /lib or /usr/lib 
> it will be picked up by the linker if it searches those 
> directories before the one that contains the local one. The 
> search order for ld depends on the order in which they appear 
> on the commandline.

Thanks, that makes sense.

I found in dmd's link.c that special treatment is given to "-l" 
by eliding -Xlinker.  If I expand this logic to include -L it 
takes care of my issue.  I think it's the right thing given the 
interaction between gcc and the linker-- it's not unlikely that D 
libraries could appear in the default gcc library path and we 
want paths supplied explicitly to dmd to take precedence.  I'll 
submit a patch.

If I can get that accepted I'll try to follow up and have 
update.sh make a coherent dmd.conf.



More information about the Digitalmars-d mailing list