Closed AgostinoSturaro closed 3 years ago
Looks like you're building with a 32-bit perl on a 64-bit user space. What does
$ file /opt/ActivePerl-5.16/bin/perl{,-static} /opt/ActivePerl-5.16/lib/CORE/libperl.so
$ /opt/ActivePerl-5.16/bin/perl -V
$ /opt/ActivePerl-5.16/bin/perl-static -V
print?
Yes, I'm trying to build 32 bit on a 64 bit OS.
[/opt/ActivePerl-5.16/site/bin]
$ file /opt/ActivePerl-5.16/bin/perl{,-static} /opt/ActivePerl-5.16/lib/CORE/libperl.so
/opt/ActivePerl-5.16/bin/perl: symbolic link to `perl-static'
/opt/ActivePerl-5.16/bin/perl-static: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
/opt/ActivePerl-5.16/lib/CORE/libperl.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
[/opt/ActivePerl-5.16/site/bin]
$ /opt/ActivePerl-5.16/bin/perl -V
Summary of my perl5 (revision 5 version 16 subversion 3) configuration:
Platform:
osname=linux, osvers=2.6.17-1.2142_fc4, archname=i686-linux-thread-multi
uname='linux perl-linux-vm 2.6.17-1.2142_fc4 #1 tue jul 11 22:41:14 edt 2006 i686 i686 i386 gnulinux '
config_args='-ders -Dcc=gcc -Dusethreads -Duseithreads -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Accflags=-DUSE_SITECUSTOMIZE -Duselargefiles -Accflags=-DPERL_RELOCATABLE_INCPUSH -Accflags=-fno-merge-constants -Dprefix=/opt/ActivePerl-5.16 -Dprivlib=/opt/ActivePerl-5.16/lib -Darchlib=/opt/ActivePerl-5.16/lib -Dsiteprefix=/opt/ActivePerl-5.16/site -Dsitelib=/opt/ActivePerl-5.16/site/lib -Dsitearch=/opt/ActivePerl-5.16/site/lib -Dsed=/bin/sed -Duseshrplib -Dcf_by=ActiveState -Dcf_email=support@ActiveState.com'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH -fno-merge-constants -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH -fno-merge-constants -fno-strict-aliasing -pipe'
ccversion='', gccversion='4.0.2 20051125 (Red Hat 4.0.2-8)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc', ldflags =''
libpth=/lib /usr/lib /usr/local/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.3.6.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.3.6'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/ActivePerl-5.16/lib/CORE'
cccdlflags='-fPIC', lddlflags='-shared -O2'
Characteristics of this binary (from libperl):
Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP PERL_PRESERVE_IVUV
PERL_RELOCATABLE_INCPUSH USE_ITHREADS USE_LARGE_FILES
USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
USE_REENTRANT_API USE_SITECUSTOMIZE
Locally applied patches:
ActivePerl Build 1604 [298023]
Built under linux
Compiled at Apr 14 2014 14:46:50
%ENV:
PERL5LIB="/git/BESTools/BESToolsFramework/SharedPerlModules"
@INC:
/git/BESTools/BESToolsFramework/SharedPerlModules
/opt/ActivePerl-5.16/site/lib
/opt/ActivePerl-5.16/lib
.
[/opt/ActivePerl-5.16/site/bin]
$ /opt/ActivePerl-5.16/bin/perl-static -V
Summary of my perl5 (revision 5 version 16 subversion 3) configuration:
Platform:
osname=linux, osvers=2.6.17-1.2142_fc4, archname=i686-linux-thread-multi
uname='linux perl-linux-vm 2.6.17-1.2142_fc4 #1 tue jul 11 22:41:14 edt 2006 i686 i686 i386 gnulinux '
config_args='-ders -Dcc=gcc -Dusethreads -Duseithreads -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Accflags=-DUSE_SITECUSTOMIZE -Duselargefiles -Accflags=-DPERL_RELOCATABLE_INCPUSH -Accflags=-fno-merge-constants -Dprefix=/opt/ActivePerl-5.16 -Dprivlib=/opt/ActivePerl-5.16/lib -Darchlib=/opt/ActivePerl-5.16/lib -Dsiteprefix=/opt/ActivePerl-5.16/site -Dsitelib=/opt/ActivePerl-5.16/site/lib -Dsitearch=/opt/ActivePerl-5.16/site/lib -Dsed=/bin/sed -Duseshrplib -Dcf_by=ActiveState -Dcf_email=support@ActiveState.com'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH -fno-merge-constants -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH -fno-merge-constants -fno-strict-aliasing -pipe'
ccversion='', gccversion='4.0.2 20051125 (Red Hat 4.0.2-8)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc', ldflags =''
libpth=/lib /usr/lib /usr/local/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.3.6.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.3.6'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/ActivePerl-5.16/lib/CORE'
cccdlflags='-fPIC', lddlflags='-shared -O2'
Characteristics of this binary (from libperl):
Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP PERL_PRESERVE_IVUV
PERL_RELOCATABLE_INCPUSH USE_ITHREADS USE_LARGE_FILES
USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
USE_REENTRANT_API USE_SITECUSTOMIZE
Locally applied patches:
ActivePerl Build 1604 [298023]
Built under linux
Compiled at Apr 14 2014 14:46:50
%ENV:
PERL5LIB="/git/BESTools/BESToolsFramework/SharedPerlModules"
@INC:
/git/BESTools/BESToolsFramework/SharedPerlModules
/opt/ActivePerl-5.16/site/lib
/opt/ActivePerl-5.16/lib
.
@AgostinoSturaro
Yes, I'm trying to build 32 bit on a 64 bit OS.
Here's your problem:
Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH -fno-merge-constants -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
I guess you don't have a 32-bit gcc installed so that gcc
will invoke your "native" 64-bit compiler (which produces 64-bit objects
by default). I doubt that you ever built any XS perl module in this setting. The easiest solution is to patch
/opt/ActivePerl-5.16/.../Config.pm
and add -m32
to the value of cflags
.
Thank you. I updated cpan, installed cpanm and other modules just fine, but I'm sure if that built modules with C code. I thought so, but I might be wrong. The installed gcc does build 32 and 64 bit projects (I tried it) but I'm not really an expert in picking compiler flags.
I searched for ccflags
in both .pl
and .pm
files and the most interesting are:
In /opt/ActivePerl-5.16/lib/ActivePerl/Config.pm
I see $^O eq
OS checks for many kernels except Linux specifically.
It was quite involved and I didn't change it. I can paste it if you need to see it.
In /opt/ActivePerl-5.16/lib/Config_heavy.pl
looked more promising, with a clearly stated ccflags
value.
I changed /opt/ActivePerl-5.16/lib/Config_heavy.pl
like this
ccflags='-D_REENTRANT -D_GNU_SOURCE -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH -fno-merge-constants -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' -m32
That's the only change I made. I'm not sure If I also need to add it to ccflags_nolargefiles
our $Config_SH_expanded = "\n$_" . << 'EOVIRTUAL';
ccflags_nolargefiles='-D_REENTRANT -D_GNU_SOURCE -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH -fno-merge-constants -fno-strict-aliasing -pipe '
ldflags_nolargefiles=''
libs_nolargefiles='-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc'
libswanted_nolargefiles='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m crypt sec util pthread c cposix posix ucb BSD gdbm_compat'
EOVIRTUAL
and to ccflags_uselargefiles
.
ccflags_uselargefiles='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
But the build still fails
[/opt/ActivePerl-5.16/site/bin]
$ ./cpanm PAR::Packer
--> Working on PAR::Packer
Fetching http://www.cpan.org/authors/id/R/RS/RSCHUPP/PAR-Packer-1.051.tar.gz ... OK
Configuring PAR-Packer-1.051 ... OK
Building and testing PAR-Packer-1.051 ... FAIL
! Installing PAR::Packer failed. See /root/.cpanm/work/1606995215.30120/build.log for details. Retry with --force to force install it.
I see noticed this, and I'm not sure it really built anything
Running Makefile.PL
/usr/bin/ld: i386 architecture of input file `compilet-fsK16.o' is incompatible with i386:x86-64 output
collect2: ld returned 1 exit status
No compiler found, won't generate 'script/parl!
Should I add -m32
to ccflags_nolargefiles
and to ccflags_nolargefiles
?
Any other idea?
Thank you.
OK, let's back off a bit: what are you trying to achieve? I assume you're trying to build executables (via PAR::Packer's pp
)
with a 32-bit perl distribution. So you can only expect to generate 32-bit executables. Why do you need these?
Good question. I have a set of small Perl tools for system diagnostics, and I can't go install a custom Perl interpreter and the needed modules on all the target endpoints. I mostly need to target RHEL/CentOS >=6 and 64 bits, but there are a few 32 bit CentOS 6 and 32 bit Ubuntu LTS, possibly some SuSe as well (quite a mix, I know). I still need to care for the 32 bit hosts and I was hoping to build everything in 32 bits and run that on 64 bit systems as well.
If I can build a 32 bit executable on a 32 bit CentOS 6, can I expect it to work on a 64 bit CentOS 8? If so, that might be fine. If it worked on Ubuntu (and Suse) as well, that would be really nice.
I was hoping to build everything in 32 bits and run that on 64 bit systems as well.
Should be doable, but probably takes some more tweaks to compiler and linker flags to achieve. In general, one should build on the same platform as the target.
If I can build a 32 bit executable on a 32 bit CentOS 6, can I expect it to work on a 64 bit CentOS 8?
That should work. Of course the 64-bit systems must have the required 32-bit system libs (libc.so, libm.so etc, but nothing perl specific) installed. There shouldn't be any GLIBC versioning problems as your building on older systems.
Thank you. I'll try and let you know.
The installation worked on CentOS 6.10 32 bit and ActivePerl 5.16.3 x86. ODBC stuff does not seem to get wrapped correctly though. I'll open a separate ticket for that once I can get more information. Thank you.
I'm trying to install PAR::Packer on an ActivePerl 5.16.3 x86 on a RHEL 6.10 x64. It fails to install. Here is the command prompt
Here is the content of
/root/.cpanm/work/1606926712.5624/build.log
I also have an older Perl version installed, but not in PATH.
Any idea how to get this to install on the ActivePerl version? I had no problem installing cpanm there. Thank you.