8000 all: fix the link error with Go 1.24.3 by hajimehoshi · Pull Request #312 · ebitengine/purego · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

all: fix the link error with Go 1.24.3 #312

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

Merged
merged 3 commits into from
May 7, 2025

Conversation

hajimehoshi
Copy link
Member
@hajimehoshi hajimehoshi commented May 7, 2025

What issue is this addressing?

This addresses the issue golang/go#73617.

What type of issue is this addressing?

n/a

What this PR does | solves

Closes #313

Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the Go versions in the workflow configuration to include newer available versions.

  • Updated Go version matrix in the test workflow
  • Minor version bumps for Go 1.23 and 1.24 in the CI configuration

@corani
Copy link
corani commented May 7, 2025

See also: golang/go#73617

I don't know if this is an issue with Go, or with this module...

@corani
Copy link
corani commented May 7, 2025

I noticed:

purego/dlfcn_darwin.go

Lines 16 to 24 in 9059adf

//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib"

Is it intentional that this block is duplicated?
-> this doesn't seem to be the issue though...

@hajimehoshi
Copy link
Member Author

@TotallyGamerJet

@TotallyGamerJet
Copy link
Collaborator

See also: golang/go#73617

I don't know if this is an issue with Go, or with this module...

At first glance, this looks like a regression in the Go toolchain itself.

I noticed:

purego/dlfcn_darwin.go

Lines 16 to 24 in 9059adf

//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib"
//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib"

Is it intentional that this block is duplicated? -> this doesn't seem to be the issue though...

I don't remember why I did it that way. I'm pretty confident the duplicated lines are unnecessary. We can remove it after the Go toolchain is resolved

@hajimehoshi
Copy link
Member Author

We can remove it after the Go toolchain is resolved

Don't we have to wait for the Go toolchain fix?

@hajimehoshi
Copy link
Member Author

The test failure for FreeBSD seems another issue by the way.

@TotallyGamerJet
Copy link
Collaborator

We can remove it after the Go toolchain is resolved

Don't we have to wait for the Go toolchain fix?

We can remove it now it doesn't break any of the current Go versions but it's probably best to wait until things are resolved

@TotallyGamerJet
Copy link
Collaborator

The test failure for FreeBSD seems another issue by the way.

FreeBSD is having the same issue as macOS described in the Go issue

@hajimehoshi
Copy link
Member Author
# github.com/ebitengine/purego/examples/libc
  link: duplicated definition of symbol dlopen, from github.com/ebitengine/purego and github.com/ebitengine/purego
  github.com/ebitengine/purego/examples/objc
  github.com/ebitengine/purego/examples/window
  # github.com/ebitengine/purego/examples/window
  link: duplicated definition of symbol dlopen, from github.com/ebitengine/purego and github.com/ebitengine/purego
  # github.com/ebitengine/purego/examples/objc
  link: duplicated definition of symbol dlopen, from github.com/ebitengine/purego and github.com/ebitengine/purego

Ah yes that's right.

Maybe the CI doesn't run the latest Go for macOS yet, which is why the tests passed for macOS now.

@hajimehoshi
Copy link
Member Author

Removing the duplicated symbols didn't fix the issue. Hmm?

@TotallyGamerJet
Copy link
Collaborator

Removing the duplicated symbols didn't fix the issue. Hmm?

I wouldn't think it would. The issue is in the linker not with our code

@TotallyGamerJet
Copy link
Collaborator

@hajimehoshi this patch suggested by cherrymui appears to fix the issue

Subject: [PATCH] uintptr -> uint8
---
Index: dlfcn.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/dlfcn.go b/dlfcn.go
--- a/dlfcn.go	(revision 2c36c15debde48b37b30e9ae9dea32483ef79922)
+++ b/dlfcn.go	(date 1746631095267)
@@ -83,17 +83,17 @@
 // appear to work if you link directly to the C function on darwin arm64.
 
 //go:linkname dlopen dlopen
-var dlopen uintptr
+var dlopen uint8
 var dlopenABI0 = uintptr(unsafe.Pointer(&dlopen))
 
 //go:linkname dlsym dlsym
-var dlsym uintptr
+var dlsym uint8
 var dlsymABI0 = uintptr(unsafe.Pointer(&dlsym))
 
 //go:linkname dlclose dlclose
-var dlclose uintptr
+var dlclose uint8
 var dlcloseABI0 = uintptr(unsafe.Pointer(&dlclose))
 
 //go:linkname dlerror dlerror
