Suggesting removal of dependency on libc on Linux systems #975
Replies: 2 comments
-
|
This will be a goal in the future but it is not a huge priority at the moment. |
Beta Was this translation helpful? Give feedback.
-
|
It struck me that it may be sufficient to link using This creates an executable that is SMALLER than the shared library version! Note: You don't always use the Now I'm stuck. I've attached the minor changes I made to the end of this message. I think the "best" short term next step might be to copy&paste the relevant functions from dietlibc and include them as a tiny diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin
index 6e60f0e..fa9511b 100644
--- a/core/os/os_linux.odin
+++ b/core/os/os_linux.odin
@@ -362,7 +362,9 @@ nanosleep :: proc(nanoseconds: i64) -> int {
}
current_thread_id :: proc "contextless" () -> int {
- return syscall(SYS_GETTID);
+ return cast(int) _unix_gettid();
+ // return syscall(SYS_GETTID);
+ // return 0;
}
dlopen :: inline proc(filename: string, flags: int) -> rawptr {
diff --git a/src/main.cpp b/src/main.cpp
index a6838dd..7cfc20e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1059,7 +1059,7 @@ int main(int arg_count, char **arg_ptr) {
if (str_eq_ignore_case(cross_compile_target, str_lit("Essence"))) {
linker = "x86_64-elf-gcc -T core/sys/essence_linker_userland64.ld -ffreestanding -nostdlib -lgcc -g -z max-page-size=0x1000 -Wno-unused-command-line-argument";
} else {
- linker = "clang -Wno-unused-command-line-argument";
+ linker = "diet clang -m64 -Wno-unused-command-line-argument";
}
#endif
@@ -1079,7 +1079,7 @@ int main(int arg_count, char **arg_ptr) {
#endif
, linker, LIT(output_base), LIT(output_base), output_ext,
lib_str,
- str_eq_ignore_case(cross_compile_target, str_lit("Essence")) ? "-lfreetype -lglue" : "-lc -lm",
+ str_eq_ignore_case(cross_compile_target, str_lit("Essence")) ? "-lfreetype -lglue" : "-lc -Wl,--as-needed -lm -Wl,--no-as-needed ",
LIT(build_context.link_flags),
link_settings,
LIT(cross_compile_lib_dir)
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As libc is a bloated, large, old and non-required library for creating programs, I think we should not depend on it in the standard library (and
core:os_linux.odinin particular).All we need from libc is the bindings to the Unix syscalls, whilst we are still linking in all the other C stuff, which we don't need.
Beta Was this translation helpful? Give feedback.
All reactions