Bug 1660 – DFLAGS environment variables is not working
Status
RESOLVED
Resolution
WONTFIX
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2007-11-12T12:00:00Z
Last change time
2016-10-14T05:49:11Z
Assigned to
bugzilla
Creator
witold.baryluk+d
Comments
Comment #0 by witold.baryluk+d — 2007-11-12T12:00:25Z
dmd is not respecting DFLAGS environment variable, this prevents from easy switching beetwen phobos and tango.
example:
$ export DFLAGS="-I/usr/lib/dmd-tango/src -defaultlib=dtango-base-dmd -debuglib=dtango-base-dmd -version=Tango -version=Posix"
$ ls /usr/lib/dmd-tango/src/tango/io/Console.d
/usr/lib/dmd-tango/src/tango/io/Console.d
~/tango-0.99.2-src/example/console$ dmd hello.d
hello.d(16): module Console cannot read file 'tango/io/Console.d'
CC environment variables is working, DFLAGS seems to not.
Comment #1 by witold.baryluk+d — 2008-06-22T14:31:56Z
This is so simple bug, and fix is trivial. Please do something with it.
Comment #2 by bugzilla — 2008-06-23T03:03:35Z
The dmd.conf file overrides any DFLAGS environment variable setting prior to running dmd. This is by design. You can set a local dmd.conf for each of your projects, however.
Comment #3 by larsivar — 2008-06-23T07:18:27Z
Config files are more inconvenient than env variables, thus env variables should have higher priority. I'll leave it to the reporter whether it should be reopened though.
Comment #4 by witold.baryluk+d — 2008-06-23T11:16:17Z
Most tools behaves in this way, gcc, make. IMHO environment variables should have higher priority than /etc/dmd.conf. Practicly always we have configured /etc/dmd.conf so is env. variable have smaller priority and it will be never used.
Proposed order:
1. DMD=`which dmd`; `dirname $DMD`/dmd.conf - compiler settings
2. /etc/dmd.conf - system settings
3. $HOME/dmd.conf - user settings
4. `pwd`/dmd.conf - project settings
5. DFLAGS env variable - overrding them
6. command line - from make/rebuild/manual compilation
as oposed to current:
1. DFLAGS env variable
2. `pwd`/dmd.conf
3. $HOME/dmd.conf
4. DMD=`which dmd`; `dirname $DMD`/dmd.conf
5. /etc/dmd.conf
6. command line
which is very strange to me.
I want for example create wrapper dmd-tango:
#!/bin/sh
export DFLAGS="override /etc/dmd.conf which have conf for dmd-phobos"
exec /usr/bin/dmd $*
Currently there is no easy way to do this.
I don't exactly understand phrase "This is handy to make dmd independent of programs with conflicting use of environment variables." from http://www.digitalmars.com/d/2.0/dmd-linux.html#dmd_conf
We are using only DFLAGS and CC, what programs will/can conflict with them?
Comment #5 by bugzilla — 2016-10-14T03:09:32Z
Other programs set and use environment variables. We have no control over that whatsoever. We have little choice but have dmd.conf override such settings.
Comment #6 by dlang-bugzilla — 2016-10-14T05:49:11Z
The configuration file can reference existing environment variables. Thus, if you want dmd to get command-line options from the environment, append %MY_DFLAGS% at the end of the DFLAGS setting in the configuration file, and specify your flags in the MY_DFLAGS variable.