]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/cgo: build iOS-specific code only on iOS
authorCherry Zhang <cherryyz@google.com>
Wed, 14 Oct 2020 23:26:20 +0000 (19:26 -0400)
committerCherry Zhang <cherryyz@google.com>
Sat, 17 Oct 2020 00:01:00 +0000 (00:01 +0000)
Don't build them on macOS/ARM64.

Updates #38485.

Change-Id: I9fbea838fdce52db22742487926879761dea0d6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/262559
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/cgo/gcc_darwin_arm64.c
src/runtime/cgo/gcc_signal_ios_nolldb.c [moved from src/runtime/cgo/gcc_signal_darwin_nolldb.c with 88% similarity]

index 9ea43ae4af5c5b23fbb9228fa0aeec7f70fd0aca..dbe848b4ee5f10726da772ae11821a8010bdb43e 100644 (file)
 #include <unistd.h>
 #include <stdlib.h>
 
-#include <CoreFoundation/CFBundle.h>
-#include <CoreFoundation/CFString.h>
-
 #include "libcgo.h"
 #include "libcgo_unix.h"
 
+#include <TargetConditionals.h>
+
+#if TARGET_OS_IPHONE
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFString.h>
+#endif
+
 #define magic (0xc476c475c47957UL)
 
 // inittls allocates a thread-local storage slot for g.
@@ -87,14 +91,18 @@ threadentry(void *v)
        ts = *(ThreadStart*)v;
        free(v);
 
+#if TARGET_OS_IPHONE
        darwin_arm_init_thread_exception_port();
+#endif
 
        crosscall1(ts.fn, setg_gcc, (void*)ts.g);
        return nil;
 }
 
+#if TARGET_OS_IPHONE
+
 // init_working_dir sets the current working directory to the app root.
-// By default darwin/arm64 processes start in "/".
+// By default ios/arm64 processes start in "/".
 static void
 init_working_dir()
 {
@@ -145,6 +153,8 @@ init_working_dir()
        }
 }
 
+#endif // TARGET_OS_IPHONE
+
 void
 x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
 {
@@ -161,8 +171,9 @@ x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
        // yes, tlsbase from mrs might not be correctly aligned.
        inittls(tlsg, (void**)((uintptr)tlsbase & ~7));
 
+#if TARGET_OS_IPHONE
        darwin_arm_init_mach_exception_handler();
        darwin_arm_init_thread_exception_port();
-
        init_working_dir();
+#endif
 }
similarity index 88%
rename from src/runtime/cgo/gcc_signal_darwin_nolldb.c
rename to src/runtime/cgo/gcc_signal_ios_nolldb.c
index 26be71bd1da9f9248fb46b301f0b15319df0a8f1..cfa402541465313c67d4fcc65df10b84ef81e69e 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build !lldb !ios
-// +build darwin
+// +build !lldb
+// +build ios
 // +build arm64
 
 #include <stdint.h>