-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Cgo support for NetBSD #268
Draft
TotallyGamerJet
wants to merge
33
commits into
ebitengine:main
Choose a base branch
from
TotallyGamerJet:issue-249_netbsd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+153
−17
Draft
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
10556e5
CGO support for Netbsd
TotallyGamerJet 5068751
missing build tag
TotallyGamerJet 92769ac
syscallArgs
TotallyGamerJet 000117c
syscall15Args
TotallyGamerJet b23644e
some more
TotallyGamerJet 68d652c
build tag
TotallyGamerJet cf0745d
test
TotallyGamerJet 3c3731e
build tag for netbsd
TotallyGamerJet e87d728
some more stuff needed fixing
TotallyGamerJet 0b92ec5
ignore tests
TotallyGamerJet 68c9fa4
github actions
TotallyGamerJet 4d82012
include go
TotallyGamerJet f37da23
examples/window: replace deprecated functions (#269)
hajimehoshi f8c7742
all: remove dependencies on golang.org/x/sys (#271)
hajimehoshi 128551e
Clarify Example section and Dl* windows equivalents (#274)
TotallyGamerJet 5ad9415
purego: mention LoadLibraryEx at Dlopen (#275)
hajimehoshi c3f4c9c
examples: remove depdencies on golang.org/x/sys/windows (#278)
hajimehoshi f091b66
all: release v0.9.0-alpha
hajimehoshi 570751c
test
TotallyGamerJet 4b324b2
fix install Go on freebsd
TotallyGamerJet 7ab8812
fix install Go on freebsd
TotallyGamerJet 3b55709
fix install Go
TotallyGamerJet ec53690
remove Go versions that dl doesn't have downloads for
TotallyGamerJet 49cf092
mkdir
TotallyGamerJet ae1d516
specify default shell
TotallyGamerJet 6c57d3f
disabled syncing to host VM
TotallyGamerJet ed60fb8
try installing bash
TotallyGamerJet c5caadb
prefix pkg_add
TotallyGamerJet d668211
try bash
TotallyGamerJet 85a72ad
remove some bash references
TotallyGamerJet 7773c24
go plugin not supported on netbsd
TotallyGamerJet 9ddd066
remove echo
TotallyGamerJet ea999fd
Merge branch 'refs/heads/main' into issue-249_netbsd
TotallyGamerJet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2024 The Ebitengine Authors | ||
|
||
package purego | ||
|
||
import "github.com/ebitengine/purego/internal/cgo" | ||
|
||
// Source for constants: https://github.com/NetBSD/src/blob/trunk/include/dlfcn.h | ||
|
||
const ( | ||
intSize = 32 << (^uint(0) >> 63) // 32 or 64 | ||
RTLD_DEFAULT = 1<<intSize - 2 // Pseudo-handle for dlsym so search for any loaded symbol | ||
RTLD_LAZY = 0x00000001 // Relocations are performed at an implementation-dependent time. | ||
RTLD_NOW = 0x00000002 // Relocations are performed when the object is loaded. | ||
RTLD_LOCAL = 0x00000000 // All symbols are not made available for relocation processing by other modules. | ||
RTLD_GLOBAL = 0x00000100 // All symbols are available for relocation processing of other modules. | ||
) | ||
|
||
func Dlopen(path string, mode int) (uintptr, error) { | ||
return cgo.Dlopen(path, mode) | ||
} | ||
|
||
func Dlsym(handle uintptr, name string) (uintptr, error) { | ||
return cgo.Dlsym(handle, name) | ||
} | ||
|
||
func Dlclose(handle uintptr) error { | ||
return cgo.Dlclose(handle) | ||
} | ||
|
||
func loadSymbol(handle uintptr, name string) (uintptr, error) { | ||
return Dlsym(handle, name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 The Ebitengine Authors | ||
|
||
//go:build darwin || freebsd || linux | ||
//go:build darwin || freebsd || linux || netbsd | ||
|
||
package purego_test | ||
|
||
|
@@ -54,7 +54,7 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | |
} | ||
|
||
var args []string | ||
if runtime.GOOS == "freebsd" { | ||
if runtime.GOOS == "freebsd" || runtime.GOOS == "netbsd" { | ||
args = []string{"-shared", "-Wall", "-Werror", "-fPIC", "-o", libFile} | ||
} else { | ||
args = []string{"-shared", "-Wall", "-Werror", "-o", libFile} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of curiosity, can't we use -fPIC for other platforms than FreeBSD and NetBSD? |
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2024 The Ebitengine Authors | ||
|
||
//go:build cgo | ||
|
||
package purego | ||
|
||
import ( | ||
"github.com/ebitengine/purego/internal/cgo" | ||
) | ||
|
||
var syscall15XABI0 = uintptr(cgo.Syscall15XABI0) | ||
|
||
//go:nosplit | ||
func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) { | ||
return cgo.Syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) | ||
} | ||
|
||
func NewCallback(_ interface{}) uintptr { | ||
panic("purego: NewCallback is not supported on NetBSD") | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add to build tests for NetBSD in other platforms (e.g. Can we build a NetBSD binary in FreeBSD?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's possible. We'd need to explicitly enable cgo since it's a cross compile. I'll try once the build in NetBSD is working