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
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")
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)
# 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 ()