JuliaPackaging / Yggdrasil

Collection of builder repositories for BinaryBuilder.jl
https://binarybuilder.org
Other
304 stars 538 forks source link

Error building Perl application due to relocability #6325

Open Roger-luo opened 1 year ago

Roger-luo commented 1 year ago

trying to resolve #5633 , thus trying to build pp and run into the following

sandbox:${WORKSPACE}/srcdir/PAR-Packer # curl -L https://cpanmin.us | perl - App::cpanminus
Error relocating /workspace/destdir/lib/libperl.so: __snprintf_chk: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __vfprintf_chk: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __isnan: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __isinf: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __realpath_chk: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __memcpy_chk: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __open64_2: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __vsnprintf_chk: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __strncpy_chk: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __longjmp_chk: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: __sprintf_chk: symbol not found
Error relocating /workspace/destdir/lib/libperl.so: _LIB_VERSION: symbol not found

it seems any perl build script has this issue, not just pp (I also tried other perl packages's MAKEFILE.perl in the dependency chain).

giordano commented 1 year ago

What platform is that? Bit weird that perl is referencing ${libdir}/libperl.so. Also, what is

type perl

?

Roger-luo commented 1 year ago
sandbox:${WORKSPACE}/srcdir/biber # type perl
perl is /usr/bin/perl

the platform is linux_x86_64_musl

Roger-luo commented 1 year ago

also if you try to run perl's package manager, it also errors

sandbox:${WORKSPACE}/srcdir/biber # cpan App::cpanminus
Loading internal logger. Log::Log4perl recommended for better logging
Attempt to reload Time/HiRes.pm aborted.
Compilation failed in require at /workspace/x86_64-linux-gnu-libgfortran3-cxx03/artifacts/07ef9c18296d78f06f5b946ed2c127b4aae6ac2c/lib/perl5/5.34.0/Net/Ping.pm line 20.
BEGIN failed--compilation aborted at /workspace/x86_64-linux-gnu-libgfortran3-cxx03/artifacts/07ef9c18296d78f06f5b946ed2c127b4aae6ac2c/lib/perl5/5.34.0/Net/Ping.pm line 20.
Compilation failed in require at /workspace/x86_64-linux-gnu-libgfortran3-cxx03/artifacts/07ef9c18296d78f06f5b946ed2c127b4aae6ac2c/lib/perl5/5.34.0/CPAN/Mirrors.pm line 42.
BEGIN failed--compilation aborted at /workspace/x86_64-linux-gnu-libgfortran3-cxx03/artifacts/07ef9c18296d78f06f5b946ed2c127b4aae6ac2c/lib/perl5/5.34.0/CPAN/Mirrors.pm line 42.
Compilation failed in require at /workspace/x86_64-linux-gnu-libgfortran3-cxx03/artifacts/07ef9c18296d78f06f5b946ed2c127b4aae6ac2c/lib/perl5/5.34.0/CPAN/FirstTime.pm line 11.
BEGIN failed--compilation aborted at /workspace/x86_64-linux-gnu-libgfortran3-cxx03/artifacts/07ef9c18296d78f06f5b946ed2c127b4aae6ac2c/lib/perl5/5.34.0/CPAN/FirstTime.pm line 11.
Compilation failed in require at /workspace/x86_64-linux-gnu-libgfortran3-cxx03/artifacts/07ef9c18296d78f06f5b946ed2c127b4aae6ac2c/lib/perl5/5.34.0/CPAN/HandleConfig.pm line 591.
benlorenz commented 1 year ago

The reason for these symbol errors are a mix of two things:

Then the system perl binary will not use its own rpath of /usr/lib/perl5/core_perl/CORE to load libperl but load the version for the target architecture. This seems to cause the __snprintf_chk: symbol not found errors for a -gnu target on the musl host.

And the cpan command you are trying to run is a target-cpan which seems to load some host-libraries.

If pp would be just for building then installing it from the alpine repositories (apk add perl-par-packer) should work. Once the LD_LIBRARY_PATH is cleaned up a bit:

sandbox:${WORKSPACE}/srcdir # LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | sed -e 's#:/workspace[^:]*##g')
sandbox:${WORKSPACE}/srcdir # apk add perl-par-packer
(1/6) Installing perl-archive-zip (1.68-r1)
(2/6) Installing perl-par-dist (0.51-r0)
(3/6) Installing perl-par (1.017-r0)
(4/6) Installing perl-module-scandeps (1.31-r0)
(5/6) Installing perl-getopt-argvfile (1.11-r3)
(6/6) Installing perl-par-packer (1.052-r3)
Executing busybox-1.34.1-r3.trigger
OK: 294 MiB in 123 packages

sandbox:${WORKSPACE}/srcdir # pp --help
PAR Packager, version 1.052 (PAR version 1.017)

No documentation found for "/usr/bin/pp".

With all that being said, I don't think pp will work for building biber: pp will create fancy self-extracting archives which package all the required system and perl libraries, but to create these I think it needs to run on the target system.

Perl is unfortunately very bad for cross-compilation. The Perl_jll was mostly created to get polymake_jll working and I added a few required perl modules directly in the build-recipe for Perl_jll. I have never tried to build extra modules on top as usually perl relies on running the build scripts with exactly the same perl (version+arch) as the target which doesn't really work in BinaryBuilder.

The BUILDERS.README in the biber repository does claim:

For developers and the more adventurous, Biber can be run as a raw perl
program from the github source and this requires perl to be installed.
After fetching the github sources, run "perl Build.PL" and then "Build
installdeps" to check the minimum perl requirements and install all
required modules.

This is the way debian builds biber, but this approach is also problematic as this perl Build.PL will probably only build for exactly this perl which will (at least by default) only work for native platforms. Maybe we can trick this approach into installing the correct versions by combining a Dependency and a HostBuildDependency. At the end we will also need to find a way to make sure the biber perl script finds the correct perl and perl modules.