[RFC] libga68: Add symbol versions to exports

Pietro Monteiro pietro@sociotechnical.xyz
Sat Dec 27 03:02:12 GMT 2025


I did it pretty much the same way other gcc libs do.
I added all functions used in gcc/algol68/a68-low-runtime.def to the global map.
-- >8 --
libga68/ChangeLog:

	* configure.ac: New test to determine if symbol versioning is
	supported.
	* Makefile.am: Use result of above test to add appropriate linker
	flags.
	* Makefile.in: Regenerated.
	* configure: Likewise.
	* ga68.map: New file.
	* libtool-version: New file.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
---
 libga68/Makefile.am     |  27 +++++++-
 libga68/Makefile.in     |  20 ++++--
 libga68/configure       | 134 ++++++++++++++++++++++++++++++++++++++--
 libga68/configure.ac    |  50 +++++++++++++--
 libga68/ga68.map        |  41 ++++++++++++
 libga68/libtool-version |   6 ++
 6 files changed, 262 insertions(+), 16 deletions(-)
 create mode 100644 libga68/ga68.map
 create mode 100644 libga68/libtool-version

diff --git a/libga68/Makefile.am b/libga68/Makefile.am
index accdd910d8d..16917554da7 100644
--- a/libga68/Makefile.am
+++ b/libga68/Makefile.am
@@ -44,6 +44,27 @@ endif
 
 A68_BUILDDIR := $(shell pwd)
 
+if LIBGA68_USE_SYMVER
+if LIBGA68_USE_SYMVER_GNU
+version_arg = -Wl,--version-script=$(srcdir)/ga68.map
+version_dep = $(srcdir)/ga68.map
+endif
+if LIBGA68_USE_SYMVER_SUN
+version_arg = -Wl,-M,ga68.map-sun
+version_dep = ga68.map-sun
+ga68.map-sun : $(srcdir)/ga68.map \
+		$(top_srcdir)/../contrib/make_sunver.pl \
+		$(libga68_la_OBJECTS) $(libga68_la_LIBADD)
+	perl $(top_srcdir)/../contrib/make_sunver.pl \
+	  $(srcdir)/ga68.map \
+	  $(libga68_la_OBJECTS) $(libga68_la_LIBADD) \
+	> $@ || (rm -f $@ ; exit 1)
+endif
+else
+version_arg =
+version_dep =
+endif
+
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
 # values defined in terms of make variables, as is the case for CC and
 # friends when we are called from the top level Makefile.
@@ -111,9 +132,9 @@ libga68_la_SOURCES = libga68.c \
                      ga68.h
 libga68_la_LIBTOOLFLAGS =
 libga68_la_CFLAGS = $(LIBGA68_GCFLAGS) $(LIBGA68_BOEHM_GC_INCLUDES)
-libga68_la_LDFLAGS = -version-info $(libga68_VERSION) \
-    $(extra_darwin_ldflags_libga68)
-libga68_la_DEPENDENCIES = libga68.spec
+libga68_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
+		     $(version_arg) $(lt_host_flags) $(extra_darwin_ldflags_libga68)
+libga68_la_DEPENDENCIES = libga68.spec $(version_dep)
 libga68_la_LIBADD = $(LIBGA68_BOEHM_GC_LIBS)
 
 # target overrides
diff --git a/libga68/Makefile.in b/libga68/Makefile.in
index efba8b8ee11..24f5ed6b4d9 100644
--- a/libga68/Makefile.in
+++ b/libga68/Makefile.in
@@ -357,7 +357,6 @@ infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
-libga68_VERSION = @libga68_VERSION@
 localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
@@ -395,6 +394,12 @@ GCC_DIR = $(TOP_GCCDIR)/gcc
 A68_SRC = $(GCC_DIR)/algol68
 A68_FOR_TARGET = @A68_FOR_TARGET@
 A68_BUILDDIR := $(shell pwd)
