diff mbox series

[meta-oe,1/2] googletest: Pass -fPIC to CFLAGS

Message ID 20240307032105.1806173-1-mingli.yu@windriver.com
State Accepted
Headers show
Series [meta-oe,1/2] googletest: Pass -fPIC to CFLAGS | expand

Commit Message

Yu, Mingli March 7, 2024, 3:21 a.m. UTC
From: Mingli Yu <mingli.yu@windriver.com>

Fail to build re2 which depends on googletest as below:
/build/tmp-glibc/work/core2-64-wrs-linux/re2/2024.03.01/recipe-sysroot-native/usr/bin/x86_64-wrs-linux/../../libexec/x86_64-wrs-linux/gcc/x86_64-wrs-linux/13.2.0/ld: /build/tmp-glibc/work/core2-64-wrs-linux/re2/2024.03.01/recipe-sysroot/usr/lib64/libgtest.a(gtest-all.cc.o): warning: relocation against `_ZTVN7testing8internal11MatcherBaseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE' in read-only section `.text._ZN7testing8internal11MatcherBaseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED0Ev[_ZN7testing8internal11MatcherBaseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED5Ev]'
/build/tmp-glibc/work/core2-64-wrs-linux/re2/2024.03.01/recipe-sysroot-native/usr/bin/x86_64-wrs-linux/../../libexec/x86_64-wrs-linux/gcc/x86_64-wrs-linux/13.2.0/ld: /build/tmp-glibc/work/core2-64-wrs-linux/re2/2024.03.01/recipe-sysroot/usr/lib64/libgtest.a(gtest-all.cc.o): relocation R_X86_64_PC32 against symbol `_ZTVN7testing8internal17TestEventRepeaterE' can not be used when making a shared object; recompile with -fPIC
/build/tmp-glibc/work/core2-64-wrs-linux/re2/2024.03.01/recipe-sysroot-native/usr/bin/x86_64-wrs-linux/../../libexec/x86_64-wrs-linux/gcc/x86_64-wrs-linux/13.2.0/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

So pass -fPIC to fix the above issue.

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 meta-oe/recipes-test/googletest/googletest_1.14.0.bb | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/meta-oe/recipes-test/googletest/googletest_1.14.0.bb b/meta-oe/recipes-test/googletest/googletest_1.14.0.bb
index 1b05f3d33..4c9d1e709 100644
--- a/meta-oe/recipes-test/googletest/googletest_1.14.0.bb
+++ b/meta-oe/recipes-test/googletest/googletest_1.14.0.bb
@@ -16,6 +16,7 @@  inherit cmake pkgconfig
 #
 PACKAGECONFIG[shared] = "-DBUILD_SHARED_LIBS=ON,-DBUILD_SHARED_LIBS=OFF,,"
 
+CXXFLAGS:append = " -fPIC"
 
 ALLOW_EMPTY:${PN} = "1"
 ALLOW_EMPTY:${PN}-dbg = "1"