Closed
Description
Module:
POSIX
Description
POSIX.xs at https://github.com/Perl/perl5/blob/blead/ext/POSIX/POSIX.xs#L3350= uses uname(3) for detecting architecture on FreeBSD. However, uname -m
will print "powerpc" on all powerpc architectures (powerpc, powerpcspe, powerpc64 and powerpc64le), "riscv" on riscv architectures (riscv64, riscv64sf) and "arm" on 32-bit arm (armv6, armv7). For uname
binary, -p
switch is available that will print a correct name, but it's name available in uname
C function.
This is in particular wrong on 64-bit architectures, since bitness is misdetected.
Steps to Reproduce
root@powerpc64-131-default:~ # perl5.35.11 -v
This is perl 5, version 35, subversion 11 (v5.35.11 (66f51c878ffb217ed5ec7a4563fa1167ca9e7ca6)) built for **powerpc-freebsd-thread-multi**
Copyright 1987-2022, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at https://www.perl.org/, the Perl Home Page.
The above is on powerpc64 host.
Expected behavior
root@powerpc64-131-default:~ # perl5.35.11 -v
This is perl 5, version 35, subversion 11 (v5.35.11 (66f51c878ffb217ed5ec7a4563fa1167ca9e7ca6)) built for **powerpc64-freebsd-thread-multi**
Copyright 1987-2022, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at https://www.perl.org/, the Perl Home Page.
The correct way would be to use sysctl hw.machine_arch output, like this:
int mib[] = { CTL_HW, HW_MACHINE_ARCH };
static char buf[48];
size_t len = sizeof(buf);
if (sysctl(mib, 2, &buf, &len, NULL, 0) == 0)
return buf;
Perl configuration
root@powerpc64-131-default:~ # perl5.35.11 -V
Summary of my perl5 (revision 5 version 35 subversion 11) configuration:
Snapshot of: 66f51c878ffb217ed5ec7a4563fa1167ca9e7ca6
Platform:
osname=freebsd
osvers=13.1-release
archname=powerpc-freebsd-thread-multi
uname='freebsd powerpc64-131-default 13.1-release freebsd 13.1-release 1301000 powerpc '
config_args='-Accflags=-DUSE_THREAD_SAFE_LOCALE -Darchlib=/usr/local/lib/perl5/5.35/mach -Dcc=cc -Dcf_by=mat [email protected] -Dcf_time=Mon Apr 11 06:56:21 UTC 2022 -Dinc_version_list=none -Dlibperl=libperl.so.5.35.10.86 -Dman1dir=/usr/local/lib/perl5/5.35/perl/man/man1 -Dman3dir=/usr/local/lib/perl5/5.35/perl/man/man3 -Dprefix=/usr/local -Dprivlib=/usr/local/lib/perl5/5.35 -Dscriptdir=/usr/local/bin -Dsitearch=/usr/local/lib/perl5/site_perl/mach/5.35 -Dsitelib=/usr/local/lib/perl5/site_perl -Dsiteman1dir=/usr/local/lib/perl5/site_perl/man/man1 -Dsiteman3dir=/usr/local/lib/perl5/site_perl/man/man3 -Dusenm=n -Duseshrplib -sde -Ui_iconv -Ui_malloc -Uinstallusrbinperl -Alddlflags=-L/wrkdirs/usr/ports/lang/perl5-devel/work/perl5-5.35.10-86-g66f51c878f -L/usr/local/lib/perl5/5.35/mach/CORE -lperl -Dshrpldflags=$(LDDLFLAGS:N-L/wrkdirs/usr/ports/lang/perl5-devel/work/perl5-5.35.10-86-g66f51c878f:N-L/usr/local/lib/perl5/5.35/mach/CORE:N-lperl) -Wl,-soname,$(LIBPERL) -Dusedevel -Uversiononly -Doptimize=-O2 -pipe -fstack-protector-strong -fno-strict-aliasing -Dusedtrace -Ui_gdbm -Dusemultiplicity=y -Duse64bitint -Dusemymalloc=n -Dusethreads=y -Dversiononly'
hint=recommended
useposix=true
d_sigaction=define
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cc'
ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DUSE_THREAD_SAFE_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
optimize='-O2 -pipe -fstack-protector-strong -fno-strict-aliasing '
cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -DUSE_THREAD_SAFE_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion=''
gccversion='FreeBSD Clang 13.0.0 ([email protected]:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)'
gccosandvers=''
intsize=4
longsize=8
ptrsize=8
doublesize=8
byteorder=87654321
doublekind=4
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=8
longdblkind=0
ivtype='long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='cc'
ldflags ='-pthread -Wl,-E -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib /usr/lib/clang/13.0.0/lib
libs=-lpthread -lm -lcrypt -lutil
perllibs=-lpthread -lm -lcrypt -lutil
libc=
so=so
useshrplib=true
libperl=libperl.so.5.35.10.86
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags=' -Wl,-R/usr/local/lib/perl5/5.35/mach/CORE'
cccdlflags='-DPIC -fPIC'
lddlflags='-shared -L/usr/local/lib/perl5/5.35/mach/CORE -lperl -L/usr/local/lib -fstack-protector-strong'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_TIMES
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_DEVEL
USE_64_BIT_ALL
USE_64_BIT_INT
USE_ITHREADS
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
USE_REENTRANT_API
USE_THREAD_SAFE_LOCALE
Built under freebsd
@INC:
/usr/local/lib/perl5/site_perl/mach/5.35
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.35/mach
/usr/local/lib/perl5/5.35