#56 multiply defined symbol building VLC3 on Linux
Closed 9 months ago by RJVB. Opened 9 months ago by RJVB.

I thought I'd try a VLC build on Linux for comparison in #54 (knowing that it'd be a newer version) but it turns out that build fails too, on a different task.

Still, #54 is relevant because of the interrogation over the use of --whole-archive I voiced there. The multiple definitions of the 2 symbols stem from the fact that the entire libcompat.a archive is included into libvlc_http.a and then both are included into libhttps_plugin.so :

> llvm-nm vlc-lnx-work/vlc-3.0.12/compat/.libs/libcompat.a | fgrep strlcpy
strlcpy.o:
---------------- T strlcpy
> llvm-nm vlc-lnx-work/vlc-3.0.12/modules/.libs/libvlc_http.a | fgrep strlcpy
strlcpy.o:
---------------- T strlcpy

The name of that target is ambiguous but it is clearly intended to be a plugin primarily. That means that neither static archive needs to be included "whole"; they just serve to provide whatever dependencies they can.
vlc3-build.log


I thought I'd try a VLC build on Linux for comparison in #54 (knowing that it'd be a newer version) but it turns out that build fails too, on a different task.

I'd like to try that myself on Linux. To be on the safe side, can you specify:
- the sha256 signautre of the vlc3 tarball.
- the ./configure command that you used.

Thanks!

On Gentoo with vlc-3.0.20 I see this:

rdlibtool --tag=CC --mode=link x86_64-gentoo-linux-musl-gcc -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -fno-strict-aliasing -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -fvisibility=hidden -avoid-version -module -export-symbols-regex ^vlc_entry -shrext .so -no-undefined ../compat/libcompat.la ../src/libvlccore.la -Wl,-O1 -Wl,--as-needed -L/usr/lib/sidplay/builders/ -Wl,-z,defs -o libhttps_plugin.la -rpath /usr/lib/vlc/plugins/access access/http/access.lo libvlc_http.la

rdlibtool: lconf: {.name="libtool"}.
rdlibtool: fdcwd: {.fdcwd=AT_FDCWD, .realpath="/var/tmp/portage/media-video/vlc-3.0.20-r3/work/vlc-3.0.20/modules"}.
rdlibtool: lconf: fstatat(AT_FDCWD,".",...) = 0 {.st_dev = 65026, .st_ino = 134810722}.
rdlibtool: lconf: openat(AT_FDCWD,"libtool",O_RDONLY,0) = -1 [ENOENT].
rdlibtool: lconf: openat(AT_FDCWD,"../",O_DIRECTORY,0) = 3.
rdlibtool: lconf: fstat(3,...) = 0 {.st_dev = 65026, .st_ino = 67110665}.
rdlibtool: lconf: openat(3,"libtool",O_RDONLY,0) = 4.
rdlibtool: lconf: found "/var/tmp/portage/media-video/vlc-3.0.20-r3/work/vlc-3.0.20/libtool".
rdlibtool: link: ln -s libhttps_plugin.so.def .libs/libhttps_plugin.so.def.linux
rdlibtool: link: ln -s libhttps_plugin.so.def.linux .libs/libhttps_plugin.so.def.host
rdlibtool: link: ln -s /dev/null .libs/libhttps_plugin.a.disabled
rdlibtool: link: ln -s libhttps_plugin.la .libs/libhttps_plugin.la.shrext.so
rdlibtool: link: ln -s libhttps_plugin.la.shrext.so .libs/libhttps_plugin.la.shrext
rdlibtool: link: ln -s /usr/lib/vlc/plugins/access .libs/libhttps_plugin.so.slibtool.rpath
rdlibtool: link: x86_64-gentoo-linux-musl-gcc -Wl,--whole-archive ../compat/.libs/libcompat.a -Wl,--no-whole-archive access/http/.libs/access.o -Wl,--whole-archive .libs/libvlc_http.a -Wl,--no-whole-archive -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -fno-strict-aliasing -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -fvisibility=hidden -L/usr/lib/sidplay/builders/ -lm -L../src/.libs -lvlccore -lm -lidn -lm -Wl,-O1 -Wl,--as-needed -Wl,-z,defs -L.libs -L./../src/.libs -lvlccore -shared -fPIC -Wl,--no-undefined -Wl,-soname -Wl,libhttps_plugin.so -o .libs/libhttps_plugin.so
/usr/lib/gcc/x86_64-gentoo-linux-musl/13/../../../../x86_64-gentoo-linux-musl/bin/ld: .libs/libvlc_http.a(strnstr.o): in function `strnstr':
strnstr.c:(.text+0x0): multiple definition of `strnstr'; ../compat/.libs/libcompat.a(strnstr.o):strnstr.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
rdlibtool: error logged in slbt_exec_link_create_library(), line 268: flow error: unexpected condition or other.
rdlibtool: < returned to > slbt_exec_link(), line 375.

