Skip to content

macos-aarch64: segfault when running a CGo binary #14923

Closed
@motiejus

Description

@motiejus

Steps to reproduce:

1. Take CoreFoundation.tbd from an existing MacOS M1 host

I use Ventura 13.2.1:

$ find ~/x/trimmed/ -type f
/home/motiejus/x/trimmed/MacOSX13.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd

2. Compile a Go binary (this file) on a Linux machine:

$ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 CC="/code/zig-linux-x86_64-0.11.0-dev.1975+e17998b39/zig cc -target aarch64-macos-none" go build -buildmode=pie -ldflags "-s -w -linkmode external -extldflags '--sysroot $HOME/x/trimmed/MacOSX13.1.sdk -F /System/Library/Frameworks' " .

3. Actual response

$ ./cgo
minpc= 0x102974960 min= 0x0 maxpc= 0x0 max= 0x0
fatal error: minpc or maxpc invalid
runtime: panic before malloc heap initialized

runtime stack:
zsh: segmentation fault  ./cgo

4. Expected response

$ ./cgo
hello, world

Metadata

Commands taken from @slimsag 's #11303 (comment)
go version 1.20.2 linux/amd64
zig 0.11.0-dev.1975+e17998b39

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions