Skip to content

Commit d3ebe71

Browse files
committed
[CMake] Don't override required compiler flags in the runtimes build
Ensure that HandleLLVMOptions adds all necessary required flags, including -Wno-error when building with LLVM_ENABLE_WERROR enabled. Differential Revision: https://reviews.llvm.org/D58092 llvm-svn: 353790
1 parent 093b896 commit d3ebe71

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

llvm/runtimes/CMakeLists.txt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,15 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
9393
set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
9494
endif()
9595

96-
set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
97-
set(SAFE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
98-
9996
include(CheckLibraryExists)
10097
include(CheckCCompilerFlag)
10198

102-
check_library_exists(c fopen "" LLVM_HAS_C_LIB)
103-
check_c_compiler_flag(-nodefaultlibs LLVM_HAS_NODEFAULTLIBS_FLAG)
104-
if(LLVM_HAS_NODEFAULTLIBS_FLAG)
105-
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
106-
if(LLVM_HAS_C_LIB)
107-
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
108-
endif()
109-
endif()
99+
# We don't have libc++ (yet).
100+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
110101

111102
# Avoid checking whether the compiler is working.
112103
set(LLVM_COMPILER_CHECKED ON)
104+
# Mark the compiler as compatible with GCC.
113105
# Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions
114106
# resulting in unjustified successes by check_cxx_compiler_flag.
115107
set(LLVM_ENABLE_WARNINGS ON)
@@ -119,8 +111,8 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
119111
include(HandleLLVMOptions)
120112
include(FindPythonInterp)
121113

122-
set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS})
123-
set(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES})
114+
# Remove the -nostdlib++ option we've added earlier.
115+
string(REPLACE "-nostdlib++" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
124116

125117
# This can be used to detect whether we're in the runtimes build.
126118
set(RUNTIMES_BUILD ON)

0 commit comments

Comments
 (0)