From b6ec120435a070a28eafe0b3e686ef2ac9b0f042 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Thu, 22 Feb 2024 20:26:02 -0500 Subject: [PATCH 1/4] DX_RUN_LOG: Work around DJGPP subshell bug. On DJGPP bash, running set -x in a subshell also affects the parent shell environment. Inadvertently turning on traces for the whole rest of the configure run is not desirable, so work around the problem by manually turning the traces back off when this happens. --- m4/base.m4 | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/m4/base.m4 b/m4/base.m4 index c14ba68..4dc0d14 100644 --- a/m4/base.m4 +++ b/m4/base.m4 @@ -1,10 +1,10 @@ -dnl Copyright © 2012, 2014, 2021, 2023 Nick Bowler -dnl -dnl Basic macros for dxcommon. -dnl -dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. -dnl This is free software: you are free to do what the fuck you want to. -dnl There is NO WARRANTY, to the extent permitted by law. +# Copyright © 2012, 2014, 2021, 2023-2024 Nick Bowler +# +# Basic macros for dxcommon. +# +# 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. AC_PREREQ([2.64]) @@ -68,14 +68,20 @@ dnl dnl This macro expands to the dxcommon base directory, as a quoted string. AC_DEFUN([DX_BASEDIR], [m4_ignore(DX_INIT())m4_defn([_DX_BASEDIR])]) -dnl DX_RUN_LOG(command) -dnl -dnl Run a command, logging all of the command, its output, and overall -dnl exit status to config.log. The expansion of this macro is a single -dnl complex shell command suitable for use in shell conditionals. -AC_DEFUN([DX_RUN_LOG], [{ (set -x; $1;) >&AS_MESSAGE_LOG_FD 2>&1 - dx_status=$?; AS_ECHO(["\$? = $dx_status"]) >&AS_MESSAGE_LOG_FD 2>&1 - test $dx_status = 0; }]) +# DX_RUN_LOG(command) +# +# Run a command, logging all of the command, its output, and overall +# exit status to config.log. The expansion of this macro is a single +# complex shell command suitable for use in shell conditionals. +AC_DEFUN([DX_RUN_LOG], +[{ _dx_shopt=$- +( set -x +$1 +) >&AS_MESSAGE_LOG_FD 2>&1 +_dx_status=$? +test x"$-" = x"$_dx_shopt" || set +x # work around DJGPP subshell bug +AS_ECHO(["\$? = $_dx_status"]) >&AS_MESSAGE_LOG_FD +test $_dx_status = 0; } 2>/dev/null]) # DX_PATCH_MACRO([macro-name], [regexp], [replacement]) # -- 2.43.2 From e2f2206552cd2153641c17908d938930fb15d3d4 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 28 Feb 2024 23:08:12 -0500 Subject: [PATCH 2/4] 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 From f5df895ced92ac539cafd825efee98835d8bf0d3 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 3 Apr 2024 23:57:32 -0400 Subject: [PATCH 3/4] Avoid _Alignas/_Alignof redefinition on FreeBSD. It seems that FreeBSD provides _Alignof and _Alignas macros in various standard header files, including . Since the configure probes don't include any headers, these are missed, resulting in conflicting macro definitions. To fix this, all we really need to do is include some header file in the test program, so these system versions are visible when testing for _Alignas and _Alignof support. --- m4/align.m4 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/m4/align.m4 b/m4/align.m4 index 03e18a8..945beff 100644 --- a/m4/align.m4 +++ b/m4/align.m4 @@ -8,10 +8,14 @@ # # Probe whether the C compiler understands _Alignof(T). # +# Some implementations (e.g., FreeBSD 9) define a usable _Alignof macro +# in (and other headers), so we can use that if available. +# # If not supported, _Alignof(T) is defined as a function-like macro which # uses offsetof to guess the alignment of T, which must be a type such that -# T x; is a valid declaration of x as an object of type T. It is therefore -# necessary that the caller includes before using _Alignof. +# T x; is a valid declaration of x as an object of type T. +# +# For these reasons, callers should #include before using _Alignof. # # We skip the test if Autoconf has previously determined that the C compiler # supports C11 or a newer standard, since the C11 test program checks this. @@ -22,7 +26,8 @@ AC_DEFUN([DX_C_ALIGNOF], [AS_CASE([${ac_cv_prog_cc_c11-no}/${ac_prog_cc_stdc-no}], [no/no|*/c89|*/c99], [AC_CACHE_CHECK([if $CC supports _Alignof], [dx_cv_have_alignof], - [AC_COMPUTE_INT([_dx_tmp], [_Alignof(char)], [@&t@], [_dx_tmp=0]) + [AC_COMPUTE_INT([_dx_tmp], [_Alignof(char)], [#include +], [_dx_tmp=0]) AS_CASE([$_dx_tmp], [1], [dx_cv_have_alignof=yes], [dx_cv_have_alignof=no])])], [dx_cv_have_alignof=yes]) AS_CASE([$dx_cv_have_alignof], [no], [AC_DEFINE([_Alignof(T)], @@ -33,6 +38,10 @@ AS_CASE([$dx_cv_have_alignof], [no], [AC_DEFINE([_Alignof(T)], # # Probe whether the C compiler understands _Alignas(X). # +# Some implementations (e.g., FreeBSD 9) define a usable _Alignas macro +# in (and other headers), so we can use that if available. For +# this reason, callers should #include before using _Alignas. +# # If not supported, but the compiler supports the GNU __attribute__ or # Microsoft __declspec methods to set alignment, _Alignas(X) is defined # as a function-like macro which expands to such syntax. These only @@ -55,7 +64,8 @@ in '_Alignas(X)' '__attribute__((__aligned__(X)))' '__declspec(align(X))' do AC_COMPUTE_INT([_dx_tmp], [sizeof (struct { char a; char ALIGNAS_TEST(4) b; }) >= 8], - [#define ALIGNAS_TEST(X) $_dx_alignas + [#include +#define ALIGNAS_TEST(X) $_dx_alignas ],[_dx_tmp=0]) AS_CASE([$_dx_tmp/$_dx_alignas], [1/_Alignas*], [dx_cv_have_alignas=yes; break], -- 2.43.2 From 419ef0274998c19b8c46b0f511bf44f49a514670 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 10 Apr 2024 20:57:36 -0400 Subject: [PATCH 4/4] DX_C_ALIGNAS: Work around bash-5 parsing bug. Apparently bash-5 and later versions fail to parse for loops with a newline before the 'in' keyword, if that loop itself is in a case. statement. Previous versions of bash have no such problem, nor does any other shell I've tried, but the workaround is simple enough. --- m4/align.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/align.m4 b/m4/align.m4 index 945beff..a69e640 100644 --- a/m4/align.m4 +++ b/m4/align.m4 @@ -59,7 +59,7 @@ AC_DEFUN([DX_C_ALIGNAS], [no/no|*/c89|*/c99], [AC_CACHE_CHECK([if $CC supports _Alignas], [dx_cv_have_alignas], [dx_cv_have_alignas=no -for _dx_alignas +for _dx_alignas dnl Eat newline to work around bash-5 parsing bug. in '_Alignas(X)' '__attribute__((__aligned__(X)))' '__declspec(align(X))' do AC_COMPUTE_INT([_dx_tmp], -- 2.43.2