]> git.draconx.ca Git - dxcommon.git/commitdiff
Add helper macro for libtool patches.
authorNick Bowler <nbowler@draconx.ca>
Thu, 29 Feb 2024 04:08:12 +0000 (23:08 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 29 Feb 2024 04:08:12 +0000 (23:08 -0500)
Monkey patch libtool to workaround a problem discovered when using the
VAX C compiler.  It seems that read-only static data initialized with
function pointers can lead to trouble with this compiler.

It is obviously not the only compiler with a problem like this, since
libtool already similar exceptions to avoid "const" on other systems,
we just need to add another case.

m4/lt-patches.m4 [new file with mode: 0644]

diff --git a/m4/lt-patches.m4 b/m4/lt-patches.m4
new file mode 100644 (file)
index 0000000..735633f
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright © 2024 Nick Bowler
+#
+# Monkey patches for libtool.
+#
+# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+# This is free software: you are free to do what the fuck you want to.
+# There is NO WARRANTY, to the extent permitted by law.
+
+# DX_PATCH_LIBTOOL
+#
+# Apply all the patches described below.  Should be expanded before LT_INIT.
+AC_DEFUN([DX_PATCH_LIBTOOL],
+[AC_BEFORE([$0], [LT_INIT])dnl
+m4_foreach_w([patch], m4_defn([_DX_LT_PATCHES]),
+  [m4_indir([_DX_LT_PATCH(]m4_defn([patch])[)])])])
+
+m4_define([_DX_LT_PATCHES])
+m4_define([_DX_LT_PATCH],
+  [m4_define([_DX_LT_PATCH($1)], [$2])m4_define([_DX_LT_PATCHES],
+    m4_defn([_DX_LT_PATCHES])[ $1])])
+
+# Avoid "const" on VAX C for libtool's dynamic symbol bits, like with OSF and
+# Windows platforms, as there seem to be some problems with relocations of
+# function pointer values in readonly memory.
+#
+# We patch it in ltmain.sh (via config.status) and in configure directly.
+# This code is also duplicated in libltdl so further fixes might be needed
+# for packages using bindled libltdl (not done here... yet?).
+_DX_LT_PATCH([ltmain-sh-vax-c],
+  [DX_PATCH_MACRO([_LT_CONFIG], [^\( *\)[$]SED '[$]q' "[$]ltmain"],
+  [\1# Use this opportunity also to work around a VAX C bug in upstream libtool
+\1$SED 's/^# *elif.*__osf__$/& || (defined vaxc \\&\\& defined VAXC)/' "$ltmain"])])
+
+_DX_LT_PATCH([libtool-m4-vax-c],
+  [DX_PATCH_MACRO([_LT_CMD_GLOBAL_SYMBOLS], [^# *elif.*__osf__$],
+    [\& || (defined vaxc && defined VAXC)])])