-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
downstreamAn issue with a third party project that uses Zig.An issue with a third party project that uses Zig.zig ccZig as a drop-in C compiler featureZig as a drop-in C compiler feature
Milestone
Description
Zig Version
0.10.0-dev.1734+7b7f45dc2
Steps to Reproduce
go.mod:
module test
go 1.18
foo.go:
package test
func foo() {}foo_test.go:
package test
import (
"testing"
)
func TestFoo(t *testing.T) {
foo()
}Then use zig cc as the C toolchain for go test with race detection:
CGO_ENABLED=1 CC="zig cc" go test -race testThis is on x86_64 Linux.
Expected Behavior
This should work, as it does without -race.
Actual Behavior
We get errors from the Go linker:
# test.test
runtime/race(.text): relocation target getuid not defined
runtime/race(.text): relocation target pthread_self not defined
runtime/race(.text): relocation target sleep not defined
runtime/race(.text): relocation target usleep not defined
runtime/race(.text): relocation target abort not defined
runtime/race(.text): relocation target isatty not defined
runtime/race(.text): relocation target pthread_attr_getstack not defined
runtime/race(.text): relocation target sigaction not defined
runtime/race(.text): relocation target getrusage not defined
runtime/race(.text): relocation target syslog not defined
runtime/race(.text): relocation target confstr not defined
runtime/race(.text): relocation target getrlimit not defined
runtime/race(.text): relocation target pipe not defined
runtime/race(.text): relocation target sched_getaffinity not defined
runtime/race(.text): relocation target __sched_cpucount not defined
runtime/race(.text): relocation target pthread_attr_init not defined
runtime/race(.text): relocation target pthread_getattr_np not defined
runtime/race(.text): relocation target pthread_attr_destroy not defined
runtime/race(.text): relocation target exit not defined
runtime/race(.text): relocation target sysconf not defined
runtime/race(.text): relocation target setrlimit not defined
/home/kmicklas/go/pkg/tool/linux_amd64/link: too many errors
FAIL test [build failed]
FAIL
One interesting thing to note is that adding import "C" (i.e. triggering the use of cgo) to foo.go makes this example work. However, this only seems to work most of the time in larger examples.
Metadata
Metadata
Assignees
Labels
downstreamAn issue with a third party project that uses Zig.An issue with a third party project that uses Zig.zig ccZig as a drop-in C compiler featureZig as a drop-in C compiler feature