Libc: Define target instead of including

Including `TargetConditionals.h` had knock-on effects, breaking the zlib
build because `TARGET_OS_MAC` gets defined, for instance.

Defining `TARGET_OS_EMBEDDED` to be `0` if it's not defined is simpler
and maintains the default behavior so it shouldn't break any dependents.
This commit is contained in:
toonn 2021-07-27 15:26:03 +02:00 committed by Jonathan Ringer
parent 99bef31835
commit 5aa4c46dcd
3 changed files with 33 additions and 25 deletions

View File

@ -0,0 +1,32 @@
From c0ab867bb7888401957539b0348902028a2be6e0 Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Tue, 27 Jul 2021 15:12:14 +0200
Subject: [PATCH] Define TARGET_OS_EMBEDDED in stdlib if not defined
Originally attempted including `TargetConditionals.h` but this had
knock-on effects, for example, breaking the zlib build because of
`TARGET_OS_MAC` getting defined.
This should be the lowest impact solution and corresponds to the default
behavior IIUC.
---
include/stdlib.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/stdlib.h b/include/stdlib.h
index c04d3a7..0b454ba 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -183,6 +183,9 @@ unsigned long long
#ifndef LIBC_ALIAS_SYSTEM
//End-Libc
+#ifndef TARGET_OS_EMBEDDED
+# define TARGET_OS_EMBEDDED 0
+#endif
#if TARGET_OS_EMBEDDED
#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
#else
--
2.17.2 (Apple Git-113)

View File

@ -1,24 +0,0 @@
From 6e573a85b46dcfae323a99aa561c0dcc016a7791 Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Mon, 26 Jul 2021 16:19:44 +0200
Subject: [PATCH] Include Targetconditionals in stdlib
---
include/stdlib.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/stdlib.h b/include/stdlib.h
index c04d3a7..94a9812 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -59,6 +59,7 @@
#define _STDLIB_H_
#include <Availability.h>
+#include <TargetConditionals.h>
#include <_types.h>
#if !defined(_ANSI_SOURCE)
--
2.17.2 (Apple Git-113)

View File

@ -3,7 +3,7 @@
appleDerivation' stdenvNoCC {
nativeBuildInputs = [ ed unifdef ];
patches = [ ./0001-Include-Targetconditionals-in-stdlib.patch ];
patches = [ ./0001-Define-TARGET_OS_EMBEDDED-in-stdlib-if-not-defined.patch ];
# TODO: asl.h actually comes from syslog project now
installPhase = ''