B-C
view release on metacpan or search on metacpan
perlcompile.pod view on Meta::CPAN
=head3 Bytecode Invocation Examples
perl -MO=Bytecode,-O6,-H,-ofoo.plc foo.pl
./foo.plc
perl -MO=Bytecode,-S foo.pl > foo.S
assemble foo.S > foo.plc
perl -MByteLoader foo.plc
perl -MO=Bytecode,-m,-oFoo.pmc Foo.pm
=head2 The Optimized C Backend
The C<B::CC> optimized C backend will turn your Perl program's run time
code-path into an equivalent (but optimized) C program that manipulates
the Perl data structures directly. The program will still link against
the Perl interpreter library, to allow for eval(), C<s///e>,
C<require>, etc.
The C<perlcc> tool generates such executables when using the C<-O>
switch. To compile a Perl program (ending in C<.pl> or C<.p>):
perlcc -O myperlprogram.pl
To produce a shared library from a Perl module (ending in C<.pm>):
perlcc -O Myperlmodule.pm
=head3 CC Backend Invocation
If there are any non-option arguments, they are taken to be names of
subs to be saved. Without extra arguments, it saves the main program.
B::C takes all B::C options plus a few new ones:
-D Debug options (concat or separate flags like perl -D)
o Enable B debugging
r Writes debugging output to STDERR just as it's about
to write to the program's runtime. Otherwise writes
debugging info as comments in its C output.
O Outputs each OP as it's compiled
s Outputs the contents of the shadow stack at each OP
p Outputs the contents of the shadow pad of lexicals as
it's loaded for each sub or the main program.
q Outputs the name of each fake PP function in the queue
as it's about to processes.
l Output the filename and line number of each original
line of Perl code as it's processed (pp_nextstate).
t Outputs timing information of compilation stages
-f Force optimisations on or off one at a time.
cog Copy-on-grow: PVs declared and initialised statically
freetmps-each-bblock Delays FREETMPS from the end of each
statement to the end of the each basic
block.
freetmps-each-loop Delays FREETMPS from the end of each
statement to the end of the group of
basic blocks forming a loop. At most
one of the freetmps-each-* options can
be used.
no-inline-ops Turn off aggressive inlining of ops
omit-taint Omits generating code for handling
perl's tainting mechanism.
-On Optimisation level (n = 0, 1, 2, ...). -O means -O1.
-O1 -ffreetmps-each-bblock
-O2 -O1 -ffreetmps-each-loop
All B::C -O3 optimisations are automatically used.
=head3 CC Invocation Example
perl -MO=CC,-O2,-ofoo.c foo.pl
perl cc_harness -o foo foo.c
perl -MO=CC,-mFoo,-oFoo.c Foo.pm
perl cc_harness -shared -c -o Foo.so Foo.c
perlcc -O myperlprogram.pl
perlcc -O MyperlModule.pm
See also L<perlcc> and L<B::CC>.
=head2 Backends For Debugging
perl -MO=Terse,exec foo.pl
perl -MO=Debug bar.pl
=head1 Module List for the Compiler Suite
=over 4
=item B
This module is the introspective ("reflective" in Java terms)
module, which allows a Perl program to inspect its innards. The
backend modules all use this module to gain access to the compiled
parse tree. You, the user of a backend module, will not need to
interact with B.
=item O
This module is the front-end to the compiler's backends. Normally
called something like this:
$ perl -MO=Deparse,-q myperlprogram
This is like saying C<use O 'Deparse' qw(-q)> in your Perl program.
Used with "perl -MO=Backend,-foo,-obar prog.pl" to invoke the backend
B::Backend with options -foo and -obar. O invokes the sub
B::Backend::compile() with arguments -foo and -obar at BEGIN time.
That compile() sub must do any inital argument processing replied.
If unsuccessful, it should return a string which O arranges to be
printed as an error message followed by a clean error exit. In the
normal case where any option processing in compile() is successful,
it should return a sub ref (usually a closure) to perform the
actual compilation. When O regains control, it ensures that the
"-c" option is forced (so that the program being compiled doesn't
end up running) and registers a CHECK block to call back the sub ref
returned from the backend's compile(). Perl then continues by
parsing prog.pl (just as it would with "perl -c prog.pl") and after
doing so, assuming there are no parse-time errors, the CHECK block
of O gets called and the actual backend compilation happens. Phew.
( run in 2.509 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )