Skip to content

Fix idraw from PyPI wheel that fails with "invalid ELF header". - #3771

Open
nrnhines wants to merge 4 commits into
masterfrom
hines/nrn-PIE-idraw-fix
Open

Fix idraw from PyPI wheel that fails with "invalid ELF header".#3771
nrnhines wants to merge 4 commits into
masterfrom
hines/nrn-PIE-idraw-fix

Conversation

@nrnhines

Copy link
Copy Markdown
Member

Closes #3769
This fix forces CMAKE_POSITION_INDEPENDENT_CODE=ON for all executables.
Disables IV_ENABLE_X11_DYNAMIC on Linux wheels only

nrnhines added 4 commits May 14, 2026 19:22
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.
@nrnhines
nrnhines requested a review from ramcdougal May 15, 2026 19:47
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

✔️ f0bdff0 -> artifacts URL

@azure-pipelines

Copy link
Copy Markdown

✔️ f0bdff0 -> Azure artifacts URL

@codecov

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.34%. Comparing base (bab66a6) to head (f0bdff0).
⚠️ Report is 43 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3771   +/-   ##
=======================================
  Coverage   68.34%   68.34%           
=======================================
  Files         691      691           
  Lines      111110   111110           
=======================================
  Hits        75933    75933           
  Misses      35177    35177           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread CMakeLists.txt

# Force PIE for all executables (idraw, nrniv, etc.) This was the root cause of the original
# "invalid ELF header: RTLD_GLOBAL" error.
cmake_policy(SET CMP0083 NEW)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this implied by cmake_minimum_required(VERSION 3.19 FATAL_ERROR)? I think it's only 3.13 and earlier that use the old behavior?

Comment thread CMakeLists.txt
ON
CACHE BOOL "Force PIE for NEURON + InterViews" FORCE)

# Disable fragile dynamic X11 loading *only* for Linux wheels. This was triggering the (null)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way we could add a test for this, so we aren't bitten by it again?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so. I'll look into adding a readelf -h $NRNHOME/bin/idraw | grep Type that ought to return

$ readelf -h $NRNHOME/bin/idraw | grep Type
  Type:                              DYN (Position-Independent Executable file)

instead of

$ readelf -h $NRNHOME/bin/idraw | grep Type
  Type:                              EXEC (Executable file)

Ironically, I need to investigate this PR more thoroughly as, on the surface, 100% of the fix is the "Disable fragile dynamic X11 loading". (I.e. a wheel created by

$ bash packaging/python/build_wheels.bash linux 314

still shows

  Type:                              EXEC (Executable file)

wheras one created by

$ python3.14 -m build --wheel --no-isolation --outdir /tmp/testwheel   --config-setting=build.verbose=true

shows

  Type:                              DYN (Position-Independent Executable file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

idraw from PyPI wheel (v9.0.1) fails with “invalid ELF header: RTLD_GLOBAL” on Linux (non-PIE executable)

2 participants