Skip to content

cmd/cgo: rt0_go failure on Windows when using zig cc #43886

@andrewrk

Description

@andrewrk

Hello, any Go developers interested in working with Zig developers on this use case?

Upstream issue: ziglang/zig#7874
Tested with go 1.15.5.

main.go

package main

//int Add(int a, int b){
//    return a+b;
//}
import "C"
import "fmt"

func main() {
	a := C.int(10)
	b := C.int(20)
	c := C.Add(a, b)
	fmt.Println(c) // 30
}

CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="zcc" CXX="zc++" go build main.go

zcc

#!/bin/sh
zig cc -target x86_64-windows-gnu $@

zc++

#!/bin/sh
zig c++ -target x86_64-windows-gnu $@

output:

# command-line-arguments
warning: unsupported linker arg: --compress-debug-sections=zlib-gnu

It produces main.exe but when run it segfaults in runtime.rt0_go() (called from main()). Expected output is to print "30" to the console when run in cmd.exe.

Happy to chat on IRC or Discord if anyone has some ideas to try.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windowscompiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions