mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
22
resources/examples/nolibc-freebsd/hello_world.c3
Normal file
22
resources/examples/nolibc-freebsd/hello_world.c3
Normal file
@@ -0,0 +1,22 @@
|
||||
fn int main()
|
||||
{
|
||||
String msg = "Hello, C3 World!\n";
|
||||
$$syscall(4, 1, (uptr)msg.ptr, msg.len); // __NR_write, STDOUT
|
||||
return 0;
|
||||
}
|
||||
|
||||
fn void _start() @export("_start")
|
||||
{
|
||||
int ret = main();
|
||||
$$syscall(1, ret); // __NR_exit
|
||||
}
|
||||
|
||||
module std::core::builtin;
|
||||
|
||||
def PanicFn = fn void(String message, String file, String function, uint line);
|
||||
|
||||
PanicFn panic = &default_panic;
|
||||
|
||||
fn void default_panic(String message, String file, String function, uint line)
|
||||
{
|
||||
}
|
||||
79
resources/examples/nolibc-freebsd/project.json
Normal file
79
resources/examples/nolibc-freebsd/project.json
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
// Language version of C3.
|
||||
"langrev": "1",
|
||||
// Warnings used for all targets.
|
||||
"warnings": [ "no-unused" ],
|
||||
// Directories where C3 library files may be found.
|
||||
"dependency-search-paths": [ ],
|
||||
// Libraries to use for all targets.
|
||||
"dependencies": [ ],
|
||||
// Authors, optionally with email.
|
||||
"authors": [ "John Doe <john.doe@example.com>" ],
|
||||
// Version using semantic versioning.
|
||||
"version": "0.1.0",
|
||||
// Sources compiled for all targets.
|
||||
"sources": [ "./**" ],
|
||||
// C sources if the project also compiles C sources
|
||||
// relative to the project file.
|
||||
// "c-sources": [ "csource/**" ],
|
||||
// Output location, relative to project file.
|
||||
"output": ".",
|
||||
// Architecture and OS target.
|
||||
// You can use 'c3c --list-targets' to list all valid targets.
|
||||
"target": "freebsd-x64",
|
||||
// Targets.
|
||||
"targets": {
|
||||
"hello_world": {
|
||||
"type": "executable",
|
||||
"debug-info": "none",
|
||||
"link-libc": false,
|
||||
"opt": "O0",
|
||||
"safe": false,
|
||||
"linker": "builtin",
|
||||
"use-stdlib": false,
|
||||
},
|
||||
},
|
||||
// Global settings.
|
||||
// C compiler if the project also compiles C sources
|
||||
// defaults to 'cc'.
|
||||
"cc": "cc",
|
||||
// CPU name, used for optimizations in the LLVM backend.
|
||||
"cpu": "generic",
|
||||
// Debug information, may be "none", "full" and "line-tables".
|
||||
"debug-info": "full",
|
||||
// FP math behaviour: "strict", "relaxed", "fast".
|
||||
"fp-math": "strict",
|
||||
// Link libc other default libraries.
|
||||
"link-libc": true,
|
||||
// Memory environment: "normal", "small", "tiny", "none".
|
||||
"memory-env": "normal",
|
||||
// Optimization: "O0", "O1", "O2", "O3", "O4", "O5", "Os", "Oz".
|
||||
"opt": "O0",
|
||||
// Code optimization level: "none", "less", "more", "max".
|
||||
"optlevel": "none",
|
||||
// Code size optimization: "none", "small", "tiny".
|
||||
"optsize": "none",
|
||||
// Relocation model: "none", "pic", "PIC", "pie", "PIE".
|
||||
"reloc": "none",
|
||||
// Trap on signed and unsigned integer wrapping for testing.
|
||||
"trap-on-wrap": false,
|
||||
// Turn safety (contracts, runtime bounds checking, null pointer checks etc).
|
||||
"safe": true,
|
||||
// Compile all modules together, enables more inlining.
|
||||
"single-module": true,
|
||||
// Use / don't use soft float, value is otherwise target default.
|
||||
"soft-float": false,
|
||||
// Strip unused code and globals from the output.
|
||||
"strip-unused": true,
|
||||
// The size of the symtab, which limits the amount
|
||||
// of symbols that can be used. Should usually not be changed.
|
||||
"symtab": 1048576,
|
||||
// Select linker.
|
||||
"linker": "cc",
|
||||
// Include the standard library.
|
||||
"use-stdlib": true,
|
||||
// Set general level of x64 cpu: "baseline", "ssse3", "sse4", "avx1", "avx2-v1", "avx2-v2", "avx512", "native".
|
||||
"x86cpu": "native",
|
||||
// Set max type of vector use: "none", "mmx", "sse", "avx", "avx512", "native".
|
||||
"x86vec": "sse",
|
||||
}
|
||||
Reference in New Issue
Block a user