2

I'm trying to compile Perl so that it can run on both Arm architecture and x86_64 machines, using pp. I see from the documentation that Perl has a -m or --multiarch option, which will compile a Perl file into a PAR that can be run on multiple architectures.

-m, --multiarch Build a multi-architecture PAR file. Implies -p.

-p, --par Create PAR archives only; do not package to a standalone binary.

But as it says, this produces a PAR, not an executable. I don't know how to make this into an executable I can run on multiple architectures.

So let's say I want to compile my simple hello.pl file:

#!/usr/bin/perl

use warnings;
print("Bonjour!\n");

First I tried:

pp -S -m -o hello hello.pl

I thought that this would still convert hello.pl into a PAR and then convert the PAR into an executable, based on the example in the docs where it converts a .pl to a PAR, then a PAR into an executable in a single step:

% pp -p file                # Creates a PAR file, 'a.par'
% pp -o hello a.par         # Pack 'a.par' to executable 'hello'
% pp -S -o hello file       # Combine the two steps above

But that's not what happens. The resulting output is still a ZIP:

$ file hello    
hello: Zip archive data, at least v2.0 to extract

How can I compile the .pl so that it results in an executable that runs on multiple architectures including Arm, not just x86?

EDIT: The environment is RHE7 (Linux). I only want to run the perl scripts on Linux, not Mac or Windows, but want to target Linux machines that run both arm architecture and x86_64 architecture.

Lou
  • 2,200
  • 2
  • 33
  • 66
  • See also [Install & update a Perl module as "universal" (x86_64, arm64)?](https://stackoverflow.com/q/75983186/2173773) – Håkon Hægland May 12 '23 at 18:16
  • When you say x86, do you still mean macOS, or do you mean for any x86 architecture, like Linux or Windows? If the latter, you can’t do it! If the former, only reading the docs above, sounds like you can’t, but if you’re talking macOS (again, not clear!), just build it as x86, it will run under Rosetta 2 on ARM boxes. – jimtut May 13 '23 at 10:54
  • @jimtut - It should run on Linux only, but support x86_64 and arm architectures. – Lou May 14 '23 at 07:27
  • wouldnt you need to build seperate exe files for each architecture as they wont compile the same way – Chris Doyle May 14 '23 at 07:50
  • I was under the impression you could create a cross-compatible exe, but if that's not the case I guess that answers the question a different way. – Lou May 15 '23 at 11:12
  • In which case I would need to create both exes and select when running the script which one to use based on the architecture of the running machine – Lou May 15 '23 at 11:13

0 Answers0