1

rename zig toolchain to match go

This commit is contained in:
Motiejus Jakštys 2021-07-21 14:53:39 +03:00
parent d78d78393b
commit cb10c591be
2 changed files with 9 additions and 5 deletions

View File

@ -20,7 +20,7 @@ tasks:
- test_x86_64-linux-musl: |
cd bazel-zig-cc; . .envrc; ./build-and-file \
--platforms @io_bazel_rules_go//go/toolchain:linux_amd64_cgo \
--extra_toolchains @zig_sdk//:x86_64-linux-musl_toolchain //test:hello | \
--extra_toolchains @zig_sdk//:linux_amd64_musl_toolchain //test:hello | \
grep -q "ELF 64-bit.* x86-64.* statically linked"
- test_aarch64-linux-gnu: |
cd bazel-zig-cc; . .envrc; ./build-and-file \
@ -29,7 +29,7 @@ tasks:
- test_aarch64-linux-musl: |
cd bazel-zig-cc; . .envrc; ./build-and-file \
--platforms @io_bazel_rules_go//go/toolchain:linux_arm64_cgo \
--extra_toolchains @zig_sdk//:aarch64-linux-musl_toolchain //test:hello | \
--extra_toolchains @zig_sdk//:linux_arm64_musl_toolchain //test:hello | \
grep -q "ELF 64-bit.* ARM aarch64.* statically linked"
- test_x86_64-macos-gnu: |
cd bazel-zig-cc; . .envrc; ./build-and-file \

View File

@ -21,6 +21,7 @@ DEFAULT_INCLUDE_DIRECTORIES = [
# https://github.com/ziglang/zig/blob/0cfa39304b18c6a04689bd789f5dc4d035ec43b0/src/main.zig#L2962-L2966
TARGET_CONFIGS_LISTOFLISTS = [[
struct(
gotarget = "darwin_{}".format(gocpu),
zigtarget = "{}-macos-gnu".format(zigcpu),
includes = [
"libunwind/include",
@ -39,6 +40,7 @@ TARGET_CONFIGS_LISTOFLISTS = [[
register = True,
),
struct(
gotarget = "linux_{}_gnu".format(gocpu),
zigtarget = "{}-linux-gnu".format(zigcpu),
target_suffix = ".2.19",
includes = [
@ -59,6 +61,7 @@ TARGET_CONFIGS_LISTOFLISTS = [[
register = True,
),
struct(
gotarget = "linux_{}_musl".format(gocpu),
zigtarget = "{}-linux-musl".format(zigcpu),
includes = [
"libc/include/generic-musl",
@ -104,7 +107,7 @@ def register_all_toolchains():
for target_config in TARGET_CONFIGS:
if target_config.register:
native.register_toolchains(
"@zig_sdk//:%s_toolchain" % target_config.zigtarget,
"@zig_sdk//:%s_toolchain" % target_config.gotarget,
)
ZIG_TOOL_PATH = "tools/{zig_tool}"
@ -192,9 +195,10 @@ def zig_build_macro(absolute_path, zig_include_root):
lazy_filegroups = {}
for target_config in TARGET_CONFIGS:
gotarget = target_config.gotarget
zigtarget = target_config.zigtarget
native.platform(
name = zigtarget,
name = gotarget,
constraint_values = target_config.constraint_values,
)
@ -249,7 +253,7 @@ def zig_build_macro(absolute_path, zig_include_root):
)
native.toolchain(
name = zigtarget + "_toolchain",
name = gotarget + "_toolchain",
exec_compatible_with = None,
target_compatible_with = target_config.constraint_values,
toolchain = ":%s_cc_toolchain" % zigtarget,