+@LIBGA68_USE_SYMVER_FALSE@version_arg = 
+@LIBGA68_USE_SYMVER_GNU_TRUE@@LIBGA68_USE_SYMVER_TRUE@version_arg = -Wl,--version-script=$(srcdir)/ga68.map
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@version_arg = -Wl,-M,ga68.map-sun
+@LIBGA68_USE_SYMVER_FALSE@version_dep = 
+@LIBGA68_USE_SYMVER_GNU_TRUE@@LIBGA68_USE_SYMVER_TRUE@version_dep = $(srcdir)/ga68.map
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@version_dep = ga68.map-sun
 
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
 # values defined in terms of make variables, as is the case for CC and
@@ -462,10 +467,10 @@ libga68_la_SOURCES = libga68.c \
 
 libga68_la_LIBTOOLFLAGS = 
 libga68_la_CFLAGS = $(LIBGA68_GCFLAGS) $(LIBGA68_BOEHM_GC_INCLUDES)
-libga68_la_LDFLAGS = -version-info $(libga68_VERSION) \
-    $(extra_darwin_ldflags_libga68)
+libga68_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
+		     $(version_arg) $(lt_host_flags) $(extra_darwin_ldflags_libga68)
 
-libga68_la_DEPENDENCIES = libga68.spec
+libga68_la_DEPENDENCIES = libga68.spec $(version_dep)
 libga68_la_LIBADD = $(LIBGA68_BOEHM_GC_LIBS)
 MULTISRCTOP = 
 MULTIBUILDTOP = 
@@ -868,6 +873,13 @@ uninstall-am: uninstall-toolexeclibDATA \
 
 .PRECIOUS: Makefile
 
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@ga68.map-sun : $(srcdir)/ga68.map \
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@		$(top_srcdir)/../contrib/make_sunver.pl \
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@		$(libga68_la_OBJECTS) $(libga68_la_LIBADD)
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@	perl $(top_srcdir)/../contrib/make_sunver.pl \
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@	  $(srcdir)/ga68.map \
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@	  $(libga68_la_OBJECTS) $(libga68_la_LIBADD) \
+@LIBGA68_USE_SYMVER_SUN_TRUE@@LIBGA68_USE_SYMVER_TRUE@	> $@ || (rm -f $@ ; exit 1)
 
 # target overrides
 -include $(tmake_file)
diff --git a/libga68/configure b/libga68/configure
index b0a1302c881..c5408339f93 100755
--- a/libga68/configure
+++ b/libga68/configure
@@ -638,7 +638,12 @@ LIBGA68_BOEHM_GC_LIBS
 LIBGA68_BOEHM_GC_INCLUDES
 LIBGA68_GCFLAGS
 extra_darwin_ldflags_libga68
-libga68_VERSION
+LIBGA68_USE_SYMVER_SUN_FALSE
+LIBGA68_USE_SYMVER_SUN_TRUE
+LIBGA68_USE_SYMVER_GNU_FALSE
+LIBGA68_USE_SYMVER_GNU_TRUE
+LIBGA68_USE_SYMVER_FALSE
+LIBGA68_USE_SYMVER_TRUE
 SPEC_LIBGA68_DEPS
 get_gcc_base_ver
 CC_FOR_BUILD
@@ -798,6 +803,7 @@ with_gnu_ld
 enable_libtool_lock
 enable_darwin_at_rpath
 with_gcc_major_version_only
+enable_symvers
 enable_algol68_gc
 with_target_bdw_gc
 with_target_bdw_gc_include
@@ -1451,6 +1457,7 @@ Optional Features:
   --enable-darwin-at-rpath
                           install libraries with @rpath/library-name, requires
                           rpaths to be added to executables
+  --disable-symvers       disable symbol versioning for libga68
   --enable-algol68-gc     enable use of Boehm's garbage collector with the GNU
                           Algol runtime
 
@@ -12578,7 +12585,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12581 "configure"
+#line 12588 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12684,7 +12691,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12687 "configure"
+#line 12694 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13085,8 +13092,113 @@ fi
 SPEC_LIBGA68_DEPS="$LIBS"
 
 
