Skip to content

Commit

Permalink
cmake: make "-no-pie" optional
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lcp authored and yonghong-song committed Mar 19, 2021
1 parent 327e4c7 commit 24eeae2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ endif()
# $ cmake -DKERNEL_INCLUDE_DIRS=/tmp/headers/include/ ...
include_directories(${KERNEL_INCLUDE_DIRS})

option(ENABLE_NO_PIE "Build bcc-lua without PIE" ON)

include(cmake/GetGitRevisionDescription.cmake)
include(cmake/version.cmake)
include(CMakeDependentOption)
Expand Down
4 changes: 4 additions & 0 deletions cmake/FindCompilerFlag.cmake
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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(
Expand Down

0 comments on commit 24eeae2

Please sign in to comment.