[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
Mon Aug 10 00:40:05 PDT 2020
ro created this revision.
ro added reviewers: chandlerc, daltenty, tstellar, hans, serge-sans-paille.
Herald added subscribers: fedor.sergeev, mgorny, jyknight.
Herald added a reviewer: bollu.
Herald added a project: LLVM.
ro requested review of this revision.
Tests on Solaris/sparcv9 currently show about 250 failures, most of them like the following:
FAIL: LLVM-Unit :: Support/./SupportTests/TaskQueueTest.UnOrderedFutures (4269 of 67884)
******************** TEST 'LLVM-Unit :: Support/./SupportTests/TaskQueueTest.UnOrderedFutures' FAILED ********************
Note: Google Test filter = TaskQueueTest.UnOrderedFutures
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from TaskQueueTest
[ RUN ] TaskQueueTest.UnOrderedFutures
0 SupportTests 0x0000000100753b20 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 32
1 SupportTests 0x0000000100752974 llvm::sys::RunSignalHandlers() + 68
2 SupportTests 0x0000000100752b18 SignalHandler(int) + 372
3 libc.so.1 0xffffffff7eedc800 __sighndlr + 12
4 libc.so.1 0xffffffff7eecf23c call_user_handler + 852
5 libc.so.1 0xffffffff7eecf594 sigacthandler + 84
6 SupportTests 0x00000001006f8cb8 std::thread::_State_impl<std::thread::_Invoker<std::tuple<llvm::ThreadPool::ThreadPool(llvm::ThreadPoolStrategy)::'lambda'()> > >::_M_run() + 512
7 libstdc++.so.6.0.28 0xfffffffc628117cc execute_native_thread_routine + 16
8 libc.so.1 0xffffffff7eedc6a0 _lwp_start + 0
Since it's effectively impossible to debug such a `SEGV` in a `Release` build, I tried a `Debug` build instead, only to find that the failures had gone away.
Further investigation revealed that most of the issue centers around `llvm/lib/Support/ThreadPool.cpp`. That file is built with `-O3 -fPIC` in a `Release` build. The failure vanishes if
- compiling without `-fPIC`
- compiling with `-O -fPIC`
- linking with GNU `ld` instead of Solaris `ld`
An attempt to build with `-DLLVM_ENABLE_PIC=Off` initially failed since neither `libRemarks.so` (D85626 <https://reviews.llvm.org/D85626>) nor `LLVMPolly.so` (D85627 <https://reviews.llvm.org/D85627>) heed that option. Even with that fixed, a few codegen failures remain.
Next I tried to build just `ThreadPool.cpp` with `-O -fPIC`. While that fixed the vast majority of the failures, 16 `LLVM :: CodeGen/X86` failures remained.
Given that that solution was both incomplete and fragile, I went for building the whole tree with `-O -fPIC` for `Release` builds.
This is what this patch does, making all failures relative to a `Debug` build go away.
Tested on `sparcv9-sun-solaris2.11`.
Repository:
rG LLVM Github Monorepo
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,14 @@
NOT Uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_flag_or_print_warning("-fno-shrink-wrap" FNO_SHRINK_WRAP)
endif()
+ # When g++ builds with -O3 -fPIC on Solaris/sparcv9, executables created
+ # with the system linker SEGV.
+ if(CMAKE_COMPILER_IS_GNUCXX AND
+ ${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.284267.patch
Type: text/x-patch
Size: 1145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200810/efb6e48d/attachment.bin>
More information about the llvm-commits
mailing list