From e2f2206552cd2153641c17908d938930fb15d3d4 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 28 Feb 2024 23:08:12 -0500 Subject: [PATCH] Add helper macro for libtool patches. 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 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 m4/lt-patches.m4 diff --git a/m4/lt-patches.m4 b/m4/lt-patches.m4 new file mode 100644 index 0000000..735633f --- /dev/null +++ b/m4/lt-patches.m4 @@ -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)])]) -- 2.43.2