forked from ebitengine/purego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nocgo.go
25 lines (22 loc) · 1.23 KB
/
nocgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
//go:build !cgo && (darwin || linux)
package purego
// if CGO_ENABLED=0 import fakecgo to setup the Cgo runtime correctly.
// This is required since some frameworks need TLS setup the C way which Go doesn't do.
// We currently don't support ios in fakecgo mode so force Cgo or fail
//
// The way that the Cgo runtime (runtime/cgo) works is by setting some variables found
// in runtime with non-null GCC compiled functions. The variables that are replaced are
// var (
// iscgo bool // in runtime/cgo.go
// _cgo_init unsafe.Pointer // in runtime/cgo.go
// _cgo_thread_start unsafe.Pointer // in runtime/cgo.go
// _cgo_notify_runtime_init_done unsafe.Pointer // in runtime/cgo.go
// _cgo_setenv unsafe.Pointer // in runtime/env_posix.go
// _cgo_unsetenv unsafe.Pointer // in runtime/env_posix.go
// )
// importing fakecgo will set these (using //go:linkname) with functions written
// entirely in Go (except for some assembly trampolines to change GCC ABI to Go ABI).
// Doing so makes it possible to build applications that call into C without CGO_ENABLED=1.
import _ "github.com/ebitengine/purego/internal/fakecgo"