On Thu, Feb 24, 2022 at 11:45:27PM +0000, Stuart Henderson wrote:
> Looks like there is some issue linking sdl2-ttf with new Mesa (new ports
> bulk on i386); not sure if it will affect other ports too or if it's
> just this.
>
> (for once ld.lld actually managed to complain about an undefined
> reference, we don't usually find these until it results in a runtime
> failure)
>
> Anyone have ideas?
>
> /usr/bin/libtool --tag=CC --mode=link cc -O2 -pipe
> -I/usr/X11R6/include/freetype2 -I/usr/local/include/SDL2 -I/usr/X11R6/include
> -D_REENTRANT -I/usr/X11R6/include -DHAVE_OPENGL -L/usr/local/lib -o glfont
> glfont.o libSDL2_ttf.la -L/usr/X11R6/lib -lGL -lm -L/usr/X11R6/lib
> -lfreetype -lz -L/usr/local/lib -L/usr/X11R6/lib -lSDL2
> libtool: link: cc -o .libs/glfont -pthread -O2 -pipe
> -I/usr/X11R6/include/freetype2 -I/usr/local/include/SDL2 -I/usr/X11R6/include
> -D_REENTRANT -I/usr/X11R6/include -DHAVE_OPENGL glfont.o -L.libs -lSDL2_ttf
> -lm -lfreetype -lz -lSDL2 -lsndio -lsamplerate -lX11 -lxcb -lXext -lXcursor
> -lXrender -lXfixes -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lusbhid -lGL
> -lexpat -lX11-xcb -lxcb-glx -lXau -lXdmcp -lxcb-dri2 -lxcb-shm -ldrm
> -lpthread -lxcb-dri3 -lxcb-xfixes -lxcb-present -lxcb-sync -lxshmfence
> -lglapi -Wl,-rpath-link,/usr/local/lib,-rpath-link,/usr/X11R6/lib
> ld: error: .libs/libGL.so.17.1: undefined reference to
> std::__1::basic_string<char, std::__1::char_traits<char>,
> std::__1::allocator<char> >::find(char, unsigned long) const
> [--no-allow-shlib-undefined]
> ld: error: .libs/libGL.so.17.1: undefined reference to operator new(unsigned
> long) [--no-allow-shlib-undefined]
> ld: error: .libs/libGL.so.17.1: undefined reference to operator delete(void*)
> [--no-allow-shlib-undefined]
> ld: error: .libs/libGL.so.17.1: undefined reference to
> std::__1::__basic_string_common<true>::__throw_length_error() const
> [--no-allow-shlib-undefined] ld: error: .libs/libGL.so.17.1: undefined
> reference to __gxx_personality_v0 [--no-allow-shlib-undefined]
> cc: error: linker command failed with exit code 1 (use -v to see
> invocation)Error while executing cc -o .libs/glfont -pthread -O2 -pipe
> -I/usr/X11R6/include/freetype2 -I/usr/local/include/SDL2 -I/usr/X11R6/include
> -D_REENTRANT -I/usr/X11R6/include -DHAVE_OPENGL glfont.o -L.libs -lSDL2_ttf
> -lm -lfreetype -lz -lSDL2 -lsndio -lsamplerate -lX11 -lxcb -lXext -lXcursor
> -lXrender -lXfixes -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lusbhid -lGL
> -lexpat -lX11-xcb -lxcb-glx -lXau -lXdmcp -lxcb-dri2 -lxcb-shm -ldrm
> -lpthread -lxcb-dri3 -lxcb-xfixes -lxcb-present -lxcb-sync -lxshmfence
> -lglapi -Wl,-rpath-link,/usr/local/lib,-rpath-link,/usr/X11R6/lib
> *** Error 2 in /pobj/sdl2-ttf-2.0.15/build-i386 (Makefile:519 'glfont')
These references come from u_printf.cpp in libmesa_util.a
Follow what the meson build does and use section removal
to avoid them.
Index: lib/mesa/mk/libEGL/Makefile
===================================================================
RCS file: /cvs/xenocara/lib/mesa/mk/libEGL/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- lib/mesa/mk/libEGL/Makefile 1 Aug 2021 01:52:49 -0000 1.4
+++ lib/mesa/mk/libEGL/Makefile 25 Feb 2022 05:29:37 -0000
@@ -41,6 +41,7 @@ CPPFLAGS+= -I${MESA_SRC}/src/egl/main \
LDADD+= -Wl,--as-needed -Wl,--allow-shlib-undefined -Wl,--start-group \
${.CURDIR}/../libmesa_util/${__objdir}/libmesa_util.a \
${.CURDIR}/../libmesa_format/${__objdir}/libmesa_format.a \
+ -Wl,--gc-sections \
-lz -lm \
-L${X11BASE}/lib -lX11-xcb -lX11 -lxcb -lxcb-xfixes
Index: lib/mesa/mk/libGL/Makefile
===================================================================
RCS file: /cvs/xenocara/lib/mesa/mk/libGL/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- lib/mesa/mk/libGL/Makefile 22 Jul 2021 11:10:09 -0000 1.3
+++ lib/mesa/mk/libGL/Makefile 25 Feb 2022 05:29:37 -0000
@@ -72,7 +72,8 @@ LDADD+= -L${.CURDIR}/../libglapi/${__obj
${.CURDIR}/../libglapi_static/${__objdir}/libglapi_static.a \
${.CURDIR}/../libloader/${__objdir}/libloader.a \
${.CURDIR}/../libxmlconfig/${__objdir}/libxmlconfig.a \
- ${.CURDIR}/../libmesa_util/${__objdir}/libmesa_util.a
+ ${.CURDIR}/../libmesa_util/${__objdir}/libmesa_util.a \
+ -Wl,--gc-sections
.if ${XENOCARA_BUILD_DRI3:L} == "yes"
LDADD+=
${.CURDIR}/../libloader_dri3_helper/${__objdir}/libloader_dri3_helper.a
Index: lib/mesa/mk/libgbm/Makefile
===================================================================
RCS file: /cvs/xenocara/lib/mesa/mk/libgbm/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- lib/mesa/mk/libgbm/Makefile 24 Feb 2022 02:29:48 -0000 1.4
+++ lib/mesa/mk/libgbm/Makefile 25 Feb 2022 05:29:37 -0000
@@ -24,6 +24,7 @@ LDADD+= -Wl,--as-needed -Wl,--start-grou
${.CURDIR}/../libmesa_util/${__objdir}/libmesa_util.a \
${.CURDIR}/../libmesa_format/${__objdir}/libmesa_format.a \
${.CURDIR}/../libxmlconfig/${__objdir}/libxmlconfig.a \
+ -Wl,--gc-sections \
-lz -lm -lexpat
.if ${XENOCARA_BUILD_DRI:L} == "yes"
Index: lib/mesa/mk/libmesa_util/Makefile
===================================================================
RCS file: /cvs/xenocara/lib/mesa/mk/libmesa_util/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- lib/mesa/mk/libmesa_util/Makefile 24 Feb 2022 02:29:49 -0000 1.3
+++ lib/mesa/mk/libmesa_util/Makefile 25 Feb 2022 05:29:37 -0000
@@ -65,7 +65,7 @@ SRCS+= format_srgb.c
.include "../Makefile.inc"
CFLAGS+= ${C_VIS_ARGS}
-CXXFLAGS+= ${CXX_VIS_ARGS}
+CXXFLAGS+= ${CXX_VIS_ARGS} -ffunction-sections -fdata-sections
CPPFLAGS+= -I${MESA_SRC}/src/util \
-I${MESA_SRC}/src/mesa \
-I${MESA_SRC}/src/gallium/include \