-# libga68 soname version
-libga68_VERSION=2:0:0
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether symbol versioning is supported" >&5
+$as_echo_n "checking whether symbol versioning is supported... " >&6; }
+# Check whether --enable-symvers was given.
+if test "${enable_symvers+set}" = set; then :
+  enableval=$enable_symvers; ga68_use_symver=$enableval
+else
+  ga68_use_symver=yes
+fi
+
+if test "x$ga68_use_symver" != xno; then
+  if test x$gcc_no_link = xyes; then
+    # If we cannot link, we cannot build shared libraries, so do not use
+    # symbol versioning.
+    ga68_use_symver=no
+  else
+    save_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
+    cat > conftest.map <<EOF
+FOO_1.0 {
+  global: *foo*; bar; local: *;
+};
+EOF
+    if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo;
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ga68_use_symver=gnu
+else
+  ga68_use_symver=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    if test x$ga68_use_symver = xno; then
+      case "$target_os" in
+        solaris2*)
+          LDFLAGS="$save_LDFLAGS"
+          LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
+          # Sun ld cannot handle wildcards and treats all entries as undefined.
+          cat > conftest.map <<EOF
+FOO_1.0 {
+  global: foo; local: *;
+};
+EOF
+          if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo;
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ga68_use_symver=sun
+else
+  ga68_use_symver=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+	  ;;
+      esac
+    fi
+    LDFLAGS="$save_LDFLAGS"
+  fi
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ga68_use_symver" >&5
+$as_echo "$ga68_use_symver" >&6; }
+ if test "x$ga68_use_symver" != xno; then
+  LIBGA68_USE_SYMVER_TRUE=
+  LIBGA68_USE_SYMVER_FALSE='#'
+else
+  LIBGA68_USE_SYMVER_TRUE='#'
+  LIBGA68_USE_SYMVER_FALSE=
+fi
+
+ if test "x$ga68_use_symver" = xgnu; then
+  LIBGA68_USE_SYMVER_GNU_TRUE=
+  LIBGA68_USE_SYMVER_GNU_FALSE='#'
+else
+  LIBGA68_USE_SYMVER_GNU_TRUE='#'
+  LIBGA68_USE_SYMVER_GNU_FALSE=
+fi
+
+ if test "x$ga68_use_symver" = xsun; then
+  LIBGA68_USE_SYMVER_SUN_TRUE=
+  LIBGA68_USE_SYMVER_SUN_FALSE='#'
+else
+  LIBGA68_USE_SYMVER_SUN_TRUE='#'
+  LIBGA68_USE_SYMVER_SUN_FALSE=
+fi
 
 
 # The Boehm GC
@@ -13462,6 +13574,18 @@ if test -z "${ENABLE_DARWIN_AT_RPATH_TRUE}" && test -z "${ENABLE_DARWIN_AT_RPATH
   as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${LIBGA68_USE_SYMVER_TRUE}" && test -z "${LIBGA68_USE_SYMVER_FALSE}"; then
+  as_fn_error $? "conditional \"LIBGA68_USE_SYMVER\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${LIBGA68_USE_SYMVER_GNU_TRUE}" && test -z "${LIBGA68_USE_SYMVER_GNU_FALSE}"; then
+  as_fn_error $? "conditional \"LIBGA68_USE_SYMVER_GNU\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${LIBGA68_USE_SYMVER_SUN_TRUE}" && test -z "${LIBGA68_USE_SYMVER_SUN_FALSE}"; then
+  as_fn_error $? "conditional \"LIBGA68_USE_SYMVER_SUN\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
diff --git a/libga68/configure.ac b/libga68/configure.ac
index 56ef197e5f4..5812ce70888 100644
--- a/libga68/configure.ac
+++ b/libga68/configure.ac
@@ -162,7 +162,7 @@ AC_SUBST(enable_shared)
 AC_SUBST(enable_static)
 
 # Do compilation tests using the C compiler and preprocessor.
-AC_LANG_C([C])
+AC_LANG([C])
 
 # Allow the user to set CC_FOR_BUILD in the environment.
 CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
@@ -179,9 +179,51 @@ GCC_BASE_VER
 SPEC_LIBGA68_DEPS="$LIBS"
 AC_SUBST(SPEC_LIBGA68_DEPS)
 