-var dlerror uintptr
+var dlerror uint8
 var dlerrorABI0 = uintptr(unsafe.Pointer(&dlerror))
Index: internal/fakecgo/symbols.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/internal/fakecgo/symbols.go b/internal/fakecgo/symbols.go
--- a/internal/fakecgo/symbols.go	(revision 2c36c15debde48b37b30e9ae9dea32483ef79922)
+++ b/internal/fakecgo/symbols.go	(date 1746631236394)
@@ -126,85 +126,85 @@
 }
 
 //go:linkname _malloc _malloc
-var _malloc uintptr
+var _malloc uint8
 var mallocABI0 = uintptr(unsafe.Pointer(&_malloc))
 
 //go:linkname _free _free
-var _free uintptr
+var _free uint8
 var freeABI0 = uintptr(unsafe.Pointer(&_free))
 
 //go:linkname _setenv _setenv
-var _setenv uintptr
+var _setenv uint8
 var setenvABI0 = uintptr(unsafe.Pointer(&_setenv))
 
 //go:linkname _unsetenv _unsetenv
-var _unsetenv uintptr
+var _unsetenv uint8
 var unsetenvABI0 = uintptr(unsafe.Pointer(&_unsetenv))
 
 //go:linkname _sigfillset _sigfillset
-var _sigfillset uintptr
+var _sigfillset uint8
 var sigfillsetABI0 = uintptr(unsafe.Pointer(&_sigfillset))
 
 //go:linkname _nanosleep _nanosleep
-var _nanosleep uintptr
+var _nanosleep uint8
 var nanosleepABI0 = uintptr(unsafe.Pointer(&_nanosleep))
 
 //go:linkname _abort _abort
-var _abort uintptr
+var _abort uint8
 var abortABI0 = uintptr(unsafe.Pointer(&_abort))
 
 //go:linkname _sigaltstack _sigaltstack
-var _sigaltstack uintptr
+var _sigaltstack uint8
 var sigaltstackABI0 = uintptr(unsafe.Pointer(&_sigaltstack))
 
 //go:linkname _pthread_attr_init _pthread_attr_init
-var _pthread_attr_init uintptr
+var _pthread_attr_init uint8
 var pthread_attr_initABI0 = uintptr(unsafe.Pointer(&_pthread_attr_init))
 
 //go:linkname _pthread_create _pthread_create
-var _pthread_create uintptr
+var _pthread_create uint8
 var pthread_createABI0 = uintptr(unsafe.Pointer(&_pthread_create))
 
 //go:linkname _pthread_detach _pthread_detach
-var _pthread_detach uintptr
+var _pthread_detach uint8
 var pthread_detachABI0 = uintptr(unsafe.Pointer(&_pthread_detach))
 
 //go:linkname _pthread_sigmask _pthread_sigmask
-var _pthread_sigmask uintptr
+var _pthread_sigmask uint8
 var pthread_sigmaskABI0 = uintptr(unsafe.Pointer(&_pthread_sigmask))
 
 //go:linkname _pthread_self _pthread_self
-var _pthread_self uintptr
+var _pthread_self uint8
 var pthread_selfABI0 = uintptr(unsafe.Pointer(&_pthread_self))
 
 //go:linkname _pthread_get_stacksize_np _pthread_get_stacksize_np
-var _pthread_get_stacksize_np uintptr
+var _pthread_get_stacksize_np uint8
 var pthread_get_stacksize_npABI0 = uintptr(unsafe.Pointer(&_pthread_get_stacksize_np))
 
 //go:linkname _pthread_attr_getstacksize _pthread_attr_getstacksize
-var _pthread_attr_getstacksize uintptr
+var _pthread_attr_getstacksize uint8
 var pthread_attr_getstacksizeABI0 = uintptr(unsafe.Pointer(&_pthread_attr_getstacksize))
 
 //go:linkname _pthread_attr_setstacksize _pthread_attr_setstacksize
-var _pthread_attr_setstacksize uintptr
+var _pthread_attr_setstacksize uint8
 var pthread_attr_setstacksizeABI0 = uintptr(unsafe.Pointer(&_pthread_attr_setstacksize))
 
 //go:linkname _pthread_attr_destroy _pthread_attr_destroy
-var _pthread_attr_destroy uintptr
+var _pthread_attr_destroy uint8
 var pthread_attr_destroyABI0 = uintptr(unsafe.Pointer(&_pthread_attr_destroy))
 
 //go:linkname _pthread_mutex_lock _pthread_mutex_lock
