[LLVMdev] llvm-config --cxxflags does not give the result the configuration script wants?

Jun-qi Deng dengjunqi06323011 at gmail.com
Tue Mar 13 06:31:42 PDT 2012


Hello LLVM-DEV!

Recently I think I found a bug in llvm's CMakeLists.(I use llvm 3.1svn and
Clang 3.1) I follow the normal way to try to compile an application that
utilize both clang and llvm: I ./autogen.sh it, ./configure it and make it.
But the make fails. At last I found out the failure is because that the
Makefile's CXXFLAGS does not contain -fno-rtti option which is needed by
the compilation.

The "configure" file of the application use llvm-config --cxxflags to
assign to the CXXFLAGS. But Although I see that, under my platform, almost
all the the files inside LLVM and Clang are compiled with -fno-rtti, the
llvm-config --cxxflags does not give the correct flags that those files are
compiled. The following are something I thought is valuable to mention here:

As I probe the CMAKE_CXX_FLAGS of some of the CMakeLists.txt, I found there
is a "baseline" of this variable, mine is "-fPIC
-fvisibility-inlines-hidden". It means, no matter how a single
CMakeLists.txt changes CMAKE_CXX_FLAGS, it will remain the same when it
goes into another CMakeLists.txt.

Inside the llvm-config's source folder, the CMakeLists.txt shows how its
--cxxflags is set:
set(CXX_FLGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_
CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
...
COMMAND echo s!@LLVM_CXXFLAGS@!${CXX_FLGS}! >> ${SEDSCRIPT_OBJPATH}

and my LLVM_DEFINITIONS is:

 -D_GNU_SOURCE -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic
-Wno-long-long -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS

I also use "make VERBOSE=1" to check how llvm and clang is compiled. I see
clearly that they are both compiled with -fno-rtti.

So, at least under my system, when using cmake to configure the project, no
matter how the files are compiled, llvm-config --cxxflags will be the same.
It is:  -fPIC -fvisibility-inlines-hidden   -D_GNU_SOURCE -Wall -W
-Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS. It
is determined by the "baseline" of CMAKE_CXX_FLAGS and LLVM_DEFINITIONS.

Is this probably a problem?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120313/f4434bf7/attachment.html>


More information about the llvm-dev mailing list