The dmd.conf rant

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 31 19:28:43 PDT 2015


tl;dr, please reconsider changing the conf order or splitting the conf file

https://github.com/D-Programming-Language/dmd/pull/4256#issuecomment-88316771

That dmd.conf is driving me crazy.

I need a dmd.conf in my dmd repo, so that I can use dmd-master. It
wouldn't work without a config and putting `dmd.conf` anywhere but near
dmd itself overrides my system dmd.conf.
That setup worked nicely for me although some of you guys seem to have a
dmd.conf in your home dir (why?).

Now that we require a host D compiler to build dmd it no longer works,
because the dmd.conf for my dmd-master overrides the system wide
dmd.conf of my host dmd.
Why would my system dmd need a different configuration just because
__I__ am in a different folder?
It doesn't, it still uses the same phobos (the system wide) and still
requires the same linker switches.

Setting HOST_DC is a workaround but is impractical, because it requires
an awkward `env HOST_DC='dmd -conf=/etc/dmd.conf' make -f posix.mak` to
work.
Requiring `dmd -conf=/etc/dmd.conf` in order to not pickup some random
conf file is crazy. It's not portable either, because the config is
somewhere else on each platform.

We learned the same from dlang.org
https://github.com/D-Programming-Language/dlang.org/pull/758#issuecomment-74294012,
adding the `-conf=` switch didn't solve the actual problem and created
new ones.

It might seem intuitive, that a local configuration should override a
global one, but it's a false friend here, because the configuration
should be local from the perspective of the compiler, not from the
perspective of the user.

In fact the config is so tied to the compiler that we could almost
compile it __into__ the compiler (like gcc does with it's spec). At best
it's something package maintainers need to touch to accomodate platform
differences, but it's not a user configuration file.

If people use it to configure DFLAGS and such project dependent stuff,
then we need to split the configuration file, into one part that tells
the compiler where to find druntime/phobos and how to link, and one part
that can be used for per-project configuration of compiler arguments and
env variables.
IMO the latter is better kept in makefiles/dub.json though.

### conclusion

The lookup order for the config file should be changed to the following.
- next to dmd binary (highest precedence so that I can have multiple
installations)
- per-user conf folder (HOME) (to override the system-wide config)
- system-wide conf folder (to allow package installations .deb/.rpm)

The current situation is unmaintainable.


More information about the Digitalmars-d mailing list