The genbc binary is using two yacc parsers defining yychar, yylval
and yynerrs in two places. Newer linkers start failing on it. Use
a config flag to disable this error.

Report and change to the Makefile.am by Jean-Marc Farinas 
<jmfarina...@gmail.com>

Fixes:
/usr/bin/ld: genbc-impl.o:(.bss+0xc): multiple definition of `yychar'; 
genbc-decl.o:(.bss+0x4c): first defined here
/usr/bin/ld: genbc-impl.o:(.bss+0x10): multiple definition of `yylval'; 
genbc-decl.o:(.bss+0x50): first defined here
/usr/bin/ld: genbc-impl.o:(.bss+0x18): multiple definition of `yynerrs'; 
genbc-decl.o:(.bss+0x58): first defined here
---
 ChangeLog                       |  5 ++++
 build-aux/ax_check_link_flag.m4 | 53 +++++++++++++++++++++++++++++++++
 configure.ac                    |  3 ++
 libgst/ChangeLog                |  4 +++
 libgst/Makefile.am              |  1 +
 5 files changed, 66 insertions(+)
 create mode 100644 build-aux/ax_check_link_flag.m4

diff --git a/ChangeLog b/ChangeLog
index 94c40a3b..0f1aac24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-03-16  Holger Hans Peter Freyther  <hol...@freyther.de>
+
+       * build-aux/ax_check_link_flag.m4: Add from the autoconf archive.
+       * configure.ac: Check whether the linker supports 
-allow-multiple-definition.
+
 2018-01-23  Mathias Laurin <mathias.laurin+github....@gmail.com>
 
        * doc/tutorial.texi: Fix typo in tutorial.
diff --git a/build-aux/ax_check_link_flag.m4 b/build-aux/ax_check_link_flag.m4
new file mode 100644
index 00000000..03a30ce4
--- /dev/null
+++ b/build-aux/ax_check_link_flag.m4
@@ -0,0 +1,53 @@
+# ===========================================================================
+#    https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], 
[EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the linker or gives an error.
+#   (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the linker's default flags
+#   when the check is done.  The check is thus made with the flags: "LDFLAGS
+#   EXTRA-FLAGS FLAG".  This can for example be used to force the linker to
+#   issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_LINK_IFELSE.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <gui...@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosm...@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 6
+
+AC_DEFUN([AX_CHECK_LINK_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
+AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
+  ax_check_save_flags=$LDFLAGS
+  LDFLAGS="$LDFLAGS $4 $1"
+  AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+    [AS_VAR_SET(CACHEVAR,[yes])],
+    [AS_VAR_SET(CACHEVAR,[no])])
+  LDFLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_LINK_FLAGS
diff --git a/configure.ac b/configure.ac
index 0bac23ef..5272e9f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -312,6 +312,9 @@ case "$host_os:$WINDRES" in
 esac
 AC_SUBST(ICON)
 
+AX_CHECK_LINK_FLAG([-Wl,-allow-multiple-definition], 
[LD_ALLOW_MULTIPLE="-Wl,-allow-multiple-definition"])
+AC_SUBST(LD_ALLOW_MULTIPLE)
+
 dnl 
 dnl ------------------------------- C LIBRARY -----------------
 
diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index 9dece1d9..5924705a 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,7 @@
+2024-03-16  Holger Hans Peter Freyther  <hol...@freyther.de>
+
+       * Makefile.am: Use -Wl,-allow-multiple-definition when available. 
Needed for new linkers.
+
 2023-10-29  Holger Hans Peter Freyther  <hol...@freyther.de>
 
        * sysdep/common/files.c: Add NULL checks to _gst_file_is_readable,
diff --git a/libgst/Makefile.am b/libgst/Makefile.am
index 8841ea4c..df582139 100644
--- a/libgst/Makefile.am
+++ b/libgst/Makefile.am
@@ -51,6 +51,7 @@ genbc_SOURCES = \
        genbc-decl.y genbc-impl.y genbc-scan.l genbc.c
 
 genbc_LDADD = @LIBSNPRINTFV@ $(top_builddir)/lib-src/library.la
+genbc_LDFLAGS = @LD_ALLOW_MULTIPLE@
 
 # definitions for genvm
 
-- 
2.39.3 (Apple Git-146)


Reply via email to