[cfe-dev] configure doesn't honor CPPFLAGS
James K. Lowden
jklowden at schemamania.org
Tue Apr 24 14:44:11 PDT 2012
My experiment building clang with gcc 4.6 on NetBSD today exposed a
problem in the clang build system: although I defined CPPFLAGS before
invoking configure, the variable wasn't used in the build. It's used
in *configure*, sure enough, but by the time we're compiling
Triple.cpp, it's nowhere in sight.
With guidance, I can correct some of what's wrong. Let me first
explain what I'm seeing.
I've identified three problems with CPPFLAGS.
1. configure uses it, but it's not passed on to the main build.
2. configure.ac overwrites it (sometimes).
3. configure promises to use it.
I was able to work around that by defining my variable as part of the
CXX variable:
CPPFLAGS=-DDNU_SYS_PARAMS_H
CPP="${BINPATH}/cpp ${CPPFLAGS}"
CC="${BINPATH}/cc ${CPPFLAGS}"
CXX="${BINPATH}/c++ ${CPPFLAGS}"
export CPP CC CXX CPPFLAGS
Until I did that, -DDNU_SYS_PARAMS_H was not passed to the compiler.
The autoconf manual says CPPFLAGS is a "preset output variable", and
automake says it's one of the variables "inherited from autoconf".
Indeed, my config.log shows the variable twice on the command line e.g.:
configure:2160: /usr/pkg/gcc46/bin/cc -DDNU_SYS_PARAMS_H
-DDNU_SYS_PARAMS_H c onftest.c >&5
I won't quote the whole command line from the build log here. The
variable appears only once, immediately after the c++ command:
/usr/pkg/gcc46/bin/c++ -DDNU_SYS_PARAMS_H -I/home....
Ignoring CPPFLAGS looks to be intentional. The very nice document
http://llvm.org/docs/GettingStarted.html#environment mentions only CC
and CXX as variables, and configure --help mentions
--with-optimize-options and --with-extra-options. (I don't know if
they're intended as replacements. If I may say so, they're are a bit
vague and afaict undocumented.)
It would be better to support CPPFLAGS.
configure.ac overwrites CPPFLAGS:
1184 CPPFLAGS="-I${withval}/include";;
And configure itself promises to use it:
$ ../configure --help | sed -ne '/^Some/,/CPP /p'
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include
dir> if you have headers in a nonstandard directory <include dir>
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CPP C preprocessor
That's my story. Probably I've missed something. As I said, I'm
prepared to make corrections, but I don't want to tromp on something
that needs to be the way it is.
Humbly submitted,
--jkl
More information about the cfe-dev
mailing list