Skip to content

Commit fa96b13

Browse files
committed
cmake: force PIE executables + disable dynamic X11 on Linux wheels
This fixes the long-standing "invalid ELF header: RTLD_GLOBAL for idraw" error that occurred with PyPI Linux wheels. - Force CMAKE_POSITION_INDEPENDENT_CODE=ON for all executables. InterViews/idraw does dlopen(self, RTLD_GLOBAL|...), which modern glibc rejects for non-PIE (ET_EXEC) binaries. - Disable IV_ENABLE_X11_DYNAMIC on Linux wheels only (SKBUILD && UNIX && NOT APPLE). The dynamic X11 loading path (ivx11_dynam.cpp) was the actual trigger of the (null) error. macOS wheels and local builds are unaffected. No functional change for normal source builds or macOS.
1 parent bab66a6 commit fa96b13

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ project(
2121
LANGUAGES C CXX
2222
HOMEPAGE_URL "https://nrn.readthedocs.io/")
2323

24+
# =============================================================================
25+
# Fixes for Linux wheels
26+
# =============================================================================
27+
28+
# Force PIE for all executables (idraw, nrniv, etc.)
29+
# This was the root cause of the original "invalid ELF header: RTLD_GLOBAL" error.
30+
cmake_policy(SET CMP0083 NEW)
31+
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Force PIE for NEURON + InterViews" FORCE)
32+
33+
# Disable fragile dynamic X11 loading *only* for Linux wheels.
34+
# This was triggering the (null) RTLD_GLOBAL error.
35+
# macOS wheels and normal/local Linux builds keep the original default (ON).
36+
if(SKBUILD AND UNIX AND NOT APPLE)
37+
set(IV_ENABLE_X11_DYNAMIC OFF CACHE BOOL "Disable on Linux wheels" FORCE)
38+
endif()
39+
2440
# =============================================================================
2541
# CMake common project settings
2642
# =============================================================================

0 commit comments

Comments
 (0)