-
Notifications
You must be signed in to change notification settings - Fork 1
Quickstart Guide To Hacking On Piledriver
-
./Configure -des -Dusethreads(configure with threads) -
make(build perl) -
make testormake minitest(confirm everything works) - Make your change.
-
make testormake minitest
Perl does not use the normal configure that other C programs use. It uses Configure with completely different options. Things like --prefix will not work. Instructions can be found scattered through INSTALL. The general configure command you want to run is...
./Configure -des -Dusethreads
-des will configure Perl with the defaults without prompting you. -Dusethreads will configure Perl with threads; it's important to have them on while developing because code which works without threads might not work with them.
make works normally.
make test works normally.
Parallel testing can be used with TEST_JOBS=N make test_harness. A good number is your number of cores + 1.
Individual tests can be run with ./perl -Ilib t/blah.t.
Building all of Perl's standard libraries can take a while. If you're working on core Perl functionality, you can build and test miniperl. This can save a lot of time.
Instead of make run make miniperl.
Instead of make test run make minitest.
One does not simply walk into Mordor and one does not simply write C functions in Perl.
Non-static functions should be named with a Perl_ prefix to avoid collisions with other functions. They can usually be called without that prefix. If you define Perl_foo you can call it as just foo... sometimes.
Adding, removing or changing the signature of a C function must also be reflected in embed.fnc. Then you must rebuild a bunch of header files with make regen and then rebuild.
- Add, remove or change the signature of a function.
- Reflect that change in embed.fnc.
-
make regenand thenmakeormake miniperl.
This system takes care of generating header files for embedding Perl and for XS use. It also adds an extra layer of argument checks on top of C's type system. It also takes care of the Perl_foo to foo conversion.
The documentation for what the various flags mean are is in embed.fnc.
It's not a very friendly system. Sorry.
These are magic macros for Perl's threading. Rule of thumb is when declaring a function add pTHX_ in front of the signature.
SV *Perl_foo(pTHX_ SV *stuff) {
...
}
When calling a Perl_... function add aTHX_ to the argument list.
Perl_foo(aTHX_ things);
If you call a Perl_ function without the prefix, you don't need aTHX_.
foo(things);