Merge pull request #5462 from harold-b/hb.ios-support-2025

Add iOS & iPhoneSimulator subtargets for Darwin target
This commit is contained in:
gingerBill
2025-07-14 16:50:57 +01:00
committed by GitHub
78 changed files with 154 additions and 93 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ ODIN_OS_STRING :: ODIN_OS_STRING
/* /*
An `enum` value indicating the platform subtarget, chosen using the `-subtarget` switch. An `enum` value indicating the platform subtarget, chosen using the `-subtarget` switch.
Possible values are: `.Default` `.iOS`, and `.Android`. Possible values are: `.Default` `.iOS`, .iPhoneSimulator, and `.Android`.
*/ */
ODIN_PLATFORM_SUBTARGET :: ODIN_PLATFORM_SUBTARGET ODIN_PLATFORM_SUBTARGET :: ODIN_PLATFORM_SUBTARGET
+1
View File
@@ -558,6 +558,7 @@ ALL_ODIN_OS_TYPES :: Odin_OS_Types{
Odin_Platform_Subtarget_Type :: enum int { Odin_Platform_Subtarget_Type :: enum int {
Default, Default,
iOS, iOS,
iPhoneSimulator
Android, Android,
} }
*/ */
+1 -1
View File
@@ -3,7 +3,7 @@
package runtime package runtime
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -3,7 +3,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ import "core:c"
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -7,7 +7,7 @@ import "base:intrinsics"
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -9,7 +9,7 @@ when ODIN_OS == .Windows {
"system:legacy_stdio_definitions.lib", "system:legacy_stdio_definitions.lib",
} }
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -7,7 +7,7 @@ import "base:runtime"
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ package libc
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import libc "system:libucrt.lib" foreign import libc "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -23,7 +23,7 @@ package net
import "core:strings" import "core:strings"
import "core:sys/posix" import "core:sys/posix"
foreign import lib "system:System.framework" foreign import lib "system:System"
@(private) @(private)
_enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Interfaces_Error) { _enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Interfaces_Error) {
+1 -1
View File
@@ -10,7 +10,7 @@ import "core:sys/posix"
import "core:sys/unix" import "core:sys/unix"
import "core:time" import "core:time"
foreign import lib "system:System.framework" foreign import lib "system:System"
foreign lib { foreign lib {
sysctl :: proc( sysctl :: proc(
+2 -2
View File
@@ -1,8 +1,8 @@
package os package os
foreign import dl "system:dl" foreign import dl "system:dl"
foreign import libc "system:System.framework" foreign import libc "system:System"
foreign import pthread "system:System.framework" foreign import pthread "system:System"
import "base:runtime" import "base:runtime"
import "core:strings" import "core:strings"
+1 -1
View File
@@ -6,7 +6,7 @@ import "core:c"
import "core:sys/darwin" import "core:sys/darwin"
import "core:time" import "core:time"
foreign import System "system:System.framework" foreign import System "system:System"
foreign System { foreign System {
// __ulock_wait is not available on 10.15 // __ulock_wait is not available on 10.15
+1 -1
View File
@@ -5,7 +5,7 @@ package sync
import "core:c" import "core:c"
import "base:intrinsics" import "base:intrinsics"
foreign import pthread "system:System.framework" foreign import pthread "system:System"
_current_thread_id :: proc "contextless" () -> int { _current_thread_id :: proc "contextless" () -> int {
tid: u64 tid: u64
+1 -1
View File
@@ -62,7 +62,7 @@ global_block_descriptor := Block_Descriptor{
size = size_of(Internal_Block_Literal), size = size_of(Internal_Block_Literal),
} }
foreign import libSystem "system:System.framework" foreign import libSystem "system:System"
foreign libSystem { foreign libSystem {
_NSConcreteGlobalBlock: intrinsics.objc_class _NSConcreteGlobalBlock: intrinsics.objc_class
_NSConcreteStackBlock: intrinsics.objc_class _NSConcreteStackBlock: intrinsics.objc_class
+1 -1
View File
@@ -4,7 +4,7 @@ package darwin
import "core:c" import "core:c"
@(export) @(export)
foreign import system "system:System.framework" foreign import system "system:System"
Bool :: b8 Bool :: b8
+1 -1
View File
@@ -1,6 +1,6 @@
package darwin package darwin
foreign import mach "system:System.framework" foreign import mach "system:System"
import "core:c" import "core:c"
import "base:intrinsics" import "base:intrinsics"
+1 -1
View File
@@ -4,7 +4,7 @@ import "base:intrinsics"
import "core:sys/posix" import "core:sys/posix"
foreign import lib "system:System.framework" foreign import lib "system:System"
// Incomplete bindings to the proc API on MacOS, add to when needed. // Incomplete bindings to the proc API on MacOS, add to when needed.
+1 -1
View File
@@ -2,7 +2,7 @@
package kqueue package kqueue
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else when ODIN_OS == .Haiku { } else when ODIN_OS == .Haiku {
foreign import lib "system:network" foreign import lib "system:network"
} else { } else {
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD { } else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD {
foreign import lib "system:dl" foreign import lib "system:dl"
} else { } else {
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -2,7 +2,7 @@
package posix package posix
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import "base:intrinsics"
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .Linux { } else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .Linux {
foreign import lib "system:pthread" foreign import lib "system:pthread"
} else { } else {
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import "base:intrinsics"
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -9,7 +9,7 @@ import "core:c/libc"
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import lib "system:libucrt.lib" foreign import lib "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -10,7 +10,7 @@ when ODIN_OS == .Windows {
"system:legacy_stdio_definitions.lib", "system:legacy_stdio_definitions.lib",
} }
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import "base:intrinsics"
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -9,7 +9,7 @@ import "core:c/libc"
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import lib "system:libucrt.lib" foreign import lib "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import lib "system:libucrt.lib" foreign import lib "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import "base:intrinsics"
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -2,7 +2,7 @@
package posix package posix
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import libc "system:System.framework" foreign import libc "system:System"
} else { } else {
foreign import libc "system:c" foreign import libc "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -5,7 +5,7 @@ import "core:c"
import "core:c/libc" import "core:c/libc"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -6,7 +6,7 @@ import "core:c"
when ODIN_OS == .Windows { when ODIN_OS == .Windows {
foreign import lib "system:libucrt.lib" foreign import lib "system:libucrt.lib"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -2,7 +2,7 @@
package posix package posix
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+1 -1
View File
@@ -4,7 +4,7 @@ package posix
import "core:c" import "core:c"
when ODIN_OS == .Darwin { when ODIN_OS == .Darwin {
foreign import lib "system:System.framework" foreign import lib "system:System"
} else { } else {
foreign import lib "system:c" foreign import lib "system:c"
} }
+25 -10
View File
@@ -172,6 +172,7 @@ struct TargetMetrics {
enum Subtarget : u32 { enum Subtarget : u32 {
Subtarget_Default, Subtarget_Default,
Subtarget_iOS, Subtarget_iOS,
Subtarget_iPhoneSimulator,
Subtarget_Android, Subtarget_Android,
Subtarget_COUNT, Subtarget_COUNT,
@@ -180,6 +181,7 @@ enum Subtarget : u32 {
gb_global String subtarget_strings[Subtarget_COUNT] = { gb_global String subtarget_strings[Subtarget_COUNT] = {
str_lit(""), str_lit(""),
str_lit("ios"), str_lit("ios"),
str_lit("iphonesimulator"),
str_lit("android"), str_lit("android"),
}; };
@@ -1824,16 +1826,29 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
} }
} }
if (metrics->os == TargetOs_darwin && subtarget == Subtarget_iOS) { if (metrics->os == TargetOs_darwin) {
switch (metrics->arch) { switch (subtarget) {
case TargetArch_arm64: case Subtarget_iOS:
bc->metrics.target_triplet = str_lit("arm64-apple-ios"); switch (metrics->arch) {
break; case TargetArch_arm64:
case TargetArch_amd64: bc->metrics.target_triplet = str_lit("arm64-apple-ios");
bc->metrics.target_triplet = str_lit("x86_64-apple-ios"); break;
break; default:
default: GB_PANIC("Unknown architecture for -subtarget:ios");
GB_PANIC("Unknown architecture for darwin"); }
break;
case Subtarget_iPhoneSimulator:
switch (metrics->arch) {
case TargetArch_arm64:
bc->metrics.target_triplet = str_lit("arm64-apple-ios-simulator");
break;
case TargetArch_amd64:
bc->metrics.target_triplet = str_lit("x86_64-apple-ios-simulator");
break;
default:
GB_PANIC("Unknown architecture for -subtarget:iphonesimulator");
}
break;
} }
} else if (metrics->os == TargetOs_linux && subtarget == Subtarget_Android) { } else if (metrics->os == TargetOs_linux && subtarget == Subtarget_Android) {
switch (metrics->arch) { switch (metrics->arch) {
+4 -3
View File
@@ -1171,9 +1171,10 @@ gb_internal void init_universal(void) {
{ {
GlobalEnumValue values[Subtarget_COUNT] = { GlobalEnumValue values[Subtarget_COUNT] = {
{"Default", Subtarget_Default}, {"Default", Subtarget_Default},
{"iOS", Subtarget_iOS}, {"iOS", Subtarget_iOS},
{"Android", Subtarget_Android}, {"iPhoneSimulator", Subtarget_iPhoneSimulator},
{"Android", Subtarget_Android},
}; };
auto fields = add_global_enum_type(str_lit("Odin_Platform_Subtarget_Type"), values, gb_count_of(values)); auto fields = add_global_enum_type(str_lit("Odin_Platform_Subtarget_Type"), values, gb_count_of(values));
+49 -5
View File
@@ -591,7 +591,7 @@ try_cross_linking:;
// Do not add libc again, this is added later already, and omitted with // Do not add libc again, this is added later already, and omitted with
// the `-no-crt` flag, not skipping here would cause duplicate library // the `-no-crt` flag, not skipping here would cause duplicate library
// warnings when linking on darwin and might link libc silently even with `-no-crt`. // warnings when linking on darwin and might link libc silently even with `-no-crt`.
if (lib == str_lit("System.framework") || lib == str_lit("c")) { if (lib == str_lit("System.framework") || lib == str_lit("System") || lib == str_lit("c")) {
continue; continue;
} }
@@ -772,10 +772,54 @@ try_cross_linking:;
gbString platform_lib_str = gb_string_make(heap_allocator(), ""); gbString platform_lib_str = gb_string_make(heap_allocator(), "");
defer (gb_string_free(platform_lib_str)); defer (gb_string_free(platform_lib_str));
if (build_context.metrics.os == TargetOs_darwin) { if (build_context.metrics.os == TargetOs_darwin) {
// Get the MacOSX SDK path. // Get the SDK path.
gbString darwin_sdk_path = gb_string_make(temporary_allocator(), ""); gbString darwin_sdk_path = gb_string_make(temporary_allocator(), "");
if (!system_exec_command_line_app_output("xcrun --sdk macosx --show-sdk-path", &darwin_sdk_path)) {
darwin_sdk_path = gb_string_set(darwin_sdk_path, "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"); char const* darwin_platform_name = "MacOSX";
char const* darwin_xcrun_sdk_name = "macosx";
char const* darwin_min_version_id = "macosx";
// NOTE(harold): We set the clang_path to run through xcrun because otherwise it complaints about the the sysroot
// being set to 'MacOSX' even though we've set the sysroot to the correct SDK (-Wincompatible-sysroot).
// This is because it is likely not using the SDK's toolchain Apple Clang but another one installed in the system.
switch (selected_subtarget) {
case Subtarget_iOS:
darwin_platform_name = "iPhoneOS";
darwin_xcrun_sdk_name = "iphoneos";
darwin_min_version_id = "ios";
clang_path = "xcrun --sdk iphoneos clang";
break;
case Subtarget_iPhoneSimulator:
darwin_platform_name = "iPhoneSimulator";
darwin_xcrun_sdk_name = "iphonesimulator";
darwin_min_version_id = "ios-simulator";
clang_path = "xcrun --sdk iphonesimulator clang";
break;
}
const char* original_clang_path = clang_path;
gbString darwin_find_sdk_cmd = gb_string_make(temporary_allocator(), "");
darwin_find_sdk_cmd = gb_string_append_fmt(darwin_find_sdk_cmd, "xcrun --sdk %s --show-sdk-path", darwin_xcrun_sdk_name);
if (!system_exec_command_line_app_output(darwin_find_sdk_cmd, &darwin_sdk_path)) {
// Fallback to default clang, since `xcrun --sdk` did not work.
clang_path = original_clang_path;
// Best-effort fallback to known locations
gbString darwin_sdk_path = gb_string_make(temporary_allocator(), "");
darwin_sdk_path = gb_string_append_fmt(darwin_sdk_path, "/Library/Developer/CommandLineTools/SDKs/%s.sdk", darwin_platform_name);
if (!path_is_directory(make_string_c(darwin_sdk_path))) {
gb_string_clear(darwin_sdk_path);
darwin_sdk_path = gb_string_append_fmt(darwin_sdk_path, "/Applications/Xcode.app/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s.sdk", darwin_platform_name);
if (!path_is_directory(make_string_c(darwin_sdk_path))) {
gb_printf_err("Failed to find %s SDK\n", darwin_platform_name);
return -1;
}
}
} else { } else {
// Trim the trailing newline. // Trim the trailing newline.
darwin_sdk_path = gb_string_trim_space(darwin_sdk_path); darwin_sdk_path = gb_string_trim_space(darwin_sdk_path);
@@ -797,7 +841,7 @@ try_cross_linking:;
// Only specify this flag if the user has given a minimum version to target. // Only specify this flag if the user has given a minimum version to target.
// This will cause warnings to show up for mismatched libraries. // This will cause warnings to show up for mismatched libraries.
if (build_context.minimum_os_version_string_given) { if (build_context.minimum_os_version_string_given) {
link_settings = gb_string_append_fmt(link_settings, "-mmacosx-version-min=%.*s ", LIT(build_context.minimum_os_version_string)); link_settings = gb_string_append_fmt(link_settings, "-m%s-version-min=%.*s ", darwin_min_version_id, LIT(build_context.minimum_os_version_string));
} }
if (build_context.build_mode != BuildMode_DynamicLibrary) { if (build_context.build_mode != BuildMode_DynamicLibrary) {