Skip to content
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

cmd/link: missing MachoPlatform for Mac Catalyst and missing INODE64 extname for syscalls (fdopendir, readdir_r, getfsstat) #67175

Closed
cplepage opened this issue May 4, 2024 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. OS-Darwin
Milestone

Comments

@cplepage
Copy link
Contributor

cplepage commented May 4, 2024

Go version

devel go1.23-20130cc36a

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/cplepage/Library/Caches/go-build'
GOENV='/Users/cplepage/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/cplepage/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/cplepage/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/cplepage/go-test/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/cplepage/go-test/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='devel go1.23-20130cc36a Sat May 4 07:51:20 2024 +0000'
GODEBUG=''
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/cplepage/go-test/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/vq/zq3m1f0x5zs54mg06_0n0fnr0000gn/T/go-build2683933799=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Try to compile a Go library (esbuild) to c-archive for Mac Catalyst.

What did you see happen?

The readdir function is absolutely unusable, so I investigated and realized the $INODE64 suffix doesn't get appended to the file system syscall src/cmd/link/internal/ld/macho.go#973 because the machoPlatform gets set to 6 src/cmd/link/internal/ld/macho.go#1331 when trying to compile to target x86_64-apple-ios-macabi (Mac Catalyst).

My makefile setup:

# makefile
CGO_ENABLED=1 \
GOOS=darwin \
GOARCH=amd64 \
SDK=macosx \
CC=$(CURDIR)/clangwrap.sh \
CGO_CFLAGS="-target x86_64-apple-ios-macabi" \
go build -buildmode=c-archive -tags maccatalyst -o esbuild.a ../esbuild/cmd/esbuild

clangwrap.sh

#!/bin/sh

# clangwrap.sh

SDK_PATH=`xcrun --sdk $SDK --show-sdk-path`
CLANG=`xcrun --sdk $SDK --find clang`

if [ "$GOARCH" == "amd64" ]; then
    CARCH="x86_64"
elif [ "$GOARCH" == "arm64" ]; then
    CARCH="arm64"
fi

exec $CLANG -arch $CARCH -isysroot $SDK_PATH "$@"

What did you expect to see?

To readdir as expected. My fix seems to fix the issue, but I might miss a flag or do something wrong. Very open to discussion and other propositions.

@gopherbot
Copy link

Change https://go.dev/cl/583295 mentions this issue: src/cmd/link/internal/ld/macho.go: This change fixes the missing platform for Mac Catalyst

@seankhliao seankhliao changed the title src/cmd/link/internal/ld/macho.go: Missing MachoPlatform for Mac Catalyst and missing INODE64 extname for syscalls (fdopendir, readdir_r, getfsstat) cmd/link: missing MachoPlatform for Mac Catalyst and missing INODE64 extname for syscalls (fdopendir, readdir_r, getfsstat) May 4, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label May 4, 2024
@cherrymui
Copy link
Member

Please note that Catalyst is not currently an officially supported platform. A simple CL that improves it (like the above) is fine, though. Thanks.

@cherrymui cherrymui added this to the Unplanned milestone May 6, 2024
@cherrymui cherrymui added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. OS-Darwin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants