[PATCH] D85627: [polly][cmake] Don't build LLVMPolly.so without PIC
Rainer Orth via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 00:18:49 PDT 2020
ro created this revision.
ro added a reviewer: grosser.
ro added a project: Polly.
Herald added subscribers: llvm-commits, fedor.sergeev, mgorny, jyknight.
Herald added a reviewer: bollu.
Herald added a project: LLVM.
ro requested review of this revision.
A build on `sparcv9-sun-solaris2.11` with `-DLLVM_ENABLE_PIC=Off` failed linking `LLVMPolly.so`:
[2277/2297] Linking CXX shared module lib/LLVMPolly.so
FAILED: lib/LLVMPolly.so
[...]
ld: fatal: relocation error: R_SPARC_H44: file tools/polly/lib/CMakeFiles/obj.Polly.dir/Analysis/DependenceInfo.cpp.o: symbol .data._ZL16__gthread_active (section): invalid shared object relocation type: ABS44 code model unsupported
[...]
As on many other targets, one cannot link non-PIC objects into a shared object on Solaris/sparcv9.
The following patch avoids this by not building the library without PIC. It allowed the build to finish.
Testing showed one regression however:
FAIL: Polly :: Isl/isl-args.ll (66183 of 67884)
[...]
Command Output (stderr):
--
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: opt -polly-process-unprofitable -polly-remarks-minimal -polly-use-llvm-names -polly-import-jscop-dir=/vol/llvm/src/llvm-project/dist/polly/test/Isl -polly-codegen-verify -polly-scops -disable-output -polly-isl-arg=-h
1. Running pass 'Function Pass Manager' on module '<stdin>'.
2. Running pass 'Region Pass Manager' on function '@foo_1d'
3. Running pass 'Polly - Create polyhedral description of Scops' on basic block '%bb1'
0 opt 0x000000010460fb70 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 20
1 opt 0x000000010460e650 SignalHandler(int) + 420
2 libc.so.1 0xffffffff7eedc800 __sighndlr + 12
3 libc.so.1 0xffffffff7eecf23c call_user_handler + 852
4 libc.so.1 0xffffffff7eecf594 sigacthandler + 84
5 libc.so.1 0xffffffff7edecd50 strlen + 80
6 libc.so.1 0xffffffff7ee4d28c _ndoprnt + 20
7 libc.so.1 0xffffffff7ee4c110 printf + 272
8 opt 0x0000000105208814 print_bool_help + 308
9 opt 0x0000000105209e70 isl_args_parse + 1764
10 opt 0x0000000104f36310 polly::Scop::Scop(llvm::Region&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::DominatorTree&, polly::ScopDetection::DetectionContext&, llvm::OptimizationRemarkEmitter&, int) + 692
11 opt 0x0000000104f69b50 polly::ScopBuilder::buildScop(llvm::Region&, llvm::AssumptionCache&) + 80
12 opt 0x0000000104f6ada0 polly::ScopBuilder::ScopBuilder(llvm::Region*, llvm::AssumptionCache&, llvm::AAResults&, llvm::DataLayout const&, llvm::DominatorTree&, llvm::LoopInfo&, polly::ScopDetection&, llvm::ScalarEvolution&, llvm::OptimizationRemarkEmitter&) + 588
13 opt 0x0000000104f37400 polly::ScopInfoRegionPass::runOnRegion(llvm::Region*, llvm::RGPassManager&) + 744
14 opt 0x00000001036beda8 llvm::RGPassManager::runOnFunction(llvm::Function&) + 3172
15 opt 0x0000000103dd1c18 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1084
16 opt 0x0000000103dd32e0 llvm::FPPassManager::runOnModule(llvm::Module&) + 32
17 opt 0x0000000103dd0ee0 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1440
18 opt 0x00000001021070ac main + 9856
19 opt 0x00000001020e6864 _start + 100
`gdb` shows that `strlen` incurred a `SEGV` which is usually a sign of calling it with `NULL`. Debugging that requires a `Debug` build which I don't currently have the time and disk space to try.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85627
Files:
polly/CMakeLists.txt
polly/cmake/CMakeLists.txt
polly/lib/CMakeLists.txt
Index: polly/lib/CMakeLists.txt
===================================================================
--- polly/lib/CMakeLists.txt
+++ polly/lib/CMakeLists.txt
@@ -137,7 +137,7 @@
# Create a loadable module Polly.so that can be loaded using
# LLVM's/clang's "-load" option.
-if (MSVC)
+if (MSVC OR NOT LLVM_ENABLE_PIC)
# Add dummy target, because loadable modules are not supported on Windows
add_custom_target(LLVMPolly)
set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly")
Index: polly/cmake/CMakeLists.txt
===================================================================
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -10,7 +10,7 @@
endif()
set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET})
-if (NOT MSVC)
+if (NOT MSVC AND LLVM_ENABLE_PIC)
# LLVMPolly is a dummy target on Win
list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly)
endif()
Index: polly/CMakeLists.txt
===================================================================
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -58,8 +58,10 @@
endif()
endif()
- # Make sure the isl c files are built as fPIC
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+ if (LLVM_ENABLE_PIC)
+ # Make sure the isl c files are built as fPIC
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+ endif ()
# Set directory for polly-isl-test.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85627.284263.patch
Type: text/x-patch
Size: 1433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200810/041fd2b2/attachment.bin>
More information about the llvm-commits
mailing list