Revert "Fix issue 189 (#197)"
This reverts commit 579fc8763f10ed6048773f923891d79d7e0568d4. Reason: go-vet fails: ``` Error: ./syscall_cgo_linux.go:14:33: undefined: cgo.Syscall9XABI0 Error: ./syscall_cgo_linux.go:25:13: undefined: cgo.Syscall9X Error: Process completed with exit code 1. ```
- commit
- 18dee4e144ae4dfb9f5088a7f96ff04f5833fcfd
- author
- Hajime Hoshi · · 2024-01-17 15:51 UTC
- parent
- 579fc87
- signature
- unsigned
9 files · +22 -67
M cgo.go +1 -5
| @@ -12,8 +12,4 @@ package purego | |||
| 12 | 12 | // which will import this package automatically. Normally this isn't an issue since it | |
| 13 | 13 | // usually isn't possible to call into C without using that import. However, with purego | |
| 14 | 14 | // it is since we don't use `import "C"`! | |
| 15 | - | import ( | |
| 16 | - | _ "runtime/cgo" | |
| 17 | - | ||
| 18 | - | _ "github.com/ebitengine/purego/internal/cgo" | |
| 19 | - | ) | |
| 15 | + | import _ "runtime/cgo" | |
| @@ -12,8 +12,4 @@ package purego | |||||
| 12 | // which will import this package automatically. Normally this isn't an issue since it | 12 | // which will import this package automatically. Normally this isn't an issue since it | ||
| 13 | // usually isn't possible to call into C without using that import. However, with purego | 13 | // usually isn't possible to call into C without using that import. However, with purego | ||
| 14 | // it is since we don't use `import "C"`! | 14 | // it is since we don't use `import "C"`! | ||
| 15 | - | import ( | 15 | + | import _ "runtime/cgo" |
| 16 | - | _ "runtime/cgo" | |||
| 17 | - | ||||
| 18 | - | _ "github.com/ebitengine/purego/internal/cgo" | |||
| 19 | - | ) | |||
M dlfcn_darwin.go +5 -0
| @@ -12,3 +12,8 @@ const ( | |||
| 12 | 12 | RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules. | |
| 13 | 13 | RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules. | |
| 14 | 14 | ) | |
| 15 | + | ||
| 16 | + | //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" | |
| 17 | + | //go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" | |
| 18 | + | //go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" | |
| 19 | + | //go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib" | |
| @@ -12,3 +12,8 @@ const ( | |||||
| 12 | RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules. | 12 | RTLD_LOCAL = 0x4 // All symbols are not made available for relocation processing by other modules. | ||
| 13 | RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules. | 13 | RTLD_GLOBAL = 0x8 // All symbols are available for relocation processing of other modules. | ||
| 14 | ) | 14 | ) | ||
| 15 | + | ||||
| 16 | + | //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" | |||
| 17 | + | //go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" | |||
| 18 | + | //go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" | |||
| 19 | + | //go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib" | |||
M dlfcn_freebsd.go +5 -0
| @@ -11,3 +11,8 @@ const ( | |||
| 11 | 11 | RTLD_LOCAL = 0x00000 // All symbols are not made available for relocation processing by other modules. | |
| 12 | 12 | RTLD_GLOBAL = 0x00100 // All symbols are available for relocation processing of other modules. | |
| 13 | 13 | ) | |
| 14 | + | ||
| 15 | + | //go:cgo_import_dynamic purego_dlopen dlopen "libc.so.7" | |
| 16 | + | //go:cgo_import_dynamic purego_dlsym dlsym "libc.so.7" | |
| 17 | + | //go:cgo_import_dynamic purego_dlerror dlerror "libc.so.7" | |
| 18 | + | //go:cgo_import_dynamic purego_dlclose dlclose "libc.so.7" | |
| @@ -11,3 +11,8 @@ const ( | |||||
| 11 | RTLD_LOCAL = 0x00000 // All symbols are not made available for relocation processing by other modules. | 11 | RTLD_LOCAL = 0x00000 // All symbols are not made available for relocation processing by other modules. | ||
| 12 | RTLD_GLOBAL = 0x00100 // All symbols are available for relocation processing of other modules. | 12 | RTLD_GLOBAL = 0x00100 // All symbols are available for relocation processing of other modules. | ||
| 13 | ) | 13 | ) | ||
| 14 | + | ||||
| 15 | + | //go:cgo_import_dynamic purego_dlopen dlopen "libc.so.7" | |||
| 16 | + | //go:cgo_import_dynamic purego_dlsym dlsym "libc.so.7" | |||
| 17 | + | //go:cgo_import_dynamic purego_dlerror dlerror "libc.so.7" | |||
| 18 | + | //go:cgo_import_dynamic purego_dlclose dlclose "libc.so.7" | |||
D dlfcn_nocgo_darwin.go +0 -11
| @@ -1,11 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2024 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build !cgo | |
| 5 | - | ||
| 6 | - | package purego | |
| 7 | - | ||
| 8 | - | //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" | |
| 9 | - | //go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" | |
| 10 | - | //go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" | |
| 11 | - | //go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib" | |
| @@ -1,11 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2024 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build !cgo | |||
| 5 | - | ||||
| 6 | - | package purego | |||
| 7 | - | ||||
| 8 | - | //go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib" | |||
| 9 | - | //go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib" | |||
| 10 | - | //go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib" | |||
| 11 | - | //go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib" | |||
D dlfcn_nocgo_freebsd.go +0 -11
| @@ -1,11 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build !cgo | |
| 5 | - | ||
| 6 | - | package purego | |
| 7 | - | ||
| 8 | - | //go:cgo_import_dynamic purego_dlopen dlopen "libc.so.7" | |
| 9 | - | //go:cgo_import_dynamic purego_dlsym dlsym "libc.so.7" | |
| 10 | - | //go:cgo_import_dynamic purego_dlerror dlerror "libc.so.7" | |
| 11 | - | //go:cgo_import_dynamic purego_dlclose dlclose "libc.so.7" | |
| @@ -1,11 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build !cgo | |||
| 5 | - | ||||
| 6 | - | package purego | |||
| 7 | - | ||||
| 8 | - | //go:cgo_import_dynamic purego_dlopen dlopen "libc.so.7" | |||
| 9 | - | //go:cgo_import_dynamic purego_dlsym dlsym "libc.so.7" | |||
| 10 | - | //go:cgo_import_dynamic purego_dlerror dlerror "libc.so.7" | |||
| 11 | - | //go:cgo_import_dynamic purego_dlclose dlclose "libc.so.7" | |||
M dlfcn_stubs.s +1 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | - | //go:build !cgo && (darwin || freebsd || linux) | |
| 4 | + | //go:build darwin || freebsd || (linux && !cgo) | |
| 5 | 5 | ||
| 6 | 6 | #include "textflag.h" | |
| 7 | 7 | ||
| @@ -1,7 +1,7 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | - | //go:build !cgo && (darwin || freebsd || linux) | 4 | + | //go:build darwin || freebsd || (linux && !cgo) |
| 5 | 5 | ||||
| 6 | #include "textflag.h" | 6 | #include "textflag.h" | ||
| 7 | 7 | ||||
D internal/buildtest/main.go +0 -16
| @@ -1,16 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2024 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build !windows | |
| 5 | - | ||
| 6 | - | package main | |
| 7 | - | ||
| 8 | - | import ( | |
| 9 | - | _ "github.com/ebitengine/purego" | |
| 10 | - | ) | |
| 11 | - | ||
| 12 | - | import "C" | |
| 13 | - | ||
| 14 | - | // This file tests that build Cgo and purego at the same time succeeds to build (#189). | |
| 15 | - | func main() { | |
| 16 | - | } | |
| @@ -1,16 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2024 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build !windows | |||
| 5 | - | ||||
| 6 | - | package main | |||
| 7 | - | ||||
| 8 | - | import ( | |||
| 9 | - | _ "github.com/ebitengine/purego" | |||
| 10 | - | ) | |||
| 11 | - | ||||
| 12 | - | import "C" | |||
| 13 | - | ||||
| 14 | - | // This file tests that build Cgo and purego at the same time succeeds to build (#189). | |||
| 15 | - | func main() { | |||
| 16 | - | } | |||
D internal/cgo/dlfcn_cgo_unix.go +0 -22
| @@ -1,22 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2024 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build darwin || freebsd || linux | |
| 5 | - | ||
| 6 | - | package cgo | |
| 7 | - | ||
| 8 | - | /* | |
| 9 | - | #cgo LDFLAGS: -ldl | |
| 10 | - | ||
| 11 | - | #include <dlfcn.h> | |
| 12 | - | */ | |
| 13 | - | import "C" | |
| 14 | - | ||
| 15 | - | // all that is needed is to assign each dl function because then its | |
| 16 | - | // symbol will then be made available to the linker and linked to inside dlfcn.go | |
| 17 | - | var ( | |
| 18 | - | _ = C.dlopen | |
| 19 | - | _ = C.dlsym | |
| 20 | - | _ = C.dlerror | |
| 21 | - | _ = C.dlclose | |
| 22 | - | ) | |
| @@ -1,22 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2024 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build darwin || freebsd || linux | |||
| 5 | - | ||||
| 6 | - | package cgo | |||
| 7 | - | ||||
| 8 | - | /* | |||
| 9 | - | #cgo LDFLAGS: -ldl | |||
| 10 | - | ||||
| 11 | - | #include <dlfcn.h> | |||
| 12 | - | */ | |||
| 13 | - | import "C" | |||
| 14 | - | ||||
| 15 | - | // all that is needed is to assign each dl function because then its | |||
| 16 | - | // symbol will then be made available to the linker and linked to inside dlfcn.go | |||
| 17 | - | var ( | |||
| 18 | - | _ = C.dlopen | |||
| 19 | - | _ = C.dlsym | |||
| 20 | - | _ = C.dlerror | |||
| 21 | - | _ = C.dlclose | |||
| 22 | - | ) | |||
M internal/cgo/syscall_cgo_unix.go +10 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | - | //go:build freebsd || (linux && !(arm64 || amd64)) | |
| 4 | + | //go:build freebsd || linux | |
| 5 | 5 | ||
| 6 | 6 | package cgo | |
| 7 | 7 | ||
| @@ -39,6 +39,15 @@ import "unsafe" | |||
| 39 | 39 | // assign purego.syscall9XABI0 to the C version of this function. | |
| 40 | 40 | var Syscall9XABI0 = unsafe.Pointer(C.syscall9) | |
| 41 | 41 | ||
| 42 | + | // all that is needed is to assign each dl function because then its | |
| 43 | + | // symbol will then be made available to the linker and linked to inside dlfcn.go | |
| 44 | + | var ( | |
| 45 | + | _ = C.dlopen | |
| 46 | + | _ = C.dlsym | |
| 47 | + | _ = C.dlerror | |
| 48 | + | _ = C.dlclose | |
| 49 | + | ) | |
| 50 | + | ||
| 42 | 51 | //go:nosplit | |
| 43 | 52 | func Syscall9X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr) { | |
| 44 | 53 | args := C.syscall9Args{C.uintptr_t(fn), C.uintptr_t(a1), C.uintptr_t(a2), C.uintptr_t(a3), | |
| @@ -1,7 +1,7 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | - | //go:build freebsd || (linux && !(arm64 || amd64)) | 4 | + | //go:build freebsd || linux |
| 5 | 5 | ||||
| 6 | package cgo | 6 | package cgo | ||
| 7 | 7 | ||||
| @@ -39,6 +39,15 @@ import "unsafe" | |||||
| 39 | // assign purego.syscall9XABI0 to the C version of this function. | 39 | // assign purego.syscall9XABI0 to the C version of this function. | ||
| 40 | var Syscall9XABI0 = unsafe.Pointer(C.syscall9) | 40 | var Syscall9XABI0 = unsafe.Pointer(C.syscall9) | ||
| 41 | 41 | ||||
| 42 | + | // all that is needed is to assign each dl function because then its | |||
| 43 | + | // symbol will then be made available to the linker and linked to inside dlfcn.go | |||
| 44 | + | var ( | |||
| 45 | + | _ = C.dlopen | |||
| 46 | + | _ = C.dlsym | |||
| 47 | + | _ = C.dlerror | |||
| 48 | + | _ = C.dlclose | |||
| 49 | + | ) | |||
| 50 | + | ||||
| 42 | //go:nosplit | 51 | //go:nosplit | ||
| 43 | func Syscall9X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr) { | 52 | func Syscall9X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr) { | ||
| 44 | args := C.syscall9Args{C.uintptr_t(fn), C.uintptr_t(a1), C.uintptr_t(a2), C.uintptr_t(a3), | 53 | args := C.syscall9Args{C.uintptr_t(fn), C.uintptr_t(a1), C.uintptr_t(a2), C.uintptr_t(a3), | ||