Lou
Lou

Reputation: 2509

How to compile a Perl file to be executable on multiple architectures?

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.

Upvotes: 3

Views: 351

Answers (0)

Related Questions