[PATCH] D58092: [CMake] Don't override required compiler flags in the runtimes build

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 11 17:52:39 PST 2019


phosek created this revision.
phosek added reviewers: smeenai, beanz.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.

Ensure that HandleLLVMOptions adds all necessary required flags,
including -Wno-error when building with LLVM_ENABLE_WERROR enabled.


Repository:
  rL LLVM

https://reviews.llvm.org/D58092

Files:
  llvm/runtimes/CMakeLists.txt


Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -93,23 +93,16 @@
     set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   endif()
 
-  set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
-  set(SAFE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
-
   include(CheckLibraryExists)
   include(CheckCCompilerFlag)
 
-  check_library_exists(c fopen "" LLVM_HAS_C_LIB)
-  check_c_compiler_flag(-nodefaultlibs LLVM_HAS_NODEFAULTLIBS_FLAG)
-  if(LLVM_HAS_NODEFAULTLIBS_FLAG)
-    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
-    if(LLVM_HAS_C_LIB)
-      list(APPEND CMAKE_REQUIRED_LIBRARIES c)
-    endif()
-  endif()
+  # We don't have libc++ (yet).
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 
   # Avoid checking whether the compiler is working.
   set(LLVM_COMPILER_CHECKED ON)
+  # Mark the compiler as compatible with GCC.
+  set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
   # Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions
   # resulting in unjustified successes by check_cxx_compiler_flag.
   set(LLVM_ENABLE_WARNINGS ON)
@@ -119,8 +112,8 @@
   include(HandleLLVMOptions)
   include(FindPythonInterp)
 
-  set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS})
-  set(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES})
+  # Remove the -nostdlib++ option we've added earlier.
+  string(REPLACE "-nostdlib++" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
 
   # This can be used to detect whether we're in the runtimes build.
   set(RUNTIMES_BUILD ON)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58092.186382.patch
Type: text/x-patch
Size: 1661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190212/867cdebf/attachment.bin>


More information about the llvm-commits mailing list