Warning
PSXQCC is still work-in-progress and does not yet support the entire QuakeC language correctly.
Current focus is on getting it to work with the original Quake game sources without spending too much time on compiled programs being memory safe. This means that you shouldn't use this to compile and run untrusted code.
QuakeC compiler targeting native code using LLVM.
PSXQCC can be used to compile QuakeC sources into object or assembly files, which can then be linked directly into a modified Quake engine. This allows the QuakeC VM to be removed from the engine, saving memory and improving performance.
Due to the fact that PSXQCC uses LLVM, then PSXQCC supports generating code for
all platforms supported by LLVM. Use the command line option --target to specify
the target triple and the command line option --float-abi to select a float ABI.
My port of the Quake 1 to the PlayStation 1 uses 8 MiB of memory, retail units only have 2 MiB of memory installed. Being able to remove the QuakeC VM would free up some memory and CPU time.
But mostly I guess I just needed an excuse to use LLVM in a project, as it would've been faster to rewrite the QuakeC sources to C by hand :).
Usage: psxqcc [options...]
Options:
--src,--source : Path for to search for progs.src in [default: ]
-i,--input : Input file path to compile, probably useful only for psxqcc tests [default: ]
-o,--output : Override output file path (without file extension) [default: ]
--builtin : Input file path containing a list of built-ins that will be provided by the engine [default: ]
-f,--format : Output format [allowed: <object, assembly>, default: OBJECT]
-t,--target : Target triple to pass to LLVM, by default host system [default: ]
--float-abi : Select the float ABI type [allowed: <hard, soft, softfp>, default: HARD]
--save-ir : Target file to save the generated LLVM IR to [default: ]
--O0 : Optimization level 0 [implicit: "true", default: false]
--O1 : Optimization level 1 [implicit: "true", default: false]
--O2 : Optimization level 2 [implicit: "true", default: false]
--O3 : Optimization level 3 [implicit: "true", default: false]
--Os : Optimize for size [implicit: "true", default: false]
--Oz : Optimize for size at the cost of speed [implicit: "true", default: false]
-?,-h,--help : print help [implicit: "true", default: false]Before being able to build the project you'll need to install LLVM and a C++ compiler supporting at least C++23 on your system.
At the moment of writing PSXQCC is developed against LLVM 21. If I forget to update the LLVM version number then just check which LLVM version was the current one in Arch Linux repos when the last commit was made.
Note
If you wish to use a non-system LLVM installation (e.g. a locally compiled one
with debug symbols) then you can use the CMake options PSXQCC_LLVM_PATH and
PSXQCC_LLVM_LIBRARY_NAME to configure it.
-
Fetch the code;
-
Generate the build system using CMake:
cmake -S . -B ./build -G "Ninja"- Build the project:
cmake --build ./build- (Optional) Run the tests to verify that the compiler is able to correctly compile programs:
ctest --test-dir ./build