Bug#907207: phlipple: build compatibility with -Wl,--as-needed

Steve Langasek steve.langasek at canonical.com
Fri Aug 24 19:01:53 BST 2018


Package: phlipple
Version: 0.8.5-3
Severity: minor
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu cosmic ubuntu-patch

Dear maintainers,

The phlipple package is failing to build in Ubuntu, because the linker is
failing to find symbols from libm:

[...]
gcc -Wall -g -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security  -Wl,-Bsymbolic-functions -Wl,-z,relro -lm -o phlipple camera.o engine.o game.o gfxconstants.o gradientrenderer.o interpolator.o levels.o main.o mainscreen.o osinterface_sdl.o phlipplerootscene.o quad.o quadrenderer.o scenes.o settings.o textrenderer.o texture.o vertex.o -lSDL -lvorbisfile -lGLEW -lGLU -lGL   -lGLU -lGL -lSDL_mixer -lSDL_image
/usr/bin/ld: engine.o: undefined reference to symbol 'sin@@GLIBC_2.2.5'
/usr/bin/ld: //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:392: phlipple] Error 1
[...]

 (https://launchpad.net/ubuntu/+source/phlipple/0.8.5-3)

I see you have already tried to handle the lack of -lm in the upstream
Makefile by adding it to LDFLAGS in debian/rules.  However, using LDFLAGS
for this doesn't work on Ubuntu because Ubuntu's toolchain uses
-Wl,--as-needed by default, which means that libraries must be listed
/after/ the objects which reference them, or else the linker will discard
them from the final binary as unused.

  https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-Wl.2C--as-needed

Please consider the attached patch as a solution that works for both Debian
and Ubuntu.  It probably needs further enhancement to be suitable for
upstream, since there are non-glibc platforms that don't have libm as a
separate library.

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slangasek at ubuntu.com                                     vorlon at debian.org
-------------- next part --------------
diff -Nru phlipple-0.8.5/debian/patches/link-libm.patch phlipple-0.8.5/debian/patches/link-libm.patch
--- phlipple-0.8.5/debian/patches/link-libm.patch	1969-12-31 16:00:00.000000000 -0800
+++ phlipple-0.8.5/debian/patches/link-libm.patch	2018-08-24 10:33:31.000000000 -0700
@@ -0,0 +1,17 @@
+Description: Explicitly link against libm
+ phlipple requires sin() which is provided by libm.  Ensure that we link
+ to it, avoiding a build failure.  This won't work on platforms that don't
+ have a separate libm.
+Author: Steve Langasek <steve.langasek at ubuntu.com>
+Last-Modified: 2018-08-24
+
+Index: phlipple-0.8.5/src/Makefile.am
+===================================================================
+--- phlipple-0.8.5.orig/src/Makefile.am
++++ phlipple-0.8.5/src/Makefile.am
+@@ -48,4 +48,4 @@
+ 	
+ phlipple_LDFLAGS = 
+ 
+-phlipple_LDADD = $(PHLIPPLE_LIBS) $(GL_LIBS) 
++phlipple_LDADD = $(PHLIPPLE_LIBS) $(GL_LIBS) -lm
diff -Nru phlipple-0.8.5/debian/patches/series phlipple-0.8.5/debian/patches/series
--- phlipple-0.8.5/debian/patches/series	2018-05-20 14:40:34.000000000 -0700
+++ phlipple-0.8.5/debian/patches/series	2018-08-24 10:33:45.000000000 -0700
@@ -1,2 +1,3 @@
 support_us.patch
 desktop-file.patch
+link-libm.patch
diff -Nru phlipple-0.8.5/debian/rules phlipple-0.8.5/debian/rules
--- phlipple-0.8.5/debian/rules	2018-05-20 14:40:34.000000000 -0700
+++ phlipple-0.8.5/debian/rules	2018-08-24 10:16:28.000000000 -0700
@@ -2,7 +2,6 @@
 
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
-export DEB_LDFLAGS_MAINT_APPEND = -lm
 
 %:
 	dh $@


More information about the Pkg-games-devel mailing list