diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index ba8ec07..e8c1fd9 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -362,11 +362,23 @@ def declare_files(os): ]), ) + filegroup( + name = "{}_ar_files".format(target_config.zigtarget), + srcs = [ + ":zig", + ":" + zig_tool_path(os).format( + zig_tool = "ar", + zigtarget = target_config.zigtarget, + ) + ], + ) + filegroup( name = "{}_all_files".format(target_config.zigtarget), srcs = [ ":{}_linker_files".format(target_config.zigtarget), ":{}_compiler_files".format(target_config.zigtarget), + ":{}_ar_files".format(target_config.zigtarget), ], ) diff --git a/toolchain/private/cc_toolchains.bzl b/toolchain/private/cc_toolchains.bzl index 5b7b894..3fa0b93 100644 --- a/toolchain/private/cc_toolchains.bzl +++ b/toolchain/private/cc_toolchains.bzl @@ -61,7 +61,7 @@ def declare_cc_toolchains(os, zig_sdk_path): toolchain_identifier = zigtarget + "-toolchain", toolchain_config = ":%s_cc_config" % zigtarget, all_files = "@zig_sdk//:%s_all_files" % zigtarget, - ar_files = "@zig_sdk//:zig", + ar_files = "@zig_sdk//:%s_ar_files" % zigtarget, compiler_files = "@zig_sdk//:%s_compiler_files" % zigtarget, linker_files = "@zig_sdk//:%s_linker_files" % zigtarget, dwp_files = "@zig_sdk//:empty", diff --git a/toolchain/private/defs.bzl b/toolchain/private/defs.bzl index ea9931f..b650f1e 100644 --- a/toolchain/private/defs.bzl +++ b/toolchain/private/defs.bzl @@ -22,6 +22,8 @@ _GLIBCS = [ "2.34", ] +_INCLUDE_TAIL = ["libcxx/include", "include"] + LIBCS = ["musl"] + ["gnu.{}".format(glibc) for glibc in _GLIBCS] def zig_tool_path(os): @@ -51,8 +53,7 @@ def _target_darwin(gocpu, zigcpu): "libc/include/{}-macos.{}-none".format(zigcpu, min_os), "libc/include/any-macos.{}-any".format(min_os), "libc/include/any-macos-any", - "include", - ], + ] + _INCLUDE_TAIL, dynamic_library_linkopts = ["-Wl,-undefined=dynamic_lookup"], copts = [], libc = "darwin", @@ -72,8 +73,7 @@ def _target_windows(gocpu, zigcpu): "libc/mingw", "libunwind/include", "libc/include/any-windows-any", - "include", - ], + ] + _INCLUDE_TAIL, dynamic_library_linkopts = [], copts = [], libc = "mingw", @@ -103,8 +103,7 @@ def _target_linux_gnu(gocpu, zigcpu, glibc_version): (["libc/include/x86-linux-any"] if zigcpu == "x86_64" else []) + (["libc/include/{}-linux-any".format(zigcpu)] if zigcpu != "x86_64" else []) + [ "libc/include/any-linux-any", - "include", - ], + ] + _INCLUDE_TAIL, toplevel_include = ["glibc-hacks"] if fcntl_hack else [], compiler_extra_includes = ["glibc-hacks/glibchack-fcntl.h"] if fcntl_hack else [], linker_version_scripts = ["glibc-hacks/fcntl.map"] if fcntl_hack else [], @@ -132,8 +131,7 @@ def _target_linux_musl(gocpu, zigcpu): (["libc/include/x86-linux-any"] if zigcpu == "x86_64" else []) + (["libc/include/{}-linux-any".format(zigcpu)] if zigcpu != "x86_64" else []) + [ "libc/include/any-linux-any", - "include", - ], + ] + _INCLUDE_TAIL, dynamic_library_linkopts = [], copts = ["-D_LIBCPP_HAS_MUSL_LIBC", "-D_LIBCPP_HAS_THREAD_API_PTHREAD"], libc = "musl",