[polly] 26d659b - [polly][cmake] Don't build LLVMPolly.so without PIC
Rainer Orth via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 02:01:36 PDT 2020
Author: Rainer Orth
Date: 2020-08-27T10:59:51+02:00
New Revision: 26d659bbe08028c0e04ddc3f4c698a995f41a131
URL: https://github.com/llvm/llvm-project/commit/26d659bbe08028c0e04ddc3f4c698a995f41a131
DIFF: https://github.com/llvm/llvm-project/commit/26d659bbe08028c0e04ddc3f4c698a995f41a131.diff
LOG: [polly][cmake] Don't build LLVMPolly.so without PIC
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.
Differential Revision: https://reviews.llvm.org/D85627
Added:
Modified:
polly/CMakeLists.txt
polly/cmake/CMakeLists.txt
polly/lib/CMakeLists.txt
Removed:
################################################################################
diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt
index 8b771f163f12..0f5f71bba9d9 100644
--- a/polly/CMakeLists.txt
+++ b/polly/CMakeLists.txt
@@ -39,8 +39,10 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
set(POLLY_GTEST_AVAIL 1)
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 if possible
+ 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")
diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt
index 211f95512717..fd8028a8937a 100644
--- a/polly/cmake/CMakeLists.txt
+++ b/polly/cmake/CMakeLists.txt
@@ -10,8 +10,8 @@ else()
endif()
set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET})
-if (NOT MSVC)
- # LLVMPolly is a dummy target on Win
+if (NOT MSVC AND LLVM_ENABLE_PIC)
+ # LLVMPolly is a dummy target on Win or if PIC code is disabled.
list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly)
endif()
if (POLLY_ENABLE_GPGPU_CODEGEN)
diff --git a/polly/lib/CMakeLists.txt b/polly/lib/CMakeLists.txt
index 2b9a77b93926..113ae5f2eb57 100644
--- a/polly/lib/CMakeLists.txt
+++ b/polly/lib/CMakeLists.txt
@@ -137,8 +137,9 @@ endif ()
# Create a loadable module Polly.so that can be loaded using
# LLVM's/clang's "-load" option.
-if (MSVC)
- # Add dummy target, because loadable modules are not supported on Windows
+if (MSVC OR NOT LLVM_ENABLE_PIC)
+ # Add dummy target, either because loadable modules are not supported
+ # as on Windows or because PIC code has been disabled
add_custom_target(LLVMPolly)
set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly")
else ()
More information about the llvm-commits
mailing list