Skip to content

Commit db8ecc2

Browse files
authored
Add explicit libm linkage to fix undefined symbol errors (#1305)
When building asyncpg on certain platforms (e.g., Amazon Linux 2023 with Clang 20), the C extensions fail to load at runtime with errors like "undefined symbol: log10". This happens because the extensions use math functions from libm but don't explicitly link against it. On some toolchains, libm is not implicitly linked, causing runtime symbol resolution failures even though compilation succeeds. This fix adds `-lm` to LDFLAGS on non-Windows systems to ensure proper linkage with the math library. Fixes #1297
1 parent 9b2b027 commit db8ecc2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
if platform.uname().system != 'Windows':
3434
CFLAGS.extend(['-fsigned-char', '-Wall', '-Wsign-compare', '-Wconversion'])
35+
# Link against libm (math library) for functions like log10()
36+
LDFLAGS.extend(['-lm'])
3537

3638

3739
_ROOT = pathlib.Path(__file__).parent

0 commit comments

Comments
 (0)