0001-force-position-independent-code.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From d170b19e500d85381369e379771be8d7816bcc92 Mon Sep 17 00:00:00 2001
  2. From: Adam Duskett <Aduskett@gmail.com>
  3. Date: Tue, 21 Jul 2020 13:08:50 -0700
  4. Subject: [PATCH] force position independent code
  5. Without this option, programs building for arm64 or x86-64 will fail when
  6. attempting to link to the built libraries with the following (abbreviated)
  7. error:
  8. "relocation against `.rodata' can not be used when making a shared object;
  9. recompile with -fPIC."
  10. Because libabseil-cpp builds static libraries, it is better to set the
  11. POSITION_INDEPENDENT_CODE to ON instead of forcing fPIC, as forcing fPIC may
  12. cause relocation errors when shared libraries link against the built static
  13. libraries.
  14. Signed-off-by: Adam Duskett <Aduskett@gmail.com>
  15. ---
  16. CMake/AbseilHelpers.cmake | 2 ++
  17. 1 file changed, 2 insertions(+)
  18. diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake
  19. index 86ff9eb..bdb7a89 100644
  20. --- a/CMake/AbseilHelpers.cmake
  21. +++ b/CMake/AbseilHelpers.cmake
  22. @@ -209,6 +209,8 @@ function(absl_cc_library)
  23. set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
  24. set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
  25. + # Without this setting, other programs such as GRPC will fail when linking.
  26. + set_property(TARGET ${_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
  27. # When being installed, we lose the absl_ prefix. We want to put it back
  28. # to have properly named lib files. This is a no-op when we are not being
  29. # installed.
  30. --
  31. 2.26.2