Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions recipes/perl/perl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metaEnvironment:

privateEnvironment:
APPLY_UPDATE_CONFIG: "no"
PERL_CROSS_VERSION: "1.6.2"
PERL_CROSS_VERSION: "1.6.5"
PERL_ARCH: "$(if-then-else,$(eq,${ARCH},arm64),aarch64-linux,${ARCH}-linux)"

checkoutSCM:
Expand All @@ -18,8 +18,9 @@ checkoutSCM:
stripComponents: 1
-
scm: url
url: "https://github.com/arsv/perl-cross/raw/releases/perl-cross-${PERL_CROSS_VERSION}.tar.gz"
digestSHA256: "131f7496152ee32067dbac2bc9b44b2f582fc778140e545701b3b2faee782f1d"
url: "https://github.com/arsv/perl-cross/releases/download/${PERL_CROSS_VERSION}/\
perl-cross-${PERL_CROSS_VERSION}.tar.gz"
digestSHA256: "81130cd4b8c6d9eb2a1959f37d44391a46ad6a6794fc41fed5441f74e85e3dd0"
extract: False
dir: perl-cross
fileName: perl-cross.tar.gz
Expand All @@ -38,6 +39,12 @@ buildTools: [host-toolchain, target-toolchain]
buildVars: [AUTOCONF_HOST, CROSS_COMPILE, TOOLCHAIN_SYSROOT,
CPPFLAGS, CFLAGS, LDFLAGS]
buildScript: |
# perl-cross symlinks the sources into the build directory only if there
# is no MANIFEST yet. Start over if configure did not complete before,
# e.g. because a previous run was interrupted while symlinking.
if [ -d build ] && [ ! -e build/.bob-configured ]; then
rm -rf build
fi
mkdir -p build install
cd build

Expand All @@ -60,6 +67,8 @@ buildScript: |
-Dperladmin=root \
-Duserelocatableinc \

touch .bob-configured

makeParallel all
make DESTDIR=$PWD/../install install.perl

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
From 6bdfdff24f4a7d17d3b7d9d02bca3eac11c235a4 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Date: Wed, 26 Aug 2026 19:34:39 +0200
Subject: [PATCH] configure: keep _GNU_SOURCE in build flags

The checkfunc() function probes available libc functions with _GNU_SOURCE
defined. The generated config.sh did not retain that define in ccflags, so
the actual cross build could use functions whose prototypes remain hidden by
feature-test macros. This breaks musl builds, where memrchr is declared only
with _GNU_SOURCE.

To fix this, append _GNU_SOURCE to explicit -Dccflags values while parsing
configure arguments. Such values are locked before configure_tool.sh can
append flags. This keeps the function-availability checks and subsequent
compilation in the same feature set, including when flags are supplied
through CFLAGS.

This fixes the regression introduced by b40c560f5d5e (configure_func.sh: Add
_GNU_SOURCE define and function signatures).

It fixes the following build issue with musl:

In file included from op.c:163:
op.c: In function 'Perl_newATTRSUB_x':
perl.h:2385:25: error: implicit declaration of function 'memrchr'; did
you mean 'memchr'? [-Wimplicit-function-declaration]
2385 | # define my_memrchr memrchr
| ^~~~~~~

This issue is worked around in several build systems:

- In OpenEmbedded:
https://github.com/openembedded/openembedded-core/commit/6422e62

- In NixOS:
https://github.com/NixOS/nixpkgs/pull/441527

Fixes: https://github.com/arsv/perl-cross/issues/158
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
cnf/configure_args.sh | 3 +++
1 file changed, 3 insertions(+)

diff --git a/cnf/configure_args.sh b/cnf/configure_args.sh
index 5bc4c6b..65ffc96 100644
--- a/cnf/configure_args.sh
+++ b/cnf/configure_args.sh
@@ -225,6 +225,9 @@ while [ $i -le $# -o -n "$n" ]; do
host|target|build) ;;
# original Configure options
D)
+ if [ "$k" = 'ccflags' ]; then
+ v="$v -D_GNU_SOURCE"
+ fi
setordefine "$k" "$x" "$v" 'define' 'true'
;;
U)
--
2.55.0

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
From: Adam Lackorzynski <adam@l4re.de>
Subject: [PATCH] configure: detect musl's setlocale(LC_ALL) format

perl-cross hardcodes the glibc format of the string that
setlocale(LC_ALL, NULL) returns for mixed locales, i.e. name=value pairs
like "LC_CTYPE=C.UTF-8;LC_NUMERIC=C;...". musl instead returns the
category names positionally, separated by ';', in the order of the LC_*
constants: "C.UTF-8;C;C;C;C;C". Perl's native Configure detects this by
running a probe, which is not possible when cross compiling.

With the wrong setting, perl panics on musl as soon as the locale
categories differ, which is the default there (LC_CTYPE is C.UTF-8):

locale.c: 1484: panic: 'C.UTF-8;C;C;C;C;C' needs an '=' to split name=value
; errno=0
Called by locale.c: 4101

musl has no identifying macro, so check at compile time for a libc that
is neither glibc nor uclibc and has musl's category layout, and configure
the positional format for it.

---
cnf/configure_misc.sh | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)

--- a/cnf/configure_misc.sh
+++ b/cnf/configure_misc.sh
@@ -240,11 +240,32 @@
define stdio_stream_array
define d_lc_monetary_2008 'undef'

-define d_perl_lc_all_uses_name_value_pairs 'define'
-define d_perl_lc_all_category_positions_init 'undef'
-define d_perl_lc_all_separator 'undef'
-define perl_lc_all_separator ''
-define perl_lc_all_category_positions_init ''
+# The format of setlocale(LC_ALL, NULL) for mixed locales cannot be probed
+# by running code when cross compiling. glibc returns name=value pairs,
+# musl the six category names positionally, separated by ';', in the order
+# of the LC_* constants. musl has no identifying macro, so check for a
+# non-glibc libc with musl's category layout.
+mstart "Checking setlocale(LC_ALL) format"
+try_start
+try_includes locale.h
+try_add '#if defined(__GLIBC__) || defined(__UCLIBC__) || LC_ALL != 6 || LC_MESSAGES != 5'
+try_add '#error not musl'
+try_add '#endif'
+if try_compile; then
+ result 'positional (musl)'
+ define d_perl_lc_all_uses_name_value_pairs 'undef'
+ define d_perl_lc_all_category_positions_init 'define'
+ define d_perl_lc_all_separator 'define'
+ define perl_lc_all_separator '";"'
+ define perl_lc_all_category_positions_init '{ 0, 1, 2, 3, 4, 5 }'
+else
+ result 'name=value pairs'
+ define d_perl_lc_all_uses_name_value_pairs 'define'
+ define d_perl_lc_all_category_positions_init 'undef'
+ define d_perl_lc_all_separator 'undef'
+ define perl_lc_all_separator ''
+ define perl_lc_all_category_positions_init ''
+fi

define sharpbang '#!'
define startperl "$sharpbang$perlpath"
Loading