ImportError: dynamic module does not define module export function
Open
Nobody has claimed this yet.
bug
topic-mypyc
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
When mypy is built with mold linker and LTO (both are necessary i.e. no error with mold + no LTO or bfd + LTO), mypy fails with ImportError: dynamic module does not define module export function.
To Reproduce
Run mypy.
Expected Behavior
No ImportError
Actual Behavior
Traceback (most recent call last):
File "/usr/lib/python-exec/python3.13/mypy", line 5, in <module>
from mypy.__main__ import console_entry
ImportError: dynamic module does not define module export function (PyInit_edfc647aaf02b20aa651__mypyc)
Your Environment
- Mypy version used: 1.17.0
- Mypy command-line flags: The error occurs regardless of flags.
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.13.5
- System: Gentoo
emerge --info dev-python/mypy:
dev-python/mypy-1.17.0::gentoo was built with the following:
USE="debug native-extensions -test" PYTHON_TARGETS="python3_13 -python3_11 -python3_12"
CFLAGS="-march=native -flto=auto -Og -ggdb -pipe -Wl,-O1 -Wl,--as-needed -fuse-ld=mold"
CXXFLAGS="-march=native -flto=auto -Og -ggdb -pipe -Wl,-O1 -Wl,--as-needed -fuse-ld=mold"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks export-pms-vars fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news nostrip parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -fuse-ld=mold -march=native -flto=auto -Og -ggdb -pipe"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing mypy with Python 3.13.5, mold, and LTO using the reported Gentoo build flags. Trace how the native extension is built and linked; done means mypy starts without the reported ImportError under mold and LTO.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100