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