Configure compilation targets and output
mainThe compiler's behavior is heavily influenced by the Prefs object (imported internally) and environment variables. While the main function accepts a module name, the target and output file are typically controlled via Prefs or CLI arguments.
Key Configuration Concepts:
- Targeting C: If the target is set to
'c', the compiler will either write the C code toPrefs.o(if provided), print it to stdout, or useuwebsockets.writeNativeFetchPackageifPrefs.nativeFetchis enabled. - Targeting Native: If the target is set to
'native', the compiler invokes a system compiler (likecc,gcc, orclang) or an embeddedtccto produce an executable. - Compiler Selection: The system compiler can be configured via
Prefs.compileror theCCenvironment variable. The C++ compiler is configured viaPrefs.cxxorCXX. - Optimization: Optimization levels can be passed via the
-Oflag in command line arguments (e.g.,-O3).