Skip to content
Snippets Groups Projects

modules: fix multiple definitions build failure

Closed orbea requested to merge orbea/vlc:libcompat into master
1 unresolved thread

Disclaimer: I tested this against commit fd1444e8 to avoid issue #28526 (closed).

With slibtool the build fails with multiple definitions of strnstr because libcompat.la is being overlinked. GNU libtool is more forgiving in this regard and silently hides the issue, but it can be easily solved by removing libcompat.la from a few Makefile.am files.

This issue was reported to the Slibtool issue tracker. https://dev.midipix.org/cross/slibtool/issue/56

rdlibtool --tag=CC --mode=link x86_64-gentoo-linux-musl-gcc -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -fno-strict-aliasing -pthread -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wduplicated-branches -Wduplicated-cond -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -Wmultistatement-macros -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-9999/work/vlc-9999/modules"}.
rdlibtool: lconf: fstatat(AT_FDCWD,".",...) = 0 {.st_dev = 65026, .st_ino = 202103912}.
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 = 67110689}.
rdlibtool: lconf: openat(3,"libtool",O_RDONLY,0) = 4.
rdlibtool: lconf: found "/var/tmp/portage/media-video/vlc-9999/work/vlc-9999/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 -pthread -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat -Wformat-security -Wduplicated-branches -Wduplicated-cond -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -Wmultistatement-macros -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.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Thanks

    Thanks for your contribution!

    When all of the following conditions are fulfilled, your MergeRequest will be reviewed by the Team:

    • the check pipeline passes
    • the MR is considered as 'mergeable' by gitlab

    You can find more details about the acceptance process here.

    This message was automatically generated by homer-bot.

17 17 access/http/chunked.c access/http/tunnel.c access/http/conn.h \
18 18 access/http/connmgr.c access/http/connmgr.h
19 19 libvlc_http_la_CPPFLAGS = -Dneedsomethinghere
20 libvlc_http_la_LIBADD = $(LTLIBVLCCORE) ../compat/libcompat.la $(SOCKET_LIBS)
20 libvlc_http_la_LIBADD = $(LTLIBVLCCORE) $(SOCKET_LIBS)
  • libvlc_http depends on libcompat, e.g. for gmtime_r. This change seems plain wrong to me.

    This might not be an issue on your system (I guess Linux) but that does not make the change right.

  • Author Contributor

    The problem is that libcompat.la is already part of libvlccore_la_LIBADD in src/Makefile.am so when linking using both $(LTLIBVLCCORE) and ../compat/libcompat.la there ends up multiple definitions from libcompat.la.

  • If a library depends on symbols from another library, it shall depend on it directly. Relying on transitive dependencies or on dependencies of reverse dependencies is well known to be problematic not to say wrong.

    I fail to see a problem here, except your build tool being buggy.

  • Author Contributor

    I fail to see a problem here, except your build tool being buggy.

    Perhaps you are right, this was fixed in the slibtool main branch and will be fixed in the next slibtool release.

    What was happening is that GNU libtool adds -Wl,--whole-archive to only convenience libraries while slibtool was adding it to all .a files. This is now changed and slibtool should have the same behavior as GNU libtool in this regard, at least enough that vlc compiles.

    However investigating this in greater revealed commit 78d45cc1 which shows that libcompat.la was changed from noinst_ to pkglib_. If it were to be changed back then GNU libtool would reproduce the same issue as shown here, but that doesn't seem to have been the intent so I will close this MR now.

    Thank you very much for the quick responses and time!

  • Note: libtool does not always do what you would expect either in that case: https://lists.gnu.org/archive/html/libtool-patches/2021-04/msg00000.html. This works because libcompat.la is a libtool archive, but adding a static library instead would result in the static library being copied to the library archive and then linked as an object, which is equivalent to -Wl,--whole-archive.

    I agree that we should keep libcompat in libvlc_http.

    It's interesting to see where slibtool goes in VLC build, thanks for opening this!

  • Please register or sign in to reply
  • closed

  • Please register or sign in to reply
    Loading