[PATCH] D85626: [tools][remarks-shlib] Don't build libRemarks.so without PIC

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 00:05:00 PDT 2020


ro created this revision.
ro added reviewers: thegameg, JDevlieghere.
Herald added subscribers: fedor.sergeev, mgorny, jyknight.
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 `libRemarks.so`:

  [27/2297] Linking CXX shared library lib/libRemarks.so.12git
  FAILED: lib/libRemarks.so.12git
  [...]
  ld: fatal: relocation error: R_SPARC_H44: file lib/libLLVMRemarks.a(Remark.cpp.o): symbol _ZTVN4llvm18raw_string_ostreamE: invalid shared object relocation type: ABS44 code model unsupported
  [...]

On Solaris/sparcv9 as on many other targets you cannot link non-PIC objects into a shared object.

The following patch avoids this by not building the library with PIC.  It allowed the build to complete and `ninja check-all` showed no errors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85626

Files:
  llvm/tools/remarks-shlib/CMakeLists.txt


Index: llvm/tools/remarks-shlib/CMakeLists.txt
===================================================================
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -8,7 +8,9 @@
 
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Remarks.exports)
 
-add_llvm_library(Remarks SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES})
+if( LLVM_ENABLE_PIC )
+  add_llvm_library(Remarks SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES})
+endif()
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
   DESTINATION include/llvm-c


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85626.284260.patch
Type: text/x-patch
Size: 558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200810/552feaa6/attachment.bin>


More information about the llvm-commits mailing list