[PATCH] D85630: [cmake] Don't build with -O3 -fPIC on Solaris/sparcv9
Rainer Orth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 06:03:22 PDT 2020
ro updated this revision to Diff 286800.
ro added a comment.
Update comment.
Use -O with `clang`, too.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85630/new/
https://reviews.llvm.org/D85630
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -12,6 +12,7 @@
include(CheckCXXCompilerFlag)
include(CheckSymbolExists)
include(CMakeDependentOption)
+include(LLVMProcessSources)
if(CMAKE_LINKER MATCHES "lld-link" OR (MSVC AND (LLVM_USE_LINKER STREQUAL "lld" OR LLVM_ENABLE_LLD)))
set(LINKER_IS_LLD_LINK TRUE)
@@ -296,6 +297,16 @@
NOT Uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_flag_or_print_warning("-fno-shrink-wrap" FNO_SHRINK_WRAP)
endif()
+ # gcc with -O3 -fPIC generates TLS sequences that violate the spec on
+ # Solaris/sparcv9, causing executables created with the system linker
+ # to SEGV (GCC PR target/96607).
+ # clang with -O3 -fPIC generates code that SEGVs.
+ # Both can be worked around by compiling with -O instead.
+ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" AND
+ LLVM_NATIVE_ARCH STREQUAL "Sparc" AND
+ NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+ llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O")
+ endif()
endif()
if(NOT WIN32 AND NOT CYGWIN AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85630.286800.patch
Type: text/x-patch
Size: 1296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200820/e0c8898f/attachment.bin>
More information about the llvm-commits
mailing list