summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-07-21 00:45:20 -0700
committerStephen Hines <srhines@google.com>2014-07-21 00:45:20 -0700
commitc6a4f5e819217e1e12c458aed8e7b122e23a3a58 (patch)
tree81b7dd2bb4370a392f31d332a566c903b5744764 /cmake
parent19c6fbb3e8aaf74093afa08013134b61fa08f245 (diff)
downloadexternal_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.zip
external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.gz
external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.bz2
Update LLVM for rebase to r212749.
Includes a cherry-pick of: r212948 - fixes a small issue with atomic calls Change-Id: Ib97bd980b59f18142a69506400911a6009d9df18
Diffstat (limited to 'cmake')
-rwxr-xr-xcmake/config-ix.cmake31
-rw-r--r--cmake/modules/AddLLVM.cmake23
-rw-r--r--cmake/modules/HandleLLVMOptions.cmake81
3 files changed, 56 insertions, 79 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index 1325e79..b862ceb 100755
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -252,15 +252,9 @@ function(llvm_find_program name)
endif(LLVM_PATH_${NAME})
endfunction()
-llvm_find_program(gv)
-llvm_find_program(circo)
-llvm_find_program(twopi)
-llvm_find_program(neato)
-llvm_find_program(fdp)
-llvm_find_program(dot)
-llvm_find_program(dotty)
-llvm_find_program(xdot xdot.py)
-llvm_find_program(Graphviz)
+if (LLVM_ENABLE_DOXYGEN)
+ llvm_find_program(dot)
+endif ()
if( LLVM_ENABLE_FFI )
find_path(FFI_INCLUDE_PATH ffi.h PATHS ${FFI_INCLUDE_DIR})
@@ -304,25 +298,6 @@ else()
set(ENABLE_PIC 0)
endif()
-find_package(LibXml2)
-if (LIBXML2_FOUND)
- set(CLANG_HAVE_LIBXML 1)
- # When cross-compiling, liblzma is not detected as a dependency for libxml2,
- # which makes linking c-index-test fail. But for native builds, all libraries
- # are installed and checked by CMake before Makefiles are generated and everything
- # works according to the plan. However, if a -llzma is added to native builds,
- # an additional requirement on the static liblzma.a is required, but will not
- # be checked by CMake, breaking native compilation.
- # Since this is only pertinent to cross-compilations, and there's no way CMake
- # can check for every foreign library on every OS, we add the dep and warn the dev.
- if ( CMAKE_CROSSCOMPILING )
- if (NOT PC_LIBXML_VERSION VERSION_LESS "2.8.0")
- message(STATUS "Adding LZMA as a dep to XML2 for cross-compilation, make sure liblzma.a is available.")
- set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} "-llzma")
- endif ()
- endif ()
-endif ()
-
check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG)
set(USE_NO_MAYBE_UNINITIALIZED 0)
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 69ffa5b..31540d9 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -150,6 +150,11 @@ endfunction(add_dead_strip)
# Note: Don't set variables CMAKE_*_OUTPUT_DIRECTORY any more,
# or a certain builder, for eaxample, msbuild.exe, would be confused.
function(set_output_directory target bindir libdir)
+ # Do nothing if *_OUTPUT_INTDIR is empty.
+ if("${bindir}" STREQUAL "")
+ return()
+ endif()
+
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
@@ -205,7 +210,7 @@ function(llvm_add_library name)
if(ARG_SHARED OR ARG_STATIC)
message(WARNING "MODULE with SHARED|STATIC doesn't make sense.")
endif()
- if(NOT LLVM_ON_UNIX OR CYGWIN)
+ if(NOT LLVM_ENABLE_PLUGINS)
message(STATUS "${name} ignored -- Loadable modules not supported on this platform.")
return()
endif()
@@ -570,12 +575,6 @@ function(configure_lit_site_cfg input output)
set(SHLIBEXT "${LTDL_SHLIB_EXT}")
- if(BUILD_SHARED_LIBS)
- set(LLVM_SHARED_LIBS_ENABLED "1")
- else()
- set(LLVM_SHARED_LIBS_ENABLED "0")
- endif(BUILD_SHARED_LIBS)
-
# Configuration-time: See Unit/lit.site.cfg.in
if (CMAKE_CFG_INTDIR STREQUAL ".")
set(LLVM_BUILD_MODE ".")
@@ -590,10 +589,16 @@ function(configure_lit_site_cfg input output)
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLVM_LIBS_DIR ${LLVM_LIBRARY_DIR})
# SHLIBDIR points the build tree.
- string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} SHLIBDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
+ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
- set(ENABLE_SHARED ${LLVM_SHARED_LIBS_ENABLED})
+ # FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for
+ # plugins. We may rename it.
+ if(LLVM_ENABLE_PLUGINS)
+ set(ENABLE_SHARED "1")
+ else()
+ set(ENABLE_SHARED "0")
+ endif()
if(LLVM_ENABLE_ASSERTIONS AND NOT MSVC_IDE)
set(ENABLE_ASSERTIONS "1")
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index 447ba52..b8577f7 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -67,12 +67,6 @@ if( LLVM_ENABLE_ASSERTIONS )
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
endforeach()
endif()
-else()
- if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
- if( NOT MSVC_IDE AND NOT XCODE )
- add_definitions( -DNDEBUG )
- endif()
- endif()
endif()
if(WIN32)
@@ -113,18 +107,6 @@ if(APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
-function(add_flag_or_print_warning flag)
- check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
- check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)
- if (C_SUPPORTS_FLAG AND CXX_SUPPORTS_FLAG)
- message(STATUS "Building with ${flag}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
- else()
- message(WARNING "${flag} is not supported.")
- endif()
-endfunction()
-
function(append value)
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
@@ -139,13 +121,25 @@ function(append_if condition value)
endif()
endfunction()
-macro(add_flag_if_supported flag)
- check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
- append_if(C_SUPPORTS_FLAG "${flag}" CMAKE_C_FLAGS)
- check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)
- append_if(CXX_SUPPORTS_FLAG "${flag}" CMAKE_CXX_FLAGS)
+macro(add_flag_if_supported flag name)
+ check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}")
+ append_if("C_SUPPORTS_${name}" "${flag}" CMAKE_C_FLAGS)
+ check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}")
+ append_if("CXX_SUPPORTS_${name}" "${flag}" CMAKE_CXX_FLAGS)
endmacro()
+function(add_flag_or_print_warning flag name)
+ check_c_compiler_flag("-Werror ${flag}" "C_SUPPORTS_${name}")
+ check_cxx_compiler_flag("-Werror ${flag}" "CXX_SUPPORTS_${name}")
+ if ("C_SUPPORTS_${name}" AND "CXX_SUPPORTS_${name}")
+ message(STATUS "Building with ${flag}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
+ else()
+ message(WARNING "${flag} is not supported.")
+ endif()
+endfunction()
+
if( LLVM_ENABLE_PIC )
if( XCODE )
# Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't
@@ -154,7 +148,7 @@ if( LLVM_ENABLE_PIC )
elseif( WIN32 OR CYGWIN)
# On Windows all code is PIC. MinGW warns if -fPIC is used.
else()
- add_flag_or_print_warning("-fPIC")
+ add_flag_or_print_warning("-fPIC" FPIC)
if( WIN32 OR CYGWIN)
# MinGW warns if -fvisibility-inlines-hidden is used.
@@ -290,10 +284,7 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
endif()
append_if(LLVM_ENABLE_PEDANTIC "-pedantic -Wno-long-long" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
- check_cxx_compiler_flag("-Werror -Wcovered-switch-default" CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
- append_if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG "-Wcovered-switch-default" CMAKE_CXX_FLAGS)
- check_c_compiler_flag("-Werror -Wcovered-switch-default" C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
- append_if(C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG "-Wcovered-switch-default" CMAKE_C_FLAGS)
+ add_flag_if_supported("-Wcovered-switch-default" COVERED_SWITCH_DEFAULT_FLAG)
append_if(USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS)
append_if(USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG)
@@ -311,6 +302,9 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
endif()
endif (LLVM_ENABLE_WARNINGS)
append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ if (NOT LLVM_ENABLE_TIMESTAMPS)
+ add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
+ endif ()
if (LLVM_ENABLE_CXX1Y)
check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
@@ -333,14 +327,14 @@ endif( MSVC )
macro(append_common_sanitizer_flags)
# Append -fno-omit-frame-pointer and turn on debug info to get better
# stack traces.
- add_flag_if_supported("-fno-omit-frame-pointer")
+ add_flag_if_supported("-fno-omit-frame-pointer" FNO_OMIT_FRAME_POINTER)
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
- add_flag_if_supported("-gline-tables-only")
+ add_flag_if_supported("-gline-tables-only" GLINE_TABLES_ONLY)
endif()
# Use -O1 even in debug mode, otherwise sanitizers slowdown is too large.
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
- add_flag_if_supported("-O1")
+ add_flag_if_supported("-O1" O1)
endif()
endmacro()
@@ -349,12 +343,12 @@ if(LLVM_USE_SANITIZER)
if (LLVM_ON_UNIX)
if (LLVM_USE_SANITIZER STREQUAL "Address")
append_common_sanitizer_flags()
- add_flag_or_print_warning("-fsanitize=address")
+ append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
append_common_sanitizer_flags()
- add_flag_or_print_warning("-fsanitize=memory")
+ append("-fsanitize=memory" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
- add_flag_or_print_warning("-fsanitize-memory-track-origins")
+ append("-fsanitize-memory-track-origins" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
else()
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
@@ -390,15 +384,9 @@ if(NOT CYGWIN AND NOT WIN32)
if (C_SUPPORTS_FNO_FUNCTION_SECTIONS)
# Don't add -ffunction-section if it can be disabled with -fno-function-sections.
# Doing so will break sanitizers.
- check_c_compiler_flag("-Werror -ffunction-sections" C_SUPPORTS_FFUNCTION_SECTIONS)
- check_cxx_compiler_flag("-Werror -ffunction-sections" CXX_SUPPORTS_FFUNCTION_SECTIONS)
- append_if(C_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_C_FLAGS)
- append_if(CXX_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_CXX_FLAGS)
+ add_flag_if_supported("-ffunction-sections" FFUNCTION_SECTIONS)
endif()
- check_c_compiler_flag("-Werror -fdata-sections" C_SUPPORTS_FDATA_SECTIONS)
- check_cxx_compiler_flag("-Werror -fdata-sections" CXX_SUPPORTS_FDATA_SECTIONS)
- append_if(C_SUPPORTS_FDATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS)
- append_if(CXX_SUPPORTS_FDATA_SECTIONS "-fdata-sections" CMAKE_CXX_FLAGS)
+ add_flag_if_supported("-fdata-sections" FDATA_SECTIONS)
endif()
endif()
@@ -419,3 +407,12 @@ if(MSVC)
string(REGEX REPLACE "(^| ) */EH[-cs]+ *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
+
+# Plugin support
+# FIXME: Make this configurable.
+if(WIN32 OR CYGWIN)
+ # DLL platform(s) don't support plugins.
+ set(LLVM_ENABLE_PLUGINS OFF)
+else()
+ set(LLVM_ENABLE_PLUGINS ON)
+endif()