B-C

 view release on metacpan or  search on metacpan

perlcompile.pod  view on Meta::CPAN

for that particular platform using a C compiler.  The resulting
program links against the Perl interpreter library, so it
will not save you disk space (unless you build Perl with a shared
library) or program size. It may, however, save you startup time.

The C<perlcc> tool generates such executables by default.

  perlcc myperlprogram.pl

=head3 C Backend Invocation

If there are any non-option arguments, they are taken to be
names of objects to be saved (probably doesn't work properly yet).
Without extra arguments, it saves the main program.

        -q 		Be quiet. STDOUT goes to $O::BEGIN_output
        -qq		Be very quiet. Also suppress "Syntax OK"
	-o<filename>	Output to filename instead of STDOUT
	-v		Be verbose. Currently gives a few compilation statistics.
	--		Force end of options
	-u<package>	use package or filename. Force apparently unused subs from
                        package to be compiled. This allows programs to use run-time
                        eval "foo()" even when sub foo is never seen to be used at compile
			time. The down side is that any subs which really are
			never used also have code generated. This option is
			necessary, for example, if you have a signal handler
			foo which you initialise with $SIG{BAR} = "foo".
			A better fix, though, is just to change it to
			$SIG{BAR} = \&foo. You can have multiple -u or -U options.
        -U<package>     Unuse package or filename. Ignore all subs from package to be compiled.
                        Certain packages might not be needed at run-time, even if the
                        pessimistic walker detects it. If required those packages will be
                        run-time loaded then.
	-e ARG		Eval ARG at startup
        -c              Check and abort (used to print warnings)
NYI	-w		Warn on undefined SYMs
	-l LIMIT	Force max linelength to LIMIT (e.g. MSVC to 2048)
	-D		Debug options (concat or separate flags like perl -D)
		o	Print walkoptree OPs
		O	Prints more OP information
		c	COPs, prints COPs as processed (incl. file & line num)
		S	prints SV/RE information on saving
		A	prints AV information on saving
		C	prints CV information on saving
		M	prints MAGIC information on saving
		G	prints GV information on saving
		u       Do not print -D information when parsing unused subs.
	-f		Force optimisations on or off one at a time.
		cog		Copy-on-grow: PVs declared and initialised statically
		no-cog		No copy-on-grow
		save-data	Save package::DATA filehandles ( only available with PerlIO::scalar )
		ppaddr		Optimize the initialization of op_ppaddr.
		warn-sv		Optimize the initialization of cop_warnings.
		av-init		Faster initialization of AVs.
		av-init2	Initialization of AVs via ptmalloc3 independent_comalloc().
		use-script-name	Use the script name instead of the program name as $0.
                ro-inc          Readonly @INC and %INC pathnames.
                const-strings   Declares static readonly strings as const.
		save-sig-hash	Save compile-time modifications to the %SIG hash.
                no-destruct     Faster destruction.
                no-fold         Do not compile unicode foldings tables, needed for m//i
                no-warnings     Do not compile warnings hashes.
                stash           Add all stash hashes even if not used.
                no-delete-pkg   Do not delete compiler-internal and dependent packages.
                no-dyn-padlist  Disable dynamic padlists (5.18). This is faster but might cause
                                die and exit to crash.
		cop		Omit COP, no file+line info for warnings
	-On		Optimisation level (n = 0, 1, 2, ...). -O means -O1.
	  	-O1	-fcog -fav-init2/-fav-init -fppaddr -fwarn-sv
		-O2	-O1 -fro-inc -fsave-data
		-O3     -O2 -fsave-sig-hash -fno-destruct fconst-strings
		-O4     -O3 -fcop -fno-dyn-padlist

=head3 C Examples
	perl -MO=C foo.pl > foo.c
	perl cc_harness -o foo foo.c

	perl -MO=C,-v,-DcA bar.pl > /dev/null

For more information, see L<perlcc> and L<B::C>.

=head2 The Bytecode Backend

This backend is only useful if you also have a way to load and execute the
bytecode that it produces. The L</ByteLoader> module provides this
functionality.

To turn a Perl program into executable byte code, you can use C<perlcc>
with the C<-B> switch:

  perlcc -B myperlprogram.pl

The byte code is machine independent, so once you have a compiled
module or program, it is as portable as Perl source (assuming that
the user of the module or program has a modern-enough Perl interpreter
to decode the byte code).

=head3 Bytecode Backend Invocation

If there are any non-option arguments, they are taken to be
names of objects to be saved (probably doesn't work properly yet).
Without extra arguments, it saves the main program.

        -q 		Be quiet. STDOUT goes to $O::BEGIN_output
        -qq		Be very quiet. Also suppress "Syntax OK"
	-ofilename	Output to filename instead of STDOUT.
NYI	-v              Be verbose.
	--		Force end of options.
NYI	-f		Force optimisations on or off one at a time.
			Each can be preceded by no- to turn the option off.
		compress-nullops
			Only fills in the necessary fields of ops which have
			been optimised away by perl's internal compiler.
		omit-sequence-numbers
			Leaves out code to fill in the op_seq field of all ops
			which is only used by perl's internal compiler.
		bypass-nullops
			If op->op_next ever points to a NULLOP, replaces the
			op_next field with the first non-NULLOP in the path
			of execution.
	-s              strip-syntax-tree



( run in 2.010 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )