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