Roadsend PHP: Raven (rphp)
This is the development site for the rewrite of Roadsend PHP (rphp), based on LLVM and a new C++ runtime. It is an open source, liberally licensed project.
A mailing list is available at http://mail.roadsend.com/mailman/listinfo/rphp-devel
You can find the latest summary on recent developments on the Development Blog.
Features/Goals include:
- Highly optimized, JIT or static compiled native binaries (via LLVM)
- PHP source level analysis and optimization
- Rich diagnostics and error messages
- Modular design
- Clean and easy runtime and extension API
- Full unicode support
- Latest language features (e.g. PHP5 objects, exceptions, namespaces, lambda functions, etc)
- Portability, Speed, Security
Unlike our previous project, we are not aiming for 100% compatibility with Zend Engine based PHP. A page with (planned) language differences is here.
Current Status
- CMake build system
- Runtime library
- Runtime variable representation
- Port of basic runtime system layout
- Standard Extension started
- Commandline front end
- Compile stand alone
- Run in JIT
- Compiler and Analysis
- Full unicode preprocessor/lexer/parser in place
- Pass system for AST tree traversal and transforming
- Some code (IR) generation (detailed progress list coming soon)
- Static analyzer which dumps (in XML)
- Tokens
- AST
- Generated IR
- Various analysis passes
- Port of phc optimizer passes
- Runtime Test Suite (CppUnit? and PHP based)
Development currently takes place on Linux x86 (32 and 64) and OSX, but other platforms will be supported.
If you are looking for a fully functioning PHP compiler that works right now, please see our original implementation instead.
If you'd like to contribute, please contact us or join us in #roadsend on irc.freenode.net
Requires
- LLVM 2.6+, and llvm-g++ 4.2
- Boost 1.38+ (only headers required, no libraries)
- CMake 2.6+
- ICU 4.2+
- GMP 4.3.1+
Docs
Source
Browse the source at: http://code.roadsend.com/rphp/browser/trunk/rphp
Checkout the source with:
svn co http://code.roadsend.com/svn/pcc/trunk/rphp
Checkout the rphp testsuite with:
svn co http://code.roadsend.com/svn/pcc/trunk/rphp-testsuite
There is a git repository tracking the svn repo here:
git clone git://gitorious.org/rphp/rphp.git
Build
rphp uses the CMake build system. Basic *nix instructions:
- create "build" directory inside of rphp
- in the build directory, type "cmake .."
- make
Note that an in-tree build is not recommended, you should create a separate build directory.
- NOTE: There is a bug in LLVM 2.6 preventing rphp/lib/c-runtime.bc from working without first running rphp/lib/llvm-2.6-fixup.sh. This has been fixed in 2.7svn
Sample Checkout and Build Session
Assuming you have the prerequisites installed, a sample checkout and build session might look like this:
~$ svn co http://code.roadsend.com/svn/pcc/trunk/rphp (... svn file checkout ...) ~$ cd rphp ~rphp/$ mkdir build ~rphp/$ cd build ~rphp/build$ cmake .. (... output ...) ~rphp/build$ make (... build output ...)
All of the build files (including libraries and executables that are built) will be underneath this build directory.
Running
PLEASE NOTE that code generation is currently disabled while we finish rewriting the front end. Try rphp-analyzer instead!
Before running, setup some environment variables so rphp can find its library files. The following is a .bashrc excerpt, but what's important is to define RPHP_IR_PATH, RPHP_RUNTIME_PATH, and LD_LIBRARY_PATH if you wan to try both compiling and interpreting.
RPHP_PATH=~/rphp RPHP_IR_PATH=$RPHP_PATH/lib RPHP_RUNTIME_PATH=$RPHP_PATH/build/runtime/ LD_LIBRARY_PATH=$RPHP_RUNTIME_PATH:$LD_LIBRARY_PATH export RPHP_IR_PATH RPHP_RUNTIME_PATH LD_LIBRARY_PATH
The compiler binaries will be located in the build directory in frontend/cli/. "rphp" is the compiler and JIT interpreter. To execute a source file immediately (using JIT):
$ frontend/cli/rphp -f helloworld.php
To compile to a binary and run native:
$ frontend/cli/rphp helloworld.php $ ./helloworld
To dump the various passes:
rphp-analyzer --dump-toks <file> rphp-analyzer --dump-ast <file> rphp --dump-ir <file>
