Commit 4790963ac8 for perl
commit 4790963ac8734ca9495fce1a01bdbbf1804c402e
Author: Karl Williamson <khw@cpan.org>
Date: Tue Sep 29 12:17:21 2026 -0600
Avoid changing ccflags in /hints when changes intrp size
Fixes #23306. Fixes #24868.
C compilers come with a vast (and bewildering) quantity of options. The
Perl interpreter is compiled with a particular set of them that we deem
appropriate. From time to time, we change those as experience informs
us. Sometimes we set an option because of some quirk in a platform's
hardware or compiler. There are a multitude of possibilities for why we
would want to set an option.
One of those options in all compilers we deal with is
-Dname[=definition]
which tells the compiler to create a macro with the given name, and
definition (default is '1'). The most prominent one we use is
-DDEBUGGING. Our code is full of preprocessor checks for symbols
created this way.
Now consider a module containing XS code. It has a makefile which
calls the C compiler. The author/maintainer chooses what options with
which to call the C compiler in order to compile that XS code.
Some of those options can affect the compatibility of the compiled
module with the compiled interpreter, to varying degrees. If the two
are highly incompatible, it is obvious, and so the module gets fixed
before it ever reaches the field. Others are more subtle. The module
is able to be loaded with the interpreter, and mostly works, but
hard-to-diagnose bugs are present. Or the module has bugs on particular
platforms or compiler versions because the maintainer did not know
enough to realize these existed.
The module's makefile should start with the interpreter's options, and
add or subtract from that base as needed. This is easy to do. For
example, using
CCFLAGS => "Config{ccflags} -Wall"
However, there are prominent XS modules that don't do that, and it
wasn't until 2021 that we documented that this should be done.
It is better then for core development to avoid setting CCFLAGS if there
is an alternative way to get the same effect. This commit does that for
three cases where platforms have buggy implementations of POSIX 2008
locales. Instead of using the -D option to the compiler to tell our
code not to use POSIX 2008, the commit tells Configure for each platform
not to use a function that is essential for the POSIX 2008
implementation to be chosen by our code. That changes config.h, and
makes whatever the XS makefile does irrelevant.
Most compiler options do not affect the interface between a module and
the interpreter. But some do. In all three cases here, the -D changed
the interpreter size. The XS makefile, without the -D, caused the
module to be expecting a different size.
In this case, it was easy to avoid using compiler options. But there
are plenty of cases where it wouldn't be. And there still is the issue
where an option works around a platform/compiler quirk, such as a
higher optimization level being broken, so a lower one needs to be
selected. The ultimate solution is to get the modules to change their
makefiles.
diff --git a/hints/darwin.sh b/hints/darwin.sh
index 5a4db393ee..56397b7605 100644
--- a/hints/darwin.sh
+++ b/hints/darwin.sh
@@ -346,7 +346,7 @@ ccflags="$ccflags -DNO_THREAD_SAFE_QUERYLOCALE"
# But it doesn't much matter because the whole implementation has bugs [GH
# #21556]
-ccflags="$ccflags -DNO_POSIX_2008_LOCALE"
+d_uselocale='undef'
# See comments in locale.c about this #define
ccflags="$ccflags -DHAS_BROKEN_LANGINFO_CODESET"
diff --git a/hints/dragonfly.sh b/hints/dragonfly.sh
index be9a089980..eb92da9aab 100644
--- a/hints/dragonfly.sh
+++ b/hints/dragonfly.sh
@@ -89,6 +89,7 @@ case "$cc" in
esac
# Dragonfly leaks with a newlocale/freelocale combination. See
-# https://bugs.dragonflybsd.org/issues/3361
-ccflags="$ccflags -DNO_POSIX_2008_LOCALE"
+# https://bugs.dragonflybsd.org/issues/3361. As of October 2026, their 6.4.3
+# is scheduled to contain a fix for this.
+d_uselocale='undef'
diff --git a/hints/freebsd.sh b/hints/freebsd.sh
index 080d2fe652..4e5864c6c4 100644
--- a/hints/freebsd.sh
+++ b/hints/freebsd.sh
@@ -336,7 +336,7 @@ then
fi
# See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265950
-ccflags="${ccflags} -DNO_POSIX_2008_LOCALE"
+d_uselocale='undef'
# localeconv() is supposed to be thread-safe on this platform when used with
# POSIX 2008 locales, so when freebsd gets fixed, may want to find a way to
# tell that to the code in locale.c that assumes that function isn't