Search code examples
d

How does dmd determine it's library path at compile time?


How does dmd determine it's library path at compile time?

I have two versions of dmd installed, dmd 2.074 and dmd 2.080.

The dmd 2.080 was picking up the 2.074 files, which (not surprisingly) weren't compiling.

For example, dmd 2.074 has functional.d at:

  • /Library/D/dmd/src/phobos/std/functional.d

While dmd 2.080 installed by brew has functional.d at:

  • /usr/local/Cellar/dmd/2.080.0/include/dlang/dmd/std/functional.d

I renamed /Library/D/... (which has 2.074) to /Library/D2_074/....

Now dmd 2.080 (located in /usr/local/bin/dmd) is finding Phobos okay. Huzzah!

Maybe it is a bad thing to have multiple versions of dmd installed.

I'm trying to understand how the dmd compiler/linker determines the location of its compile, link, and (possibly) runtime support files. So when I install the next drop of dmd I won't make the same mistake again.


Solution

  • dmd will look for dmd.conf in the following sequence of directories:

    • current working directory
    • directory specified by the HOME environment variable
    • directory dmd resides in
    • /etc directory

    It seems a dmd.conf is placed in /etc/dmd.conf by default in an install, but as seen above you can have separate configs for separate installs.