We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently we cannot compile CGo programs to MacOS (at least x86_64) with default settings:
-no_pie
package main // #include <stdio.h> // char* hello() { return "hello, world"; } // void phello() { printf("%s\n", hello()); } import "C" func main() { C.phello() } func Chello() string { return C.GoString(C.hello()) }
$ CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC="zig cc -target x86_64-macos-none" go build -ldflags=-buildmode=pie . # example.com/x /usr/local/go/pkg/tool/linux_amd64/link: /usr/local/go/pkg/tool/linux_amd64/link: running dsymutil failed: exec: "dsymutil": executable file not found in $PATH
We can make it work by adding -w to the linker flags:
-w
$ go tool link -h |& grep -- -w -w disable DWARF generation $ CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 CC="zig cc -target x86_64-macos-none" go build -ldflags="-w -buildmode=pie" . $ file ./x ./x: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
The text was updated successfully, but these errors were encountered:
This is a GO issue and not Zig's in assuming there is a dsymutil binary in the PATH which generally is not the case on non-native hosts.
dsymutil
Sorry, something went wrong.
Oh wow, I was quite sure I saw zig exec'ing that command, not Go. Sorry!
No problem. As a heads up, I want to implement dsymutil's functionality as part of Zig's linker toolchain in the future.
No branches or pull requests
Currently we cannot compile CGo programs to MacOS (at least x86_64) with default settings:
-no_pie
is discussed in [MachO] error: unsupported linker arg: -no_pie #15438.main.go
Compile to MacOS
We can make it work by adding
-w
to the linker flags:The text was updated successfully, but these errors were encountered: