Skip to content

Undeclared names on Mac M1 #1027

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

Closed
aragonet opened this issue May 17, 2021 · 8 comments · Fixed by #1029
Closed

Undeclared names on Mac M1 #1027

aragonet opened this issue May 17, 2021 · 8 comments · Fixed by #1029

Comments

@aragonet
Copy link

When I try to compile using the latest version of gopherjs (1.16.1+go1.16.3) this is the output errors:

gopherjs build
../../../../../src/syscall/syscall_darwin.go:11:25: undeclared name: libc_stat64_trampoline
../../../../../src/syscall/syscall_darwin.go:13:25: undeclared name: libc_fstat64_trampoline
../../../../../src/syscall/syscall_darwin.go:15:25: undeclared name: libc_lstat64_trampoline

I've compiled the same code on linux and compiles fine. Maybe its something related to Mac M1 arm64.

Thanks in advance

@nevkontakte
Copy link
Member

Could you please share your go env printout?

@aragonet
Copy link
Author

GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/xxxxx/Library/Caches/go-build"
GOENV="/Users/xxxxx/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/xxxxxxx/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/xxxxxx/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.16.2/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.16.2/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/xxxxxx/logic/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sy/ht4qsj_n66v25g6d7v91thtc0000gn/T/go-build1093755415=/tmp/go-build -gno-record-gcc-switches -fno-common"

@nevkontakte
Copy link
Member

Actually, #1024 might have fixed this already, but we forgot to tag a new release with it. Could you try GopherJS from master and see if you still have a problem? If not, I'll tag a new release tomorrow.

@aragonet
Copy link
Author

I've installed from master, and the error stills appearing.

@nevkontakte
Copy link
Member

Can you provide a minimal reproduction example and the exact commands you've used?

I've tried the following and it worked just fine:

package main

import (
        "fmt"
        "syscall"
)

func main() {
        buf := [4]byte{}
        fmt.Println(syscall.Read(syscall.Stdin, buf[:]))
        fmt.Println(buf)
}

$ GOOS=darwin GOARCH=arm64 gopherjs build .

Unfortunately, I don't have access to an M1 mac, so this is the closes I can get to reproducing an error.

@nevkontakte
Copy link
Member

@aragonet could you please provide a minimal reproduction example? Otherwise I'll assume this is a duplicate of #1023.

@aragonet
Copy link
Author

Sorry for answering a bit late. Just tried to build the code you provided and the same three lines of output appear.

gopherjs build .
../../../../../src/syscall/syscall_darwin.go:11:25: undeclared name: libc_stat64_trampoline
../../../../../src/syscall/syscall_darwin.go:13:25: undeclared name: libc_fstat64_trampoline
../../../../../src/syscall/syscall_darwin.go:15:25: undeclared name: libc_lstat64_trampoline

If there is any way I can help you find the problem I'll be pleased.

@nevkontakte
Copy link
Member

nevkontakte commented May 24, 2021

Ok, thanks for confirming this is still an issue. It is strange that it builds just fine for me despite setting GOOS/GOARCH to match yours. Perhaps, there's a deeper bug lurking about here... I'll investigate more sometime this week.

nevkontakte added a commit to nevkontakte/gopherjs that referenced this issue May 30, 2021
So long as we rely on OS-specific syscalls, we must build the package
with OS-appropriate GOOS/GOARCH (see also
gopherjs#693). Using runtime.GOOS
here is not ideal, since it ignores environment variables, making
"cross-compiling" impossible.

This is not a big deal in most cases, but makes reproducing errors like
in gopherjs#1027 more difficult.
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 a pull request may close this issue.

2 participants