Repository navigation
Mark x86_64 assembly kernels as not needing an executable stack (fix import on glibc 2.41+) - #5041
Open
glenn-jocher wants to merge 1 commit into
Open
glenn-jocher wants to merge 1 commit into
glenn-jocher wants to merge 1 commit into
Conversation
The x86_64 .S kernels lack a .note.GNU-stack section, so ld marks the Python extension modules (_mnncengine, _tools) and libMNN as requiring an executable stack. glibc 2.41+ refuses to load such libraries ("cannot enable executable stack as shared object requires: Invalid argument"), which breaks import MNN on Ubuntu 25.04+/26.04, Debian 13, Fedora 42+ and Arch. Every x86 kernel includes this header, so declaring the note here fixes all of them. Fixes alibaba#3390.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3390.
Problem
On Linux with glibc 2.41+ (Ubuntu 25.04+/26.04 LTS, Debian 13, Fedora 42+, Arch),
import MNNfails with the published x86_64 wheels:All MNN 3.6.1
manylinux2014_x86_64wheels (cp311–cp314) mark_mnncengineand_toolsasRWEinPT_GNU_STACK. The aarch64 wheels areRWand load fine.Cause
The x86_64 assembly kernels in
source/backend/cpu/x86_x64/**/*.Shave no.note.GNU-stacksection, so GNU ld assumes they need an executable stack and marks every library linking them that way. The kernels never execute code on the stack. glibc 2.41 stopped allowingdlopenof such libraries.Fix
All 13 x86_64
.Sfiles includesource/backend/cpu/x86_x64/MNNAsmGlobal.h, so declaring the note once there (for ELF targets only) covers every kernel:Validation
quay.io/pypa/manylinux2014_x86_64toolchain (GCC 10.2.1, ld 2.35):_AVX_MNNGemmFloatUnitMainFMA.Slinked into a shared object givesGNU_STACK RWEbefore,RWafter.build_deps.py,setup.py bdist_wheelandauditwheel repair(cp314):_mnncengineand_toolsare bothRW.ubuntu:26.04container (glibc 2.43, Python 3.14.4):import MNNandfrom MNN.tools import mnnconvertsucceed, where the PyPI 3.6.1 wheel fails as above.