XS::TCC - Embed, wrap & compile C code in Perl without going to disk
# WARNING interface is bound to change... use XS::TCC qw(tcc_inline); tcc_inline q{ int foo(int bar) { return bar * 2; } }; print foo(3.1), "\n"; # prints 6.2 # more elaborate functions involving Perl types work as well
This is a highly experimental module. Use at your own risk. Get in touch with the author(s) if in doubt.
XS::TCC allows you to embed C code into your Perl that is compiled and linked on the fly, in memory, without ever touching your disk except to read the Perl code in the first place. This amazing feat actually has very little to do with this module's code but rather with TCC (TinyCC, see tinycc.org) which allows compilation and linking in memory.
XS::TCC
On my first-gen core i5 laptop, making two small-medium size functions available to Perl takes around 30ms including parse, wrapper code generation, typemapping, compilation, linking, and XSUB installation. Wrapping more code is bound to be relatively faster.
The output of TCC is slower than the equivalent function compiled with GCC, but both beat regular Perl by a wide margin {citation required}.
Alien::TinyCC
C::TinyCompiler
C::TCC
Inline and Inline::C
ExtUtils::ParseXS and ExtUtils::Typemaps
Steffen Mueller <smueller@cpan.org>
With much appreciated contributions from:
Tokuhiro Matsuno
David Mertens
Copyright (C) 2013, 2014 by Steffen Mueller
XS::TCC is distributed under the GNU Lesser General Public License (see COPYING file).
To install XS::TCC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XS::TCC
CPAN shell
perl -MCPAN -e shell install XS::TCC
For more information on module installation, please visit the detailed CPAN module installation guide.