From 628b899be14a6bab4b32dbd53aabd447dcc16cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 20 Aug 2016 23:47:41 +0200 Subject: [PATCH] llvm-config: Clean up exported values, update for shared linking Gentoo-specific fixup for llvm-config, including: - wiping build-specific CFLAGS, CXXFLAGS, - making --src-root return invalid path (/dev/null). Thanks to Steven Newbury for the initial patch. Bug: https://bugs.gentoo.org/565358 Bug: https://bugs.gentoo.org/501684 diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt index 744fa4e44d1..593788aaef3 100644 --- a/tools/llvm-config/CMakeLists.txt +++ b/tools/llvm-config/CMakeLists.txt @@ -32,8 +32,12 @@ get_property(COMPILE_FLAGS TARGET llvm-config PROPERTY COMPILE_FLAGS) set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR}) set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR}) set(LLVM_CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") -set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") -set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}") +# Just use CMAKE_CPP_FLAGS for CFLAGS and CXXFLAGS, otherwise compiler +# specific flags will be set when we don't know what compiler will be used +# with external project utilising llvm-config. C++ Standard is required. +# TODO: figure out if we can remove -std=c++11 and move it to revdeps. +set(LLVM_CFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") +set(LLVM_CXXFLAGS "${CMAKE_CPP_FLAGS} -std=c++11 ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") set(LLVM_BUILD_SYSTEM cmake) set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI}) set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX}") diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp index d780094861c..c61c72ff48c 100644 --- a/tools/llvm-config/llvm-config.cpp +++ b/tools/llvm-config/llvm-config.cpp @@ -549,7 +550,11 @@ int main(int argc, char **argv) { } else if (Arg == "--obj-root") { OS << ActivePrefix << '\n'; } else if (Arg == "--src-root") { - OS << LLVM_SRC_ROOT << '\n'; + if (IsInDevelopmentTree) { + OS << LLVM_SRC_ROOT << '\n'; + } else { + OS << "/dev/null\n"; + } } else if (Arg == "--ignore-libllvm") { LinkDyLib = false; LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto; -- 2.11.0