[PATCH] liblua: link shared library against libm to fix undefined sinh on glibc

63 views
Skip to first unread message

Mabrooka “Yosr” Ben Belgacem

unread,
Feb 12, 2026, 5:27:26 AM (8 days ago) Feb 12
to lua-l
Hello Lua maintainers,

While running unit tests in a glibc-based environment, I encountered a runtime
issue when loading the shared library liblua.so.5.1.5:

     Failed to load lib /lib/liblua.so.5.1.5: undefined symbol: sinh

This happens because liblua.so is under-linked: it does not explicitly declare
libm.so
as a dependency in its DT_NEEDED entries.
On glibc-based systems, standard math functions like sinh, cos, etc.,
are provided by libm, which is a separate shared library.
Without declaring libm as a dependency, loading liblua.so directly will fail
unless the consumer explicitly links against -lm, which incorrectly shifts
responsibility for resolving these symbols from the library itself to its users.

Linking -lm in downstream applications or test binaries masks the issue but is not a proper solution: the shared library itself should declare all libraries required to resolve its
own symbols.


Proposed Fix:

Update the shared library link stage for liblua.so to explicitly link against libm (-lm).
This ensures that:

1. All direct dependencies of liblua are correctly declared.
2. liblua.so can be safely loaded on glibc-based systems without requiring consumers
   to add -lm.

This change has been verified on a glibc system and resolves the undefined 'sinh' symbol.

Patch:

---
diff --git a/Makefile b/Makefile
index 7fea77e5b1..14aa34ba52 100644
--- a/Makefile
+++ b/Makefile
@@ -94,6 +94,7 @@ define Build/Configure
 TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
+TARGET_LDFLAGS += -lm
---

Signed-off-by: Mabrouka <mabrouka.ben...@softathome.com>

Luiz Henrique de Figueiredo

unread,
Feb 12, 2026, 5:32:11 AM (8 days ago) Feb 12
to lu...@googlegroups.com
> While running unit tests in a glibc-based environment, I encountered a runtime
> issue when loading the shared library liblua.so.5.1.5:
>
> Failed to load lib /lib/liblua.so.5.1.5: undefined symbol: sinh

The standard Lua distribution from lua.org does not build shared libraries.
You probably need to report this downstream.
Reply all
Reply to author
Forward
0 new messages