-# libga68 soname version
-libga68_VERSION=2:0:0
-AC_SUBST(libga68_VERSION)
+AC_MSG_CHECKING([whether symbol versioning is supported])
+AC_ARG_ENABLE(symvers,
+AS_HELP_STRING([--disable-symvers],
+  [disable symbol versioning for libga68]),
+ga68_use_symver=$enableval,
+ga68_use_symver=yes)
+if test "x$ga68_use_symver" != xno; then
+  if test x$gcc_no_link = xyes; then
+    # If we cannot link, we cannot build shared libraries, so do not use
+    # symbol versioning.
+    ga68_use_symver=no
+  else
+    save_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
+    cat > conftest.map <<EOF
+FOO_1.0 {
+  global: *foo*; bar; local: *;
+};
+EOF
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foo;]], [[]])],
+		   [ga68_use_symver=gnu],[ga68_use_symver=no])
+    if test x$ga68_use_symver = xno; then
+      case "$target_os" in
+        solaris2*)
+          LDFLAGS="$save_LDFLAGS"
+          LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
+          # Sun ld cannot handle wildcards and treats all entries as undefined.
+          cat > conftest.map <<EOF
+FOO_1.0 {
+  global: foo; local: *;
+};
+EOF
+          AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foo;]], [[]])],
+			 [ga68_use_symver=sun],[ga68_use_symver=no])
+	  ;;
+      esac
+    fi
+    LDFLAGS="$save_LDFLAGS"
+  fi
+fi
+
+AC_MSG_RESULT($ga68_use_symver)
+AM_CONDITIONAL(LIBGA68_USE_SYMVER, [test "x$ga68_use_symver" != xno])
+AM_CONDITIONAL(LIBGA68_USE_SYMVER_GNU, [test "x$ga68_use_symver" = xgnu])
+AM_CONDITIONAL(LIBGA68_USE_SYMVER_SUN, [test "x$ga68_use_symver" = xsun])
 
 # The Boehm GC
 
diff --git a/libga68/ga68.map b/libga68/ga68.map
new file mode 100644
index 00000000000..d1641e230c3
--- /dev/null
+++ b/libga68/ga68.map
@@ -0,0 +1,41 @@
+LIBGA68_1.0 {
+  global:
+    _libga68_assert;
+    _libga68_bitsboundserror;
+    _libga68_bounds;
+    _libga68_bounds_mismatch;
+    _libga68_derefnil;
+    _libga68_dim;
+    _libga68_invalidcharerror;
+    _libga68_longlongrandom;
+    _libga68_longrandom;
+    _libga68_lower_bound;
+    _libga68_malloc;
+    _libga68_posixargc;
+    _libga68_posixargv;
+    _libga68_posixclose;
+    _libga68_posixcreat;
+    _libga68_posixerrno;
+    _libga68_posixfconnect;
+    _libga68_posixfgetc;
+    _libga68_posixfgets;
+    _libga68_posixfopen;
+    _libga68_posixfputc;
+    _libga68_posixfputs;
+    _libga68_posixfsize;
+    _libga68_posixgetchar;
+    _libga68_posixgetenv;
+    _libga68_posixgets;
+    _libga68_posixlseek;
+    _libga68_posixperror;
+    _libga68_posixputchar;
+    _libga68_posixputs;
+    _libga68_posixstrerror;
+    _libga68_random;
+    _libga68_set_exit_status;
+    _libga68_u32_cmp2;
+    _libga68_unreachable;
+    _libga68_upper_bound;
+  local:
+    *;
+};
diff --git a/libga68/libtool-version b/libga68/libtool-version
new file mode 100644
index 00000000000..1b1da6a4a41
--- /dev/null
+++ b/libga68/libtool-version
@@ -0,0 +1,6 @@
+# This file is used to maintain libtool version info for libga68.
+# See the libtool manual to understand the meaning of the fields.
+# This is a separate file so that version updates don't involve re-running
+# automake.
+# CURRENT:REVISION:AGE
+2:0:0

base-commit: d53956a04837e468534e7ef89b5bee2fbc2cea8c
-- 
2.43.0



More information about the Algol68 mailing list