all: use RTLD_LAZY in dlopen for darwin (#2453)

dlopen requires either RTLD_LAZY or RTLD_NOW but there was neither.

Updates #1162
This commit is contained in:
TotallyGamerJet 2022-11-13 11:44:51 -08:00 committed by GitHub
parent 072e91d67f
commit 56ec19caa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 7 deletions

View File

@ -50,7 +50,7 @@ const (
)
var (
corefoundation = purego.Dlopen("CoreFoundation.framework/CoreFoundation", purego.RTLD_GLOBAL)
corefoundation = purego.Dlopen("CoreFoundation.framework/CoreFoundation", purego.RTLD_LAZY|purego.RTLD_GLOBAL)
procCFNumberCreate = purego.Dlsym(corefoundation, "CFNumberCreate")
procCFNumberGetValue = purego.Dlsym(corefoundation, "CFNumberGetValue")
procCFArrayCreate = purego.Dlsym(corefoundation, "CFArrayCreate")

View File

@ -85,7 +85,7 @@ type _IOHIDElementType uint32
type _IOHIDDeviceCallback func(context unsafe.Pointer, result _IOReturn, sender unsafe.Pointer, device _IOHIDDeviceRef)
var (
iokit = purego.Dlopen("IOKit.framework/IOKit", purego.RTLD_GLOBAL)
iokit = purego.Dlopen("IOKit.framework/IOKit", purego.RTLD_LAZY|purego.RTLD_GLOBAL)
procIOHIDElementGetTypeID = purego.Dlsym(iokit, "IOHIDElementGetTypeID")
procIOHIDManagerCreate = purego.Dlsym(iokit, "IOHIDManagerCreate")

View File

@ -49,7 +49,7 @@ type MetalLayer struct {
}
var (
coreGraphics = purego.Dlopen("/System/Library/Frameworks/CoreGraphics.framework/Versions/Current/CoreGraphics", purego.RTLD_GLOBAL)
coreGraphics = purego.Dlopen("/System/Library/Frameworks/CoreGraphics.framework/Versions/Current/CoreGraphics", purego.RTLD_LAZY|purego.RTLD_GLOBAL)
_CGColorSpaceCreateWithName = purego.Dlsym(coreGraphics, "CGColorSpaceCreateWithName")
_CGColorSpaceRelease = purego.Dlsym(coreGraphics, "CGColorSpaceRelease")
kCGColorSpaceDisplayP3 = purego.Dlsym(coreGraphics, "kCGColorSpaceDisplayP3")

View File

@ -35,7 +35,7 @@ func init() {
//go:cgo_import_dynamic _ _ "Metal.framework/Metal"
// It is also necessary for CoreGraphics to be linked
purego.Dlopen("/System/Library/Frameworks/CoreGraphics.framework/Versions/Current/CoreGraphics", purego.RTLD_GLOBAL)
purego.Dlopen("/System/Library/Frameworks/CoreGraphics.framework/Versions/Current/CoreGraphics", purego.RTLD_LAZY|purego.RTLD_GLOBAL)
}
func Example_listDevices() {

View File

@ -348,7 +348,7 @@ const (
)
var (
metal = purego.Dlopen("Metal.framework/Metal", purego.RTLD_GLOBAL)
metal = purego.Dlopen("Metal.framework/Metal", purego.RTLD_LAZY|purego.RTLD_GLOBAL)
_MTLCreateSystemDefaultDevice = purego.Dlsym(metal, "MTLCreateSystemDefaultDevice")
)

View File

@ -24,12 +24,12 @@ var (
)
func init() {
opengl = purego.Dlopen("/System/Library/Frameworks/OpenGLES.framework/Versions/Current/OpenGLES", purego.RTLD_GLOBAL)
opengl = purego.Dlopen("/System/Library/Frameworks/OpenGLES.framework/Versions/Current/OpenGLES", purego.RTLD_LAZY|purego.RTLD_GLOBAL)
if opengl != 0 {
isES = true
return
}
opengl = purego.Dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", purego.RTLD_GLOBAL)
opengl = purego.Dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", purego.RTLD_LAZY|purego.RTLD_GLOBAL)
}
func getProcAddress(name string) uintptr {