File bcc-bsc1183399-make-no-pie-optional.patch of Package bcc.18944
From 24eeae24265ae3143f398546b2958dd441bcd866 Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Fri, 12 Mar 2021 11:32:19 +0800
Subject: [PATCH] cmake: make "-no-pie" optional
The recent linux distros already support PIE so it shouldn't be a
problem to remove "-no-pie". To avoid issue#782, we make "-no-pie"
optional and enable it by default. For the distro with PIE luajit,
just add the following build option:
-DENABLE_NO_PIE=OFF
Then, bcc-lua will be built with PIE support.
Signed-off-by: Gary Lin <glin@suse.com>
---
CMakeLists.txt | 2 ++
cmake/FindCompilerFlag.cmake | 4 ++++
2 files changed, 6 insertions(+)
Index: bcc-0.12.0/CMakeLists.txt
===================================================================
--- bcc-0.12.0.orig/CMakeLists.txt
+++ bcc-0.12.0/CMakeLists.txt
@@ -15,6 +15,8 @@ if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
+option(ENABLE_NO_PIE "Build bcc-lua without PIE" ON)
+
include(cmake/GetGitRevisionDescription.cmake)
include(cmake/version.cmake)
include(CMakeDependentOption)
Index: bcc-0.12.0/cmake/FindCompilerFlag.cmake
===================================================================
--- bcc-0.12.0.orig/cmake/FindCompilerFlag.cmake
+++ bcc-0.12.0/cmake/FindCompilerFlag.cmake
@@ -1,6 +1,8 @@
# Copyright (c) 2017 Facebook, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
+if (ENABLE_NO_PIE)
+
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
set(COMPILER_NOPIE_FLAG "-nopie")
else()
@@ -16,6 +18,8 @@ else()
set(CMAKE_REQUIRED_FLAGS "${_backup_c_flags}")
endif()
+endif(ENABLE_NO_PIE)
+
# check whether reallocarray availability
# this is used to satisfy reallocarray usage under src/cc/libbpf/
CHECK_CXX_SOURCE_COMPILES(