From dae4d81f96e5f2abc3bda9c0e0de8957ba5badf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 3 Jun 2021 20:09:04 +0300 Subject: [PATCH] wip musl --- zig-toolchains/BUILD.bazel | 16 +++++++++++ zig-toolchains/defs.bzl | 54 +++++++++++++++++++------------------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/zig-toolchains/BUILD.bazel b/zig-toolchains/BUILD.bazel index e69de29..28143e2 100644 --- a/zig-toolchains/BUILD.bazel +++ b/zig-toolchains/BUILD.bazel @@ -0,0 +1,16 @@ +constraint_setting(name = "libc") + +constraint_value( + name = "glibc_2_28", + constraint_setting = ":libc", +) + +constraint_value( + name = "musl", + constraint_setting = ":libc", +) + +#constraint_value( +# name = "glibc_2_19", +# constraint_setting = ":libc", +#) diff --git a/zig-toolchains/defs.bzl b/zig-toolchains/defs.bzl index 8bb7111..52e9c81 100644 --- a/zig-toolchains/defs.bzl +++ b/zig-toolchains/defs.bzl @@ -2,10 +2,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load(":zig_toolchain.bzl", "zig_cc_toolchain_config") DEFAULT_TOOL_PATHS = { - "ar": "llvm-ar", # TODO this should be "build-lib", see https://github.com/ziglang/zig/issues/7915 + "ar": "ar", "gcc": "c++", # https://github.com/bazelbuild/bazel/issues/4644 - # TODO See https://github.com/ziglang/zig/issues/7917 for zig issue to implement these other tools. "cpp": "/usr/bin/false", "gcov": "/usr/bin/false", "nm": "/usr/bin/false", @@ -15,9 +14,8 @@ DEFAULT_TOOL_PATHS = { DEFAULT_INCLUDE_DIRECTORIES = [ "include", - # "libcxx/include", - # "libcxxabi/include", - # "libunwind/include", + "libcxx/include", + "libcxxabi/include", ] # https://github.com/ziglang/zig/blob/0cfa39304b18c6a04689bd789f5dc4d035ec43b0/src/main.zig#L2962-L2966 @@ -25,8 +23,6 @@ TARGET_CONFIGS = [ struct( target="x86_64-macos-gnu", includes=[ - "libcxx/include", - "libcxxabi/include", "libunwind/include", "libc/include/any-macos-any", "libc/include/x86_64-macos-any", @@ -42,28 +38,28 @@ TARGET_CONFIGS = [ # If this gets uncommented, bazel will put `-target <...>gnu`, even if # the platform is explicitly set to: # --platforms=@com_github_ziglang_zig//:x86_64-linux-musl - #struct( - # target="x86_64-linux-gnu.2.28", - # includes=[ - # "libcxx/include", - # "libcxxabi/include", - # "libunwind/include", - # "libc/include/generic-glibc", - # "libc/include/any-linux-any", - # "libc/include/x86_64-linux-gnu", - # "libc/include/x86_64-linux-any", - # ], - # linkopts=["-lc++", "-lc++abi"], - # copts=[], - # bazel_target_cpu="k8", - # constraint_values=["@platforms//os:linux", "@platforms//cpu:x86_64"], - # tool_paths={"ld": "ld.lld"}, - #), + struct( + target="x86_64-linux-gnu.2.28", + includes=[ + "libunwind/include", + "libc/include/generic-glibc", + "libc/include/any-linux-any", + "libc/include/x86_64-linux-gnu", + "libc/include/x86_64-linux-any", + ], + linkopts=["-lc++", "-lc++abi"], + copts=[], + bazel_target_cpu="k8", + constraint_values=[ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + #"//zig-toolchains:glibc_2_28", + ], + tool_paths={"ld": "ld.lld"}, + ), struct( target="x86_64-linux-musl", includes=[ - "libcxx/include", - "libcxxabi/include", "libc/include/generic-musl", "libc/include/any-linux-any", "libc/include/x86_64-linux-musl", @@ -72,7 +68,11 @@ TARGET_CONFIGS = [ linkopts=[], copts=["-D_LIBCPP_HAS_MUSL_LIBC", "-D_LIBCPP_HAS_THREAD_API_PTHREAD"], bazel_target_cpu="k8", - constraint_values=["@platforms//os:linux", "@platforms//cpu:x86_64"], + constraint_values=[ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + #"//zig-toolchains:musl", + ], tool_paths={"ld": "ld.lld"}, ), ]