From: hev Date: Thu, 1 Oct 2020 05:28:58 +0000 (+0800) Subject: Fix build errors on GCC. (#42834) X-Git-Tag: submit/tizen/20210909.063632~5253 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=036bb72b149cbce08180e7aff91ffc3547aeb65f;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix build errors on GCC. (#42834) * Fix build errors on GCC. * Enable PGO on Clang. * Fix build errors on GCC 10 and later. --- diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index cb9db28..373cc3d 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -321,6 +321,7 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wno-unused-variable) add_compile_options(-Wno-unused-value) add_compile_options(-Wno-unused-function) + add_compile_options(-Wno-tautological-compare) #These seem to indicate real issues add_compile_options($<$:-Wno-invalid-offsetof>) @@ -334,8 +335,6 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wno-unused-private-field) # Explicit constructor calls are not supported by clang (this->ClassName::ClassName()) add_compile_options(-Wno-microsoft) - # This warning is caused by comparing 'this' to NULL - add_compile_options(-Wno-tautological-compare) # There are constants of type BOOL used in a condition. But BOOL is defined as int # and so the compiler thinks that there is a mistake. add_compile_options(-Wno-constant-logical-operand) diff --git a/src/coreclr/pgosupport.cmake b/src/coreclr/pgosupport.cmake index 04bde2b..1e2be5d 100644 --- a/src/coreclr/pgosupport.cmake +++ b/src/coreclr/pgosupport.cmake @@ -47,16 +47,16 @@ function(add_pgo TargetName) set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /USEPROFILE:PGD=\"${ProfilePath}\"") else(CLR_CMAKE_HOST_WIN32) if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO) - if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6) + if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)) if(HAVE_LTO) target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-use=${ProfilePath} -Wno-profile-instr-out-of-date -Wno-profile-instr-unprofiled) set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fuse-ld=gold -fprofile-instr-use=${ProfilePath}") else(HAVE_LTO) message(WARNING "LTO is not supported, skipping profile guided optimizations") endif(HAVE_LTO) - else(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6) + else((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)) message(WARNING "PGO is not supported; Clang 3.6 or later is required for profile guided optimizations") - endif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6) + endif((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)) endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO) endif(CLR_CMAKE_HOST_WIN32) endif(NOT EXISTS ${ProfilePath}) diff --git a/src/coreclr/src/CMakeLists.txt b/src/coreclr/src/CMakeLists.txt index 1ee527d..5f74a58 100644 --- a/src/coreclr/src/CMakeLists.txt +++ b/src/coreclr/src/CMakeLists.txt @@ -60,6 +60,10 @@ if(CLR_CMAKE_HOST_UNIX) add_subdirectory(nativeresources) endif(CLR_CMAKE_HOST_UNIX) +if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 10.0)) + add_compile_options(-Wno-error=stringop-overflow=) +endif() + add_subdirectory(utilcode) add_subdirectory(gcinfo) add_subdirectory(jit) diff --git a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt index b4262529..8995556 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt @@ -43,6 +43,10 @@ if(CLR_CMAKE_TARGET_UNIX) endif() endif() +if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 10.0)) + add_compile_options(-Wno-error=stringop-truncation) +endif() + include(configure.cmake) set(NATIVEGLOBALIZATION_SOURCES