rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

Ubuntu 16.04: /lib/x86_64-linux-gnu/libcrypt.so.1: version `XCRYPT_2.0' not found #22

Closed hakonhagland closed 4 years ago

hakonhagland commented 4 years ago

I am still testing PAR::Packer to generate an exe from the Perl script in issue #21:

#! /usr/bin/env perl

use feature qw(say);
use strict;
use warnings;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new();
my $res = $ua->get(
    'https://metacpan.org/pod/pp'
);
if ($res->is_success) {
    print "ok\n";
}
else {
    die $res->status_line;
}

This time I am using perl version 5.30.0 on Ubuntu 20.04. I run:

$ perl /home/hakon/perlbrew/perls/perl-5.30.0/bin/pp_autolink.pl -o p2.exe p.pl
# Use of runtime loader module Module::Implementation detected.  Results of static scanning may be incomplete.
# Use of runtime loader module Module::Runtime detected.  Results of static scanning may be incomplete.
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/B/B.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Compress/Raw/Bzip2/Bzip2.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Compress/Raw/Zlib/Zlib.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Cwd/Cwd.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Data/Dumper/Dumper.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Digest/MD5/MD5.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Encode/Encode.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Fcntl/Fcntl.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/File/Glob/Glob.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/I18N/Langinfo/Langinfo.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/IO/IO.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/List/Util/Util.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/MIME/Base64/Base64.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/POSIX/POSIX.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Socket/Socket.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/Storable/Storable.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/mro/mro.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/bin/../lib/5.30.0/x86_64-linux/auto/re/re.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/lib/site_perl/5.30.0/x86_64-linux/auto/HTML/Parser/Parser.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/lib/site_perl/5.30.0/x86_64-linux/auto/Net/SSLeay/SSLeay.so
ldd /home/hakon/perlbrew/perls/perl-5.30.0/lib/site_perl/5.30.0/x86_64-linux/auto/Params/Validate/XS/XS.so
ldd /lib/x86_64-linux-gnu/libm.so.6
ldd /lib/x86_64-linux-gnu/libssl.so.1.1
ldd /lib/x86_64-linux-gnu/libpthread.so.0
ldd /lib/x86_64-linux-gnu/libdl.so.2
ldd /lib/x86_64-linux-gnu/libcrypto.so.1.1
Alien sys dlls added: 
Detected link list: --link /lib/x86_64-linux-gnu/libpthread.so.0 --link /lib/x86_64-linux-gnu/libm.so.6 --link /lib/x86_64-linux-gnu/libcrypto.so.1.1 --link /lib/x86_64-linux-gnu/libssl.so.1.1 --link /lib/x86_64-linux-gnu/libdl.so.2
CMD:pp --link /lib/x86_64-linux-gnu/libpthread.so.0 --link /lib/x86_64-linux-gnu/libm.so.6 --link /lib/x86_64-linux-gnu/libcrypto.so.1.1 --link /lib/x86_64-linux-gnu/libssl.so.1.1 --link /lib/x86_64-linux-gnu/libdl.so.2 -o p2.exe p.pl
# Use of runtime loader module Module::Implementation detected.  Results of static scanning may be incomplete.
# Use of runtime loader module Module::Runtime detected.  Results of static scanning may be incomplete.

If I now transfer the p2.exe to a docker container running Ubuntu 16.04 and perl version 5.22.1 and execute it:

$ ./p2.exe
/tmp/par-68616b6f6e64/cache-989af1af4fb03c158b4acd9bdb3bfa54daf511f5/p2.exe: /lib/x86_64-linux-gnu/libcrypt.so.1: version `XCRYPT_2.0' not found (required by /tmp/par-68616b6f6e64/cache-989af1af4fb03c158b4acd9bdb3bfa54daf511f5/p2.exe)
/tmp/par-68616b6f6e64/cache-989af1af4fb03c158b4acd9bdb3bfa54daf511f5/p2.exe: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /tmp/par-68616b6f6e64/cache-989af1af4fb03c158b4acd9bdb3bfa54daf511f5/p2.exe)
/tmp/par-68616b6f6e64/cache-989af1af4fb03c158b4acd9bdb3bfa54daf511f5/p2.exe: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /tmp/par-68616b6f6e64/cache-989af1af4fb03c158b4acd9bdb3bfa54daf511f5/p2.exe)

So this did not work. Seems like pp_autolink detected libcrypto.so.1.1 but is this the same as libcrypt.so (note the missing o) from the error message? For the other error from libm.so.6, does it mean that --link /lib/x86_64-linux-gnu/libm.so.6 somehow did not work properly? Or that it should also link with libc.so ? Any ideas?

rschupp commented 4 years ago

No, libcrypt and libcrypto aren't the same. The latter is comes from OpenSSL (together with libssl) while the former used to be part of libc (the original passwd hash) and nowadays contains several other hash functions.

But that's not what the error messages are about. Your perl (or stuff that it's linked to) uses stuff from libc that is too "new" for the libc of your target system (libm, libcrypt, too). Ubuntu 16.04 uses libc 2.23 so the highest symbol version in its libc is GLIBC_2.23. You're out of luck here - it's the same reason why an arbitrary binary from Ubuntu 20.04 (libc 2.31) won't run on Ubuntu 16.04. If you have wildly different libc versions on source and target you must pack on the older version.

@shawnlaffan: Is it really a good idea for autolink to pp --link libm, libphtread and libdl from the source system?

shawnlaffan commented 4 years ago

pp_autolink should probably not be packing anything from system dirs that are expected to be on all machines. I'll add an exclude for /lib/x86_64-linux-gnu, or perhaps /lib to be more complete.

shawnlaffan commented 4 years ago

@hakonhagland - I've pushed a change to the github repo to exclude /lib, followed by a version bump in https://github.com/shawnlaffan/perl-pp-autolink/commit/2ae0b1279e43f930cbbc56c7b6fe16f297eaa2c4

Can you give that a test?

hakonhagland commented 4 years ago

@rschupp

you must pack on the older version

Interesting. Can you explain a little bit more? I would think the packing the newer version (not the older) would work..

rschupp commented 4 years ago

Read about symbol versioning, e.g. this blog or in depth (chapter 3). That's one of the reasons why Python chose CentOS 6 as OS baseline ("manylinux2014") for their binary package format ("wheel").

hakonhagland commented 4 years ago

@rschupp Thanks, I will check it out. BTW the last link in your previous comment refers to the same blog post as the first link.

rschupp commented 4 years ago

Thanks, corrected.