From a71cbd4087cd7b29350a313f486c1db79867ca69 Mon Sep 17 00:00:00 2001 From: Platin21 Date: Sun, 27 Sep 2020 21:57:27 +0300 Subject: [PATCH 1/4] Changed foreign imports to now use the System Framework --- core/os/os_darwin.odin | 4 ++-- core/sys/darwin/mach_darwin.odin | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 5169572b5..36cd13804 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -1,8 +1,8 @@ package os foreign import dl "system:dl" -foreign import libc "system:c" -foreign import pthread "system:pthread" +foreign import libc "System.framework" +foreign import pthread "System.framework" import "core:runtime" import "core:strings" diff --git a/core/sys/darwin/mach_darwin.odin b/core/sys/darwin/mach_darwin.odin index 52a145507..25fc63c32 100644 --- a/core/sys/darwin/mach_darwin.odin +++ b/core/sys/darwin/mach_darwin.odin @@ -1,6 +1,6 @@ package darwin; -foreign import "system:pthread" +foreign import pthread "System.framework" import "core:c" From f7e40b8572dd51c308ceb216f5bbca3142cf4cc0 Mon Sep 17 00:00:00 2001 From: Platin21 Date: Sun, 27 Sep 2020 22:08:33 +0300 Subject: [PATCH 2/4] Adds when statement for framework include --- core/time/time_unix.odin | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/time/time_unix.odin b/core/time/time_unix.odin index 3acc636e1..995355ad5 100644 --- a/core/time/time_unix.odin +++ b/core/time/time_unix.odin @@ -3,7 +3,14 @@ package time IS_SUPPORTED :: true; // NOTE: Times on Darwin are UTC. -foreign import libc "system:c" +when ODIN_OS == "darwin" { + foreign import libc "System.framework" +} + +when ODIN_OS != "darwin" { + foreign import libc "system:c" +} + @(default_calling_convention="c") foreign libc { From 2ed6785b4af6bfef40c4c1b34167507195619f32 Mon Sep 17 00:00:00 2001 From: Platin21 Date: Sun, 27 Sep 2020 22:11:23 +0300 Subject: [PATCH 3/4] Adds -syslibroot to linker command needed for System.framework --- src/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e53f1b7d9..b15518d6e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -432,7 +432,11 @@ i32 linker_stage(lbGenerator *gen) { #endif , linker, object_files, LIT(output_base), LIT(output_ext), lib_str, - "-lc -lm", + #if defined(GB_SYSTEM_OSX) + "-lSystem -lm -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk", + #else + "-lc -lm", + #endif LIT(build_context.link_flags), LIT(build_context.extra_linker_flags), link_settings); @@ -2195,7 +2199,11 @@ int main(int arg_count, char const **arg_ptr) { #endif , linker, LIT(output_base), LIT(output_base), LIT(output_ext), lib_str, - "-lc -lm", + #if defined(GB_SYSTEM_OSX) + "-lSystem -lm -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk", + #else + "-lc -lm", + #endif LIT(build_context.link_flags), LIT(build_context.extra_linker_flags), link_settings); From 6b83159b062b72727d887663452fa445382373fc Mon Sep 17 00:00:00 2001 From: Platin21 Date: Sun, 27 Sep 2020 22:17:35 +0300 Subject: [PATCH 4/4] Switched to else instead of not equal --- core/time/time_unix.odin | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/time/time_unix.odin b/core/time/time_unix.odin index 995355ad5..2419a3f8b 100644 --- a/core/time/time_unix.odin +++ b/core/time/time_unix.odin @@ -5,9 +5,7 @@ IS_SUPPORTED :: true; // NOTE: Times on Darwin are UTC. when ODIN_OS == "darwin" { foreign import libc "System.framework" -} - -when ODIN_OS != "darwin" { +} else { foreign import libc "system:c" }