Skip to content

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

@cplepage

Description

@cplepage

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgeOS-Darwincompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions