Skip to content

Darwin: linker could not find symbol _syscall.Syscall #4794

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

Open
Tryanks opened this issue Mar 10, 2025 · 1 comment
Open

Darwin: linker could not find symbol _syscall.Syscall #4794

Tryanks opened this issue Mar 10, 2025 · 1 comment
Labels

Comments

@Tryanks
Copy link

Tryanks commented Mar 10, 2025

Cannot call the syscall.Syscall() method on MacOS.

  • System Version: MacOS 15.3.1 (24D70)
  • Go Version: 1.24.1
  • Tinygo Version: 0.36.0

Minimal reproducible code:

package main

import (
	"syscall"
)

func main() {
	// Only building is required, not executing them, so this line of code can be used for issue reproduction.
	syscall.Syscall(0, 0, 0, 0)
}

Compilation passes with the command go build; compilation also passes with GOOS=linux tinygo build.
However, compilation fails when directly using tinygo build on MacOS:

❯ tinygo build
main.go:8: linker could not find symbol _syscall.Syscall  

Additional information: This also leads to the following issues:
Package golang.org/x/sys reports an error:

golang.org/x/sys@v0.31.0/unix/zsyscall_darwin_arm64.go:734: linker could not find symbol _golang.org/x/sys/unix.syscall_syscall  

Package modernc.org/memory reports an error:

modernc.org/memory@v1.8.2/mmap_unix.go:25: linker could not find symbol _syscall.Syscall  
@aykevl
Copy link
Member

aykevl commented Mar 10, 2025

Raw syscalls are not supported on MacOS, and are not documented as far as I know. Go used to use these raw syscalls, but switched to using the system libc instead that are supported. TinyGo also uses the system libc (and not raw syscalls) for the same reason.

If you look at modernc.org/memory for example, you'll see this:

func unmap(addr uintptr, size int) error {
	_, _, errno := syscall.Syscall(syscall.SYS_MUNMAP, addr, uintptr(size), 0)
	if errno != 0 {
		return errno
	}
	return nil
}

This uses the unsupported raw syscalls. They might still work in standard Go, but can break at any time Apple decides to change these syscalls.
I think the best solution here would be for the modernc.org/memory package to use syscall.Mmap instead.

As for golang.org/x/sys, that's probably a genuine bug in TinyGo. I'll need to look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants