diff --git a/duktape-link-m.patch b/duktape-link-m.patch
new file mode 100644
index 0000000..dd0a040
--- /dev/null
+++ b/duktape-link-m.patch
@@ -0,0 +1,18 @@
+Index: duktape-2.6.0/Makefile.sharedlibrary
+===================================================================
+--- duktape-2.6.0.orig/Makefile.sharedlibrary
++++ duktape-2.6.0/Makefile.sharedlibrary
+@@ -63,11 +63,11 @@ all: libduktape.$(SO_REALNAME_SUFFIX) li
+ 
+ libduktape.$(SO_REALNAME_SUFFIX):
+ 	$(CC) -shared -fPIC -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktape.$(SO_SONAME_SUFFIX) \
+-		-o $@ $(DUKTAPE_SRCDIR)/duktape.c
++		-o $@ $(DUKTAPE_SRCDIR)/duktape.c -lm
+ 
+ libduktaped.$(SO_REALNAME_SUFFIX):
+ 	$(CC) -shared -fPIC -g -Wall -Wextra -Os -Wl,$(LD_SONAME_ARG),libduktaped.$(SO_SONAME_SUFFIX) \
+-		-o $@ $(DUKTAPE_SRCDIR)/duktape.c
++		-o $@ $(DUKTAPE_SRCDIR)/duktape.c -lm
+ 
+ # Symlinks depend on platform conventions.
+ .PHONY: install
diff --git a/duktape.changes b/duktape.changes
index c32e75e..c92bb7b 100644
--- a/duktape.changes
+++ b/duktape.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Mon Nov 28 10:47:19 UTC 2022 - Marcus Meissner <meissner@suse.com>
+
+- duktape-link-m.patch: link against libm for sin() and related functions,
+  in case the compiler with -Os creates external references. bsc#1205805
+
 -------------------------------------------------------------------
 Fri Oct 30 15:03:19 UTC 2020 - Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
 
diff --git a/duktape.spec b/duktape.spec
index 0be6cf2..93c7fa7 100644
--- a/duktape.spec
+++ b/duktape.spec
@@ -1,7 +1,7 @@
 #
 # spec file for package duktape
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -26,6 +26,7 @@ Group:          Development/Libraries/C and C++
 URL:            https://duktape.org/
 Source0:        https://duktape.org/%{name}-%{version}.tar.xz
 Source1:        duktape.pc.in
+Patch0:         duktape-link-m.patch
 BuildRequires:  gcc
 BuildRequires:  pkgconfig
 
@@ -55,6 +56,7 @@ application that use %{name}.
 
 %prep
 %setup -q
+%patch0 -p1
 
 sed -e's|@prefix@|%{_prefix}|' \
     -e's|@libdir@|%{_lib}|' \