Go 1.18 build error on Mac: "unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable"
10,864
Solution 1
As per the comments this was caused by an old version of golang.org/x/sys
(mentioned in this issue). Fix is to update with:
go get -u golang.org/x/sys
Solution 2
As documentation mentioned,
- The easiest way : run
get -u golang.org/x/sys
. - Manual : git clone the repository to
$GOPATH/src/golang.org/x/sys
.
Author by
Walter Sun
Updated on June 05, 2022Comments
-
Walter Sun almost 2 years
I upgraded to Go 1.18 on Mac 12+.
'go build' fails with errors like:
# golang.org/x/sys/unix ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/syscall_darwin.1_13.go:25:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:27:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:40:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:43:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:59:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:75:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:90:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:105:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3: //go:linkname must refer to declared function or variable ../../gopath/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3: too many errors Compilation finished with exit code 2
-
Chandra almost 2 yearsi did run
go get -u golang.org/x/sys
but still, my build is failing with the above error : /go/pkg/mod/golang.org/x/[email protected]4dd/unix/syscall_darwin.1_13.go:29:3: //go:linkname must refer to declared function or variable -
Someone Special almost 2 yearsis there a permanent solution to this? It seems I have to do this for every project I started
-
Under-qualified NASA Intern almost 2 years
'go get' is no longer supported outside a module.
Does anyone know an updated solution? -
Brits almost 2 yearsRef
go get
no longer being supported outside a module - see the release notes "In GOPATH mode (with GO111MODULE=off), go get still builds and installs packages, as before.". So if you are not using modules setGO111MODULE=off
(you would need to do this in order to build anyway).