[LLVMdev] Environment variables considered evil

Joachim Durchholz jo at durchholz.org
Tue Mar 25 05:47:15 PDT 2008

Am Dienstag, den 25.03.2008, 12:08 +0000 schrieb Ralph Corderoy:
> > No, that was written under the assumption that passing in CC and CXX
> > via env variables wouldn't work. Things work now, so that assumption
> > is obviously wrong.
> > 
> > I still don't like environment variables. They tend to remain in
> > effect long after I forgot that I set them, creating all sorts of
> > hassle. In fact I suspect I already fell prey to this, getting llvm to
> > compile and check one day and nearly despairing when trying to
> > reproduce that success on the next day.  But, well, you use what you
> > need to use to get the job done, so there :-)
> Are you aware that
>     FOO=bar ./configure
> makes the shell set an environment variable just for the running of
> ./configure,

I am.
I'm not sure that
  FOO=bar BAZ=boo ./configure
will work; at least I got some funny results (though that may have been
due to other reasons).

Well, you live and learn. I have now switched to opening a new shell
window whenever I start an experiment, since gcc won't become
environment-agnostic in my lifetime anyway.
Though that's bad. If some overambitious sysadmin adds a CFLAGS variable
to /etc/profile, people on that machine will get funny results. To make
matters worse, there does not seem to be an exhaustive list of
environment variables to check, at least not for gcc and autoconf
(though there are plenty of non-exhaustive ones). I know I have to check
exist? A RANLIBFLAGS? ARFLAGS? (This is essentially the same problem as
with global variables: lack of information hiding, making it very
difficult to check all dependencies.)

I'm pretty sure that I'm not the first to observe this kind of
difficulty, and the GNU project probably won't change their conventions
anyway, I'll stop my rant now :-)


More information about the llvm-dev mailing list