From c803ce5e8febc91cc3692cb3de34dbd4af77e291 Mon Sep 17 00:00:00 2001 From: Joseph Melber Date: Mon, 13 Jul 2026 11:19:31 -0600 Subject: [PATCH 1/2] Force PIE on bootgen to fix non-deterministic PDI-generation segfault bootgen has no dependency on MLIR/LLVM (it only links OpenSSL::SSL and its own bootgen-lib), but it's configured as part of the same CMake invocation as the rest of mlir-aie, so it silently inherits whatever global compiler/linker defaults find_package(MLIR)/ include(HandleLLVMOptions) set for that run. Building against the ROCm-built MLIR wheel (see the rocm-mlir-distro migration) flips bootgen from a PIE executable to a non-PIE one, while it still declares dynamic NEEDED libs and an RPATH. auditwheel repair's patchelf-based RPATH rewrite (needed to point at vendored/renamed OpenSSL libs) then corrupts that non-standard layout: the resulting binary SIGSEGVs (SEGV_ACCERR) jumping into its own non-executable DYNAMIC segment before main() even runs, on real Ryzen AI hardware, not just in a sandbox. This broke PDI/xclbin generation for nearly every programming_examples/*.lit test in https://github.com/Xilinx/mlir-aie/pull/3323. Pin POSITION_INDEPENDENT_CODE ON directly on bootgen-lib and bootgen so their ELF layout no longer depends on whatever the MLIR/LLVM package happens to set globally. Verified locally: before the fix, `bootgen -help` segfaults immediately (even under LD_TRACE_LOADED_OBJECTS=1, i.e. before bootgen's own code runs); after, it links as a normal PIE executable and runs correctly. Co-Authored-By: Claude Sonnet 5 --- tools/bootgen/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/bootgen/CMakeLists.txt b/tools/bootgen/CMakeLists.txt index 097aea0d159..a1798b1d1e1 100644 --- a/tools/bootgen/CMakeLists.txt +++ b/tools/bootgen/CMakeLists.txt @@ -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. +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 @@ -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}) From 2de0aab430d0849c9f463846cc2d7b25e66e88f5 Mon Sep 17 00:00:00 2001 From: Joseph Melber Date: Mon, 13 Jul 2026 11:34:12 -0600 Subject: [PATCH 2/2] Update tools/bootgen/CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Rösti --- tools/bootgen/CMakeLists.txt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tools/bootgen/CMakeLists.txt b/tools/bootgen/CMakeLists.txt index a1798b1d1e1..7e8040dbc3a 100644 --- a/tools/bootgen/CMakeLists.txt +++ b/tools/bootgen/CMakeLists.txt @@ -107,17 +107,9 @@ 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. +# bootgen must be compiled with PIE/PIC, irrespective of the remainder of +# the project, because auditwheel repair's patchelf-based RPATH rewrite +# corrupts the non-PIE binary set_target_properties(bootgen-lib PROPERTIES POSITION_INDEPENDENT_CODE ON) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") set(bootgen_warning_ignores