Categories

Posts in this category

Tue, 05 May 2009

My first executable from Perl 6


Permanent link

In various occasions I have been asked if "Perl 6 compiles programs into real executables" or so.

The answer so far has always been the same: Perl 6 is a language specification, and it's up to the implementations if they offer that option, it's not a required feature.

But today I actually compiled a Perl 6 program into an executable, with Rakudo. It's not automated, so it takes a few steps, but it would be easy to wrap into a shell script or Makefile. Here it goes:

$ cat hello.pl
say "Hello, Perl people";
$ ./perl6 --target=PIR hello.pl > hello.pir
$ ./parrot/parrot -o hello.pbc hello.pir
$ ./parrot/pbc_to_exe hello.pbc > hello
$ file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped
$./hello
Hello, Perl people

This is what the Parrot folks call a "fake executable" - it contains the byte code as a string, links to libparrot, and has a small main program that initializes parrot. But hey, it's an executable ;-)

[/perl-6] Permanent link