This fixed the build on my end.

diff --git a/modules/access/http/Makefile.am b/modules/access/http/Makefile.am
index 8e6f041..6451516 100644
--- a/modules/access/http/Makefile.am
+++ b/modules/access/http/Makefile.am
@@ -16,7 +16,7 @@ libvlc_http_la_SOURCES = \
    access/http/connmgr.c access/http/connmgr.h
 libvlc_http_la_CPPFLAGS = -Dneedsomethinghere
 libvlc_http_la_LIBADD = \
-   $(LTLIBVLCCORE) ../compat/libcompat.la \
+   $(LTLIBVLCCORE) \
    $(SOCKET_LIBS) $(LIBPTHREAD)
 #libvlc_http_la_LDFLAGS = -no-undefined -export-symbols-regex ^vlc_http_
 #pkglib_LTLIBRARIES += libvlc_http.la

I think they are over linking libcompat.la.

I also confirmed my change doesn't break GNU libtool and a more extreme case of this issue can be seen here.

https://github.com/efficios/babeltrace/pull/119

I made an upstream MR https://code.videolan.org/videolan/vlc/-/merge_requests/4944.

With the VLC git master branch there is still one failure.

rlibtool --mode=compile --tag=ASM nasm -f elf64 -DARCH_X86_32=0 -DARCH_X86_64=1 -I../extras/include/x86/ video_filter/deinterlace/yadif_x86.asm -o video_filter/deinterlace/yadif_x86.lo
rlibtool: error: 'ASM' is not a valid option value for [--tag]={CC|CXX|FC|F77|NASM|RC|disable-static|disable-shared}

This can be easily solved for both upstream's doltlibtool and for slibtool with this patch.

--- a/m4/dolt.m4
+++ b/m4/dolt.m4
@@ -155,7 +155,7 @@ for arg in "$[]@"; do
     case "$arg" in
         --mode=compile) modeok=true ;;
         --tag=CC|--tag=CXX) tagok=true ;;
-        --tag=ASM|--tag=YASM) tagok=true; passthrough=true;;
+        --tag=ASM|--tag=NASM|--tag=YASM) tagok=true; passthrough=true;;
         --silent|--quiet) ;;
         *) args@<:@${#args[@]}@:>@="$arg" ;;
     esac
diff --git a/modules/common.am b/modules/common.am
index 938e67c..7ca127e 100644
--- a/modules/common.am
+++ b/modules/common.am
@@ -41,4 +41,4 @@ AM_YFLAGS = -d -Wno-yacc
 SUFFIXES = .l .y .asm

 .asm.lo:
-   $(LIBTOOL) --mode=compile --tag=ASM $(X86ASM) $(X86ASMFLAGS) $(X86ASMDEFS) -I$(top_srcdir)/extras/include/x86/ $< -o $@
+   $(LIBTOOL) --mode=compile --tag=NASM $(X86ASM) $(X86ASMFLAGS) $(X86ASMDEFS) -I$(top_srcdir)/extras/include/x86/ $< -o $@

It seems GNU libtool doesn't know either --tag=ASM or slibtool's --tag=NASM and I am unsure if slibtool should support the former too or its better to fix it in VLC. If fixed in VLC then older slibtool versions would work too.

Following several fixes and starting with commit 35000fa, VLC3 should successfully build on linux (and possibly also on darwin).

@RJVB VLC builds with the slibtool main branch on Gentoo now for me now, can you confirm on your end?

@RJVB VLC builds with the slibtool main branch on Gentoo now for me now, can you confirm on your end?

Yes, I can. It builds, and "destroots"! :)

(and possibly also on darwin).

I'll test that once the shared library glitches have been resolved!

I think they are over linking libcompat.la.

Of course you could argue that these compatibility functions can and should go into VLC's core library. We'll see how the videolan team reacts to your suggestion!

Closing this for now, I'll reopen if ever I run into runtime issues ;)

Metadata Update from @RJVB:
- Issue status updated to: Closed (was: Open)

9 months ago

Closing this for now, I'll reopen if ever I run into runtime issues ;)

There might be some concerns how they pass both -fvisibility=hidden and -export-symbols-regex where the latter is not supported in slibtool yet, but I believe it will be supported soon anyways.

Login to comment on this ticket.

Metadata
Attachments 1
Attached 9 months ago View Comment