diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-01-03 17:25:41 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-03 17:25:41 +0000 |
| commit | 0cc72b536fe31d75ebb8b73dd3e541f08fff84c1 (patch) | |
| tree | a15864f5c253ef6adc9e3b995ab63e49fbb7e02c | |
| parent | cb1c10ce83b9a51244ad50dc7a8beb4f3271ae09 (diff) | |
| parent | 8a7c2ea9d0e6b55bcfc5068ff2bf7c2a14ccfebf (diff) | |
Merge pull request #3066 from laytan/darwin-actually-honor-no-crt
darwin: actually honor no-crt by not linking with `-lSystem -lm`
| -rw-r--r-- | core/runtime/procs.odin | 13 | ||||
| -rw-r--r-- | src/linker.cpp | 9 |
2 files changed, 18 insertions, 4 deletions
diff --git a/core/runtime/procs.odin b/core/runtime/procs.odin index 1592c608b..1b8a54c6d 100644 --- a/core/runtime/procs.odin +++ b/core/runtime/procs.odin @@ -37,7 +37,18 @@ when ODIN_NO_CRT && ODIN_OS == .Windows { } return ptr } - + + @(link_name="bzero", linkage="strong", require) + bzero :: proc "c" (ptr: rawptr, len: int) -> rawptr { + if ptr != nil && len != 0 { + p := ([^]byte)(ptr) + for i := 0; i < len; i += 1 { + p[i] = 0 + } + } + return ptr + } + @(link_name="memmove", linkage="strong", require) memmove :: proc "c" (dst, src: rawptr, len: int) -> rawptr { d, s := ([^]byte)(dst), ([^]byte)(src) diff --git a/src/linker.cpp b/src/linker.cpp index ef9fa8e59..4ab4b2cd1 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -483,10 +483,13 @@ gb_internal i32 linker_stage(LinkerData *gen) { gbString platform_lib_str = gb_string_make(heap_allocator(), ""); defer (gb_string_free(platform_lib_str)); if (build_context.metrics.os == TargetOs_darwin) { - platform_lib_str = gb_string_appendc(platform_lib_str, "-lm -Wl,-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib"); + platform_lib_str = gb_string_appendc(platform_lib_str, "-Wl,-syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib"); #if defined(GB_SYSTEM_OSX) - if(gen->needs_system_library_linked == 1) { - platform_lib_str = gb_string_appendc(platform_lib_str, " -lSystem "); + if(!build_context.no_crt) { + platform_lib_str = gb_string_appendc(platform_lib_str, " -lm "); + if(gen->needs_system_library_linked == 1) { + platform_lib_str = gb_string_appendc(platform_lib_str, " -lSystem "); + } } #endif } else { |