Open
Description
What version of Go are you using (go version
)?
$ go version go version go1.18 gollvm LLVM 15.0.0git 20230721 (experimental) linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="off" GOARCH="amd64" GOBIN="" GOCACHE="/home/abokhanko/.cache/go-build" GOENV="/home/abokhanko/.config/go/env" GOEXE="" GOEXPERIMENT="fieldtrack,regabiwrappers" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/abokhanko/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/abokhanko/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/abokhanko/gollvm/bin" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/abokhanko/gollvm/tools" GOVCS="" GOVERSION="go1.18 gollvm LLVM 15.0.0git 20230721 (experimental)" GCCGO="/home/abokhanko/gollvm/bin/llvm-goc" GOAMD64="v1" AR="ar" CC="/usr/bin/cc" CXX="/usr/bin/c++" CGO_ENABLED="1" GOMOD="" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2805243357=/tmp/go-build -gno-record-gcc-switches -funwind-tables"
What did you do?
$ cat >example10.go <<. package main import "C" import "fmt" //export Bar func Bar() C.int { fmt.Println("Hello!") return C.int(1) } func main() {} . $ cat >example10.c <<. #include "example10.h" int main(int argc, char **argv) { return Bar(); } . $ go build -gccgoflags=-static-libgo -buildmode=c-archive example10.go $ clang example10.c example10.a -lpthread
What did you expect to see?
The program compiles and then executes without errors. This is what happens when using the standard "gc" compiler.
What did you see instead?
$ clang example10.c example10.a -lpthread /usr/bin/ld: example10.a(a.out.a.o): in function `_cgo_c9ae4c457df7_Cfunc_CString': ./cgo-c-prolog-gccgo:27: undefined reference to `runtime_throw' ... /usr/bin/ld: example10.a(a.out.a.o):(.data.DW.ref.__gccgo_personality_v0[DW.ref.__gccgo_personality_v0]+0x0): undefined reference to `__gccgo_personality_v0' clang: error: linker command failed with exit code 1 (use -v to see invocation)
The created archive size is much smaller than archive created by "gc" (100634 vs 4876006 bytes on my machine). This clearly indicates that "-gccgoflags=-static-libgo" option got ignored.