Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to compile perl6 program to generate bytecode?

I am trying to understand perl6 and its changes than perl5. I come to know that perl 6 is compiled languages but I am not getting how? It is not generating any intermediate code (directly executable or jvm bytecode)? I am not getting any option to do the same. How to do it?

Currently I am able to directly execute my code.

$ perl6-j hello.p6
Hello world

I am following https://github.com/rakudo/rakudo

like image 598
Gaurav Pant Avatar asked Aug 14 '16 05:08

Gaurav Pant


1 Answers

You can use --target= on the perl6 command line to see a human readable trace of each stage of the compiler. On JVM if you wish to have a "compiled" bytecode output you can use --target=jar and then take a look inside there. But ultimately Perl 6 compiles on the fly unless asked otherwise. It leaves a bytecode representation cached in library path directories of each "CompUnit", so that the compile step is faster next time. This can be seen in .precomp directories. The precomp cache is very tricky to use by hand due to how Perl 6 hashes and indexes all comp units. This is so libraries with the same name but different version and author can sit side by side. On MoarVM there is no equivalent to --target=jar but in the .precomp directory you can see the raw bytecode files that can be directly executed by moar if you link the runtime setting.

like image 175
Matt Oates Avatar answered Sep 27 '22 22:09

Matt Oates