From 617ff014e98834197a1512c36e7c1647bf637dc5 Mon Sep 17 00:00:00 2001 From: Varun Chawla Date: Sat, 7 Feb 2026 23:10:00 -0800 Subject: [PATCH] Add explicit libm linkage to fix undefined symbol errors 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 --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index c2332822..f9fafadf 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,8 @@ if platform.uname().system != 'Windows': CFLAGS.extend(['-fsigned-char', '-Wall', '-Wsign-compare', '-Wconversion']) + # Link against libm (math library) for functions like log10() + LDFLAGS.extend(['-lm']) _ROOT = pathlib.Path(__file__).parent