www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15531] New: dmd.conf linker flags should be prepended instead


          Issue ID: 15531
           Summary: dmd.conf linker flags should be prepended instead of
                    appended to subsequent linker flags
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

I ran into this issue several times:

path/to/dmd some_d_flags some_linker_flags

Undefined symbols for architecture x86_64:
  "_D6object9Throwable7messageMxFZAxa", referenced from [...]

which can be hard to debug why.

it works if I add:
path/to/dmd some_d_flags -L-Lfoo some_linker_flags
where foo=$dirname path/to/dmd
but this is harder to use and not DRY

The issue at hand is some_linker_flags (here containing
-L-L/path/to/homebrew/lib/) may overwrite the library path for phobos libs, eg
pointing to an older version of them compared to the one from path/to/dmd, and
the flags from path/to/dmd.conf are not taken into account.

Things would work if linker flags in dmd.conf (or from $DMD_FLAGS) were
prepended (instead of appended) to subsequent linker flags when dmd calls the
system linker.

If i want to indeed overwrite the dmd.conf flags, I can always call:
DMD_FLAGS="" path/to/dmd some_d_flags some_linker_flags
so we're loosing nothing.

Jan 08 2016