[PATCH] D78306: [flang] Use LLVM's flags
Isuru Fernando via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 11:44:15 PDT 2020
isuruf updated this revision to Diff 258115.
isuruf added a comment.
Herald added a reviewer: sscalpone.
Enable pedantic on standalone build and disable werror on msvc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78306/new/
https://reviews.llvm.org/D78306
Files:
flang/CMakeLists.txt
flang/lib/Optimizer/CMakeLists.txt
flang/unittests/Evaluate/CMakeLists.txt
flang/unittests/Runtime/CMakeLists.txt
Index: flang/unittests/Runtime/CMakeLists.txt
===================================================================
--- flang/unittests/Runtime/CMakeLists.txt
+++ flang/unittests/Runtime/CMakeLists.txt
@@ -1,11 +1,12 @@
-if(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
-endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+# RuntimeTesting needs exceptions enabled
+set(LLVM_REQUIRES_EH ON)
+set(LLVM_REQUIRES_RTTI ON)
add_library(RuntimeTesting
testing.cpp
)
+llvm_update_compile_flags(RuntimeTesting)
add_executable(format-test
format.cpp
Index: flang/unittests/Evaluate/CMakeLists.txt
===================================================================
--- flang/unittests/Evaluate/CMakeLists.txt
+++ flang/unittests/Evaluate/CMakeLists.txt
@@ -88,10 +88,12 @@
# IEEE exception flags (different use of the word "exception")
# in the actual hardware floating-point status register, so ensure that
# C++ exceptions are enabled for this test.
-set_source_files_properties(real.cpp PROPERTIES COMPILE_FLAGS -fexceptions)
+set(LLVM_REQUIRES_EH ON)
+set(LLVM_REQUIRES_RTTI ON)
add_executable(real-test
real.cpp
)
+llvm_update_compile_flags(real-test)
target_link_libraries(real-test
FortranEvaluateTesting
Index: flang/lib/Optimizer/CMakeLists.txt
===================================================================
--- flang/lib/Optimizer/CMakeLists.txt
+++ flang/lib/Optimizer/CMakeLists.txt
@@ -1,5 +1,2 @@
-# Sources generated by tablegen have unused parameters.
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
-
add_subdirectory(Dialect)
add_subdirectory(Support)
Index: flang/CMakeLists.txt
===================================================================
--- flang/CMakeLists.txt
+++ flang/CMakeLists.txt
@@ -59,6 +59,14 @@
if(LLVM_ENABLE_ZLIB)
find_package(ZLIB REQUIRED)
endif()
+ option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
+ if (MSVC)
+ set(_FLANG_ENABLE_WERROR_DEFAULT OFF)
+ else ()
+ set(_FLANG_ENABLE_WERROR_DEFAULT ON)
+ endif()
+ option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." "${_FLANG_ENABLE_WERROR_DEFAULT}")
+ option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
include(CMakeParseArguments)
include(AddLLVM)
@@ -76,7 +84,6 @@
NO_DEFAULT_PATH)
endif()
- option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
option(LLVM_INSTALL_TOOLCHAIN_ONLY
"Only include toolchain files in the 'install' target." OFF)
option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
@@ -235,9 +242,6 @@
${FLANG_SOURCE_DIR}/include/flang/Config/config.h.cmake
${FLANG_BINARY_DIR}/include/flang/Config/config.h)
-# Add global F18 flags.
-set(CMAKE_CXX_FLAGS "-fno-rtti -fno-exceptions -pedantic -Wall -Wextra -Werror -Wcast-qual -Wimplicit-fallthrough -Wdelete-non-virtual-dtor ${CMAKE_CXX_FLAGS}")
-
# Builtin check_cxx_compiler_flag doesn't seem to work correctly
macro(check_compiler_flag flag resultVar)
unset(${resultVar} CACHE)
@@ -246,11 +250,11 @@
check_compiler_flag("-Werror -Wno-deprecated-copy" CXX_SUPPORTS_NO_DEPRECATED_COPY_FLAG)
if (CXX_SUPPORTS_NO_DEPRECATED_COPY_FLAG)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy")
endif()
check_compiler_flag("-Wstring-conversion" CXX_SUPPORTS_NO_STRING_CONVERSION_FLAG)
if (CXX_SUPPORTS_NO_STRING_CONVERSION_FLAG)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-string-conversion")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-string-conversion")
endif()
# Add appropriate flags for GCC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78306.258115.patch
Type: text/x-patch
Size: 3690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/f66beeff/attachment.bin>
More information about the llvm-commits
mailing list