aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2015-04-09 10:44:05 -0400
committerDavid Crawshaw <crawshaw@golang.org>2015-04-12 14:00:32 +0000
commitced7ffe95ba176b26ef835b2f225255d1cd7808f (patch)
tree03e5cbdffd2b109b0fd304d98b2cf5aa1274ffba /src/debug
parent6e3a6c4d384bb1ca532727bbd7a1cd221786c42a (diff)
downloadgo-ced7ffe95ba176b26ef835b2f225255d1cd7808f.tar.xz
cmd/interal/ld: darwin c-archive buildmode support
Uses ar to create an archive when -buildmode=c-archive. A small example (that I hope to turn into a test in a later CL): goarchive.go: package main import "fmt" import "C" func init() { fmt.Println("ran go init") } //export FuncInGo func FuncInGo() { fmt.Println("called a go function") } func main() { fmt.Println("in main") } This can be compiled with: go build -ldflags=-buildmode=c-archive -o=libgo.a goarchive.go main.c: #include <stdio.h> extern void FuncInGo(); int main(void) { printf("c hello\n"); FuncInGo(); printf("c goodbye\n"); return 0; } Can be compiled with: cc main.c libgo.a Apple provide a warning about the lack of PIE, but still produce a binary which runs and outputs (on darwin/amd64): c hello ran go init called a go function c goodbye Change-Id: I7611925f210a83afa6bd1e66a5601dd636a428c8 Reviewed-on: https://go-review.googlesource.com/8711 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/debug')
0 files changed, 0 insertions, 0 deletions