From 07abbc0a4761116f511ccc77083db2d61157ebc9 Mon Sep 17 00:00:00 2001 From: Dmitry Atamanov Date: Fri, 15 Sep 2023 19:18:44 +0500 Subject: [PATCH] Add libc-free hello_world --- resources/examples/nolibc/hello_world.c3 | 22 ++++++++++++++++++++++ resources/examples/nolibc/project.json | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 resources/examples/nolibc/hello_world.c3 create mode 100644 resources/examples/nolibc/project.json diff --git a/resources/examples/nolibc/hello_world.c3 b/resources/examples/nolibc/hello_world.c3 new file mode 100644 index 000000000..895e64384 --- /dev/null +++ b/resources/examples/nolibc/hello_world.c3 @@ -0,0 +1,22 @@ +fn int main() +{ + String msg = "Hello, C3 World!\n"; + $$syscall(1, 1, (uptr)msg.ptr, msg.len); // __NR_write, STDOUT + return 0; +} + +fn void _start() @export("_start") +{ + int ret = main(); + $$syscall(60, 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) +{ +} diff --git a/resources/examples/nolibc/project.json b/resources/examples/nolibc/project.json new file mode 100644 index 000000000..b3d8c461e --- /dev/null +++ b/resources/examples/nolibc/project.json @@ -0,0 +1,21 @@ +{ + "authors": [ "Dmitry Atamanov https://github.com/data-man" ], + "version": "0.0.1 Omega", + "sources": [ "./**" ], + "targets": { + "hello_world": { + "type": "executable", + "opt": "O3", + "nolibc": true, + "nostdlib": true + }, + }, + "debug-info": "none", + "target": "linux-x64", + "reloc": "none", + "trap-on-wrap": false, + "soft-float": false, + "x86vec": "sse", + "cpu": "generic", + "output": "." +} \ No newline at end of file