Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/perl5Public

locale.c: Fix compilation on platforms with only a C locale#22569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
khwilliamson merged 1 commit intoPerl:bleadfromthe-horo:locale-fix
Sep 9, 2024

Conversation

the-horo
Copy link
Contributor

Reported downstream in:https://bugs.gentoo.org/939014. The bug is about being impossible to bootstrap a Gentoo prefix with perl-5.40.0.

A Gentoo prefix is a Linux installation under some custom directory, modifiable by a non-root user. Bootstrapping such an installation starts with a host compiler and a shell and builds packages until the full installation is complete. Because of the nature of perl, it ends up being compiled relatively early during the whole process, before the installation is complete and the user has had the chance to select which locales to generate.

In this situation perl ends up being compiled on a bare system with only the C locale. The code inConfigure

perl5/Configure

Lines 17672 to 17675 in67e8521

if (distincts_count < C_ARRAY_LENGTH(categories)) {
fprintf(stderr, "Couldn't find a locale distinguishable from C\n");
return 1;
}
then exits early failing to prove the format ofLC_ALL which then takes the secondcase branch

perl5/Configure

Lines 17812 to 17834 in67e8521

output=`$run ./try 2>/dev/null`
separator=`echo "$output" | $sed 1q`
case $separator in
"\"=;\"")
d_perl_lc_all_uses_name_value_pairs="$define"
d_perl_lc_all_separator="$undef"
perl_lc_all_separator=
d_perl_lc_all_category_positions_init="$undef"
perl_lc_all_category_positions_init=
;;
"") d_perl_lc_all_uses_name_value_pairs="$undef"
d_perl_lc_all_separator="$undef"
perl_lc_all_separator=
d_perl_lc_all_category_positions_init="$undef"
perl_lc_all_category_positions_init=
;;
*) d_perl_lc_all_uses_name_value_pairs="$undef"
d_perl_lc_all_separator="$define"
perl_lc_all_separator="$separator"
d_perl_lc_all_category_positions_init="$define"
perl_lc_all_category_positions_init=`echo "$output" | sed -n 2p`
;;
esac
which makes all three ofPERL_LC_ALL_USES_NAME_VALUE_PAIRS,PERL_LC_ALL_SEPARATOR, andPERL_LC_ALL_CATEGORY_POSITIONS_INIT end up being undefined. Thelocale.c code, however, assumes that eitherPERL_LC_ALL_USES_NAME_VALUE_PAIRS or the other two macros are defined which leads to a compilation failure because of the usage ofPERL_LC_ALL_CATEGORY_POSITIONS_INIT:

x86_64-pc-linux-gnu-gcc -c -DPERL_CORE -O2 -pipe -O2 -pipe -fno-strict-aliasing -DNO_PERL_RAND_SEED -fwrapv -I/home/gabi/ghentu/usr/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -std=c99 -O2 -pipe -O2 -pipe -fno-strict-aliasing -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings -fPIC locale.clocale.c: In function 'Perl_init_i18nl10n':locale.c:8812:43: error: 'PERL_LC_ALL_CATEGORY_POSITIONS_INIT' undeclared (first use in this function) 8812 |         int lc_all_category_positions[] = PERL_LC_ALL_CATEGORY_POSITIONS_INIT;      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~locale.c:8812:43: note: each undeclared identifier is reported only once for each function it appears in

There is already code:

perl5/locale.c

Lines 649 to 658 in67e8521

# else/* name=value */
/* In the, hopefully never occurring, event that the platform doesn't use
* either mechanism for disparate LC_ALL's, assume the name=value pairs
* form, rather than taking the extreme step of refusing to compile. Many
* programs won't have disparate locales, so will generally work */
# definePERL_LC_ALL_SEPARATOR ";"
# defineis_disparate_LC_ALL(name) cBOOL( strchr(name, ';') \
&& strchr(name, '='))
# endif
that prevents compilation failures with missingPERL_LC_ALL_SEPARATOR. This is a similar situation in purpose but, becausePERL_LC_ALL_CATEGORY_POSITIONS_INIT is suppose to be an array initializer and, if generated inside the code, it would require a#include "locale_table.h" I think it's simpler to replace its single usage point. Themap_LC_ALL_position_to_index array should still be initialized, even with logically wrong values, to prevent possible out-of-bounds errors in other parts of the code.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
@thesamesam
Copy link

cc@khwilliamson

@khwilliamson
Copy link
Contributor

Thank you for this. I will also look into changing Configure to handle things so that this case doesn't arise. But it is a good fallback for Configure failures

thesamesam reacted with heart emoji

@khwilliamsonkhwilliamson merged commitf18202d intoPerl:bleadSep 9, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull requestFeb 11, 2025
Changelog:NAME    perldelta - what is new for perl v5.40.1DESCRIPTION    This document describes differences between the 5.40.0 release and the    5.40.1 release.    If you are upgrading from an earlier release such as 5.39.0, first read    perl5400delta, which describes differences between 5.39.0 and 5.40.0.Incompatible Changes    There are no changes intentionally incompatible with 5.40.0. If any    exist, they are bugs, and we request that you submit a report. See    "Reporting Bugs" below.Modules and Pragmata  Updated Modules and Pragmata    *   File::Spec has been upgraded from version 3.90 to 3.91.    *   Module::CoreList has been upgraded from version 5.20240609 to        5.20250118_40.    *   warnings has been upgraded from version 1.69 to 1.70.Documentation  Changes to Existing Documentation    We have attempted to update the documentation to reflect the changes    listed in this document. If you find any we have missed, open an issue    at <https://github.com/Perl/perl5/issues>.Configuration and Compilation    *   Fixed compilation on platforms (e.g. "Gentoo Prefix") with only a C        locale. [GH #22569 <Perl/perl5#22569>] Bug        first reported downstream at bugs.gentoo.org/939014        <https://bugs.gentoo.org/939014>.    *   Fixed compilation error on some systems due to a typo in a printf()        format. [GH #22793 <Perl/perl5#22793>]Testing    Tests were added and changed to reflect the other additions and changes    in this release.Selected Bug Fixes    *   Starting in Perl 5.39.8, ""strftime"" in POSIX would crash or        produce odd errors (such as "Out of memory in        perl:util:safesysmalloc") when given a format string that wasn't        actually a string, but a number, "undef", or an object (even one        with overloaded string conversion).        Now "strftime" stringifies its first argument, as before. [GH #22498        <Perl/perl5#22498>]    *   Builds with "-msse" and quadmath on 32-bit x86 systems would crash        with a misaligned access early in the build. [GH #22577        <Perl/perl5#22577>]    *   Using "goto" to tail call, or using the call_sv() and related APIs        to call, any of trim(), refaddr(), reftype(), ceil(), floor() or        stringify() in the "builtin::" package would crash or assert due to        a "TARG" handling bug. [GH #22542        <Perl/perl5#22542>]    *   Fixed an issue where utf8n_to_uvchr() failed to correctly identify        certain invalid UTF-8 sequences as invalid. Specifically, sequences        that start with continuation bytes or unassigned bytes could cause        unexpected behaviour or a panic. This fix ensures that such invalid        sequences are now properly detected and handled. This correction        also resolves related issues in modules that handle UTF-8        processing, such as Encode.    *   Fixed a double free error or possible memory leak when failing to        compile certain regexps. [GH #21661        <Perl/perl5#21661>]
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@the-horo@thesamesam@khwilliamson

[8]ページ先頭

©2009-2025 Movatter.jp