PERLCC(1)
π PERLCC(1) β perlcc is literally that girl π
okay so welcome to the perlcc manual, bestie. this is the whole page for PERLCC(1), and we're gonna get through it together because you deserve to understand it. no cap. π
πΈ NAME πΈ
perlcc β generate executables from Perl programs.
periodt. that's the name.
β¨ SYNOPSIS β¨
bestie, here's the whole mood board of invocations. every line is a real example, so keep the spelling exactly as shown:
perlcc hello.pl # Compiles into executable 'a.out'
perlcc -o hello hello.pl # Compiles into executable 'hello'
perlcc -O file.pl # Compiles using the optimised CC backend
perlcc -O3 file.pl # Compiles with C, using -O3 optimizations
perlcc -B file.pl # Compiles using the bytecode backend
perlcc -B -m file.pm # Compiles a module to file.pmc
perlcc -c file.pl # Creates a C file, 'file.c'
perlcc -S -o hello file.pl # Keep C file
perlcc -c out.c file.pl # Creates a C file, 'out.c' from 'file'
perlcc --staticxs -r -o hello hello.pl # Compiles,links and runs with
# XS modules static/dynaloaded
perlcc -e 'print q//' # Compiles a one-liner into 'a.out'
perlcc -c -e 'print q//' # Creates a C file 'a.out.c'
perlcc -I /foo hello # extra headers for C
perlcc -L /foo hello # extra libraries for C
perlcc --Wb=-Dsp # extra perl compiler options
perlcc -fno-delete-pkg # extra perl compiler options
perlcc --Wc=-fno-openmp # extra C compiler options
perlcc --Wl=-s # extra C linker options
perlcc -uIO::Socket # force saving IO::Socket
perlcc -UB # "unuse" B, compile without any B symbols
perlcc -r hello # compiles 'hello' into 'a.out', runs 'a.out'
perlcc -r hello a b c # compiles 'hello' into 'a.out', runs 'a.out'
# with arguments 'a b c'
perlcc hello -log c.log # compiles 'hello' into 'a.out', log into 'c.log'
perlcc -h # help, only SYNOPSIS
perlcc -v2 -h # verbose help, also DESCRIPTION and OPTIONS
perlcc --version # prints internal perlcc and the B-C release version
π DESCRIPTION π
okay so perlcc creates standalone executables from Perl programs, using the code generators provided by the B module. at present, you may either create executable Perl bytecode, using the -B option, or generate and compile C files using the standard and 'optimised' C backends. that's the whole deal. π
now the serious part, bestie: the code generated in this way is not guaranteed to work. the whole codegen suite (perlcc included) should be considered very experimental. use for production purposes is strongly discouraged. like, fr fr, do not ship this to prod and expect main character energy. π
π OPTIONS π
-LClibrary directories β adds the given directories to the library search path when C code is passed to your C compiler. for multiple paths use multiple-Loptions.-ICinclude directories β adds the given directories to the include file search path when C code is passed to your C compiler; when using the Perl bytecode option, adds the given directories to Perl's include path. for multiple paths use multiple-Ioptions.-ooutput file name β specifies the file name for the final compiled executable.
without a given output file name we use the base of the input file, or with -e a.out resp. a.exe and a randomized intermediate C filename. if the input file is an absolute path on a non-windows system use the basename.
-cC file name β create C file only; do not compile and link to a standalone binary.-eperl code β compile a one-liner, much the same asperl -e '...'--checkβ pass-cflag to the backend, prints all backend warnings toSTDOUTand exits before generating and compiling code. similar toperl -c.--crosspathto/config.sh β use a different%B::C::Configfrom anotherconfig.shfor cross-compilation. passes-cross=pathto the backend.-Sβ "Keep source". do not delete generated C code after compilation.-Bβ use the Perl bytecode code generator.--debugor-Dβ shortcut for--Wb=-Dfull -Sto enable all debug levels and also preserve source code; also view--Wbto enable some specific debugging options.-Oβ use the 'optimised' C code generatorB::CC. this is more experimental than everything else put together, and the code created is not guaranteed to compile in finite time and memory, or indeed, at all. π-O1-4β pass the numeric optimisation option to the compiler backend. shortcut for-Wb=-On.
this does not enforce B::CC.
-v0-6 β set verbosity of output from 0 to max. 6.-rβ run the resulting compiled script after compiling it.--loglogfile β log the output of compiling to a file rather than tostdout.-f<option>or--f=<option>β pass the options to the compiler backend, such as-fstashor-fno-delete-pkg.--Wb=optionsβ pass the options to the compiler backend, such as--Wb=-O2,-v.--Wc=optionsβ pass comma-seperated options tocc.--Wl=optionsβ pass comma-seperated options told.-Tor-tβ run the backend usingperl -Tor-t.-Aβ allow perl options to be passed to the executable first, like-D....
adds -DALLOW_PERL_OPTIONS which omits -- from being added to the options handler.
-upackage β add package(s) to compiler and force linking to it.-Upackage β skip package(s). do not compile and link the package and its sole dependencies.--stashβ detect external packages automatically viaB::Stash.--staticβ link to staticlibperl.a.--staticxsβ link to static XS if available. if the XS libs are only available as shared libs link to those (prelink).
systems without rpath (windows, cygwin) must extend LD_LIBRARY_PATH/PATH at run-time. together with -static, purely static modules and no run-time eval or require this will gain no external dependencies.
--sharedβ link to sharedlibperl.--sharedxsβ link shared XSUBs if the linker supports it. noDynaLoaderneeded. this will still require the shared XSUB libraries to be installed at the client, modification of@INCin the source is probably required. (Not yet implemented)-m/--sharedlib[Modulename] β create a module, resp. a shared library. currently only enabled for Bytecode and CC. (not yet tested)--testsuiteβ tries to be nice toTest::modules, like preallocating the file handles 4 and 5, and munge the output ofBEGIN.
perlcc -r --testsuite t/harness
--timeβ benchmark the different phasesc(B::*compilation),cc(cccompile + link), andr(runtime).--no-spawnβ do not spawn subprocesses for compilation, because broken shells might not be able to kill its children.
okay that's the whole page, bestie β brought to you by perl v5.42.3, dated 2019-05-07, and the manual name is PERLCC(1). mwah π
π¦ where this page comes from
- nixos 26.05: perl5.42.3-B-C 1.57
- nixpkgs unstable: perl5.42.3-B-C 1.57
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms