Perl: Unknown charname \\N{alpha}

2019-07-28 06:21发布

问题:

I am trying to build Encode 2.88-3 from CPAN on AIX 7.2. During the make test phase I receive various errors about unknown characters:

Use of uninitialized value $txt in pattern match (m//) at /usr/opt/perl5/lib/5.20.1/_charnames.pm line 499.
Unknown charname 'alpha' at t/Encode.t line 44, within string
BEGIN not safe after errors--compilation aborted at t/Encode.t line 148.
t/Encode.t ................. 
Use of uninitialized value $txt in pattern match (m//) at /usr/opt/perl5/lib/5.20.1/_charnames.pm line 459.
Unknown charname 'LATIN SMALL LETTER SHARP S' at t/encoding.t line 77, within string
BEGIN not safe after errors--compilation aborted at t/encoding.t line 165.
t/encoding.t ............... 

Use of uninitialized value $txt in pattern match (m//) at /usr/opt/perl5/lib/5.20.1/_charnames.pm line 459.
Unknown charname 'POUND SIGN' at t/mime-header.t line 166, within string
Execution of t/mime-header.t aborted due to compilation errors.
# Looks like your test exited with 2 just after 1.
t/mime-header.t ............ 

To test whether this is an AIX problem or a problem with the Encode-Testcase, I tried to build the same version on my linux system (Ubuntu 14.04), where Encode installs just fine.

To pick the first error:

is "\N{alpha}",substr($uni,0,1),"alpha does not map to symbol 'a'";

It seems AIX perl is unable to find the \N{alpha} character. I am a bit lost here - where does perl usually search for characters like this?

I need a hint into the direction I have to search for with this problem. Can someone provide some debugging tips?

perl -V
Summary of my perl5 (revision 5 version 20 subversion 1) configuration:

  Platform:
    osname=aix, osvers=6.1.0.0, archname=aix-thread-multi
    uname='aix blade08 1 6 00003c3ad100 '
    config_args='-d -Dprefix=/usr/opt/perl5 -Dcc=xlc_r -Duseshrplib -Dusethreads'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='xlc_r -q32', ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=-1 -qnoansialias -qlanglvl=extc99 -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT -q32 -D_LARGE_FILES',
    optimize='-O',
    cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=-1 -qnoansialias -qlanglvl=extc99 -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT'
    ccversion='12.1.0.9', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -brtl -bdynamic -b32'
    libpth=/lib /usr/lib /usr/ccs/lib
    libs=-lbind -lnsl -ldbm -ldl -lld -lm -lcrypt -lpthreads -lc
    perllibs=-lbind -lnsl -ldl -lld -lm -lcrypt -lpthreads -lc
    libc=, so=a, useshrplib=true, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -bE:/usr/opt/perl5/lib/5.20.1/aix-thread-multi/CORE/perl.exp'
    cccdlflags=' ', lddlflags='-bhalt:4 -G -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -bnoentry -lpthreads -lc -lm'


Characteristics of this binary (from libperl): 
  Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        USE_ITHREADS USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_REENTRANT_API
  Built under aix
  Compiled at Feb  6 2015 14:54:29
  %ENV:
    PERL5LIB="/home/perl_ss/perl5/lib/perl5/aix-thread-multi:/home/perl_ss/perl5/lib/perl5:/usr/local/lib/site_perl/5.8.8:/usr/local/site_perl/common"
    PERL5OPT=""
    PERL5_CPANPLUS_IS_RUNNING="9961732"
    PERL5_CPAN_IS_RUNNING="9961732"
    PERL_LOCAL_LIB_ROOT="/home/perl_ss/perl5"
    PERL_MB_OPT="--install_base /home/perl_ss/perl5"
    PERL_MM_OPT="INSTALL_BASE=/home/perl_ss/perl5"
  @INC:
    /home/perl_ss/perl5/lib/perl5/aix-thread-multi
    /home/perl_ss/perl5/lib/perl5/aix-thread-multi
    /home/perl_ss/perl5/lib/perl5
    /usr/local/lib/site_perl/5.8.8/aix-thread-multi
    /usr/local/lib/site_perl/5.8.8
    /usr/local/site_perl/common
    /usr/opt/perl5/lib/site_perl/5.20.1/aix-thread-multi
    /usr/opt/perl5/lib/site_perl/5.20.1
    /usr/opt/perl5/lib/5.20.1/aix-thread-multi
    /usr/opt/perl5/lib/5.20.1
    /usr/opt/perl5/lib/site_perl/5.8.8
    /usr/opt/perl5/lib/site_perl

UPDATE: Further inspection of the problem leads me to the conclusion that this may not be related to encode. I fired up my Debugger and performed some tests. Notice how the Character \N{greek:alpha} was found on Linux, but not on AIX: AIX 7.2:

 DB<1> use charnames qw(greek)

  DB<2> print "\N{alpha}"
Use of uninitialized value $txt in pattern match (m//) at /usr/opt/perl5/lib/5.20.1/_charnames.pm line 459.
 [...]
Unknown charname 'alpha' at (eval 9)[/usr/opt/perl5/lib/5.20.1/perl5db.pl:732] line 2, within string

  DB<3> print "\N{U+03B1}"
Wide character in print at (eval 10)[/usr/opt/perl5/lib/5.20.1/perl5db.pl:732] line 2.
 [...]

  DB<4> print "\N{greek:alpha}"  
Use of uninitialized value $txt in pattern match (m//) at /usr/opt/perl5/lib/5.20.1/_charnames.pm line 459.
 [...]
Unknown charname 'greek:alpha' at (eval 11)[/usr/opt/perl5/lib/5.20.1/perl5db.pl:732] line 2, within string

Ubuntu 14.04

DB<1> use charnames qw(greek)

 DB<2> print "\N{alpha}"
 Unknown charname 'alpha' at (eval 8)[/usr/share/perl/5.18/perl5db.pl:732] line 2, within string

 DB<3> print "\N{U+03B1}"
 Wide character in print at (eval 9)[/usr/share/perl/5.18/perl5db.pl:732] line 2.


 DB<4> print "\N{greek:alpha}"
 Wide character in print at (eval 10)[/usr/share/perl/5.18/perl5db.pl:732] line 2.

Guess there is something messed up with the AIX character-table?

UPDATE 2: I am starting to get to the bottom of this.

Name.pl is missing in AIX:

perl@t72:/usr/opt/perl5/lib/5.20.1/unicore $ ls
Blocks.txt          Decomposition.pl    Name.pm             SpecialCasing.txt   UCD.pl
CombiningClass.pl   Heavy.pl            NamedSequences.txt  To                  lib

In contrast to Linux:

perl@pod-racer:/usr/share/perl/5.18/unicore $ ls
Blocks.txt         Decomposition.pl  lib                 Name.pl  SpecialCasing.txt  UCD.pl
CombiningClass.pl  Heavy.pl          NamedSequences.txt  Name.pm  To                 version

回答1:

I figured it out. The errors on AIX came up because unicore/Name.pl was missing in AIX 7.2 for whatever reason.

As Name.pl is generated during the compilation of perl, the necessary program mktables was not to be found on the AIX System, as I does not seem to be delivered with a packaged perl.

Solution to this: Download the perl-Version which is installed from CPAN into a temporary directory. On AIX 7.2 I have perl 5.20, so I download perl 5.20 from cpan (http://www.cpan.org/src/).

Extract it, and cd to lib/unicore. There you can find the mktables program. Then generate the unicode files:

chmod 755 mktables
./mktables

This generates a bunch of files, including Name.pl. I diffed all newly generated files against the ones from my systems perl and found no difference, so I only copied Name.pl to my systems unicore-path. The Errors then vanished.



回答2:

While I agree that there is a problem with the distribution and it needs to be fixed upstream. I appreciate the answer provided that gets me past the problem at hand.

For me it looks like:

wget http://www.cpan.org/src/5.0/perl-5.20.1.tar.gz
gunzip -c ../perl-5.20.1.tar.gz | tar xvf -
cd perl-5.20.1/lib/unicore/
chmod 755 ./mktables
./mktables # Note there is no output... just wait. It will complete
sudo cp Name.pl /usr/opt/perl5/lib/5.20.1/unicore

And life was good again



标签: perl install aix