[zig ld] --gc-sections workaround + tests
`zig cc` emits `--gc-sections` for the linker, which is incompatbile with what CGo thinks about linking. This commit adds a workaround: it will add `--no-gc-sections` to the linking step if the command is not specified (falling back to the default behavior of gcc/clang). Related: https://github.com/golang/go/issues/52690
This commit is contained in:
24
test/gorace/BUILD
Normal file
24
test/gorace/BUILD
Normal file
@@ -0,0 +1,24 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
load("//rules:rules_go.bzl", "go_binary")
|
||||
|
||||
go_library(
|
||||
name = "gorace_lib",
|
||||
srcs = ["main.go"],
|
||||
# keep
|
||||
cgo = True,
|
||||
importpath = "git.sr.ht/~motiejus/bazel-zig-cc/test/gorace",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "gorace",
|
||||
embed = [":gorace_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "gorace_test",
|
||||
srcs = ["main_test.go"],
|
||||
embed = [":gorace_lib"],
|
||||
race = "on",
|
||||
)
|
||||
Reference in New Issue
Block a user