[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
This commit is contained in:
Rainer Orth 2020-08-27 10:59:51 +02:00
parent 7f1bb326ee
commit 26d659bbe0
3 changed files with 9 additions and 6 deletions

View File

@ -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
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")

View File

@ -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)

View File

@ -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 ()