Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tools/bootgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ string(REPLACE "#include \"openssl/ms/applink.c\"" "" FILE_CONTENTS "${FILE_CONT
file(WRITE ${BOOTGEN_SOURCE}/main.cpp "${FILE_CONTENTS}")

add_library(bootgen-lib STATIC ${libsources})
# Force PIE/PIC explicitly rather than inheriting whatever the top-level
# project's global flags happen to be: bootgen has no dependency on
# MLIR/LLVM, but it's configured as part of the same CMake invocation, so it
# silently inherits global compiler/linker defaults set by
# find_package(MLIR)/include(HandleLLVMOptions) upstream. When those global
# defaults produce a non-PIE bootgen executable that still declares dynamic
# NEEDED libs and an RPATH, auditwheel repair's patchelf-based RPATH rewrite
# has been observed to corrupt the binary (jumps into the non-executable
# DYNAMIC segment at runtime -- SIGSEGV/SEGV_ACCERR before main() even
# runs). Pinning PIE here keeps bootgen's ELF layout the standard one
# patchelf actually exercises, independent of what MLIR/LLVM sets globally.
Comment thread
jgmelber marked this conversation as resolved.
Outdated
set_target_properties(bootgen-lib PROPERTIES POSITION_INDEPENDENT_CODE ON)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
set(bootgen_warning_ignores
-Wno-cast-qual
Expand Down Expand Up @@ -154,6 +166,7 @@ install(
DESTINATION include)

add_executable(bootgen ${BOOTGEN_SOURCE}/main.cpp)
set_target_properties(bootgen PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(bootgen PUBLIC ${BOOTGEN_SOURCE} ${OPENSSL_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/include)
target_compile_options(bootgen PRIVATE ${bootgen_warning_ignores})
Expand Down
Loading