[Buildroot] [PATCH 1/1] package/libgpiod: compile with -fPIC when BR2_PIC_PIE is set
Ankur Tyagi
ankur.tyagi at gallagher.com
Tue Sep 28 22:03:00 UTC 2021
Otherwise build fails with following error:
Toolchain wrapper executing: '/tools/aarch64-linux-gnu/bin//aarch64-linux-gnu-g++' '--sysroot' '/home/user/work/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot' '-mabi=lp64' '-fstack-protector-strong' '-fstack-clash-protection' '-mcpu=cortex-a35' '-fPIE' '-Wl,-z,now' '-Wl,-z,relro' '-shared' '-nostdlib' '/home/user/work/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/../lib64/crti.o' '/tools/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtbeginS.o' '.libs/libgpiodcxx_la-chip.o' '.libs/libgpiodcxx_la-iter.o' '.libs/libgpiodcxx_la-line.o' '.libs/libgpiodcxx_la-line_bulk.o' '-Wl,-rpath' '-Wl,/home/user/work/buildroot/output/build/libgpiod-1.4.5/lib/.libs' '/home/user/work/buildroot/output/build/libgpiod-1.4.5/lib/.libs/libgpiod.so' '-L../../lib' '-L/tools/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.3.0' '-L/tools/aarch64-linux-gnu/bin/../lib/gcc' '-L/tools/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64' '-L/home/user/work/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/lib/../lib64' '-L/home/user/work/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/../lib64' '-L/tools/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib' '-L/home/user/work/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/lib' '-L/home/user/work/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib' '-lstdc++' '-lm' '-lc' '-lgcc_s' '/tools/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtendS.o' '/home/user/work/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/../lib64/crtn.o' '-Os' '-g2' '-Wl,-soname' '-Wl,libgpiodcxx.so.1' '-o' '.libs/libgpiodcxx.so.1.0.5'
/tools/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: .libs/libgpiodcxx_la-chip.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZNSt14_Function_base13_Base_managerIPFP10gpiod_chipRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE10_M_managerERSt9_Any_dataRKSE_St18_Manager_operation' which may bind externally can not be used when making a shared object; recompile with -fPIC
.libs/libgpiodcxx_la-chip.o: in function `std::function<gpiod_chip* (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::function<gpiod_chip* (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), void, void>(gpiod_chip* (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))':
/tools/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/8.3.0/bits/std_function.h:676:(.text.startup+0x48): dangerous relocation: unsupported relocation
/tools/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: .libs/libgpiodcxx_la-line_bulk.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEED1Ev' which may bind externally can not be used when making a shared object; recompile with -fPIC
.libs/libgpiodcxx_la-line_bulk.o: in function `__static_initialization_and_destruction_0':
/home/user/work/buildroot/output/build/libgpiod-1.4.5/bindings/cxx/line_bulk.cpp:20:(.text.startup+0x188): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
Makefile:499: recipe for target 'libgpiodcxx.la' failed
make[6]: *** [libgpiodcxx.la] Error 1
Signed-off-by: Ankur Tyagi <ankur.tyagi at gallagher.com>
---
package/libgpiod/libgpiod.mk | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/package/libgpiod/libgpiod.mk b/package/libgpiod/libgpiod.mk
index 35d003fa33..2161e68e62 100644
--- a/package/libgpiod/libgpiod.mk
+++ b/package/libgpiod/libgpiod.mk
@@ -41,4 +41,10 @@ else
LIBGPIOD_CONF_OPTS += --disable-bindings-python
endif
+ifeq ($(BR2_PIC_PIE),y)
+LIBGPIOD_CFLAGS += -fPIC
+LIBGPIOD_CXXFLAGS += -fPIC
+LIBGPIOD_CONF_OPTS += CFLAGS="$(LIBGPIOD_CFLAGS)" CXXFLAGS="$(LIBGPIOD_CXXFLAGS)"
+endif
+
$(eval $(autotools-package))
--
2.25.1
###########################################################################
This email is confidential and may contain information subject to legal
privilege. If you are not the intended recipient please advise us of our
error by return e-mail then delete this email and any attached files.
You may not copy, disclose or use the contents in any way.
The views expressed in this email may not be those of Gallagher Group
Ltd or subsidiary companies thereof.
###########################################################################
More information about the buildroot
mailing list