| From 69805f9c8973a7a4d29297f8d50c29c88f981bee Mon Sep 17 00:00:00 2001 |
| From: Yi Zhao <yi.zhao@windriver.com> |
| Date: Mon, 17 Jul 2023 14:33:32 +0800 |
| Subject: [PATCH] Do not specify PIE flag explicitly |
| |
| For nodistro distro, packages are built without PIE because |
| security_flags.inc is not included by default. But in vsomeip, the PIE |
| flag is explicitly specified in CMAKE_CXX_FLAGS, which will cause |
| building with PIE even in nodistro, causing an error when linking the |
| googletest static library: |
| |
| TOPDIR/tmp-glibc/work/cortexa53-oe-linux/vsomeip/3.1.20.3-r0/recipe-sysroot-native/usr/bin/aarch64-oe-linux/../../libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/12.2.0/ld: |
| TOPDIR/tmp-glibc/work/cortexa53-oe-linux/vsomeip/3.1.20.3-r0/recipe-sysroot/usr/lib/libgtest.a(gtest-all.cc.o)(.text+0x4a90): |
| unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `_ZSt4cerr@@GLIBCXX_3.4' |
| |
| Remove PIE flag from CMAKE_CXX_FLAGS and only enable PIE flag by |
| including security_flags.inc. |
| |
| Upstream-Status: Inappropriate [embedded specific] |
| |
| Signed-off-by: Yi Zhao <yi.zhao@windriver.com> |
| --- |
| CMakeLists.txt | 4 ++-- |
| 1 file changed, 2 insertions(+), 2 deletions(-) |
| |
| diff --git a/CMakeLists.txt b/CMakeLists.txt |
| index f6c680d4..dce1e701 100644 |
| --- a/CMakeLists.txt |
| +++ b/CMakeLists.txt |
| @@ -60,12 +60,12 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| # This is only relevant for GCC and causes warnings on Clang |
| set(EXPORTSYMBOLS "-Wl,-export-dynamic -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exportmap.gcc") |
| - set(OS_CXX_FLAGS "${OS_CXX_FLAGS} -pie -Wl,-z,relro,-z,now") |
| + set(OS_CXX_FLAGS "${OS_CXX_FLAGS} -Wl,-z,relro,-z,now") |
| endif() |
| |
| set(NO_DEPRECATED "") |
| set(OPTIMIZE "") |
| - set(OS_CXX_FLAGS "${OS_CXX_FLAGS} -D_GLIBCXX_USE_NANOSLEEP -pthread -O -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wpedantic -Werror -fPIE") |
| + set(OS_CXX_FLAGS "${OS_CXX_FLAGS} -D_GLIBCXX_USE_NANOSLEEP -pthread -O -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector-strong -fasynchronous-unwind-tables -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wpedantic") |
| |
| # force all use of std::mutex and std::recursive_mutex to use runtime init |
| # instead of static initialization so mutexes can be hooked to enable PI as needed |
| -- |
| 2.25.1 |
| |