Skip to content

Fix missing libm linkage for _core extension on Linux - #993

Merged
jcrist merged 2 commits into
msgspec:mainfrom
Siyet:971-fix-libm-linkage
Apr 8, 2026
Merged

jcrist merged 2 commits into
msgspec:mainfrom
Siyet:971-fix-libm-linkage

Conversation

@Siyet

@Siyet Siyet commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add explicit -lm linkage for the _core C extension on non-Windows platforms
  • Fixes undefined symbol errors (nextafter, fmod, lround) on aarch64 Linux systems where libm is not implicitly linked

Closes #971

Test plan

Built and verified with ldd on two environments:

Ubuntu 22.04 (WSL2, x86_64, gcc 11.4, Python 3.10):

libm linked?
Without fix No - only libc.so.6
With fix Yes - libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6

Ubuntu 24.04 (WSL2, x86_64, gcc 13.3, Python 3.12):

libm linked?
Without fix No - only libc.so.6
With fix Yes - libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6

Windows 11 (Python 3.12, AMD64):

Confirmed that -lm is not added on win32 - libraries list stays empty. libm is part of MSVC runtime, no explicit linkage needed.

  • CI passes on all platforms

Add explicit -lm linkage for the _core C extension on non-Windows
platforms. Fixes undefined symbol errors (nextafter, fmod, lround)
on aarch64 Linux systems where libm is not implicitly linked.

Closes #971
@Siyet

Siyet commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor Author

CI failures are unrelated to this change:

All build, test, and wheel jobs pass across all platforms.

@Siyet

Siyet commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Resolved in the community fork msgspec-arise: PR #9, released in v0.20.2.

@jcrist

jcrist commented Apr 8, 2026

Copy link
Copy Markdown
Member

Thanks!

@jcrist
jcrist merged commit 719a216 into msgspec:main Apr 8, 2026
20 checks passed
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.

Missing libm linkage for _core extension causes undefined symbol errors

2 participants