-var _pthread_mutex_lock uintptr
+var _pthread_mutex_lock uint8
 var pthread_mutex_lockABI0 = uintptr(unsafe.Pointer(&_pthread_mutex_lock))
 
 //go:linkname _pthread_mutex_unlock _pthread_mutex_unlock
-var _pthread_mutex_unlock uintptr
+var _pthread_mutex_unlock uint8
 var pthread_mutex_unlockABI0 = uintptr(unsafe.Pointer(&_pthread_mutex_unlock))
 
 //go:linkname _pthread_cond_broadcast _pthread_cond_broadcast
-var _pthread_cond_broadcast uintptr
+var _pthread_cond_broadcast uint8
 var pthread_cond_broadcastABI0 = uintptr(unsafe.Pointer(&_pthread_cond_broadcast))
 
 //go:linkname _pthread_setspecific _pthread_setspecific
-var _pthread_setspecific uintptr
+var _pthread_setspecific uint8
 var pthread_setspecificABI0 = uintptr(unsafe.Pointer(&_pthread_setspecific))
Index: internal/fakecgo/gen.go
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/internal/fakecgo/gen.go b/internal/fakecgo/gen.go
--- a/internal/fakecgo/gen.go	(revision 2c36c15debde48b37b30e9ae9dea32483ef79922)
+++ b/internal/fakecgo/gen.go	(date 1746631171875)
@@ -76,7 +76,7 @@
 {{end}}
 {{- range . }}
 //go:linkname _{{.Name}} _{{.Name}}
-var _{{.Name}} uintptr
+var _{{.Name}} uint8
 var {{.Name}}ABI0 = uintptr(unsafe.Pointer(&_{{.Name}}))
 {{ end }}

@hajimehoshi
Copy link
Member Author

Yeah, the uint8 patch worked, thanks!

@hajimehoshi hajimehoshi changed the title .github/workflows: update Go versions internal/fakecgo: fix the link error with Go 1.24.3 May 7, 2025
@hajimehoshi hajimehoshi changed the title internal/fakecgo: fix the link error with Go 1.24.3 all: fix the link error with Go 1.24.3 May 7, 2025
Copy link
Collaborator
@TotallyGamerJet TotallyGamerJet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hajimehoshi
Copy link
Member Author

I'll check-pick this fix to the stable branch 0.8, and tag it a few days later.

@hajimehoshi hajimehoshi merged commit 5047c08 into ebitengine:main May 7, 2025
55 of 56 checks passed
@hajimehoshi hajimehoshi deleted the update branch May 7, 2025 17:16
hajimehoshi added a commit that referenced this pull request May 7, 2025
@adrianosela
Copy link

Hi @hajimehoshi thanks for fixing this so quickly! When can we expect a new release of this module?

@TotallyGamerJet
Copy link
Collaborator

Hi @hajimehoshi thanks for fixing this so quickly! When can we expect a new release of this module?

In a few days

@hajimehoshi
Copy link
Member Author

Yeah, and if you are in a hurry, please specify the commit hash directly (1638563)

@BrunoKrugel
Copy link

Yeah, and if you are in a hurry, please specify the commit hash directly (1638563)

how to do this?

@hajimehoshi
Copy link
Member Author
hajimehoshi commented May 9, 2025

how to do this?

go get github.com/ebitengine/purego@1638563e361522e5f63511d84c4541ae1c5fd704

EDIT: We've released v0.8.3

go get github.com/ebitengine/purego@v0.8.3

eliottness added a commit to DataDog/go-libddwaf that referenced this pull request May 12, 2025
bringing up the stack ebitengine/purego#312

---------

Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
sandydoo added a commit to sandydoo/process-compose that referenced this pull request May 28, 2025
Bumps purego to fix a linker issue with dlopen on x86_64-darwin.

```
link: duplicated definition of symbol dlopen, from github.com/ebitengine/purego and github.com/ebitengine/purego
````

See ebitengine/purego#312
F1bonacc1 pushed a commit to F1bonacc1/process-compose that referenced this pull request May 28, 2025
Bumps purego to fix a linker issue with dlopen on x86_64-darwin.

```
link: duplicated definition of symbol dlopen, from github.com/ebitengine/purego and github.com/ebitengine/purego
````

See ebitengine/purego#312
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build failure for macOS with Go 1.23.9 / Go 1.24.3
5 participants
0