From be30658e59dc66c323781a837f7f61a69f611328 Mon Sep 17 00:00:00 2001 From: thesayyn Date: Tue, 24 Sep 2024 13:38:06 -0700 Subject: [PATCH] revert most --- .bazelrc | 4 +- .github/workflows/build.yaml | 3 +- BUILD.bazel | 24 - WORKSPACE | 65 +- patches/com_grail_bazel_toolchain.001.patch | 36 ++ patches/com_grail_bazel_toolchain.patch | 183 ++++++ patches/llvm+windows.patch | 630 -------------------- release/BUILD.bazel | 11 + 8 files changed, 271 insertions(+), 685 deletions(-) create mode 100644 patches/com_grail_bazel_toolchain.001.patch create mode 100644 patches/com_grail_bazel_toolchain.patch delete mode 100644 patches/llvm+windows.patch diff --git a/.bazelrc b/.bazelrc index daf0633c6..d962f69ba 100644 --- a/.bazelrc +++ b/.bazelrc @@ -19,10 +19,10 @@ common --noincompatible_disallow_empty_glob # Don't try and auto detect the cc toolchain, as we use our own gcc toolchains. common:linux --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 -common:windows --platforms @zig_sdk//platform:windows_amd64 --extra_toolchains @zig_sdk//toolchain:windows_amd64 -common:windows --sandbox_add_mount_pair=C:\Temp common --incompatible_enable_proto_toolchain_resolution +build:windows --sandbox_add_mount_pair=C:\Temp + # Tell Bazel to pass the right flags for llvm-ar, not libtool, only needed on linux. # See https://github.com/bazelbuild/bazel/blob/5c75d0acec21459bbb13520817e3806e1507e907/tools/cpp/unix_cc_toolchain_config.bzl#L1000-L1024 # TODO: maybe drop once we upgrade llvm toolchain, https://github.com/bazel-contrib/toolchains_llvm/pull/229 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a79f66de7..d605c68ed 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,8 +40,7 @@ jobs: - uses: actions/checkout@v4 # Bootstrap: the first time we release for windows, we don't have a windows version of Aspect CLI to build with # So use environment variables to defeat the .bazeliskrc file. - - run: bazel build @com_github_smacker_go_tree_sitter//python - - run: bazel build //:for_all_platforms + - run: bazel build //release:aspect_windows_amd64 - run: cp bazel-out/x64_windows-fastbuild-ST-2c60814c3ef7/bin/cmd/aspect/aspect_/aspect.exe aspect_windows_amd64.exe - name: smoke test run: ./aspect_windows_amd64.exe --help diff --git a/BUILD.bazel b/BUILD.bazel index 6f2445204..05ab335f9 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,3 @@ -load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") load("@aspect_rules_js//js:defs.bzl", "js_library") load("@bazel_gazelle//:def.bzl", "gazelle") load("@buildifier_prebuilt//:rules.bzl", "buildifier") @@ -124,26 +123,3 @@ alias( name = "format", actual = "//tools:format", ) - - -PLATFORMS = [ - # "@zig_sdk//platform:darwin_amd64", - # "@zig_sdk//platform:darwin_arm64", - # "@zig_sdk//libc_aware/platform:linux_arm64_musl", - # "@zig_sdk//libc_aware/platform:linux_amd64_musl", - "@toolchains_llvm//platforms:windows-x86_64", -] - -[ - platform_transition_filegroup( - name = "for_" + platform.split(":")[1], - srcs = ["//cmd/aspect"], - target_platform = platform, - ) - for platform in PLATFORMS -] - -filegroup( - name = "for_all_platforms", - srcs = ["for_" + platform.split(":")[1] for platform in PLATFORMS], -) \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE index be5d34df9..7940ac4ca 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -18,35 +18,15 @@ load("@hermetic_cc_toolchain//toolchain:defs.bzl", zig_toolchains = "toolchains" zig_toolchains() -http_archive( - name = "toolchains_llvm", - sha256 = "c304fc9286c6fa2acb6dcea8961dc0d526a076f8cb64da4763c36aebcf5cff56", - strip_prefix = "toolchains_llvm-v1.1.2", - canonical_id = "v1.1.2", - url = "https://github.com/bazel-contrib/toolchains_llvm/releases/download/v1.1.2/toolchains_llvm-v1.1.2.tar.gz", - patches = ["//patches:llvm+windows.patch"], - patch_args = ["-p1"] -) - -load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies") - -bazel_toolchain_dependencies() - -load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") - -llvm_toolchain( - name = "llvm_toolchain", - llvm_versions = { - "": "15.0.7", - "windows-x86_64": "18.1.1" - } +register_toolchains( + "@zig_sdk//toolchain:linux_amd64_musl", + "@zig_sdk//toolchain:linux_arm64_musl", + # "@zig_sdk//toolchain:darwin_amd64", + # "@zig_sdk//toolchain:darwin_arm64", + # "@zig_sdk//toolchain:windows_amd64", + # "@zig_sdk//toolchain:windows_arm64", ) -load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") - -llvm_register_toolchains() - - http_archive( name = "bazel_features", sha256 = "2cd9e57d4c38675d321731d65c15258f3a66438ad531ae09cb8bb14217dc8572", @@ -127,6 +107,36 @@ filegroup( ) """ + +load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain") + +llvm_toolchain( + name = "llvm_toolchain", + llvm_version = "14.0.0", + sha256 = { + "darwin-aarch64": "1b8975db6b638b308c1ee437291f44cf8f67a2fb926eb2e6464efd180e843368", + "linux-x86_64": "564fcbd79c991e93fdf75f262fa7ac6553ec1dd04622f5d7db2a764c5dc7fac6", + }, + strip_prefix = { + "darwin-aarch64": "clang+llvm-14.0.0-arm64-apple-darwin", + "linux-x86_64": "clang+llvm-14.0.0-x86_64-linux-gnu", + }, + sysroot = { + "darwin-aarch64": "@sysroot_darwin_universal//:sysroot", + "darwin-x86_64": "@sysroot_darwin_universal//:sysroot", + "linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot", + "linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot", + }, + urls = { + "darwin-aarch64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-arm64-apple-darwin.tar.xz"], + "linux-x86_64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu.tar.xz"], + }, +) + +load("//platforms/toolchains:defs.bzl", "register_llvm_toolchains") + +register_llvm_toolchains() + http_archive( name = "org_chromium_sysroot_linux_arm64", build_file_content = _SYSROOT_LINUX_BUILD_FILE, @@ -151,6 +161,7 @@ http_archive( urls = ["https://s3.us-east-2.amazonaws.com/static.aspect.build/sysroots/MacOSX11.3.sdk.tar.xz"], ) + http_archive( name = "io_bazel_rules_go", sha256 = "67b4d1f517ba73e0a92eb2f57d821f2ddc21f5bc2bd7a231573f11bd8758192e", diff --git a/patches/com_grail_bazel_toolchain.001.patch b/patches/com_grail_bazel_toolchain.001.patch new file mode 100644 index 000000000..deec79c61 --- /dev/null +++ b/patches/com_grail_bazel_toolchain.001.patch @@ -0,0 +1,36 @@ +diff --git a/toolchain/BUILD.llvm_repo b/toolchain/BUILD.llvm_repo +index a09616e..95f9280 100644 +--- a/toolchain/BUILD.llvm_repo ++++ b/toolchain/BUILD.llvm_repo +@@ -19,7 +19,7 @@ exports_files(glob([ + "bin/*", + "lib/*", + "include/*", +-])) ++], allow_empty = True)) + + ## LLVM toolchain files + +@@ -45,12 +45,12 @@ filegroup( + srcs = glob([ + "include/**/c++/**", + "lib/clang/*/include/**", +- ]), ++ ], allow_empty = True), + ) + + filegroup( + name = "bin", +- srcs = glob(["bin/**"]), ++ srcs = glob(["bin/**"], allow_empty = True), + ) + + filegroup( +@@ -67,6 +67,7 @@ filegroup( + "lib/libclang*.a", + "lib/liblld*.a", + ], ++ allow_empty = True, + ), + # Do not include the .dylib files in the linker sandbox because they will + # not be available at runtime. Any library linked from the toolchain should \ No newline at end of file diff --git a/patches/com_grail_bazel_toolchain.patch b/patches/com_grail_bazel_toolchain.patch new file mode 100644 index 000000000..25f71e45d --- /dev/null +++ b/patches/com_grail_bazel_toolchain.patch @@ -0,0 +1,183 @@ +diff --git a/toolchain/BUILD.llvm_repo b/toolchain/BUILD.llvm_repo +index 94a1a98..a09616e 100644 +--- a/toolchain/BUILD.llvm_repo ++++ b/toolchain/BUILD.llvm_repo +@@ -36,6 +36,7 @@ filegroup( + name = "ld", + srcs = [ + "bin/ld.lld", ++ "bin/ld64.lld", + ], + ) + +diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl +index da1e330..dc0da9f 100644 +--- a/toolchain/cc_toolchain_config.bzl ++++ b/toolchain/cc_toolchain_config.bzl +@@ -112,8 +112,6 @@ def cc_toolchain_config( + "-fdebug-prefix-map={}=__bazel_toolchain_llvm_repo__/".format(toolchain_path_prefix), + ] + +- is_xcompile = not (host_os == target_os and host_arch == target_arch) +- + # Default compiler flags: + compile_flags = [ + "--target=" + target_system_name, +@@ -149,12 +147,17 @@ def cc_toolchain_config( + # unused symbols are not stripped. + link_libs = [] + ++ use_lld = True ++ + # Linker flags: +- if host_os == "darwin" and not is_xcompile: +- # lld is experimental for Mach-O, so we use the native ld64 linker. +- # TODO: How do we cross-compile from Linux to Darwin? +- use_lld = False ++ if target_os == "darwin": ++ ld = "ld64.lld" ++ ld_path = toolchain_path_prefix + "/bin/" + ld ++ compile_flags.append("-mmacosx-version-min=12.0") + link_flags.extend([ ++ "-mmacosx-version-min=12.0", ++ "-Wl,-platform_version,macos,12.0,12.0", ++ "--ld-path=" + ld_path, + "-headerpad_max_install_names", + # This will issue a warning on macOS ventura; see: + # https://github.com/python/cpython/issues/97524 +@@ -163,98 +166,19 @@ def cc_toolchain_config( + "dynamic_lookup", + ]) + else: +- # Note that for xcompiling from darwin to linux, the native ld64 is +- # not an option because it is not a cross-linker, so lld is the +- # only option. +- use_lld = True ++ ld = "ld.lld" ++ ld_path = toolchain_path_prefix + "/bin/" + ld + link_flags.extend([ +- "-fuse-ld=lld", ++ "--ld-path=" + ld_path, + "-Wl,--build-id=md5", + "-Wl,--hash-style=gnu", + "-Wl,-z,relro,-z,now", + ]) + +- # Flags related to C++ standard. +- # The linker has no way of knowing if there are C++ objects; so we +- # always link C++ libraries. +- cxx_standard = compiler_configuration["cxx_standard"] +- stdlib = compiler_configuration["stdlib"] +- if stdlib == "builtin-libc++" and is_xcompile: +- stdlib = "stdc++" +- if stdlib == "builtin-libc++": +- cxx_flags = [ +- "-std=" + cxx_standard, +- "-stdlib=libc++", +- ] +- if use_lld: +- # For single-platform builds, we can statically link the bundled +- # libraries. +- link_flags.extend([ +- "-l:libc++.a", +- "-l:libc++abi.a", +- "-l:libunwind.a", +- # Compiler runtime features. +- "-rtlib=compiler-rt", +- # To support libunwind. +- "-lpthread", +- "-ldl", +- ]) +- else: +- # The only known mechanism to static link libraries in ld64 is to +- # not have the corresponding .dylib files in the library search +- # path. The link time sandbox does not include the .dylib files, so +- # anything we pick up from the toolchain should be statically +- # linked. However, several system libraries on macOS dynamically +- # link libc++ and libc++abi, so static linking them becomes a problem. +- # We need to ensure that they are dynamic linked from the system +- # sysroot and not static linked from the toolchain, so explicitly +- # have the sysroot directory on the search path and then add the +- # toolchain directory back after we are done. +- link_flags.extend([ +- "-L{}/usr/lib".format(compiler_configuration["sysroot_path"]), +- "-lc++", +- "-lc++abi", +- ]) +- +- # Let's provide the path to the toolchain library directory +- # explicitly as part of the search path to make it easy for a user +- # to pick up something. This also makes the behavior consistent with +- # targets when a user explicitly depends on something like +- # libomp.dylib, which adds this directory to the search path, and would +- # (unintentionally) lead to static linking of libraries from the +- # toolchain. +- link_flags.extend([ +- "-L{}lib".format(toolchain_path_prefix), +- ]) +- elif stdlib == "libc++": +- cxx_flags = [ +- "-std=" + cxx_standard, +- "-stdlib=libc++", +- ] +- +- link_flags.extend([ +- "-l:c++.a", +- "-l:c++abi.a", +- ]) +- elif stdlib == "stdc++": +- cxx_flags = [ +- "-std=" + cxx_standard, +- "-stdlib=libstdc++", +- ] +- +- link_flags.extend([ +- "-l:libstdc++.a", +- ]) +- elif stdlib == "none": +- cxx_flags = [ +- "-nostdlib", +- ] +- +- link_flags.extend([ +- "-nostdlib", +- ]) +- else: +- fail("Unknown value passed for stdlib: {stdlib}".format(stdlib = stdlib)) ++ link_flags.extend([ ++ "-pthread", ++ "-ldl", ++ ]) + + opt_link_flags = ["-Wl,--gc-sections"] if target_os == "linux" else [] + +@@ -325,7 +249,7 @@ def cc_toolchain_config( + "dwp": tools_path_prefix + "llvm-dwp", + "gcc": wrapper_bin_prefix + "cc_wrapper.sh", + "gcov": tools_path_prefix + "llvm-profdata", +- "ld": tools_path_prefix + "ld.lld" if use_lld else _host_tools.get_and_assert(host_tools_info, "ld"), ++ "ld": tools_path_prefix + ld if use_lld else _host_tools.get_and_assert(host_tools_info, "ld"), + "llvm-cov": tools_path_prefix + "llvm-cov", + "llvm-profdata": tools_path_prefix + "llvm-profdata", + "nm": tools_path_prefix + "llvm-nm", +@@ -342,6 +266,8 @@ def cc_toolchain_config( + # `lld` is being used as the linker. + supports_start_end_lib = use_lld + ++ cxx_flags = [] ++ + # Replace flags with any user-provided overrides. + if compiler_configuration["compile_flags"] != None: + compile_flags = _fmt_flags(compiler_configuration["compile_flags"], toolchain_path_prefix) +diff --git a/toolchain/internal/common.bzl b/toolchain/internal/common.bzl +index 37bff8c..286efbf 100644 +--- a/toolchain/internal/common.bzl ++++ b/toolchain/internal/common.bzl +@@ -21,6 +21,7 @@ host_tool_features = struct( + toolchain_tools = [ + "clang-cpp", + "ld.lld", ++ "ld64.lld", + "llvm-ar", + "llvm-dwp", + "llvm-profdata", \ No newline at end of file diff --git a/patches/llvm+windows.patch b/patches/llvm+windows.patch deleted file mode 100644 index c1e66976c..000000000 --- a/patches/llvm+windows.patch +++ /dev/null @@ -1,630 +0,0 @@ -From 26ed7133f84bb8326e2aaf6d3000049bcfe06837 Mon Sep 17 00:00:00 2001 -From: Chris Brown -Date: Sun, 16 Jun 2024 23:30:20 -0400 -Subject: [PATCH 1/6] feat: windows tools - ---- - toolchain/internal/common.bzl | 6 +++--- - toolchain/internal/configure.bzl | 13 +++++++++---- - toolchain/internal/release_name.bzl | 10 ++++++++++ - toolchain/internal/repo.bzl | 19 +++++++++++-------- - 4 files changed, 33 insertions(+), 15 deletions(-) - -diff --git a/toolchain/internal/common.bzl b/toolchain/internal/common.bzl -index ff94bfb2..d3a7d631 100644 ---- a/toolchain/internal/common.bzl -+++ b/toolchain/internal/common.bzl -@@ -12,7 +12,7 @@ - # See the License for the specific language governing permissions and - # limitations under the License. - --SUPPORTED_TARGETS = [("linux", "x86_64"), ("linux", "aarch64"), ("darwin", "x86_64"), ("darwin", "aarch64")] -+SUPPORTED_TARGETS = [("linux", "x86_64"), ("linux", "aarch64"), ("darwin", "x86_64"), ("darwin", "aarch64"), ("windows", "x86_64")] - - # Map of tool name to its symlinked name in the tools directory. - # See tool_paths in toolchain/cc_toolchain_config.bzl. -@@ -104,7 +104,7 @@ def os(rctx): - - name = rctx.attr.exec_os - if name: -- if name in ("linux", "darwin"): -+ if name in ("linux", "darwin", "windows"): - return name - else: - fail("Unsupported value for exec_os: %s" % name) -@@ -120,7 +120,7 @@ def os(rctx): - - def os_bzl(os): - # Return the OS string as used in bazel platform constraints. -- return {"darwin": "osx", "linux": "linux"}[os] -+ return {"darwin": "osx", "linux": "linux", "windows": "windows"}[os] - - def arch(rctx): - arch = rctx.attr.exec_arch -diff --git a/toolchain/internal/configure.bzl b/toolchain/internal/configure.bzl -index 6e40059c..21b72652 100644 ---- a/toolchain/internal/configure.bzl -+++ b/toolchain/internal/configure.bzl -@@ -61,9 +61,6 @@ def llvm_config_impl(rctx): - _check_os_arch_keys(rctx.attr.cxx_builtin_include_directories) - - os = _os(rctx) -- if os == "windows": -- _empty_repository(rctx) -- return - arch = _arch(rctx) - - if not rctx.attr.toolchain_roots: -@@ -311,6 +308,7 @@ def _cc_toolchain_str( - "darwin-aarch64": "aarch64-apple-macosx", - "linux-aarch64": "aarch64-unknown-linux-gnu", - "linux-x86_64": "x86_64-unknown-linux-gnu", -+ "windows-x86_64": "x86_64-pc-windows-msvc", - }[target_pair] - cxx_builtin_include_directories = [ - toolchain_path_prefix + "include/c++/v1", -@@ -545,7 +543,13 @@ cc_toolchain( - major_llvm_version = major_llvm_version, - ) - -+def _extension(os): -+ if (os == "windows"): -+ return ".exe" -+ return "" -+ - def _convenience_targets_str(rctx, use_absolute_paths, llvm_dist_rel_path, llvm_dist_label_prefix, exec_dl_ext): -+ ext = _extension(_os(rctx)) - if use_absolute_paths: - llvm_dist_label_prefix = ":" - filenames = [] -@@ -553,7 +557,7 @@ def _convenience_targets_str(rctx, use_absolute_paths, llvm_dist_rel_path, llvm_ - filename = "lib/{}.{}".format(libname, exec_dl_ext) - filenames.append(filename) - for toolname in _aliased_tools: -- filename = "bin/{}".format(toolname) -+ filename = "bin/{}{}".format(toolname, ext) - filenames.append(filename) - - for filename in filenames: -@@ -570,6 +574,7 @@ cc_import( - - tool_target_strs = [] - for name in _aliased_tools: -+ name = name+ext - template = """ - native_binary( - name = "{name}", -diff --git a/toolchain/internal/release_name.bzl b/toolchain/internal/release_name.bzl -index e3d4a540..70a01a95 100755 ---- a/toolchain/internal/release_name.bzl -+++ b/toolchain/internal/release_name.bzl -@@ -46,6 +46,16 @@ def _darwin(llvm_version, arch): - ) - - def _windows(llvm_version, arch): -+ major_llvm_version = _major_llvm_version(llvm_version) -+ if (major_llvm_version >= 18 and arch.endswith("64")): -+ arch = "x86_64" -+ suffix = "pc-windows-msvc" -+ return "clang+llvm-{llvm_version}-{arch}-{suffix}.tar.xz".format( -+ llvm_version = llvm_version, -+ arch = arch, -+ suffix = suffix, -+ ) -+ - if arch.endswith("64"): - win_arch = "win64" - else: -diff --git a/toolchain/internal/repo.bzl b/toolchain/internal/repo.bzl -index 27012db6..3b2899d0 100644 ---- a/toolchain/internal/repo.bzl -+++ b/toolchain/internal/repo.bzl -@@ -291,14 +291,17 @@ llvm_config_attrs.update({ - def llvm_repo_impl(rctx): - os = _os(rctx) - if os == "windows": -- rctx.file("BUILD.bazel", executable = False) -- return None -- -- rctx.file( -- "BUILD.bazel", -- content = rctx.read(Label("//toolchain:BUILD.llvm_repo")), -- executable = False, -- ) -+ rctx.file( -+ "BUILD.bazel", -+ content = rctx.read(Label("//toolchain:BUILD.llvm_repo_windows")), -+ executable = False, -+ ) -+ else: -+ rctx.file( -+ "BUILD.bazel", -+ content = rctx.read(Label("//toolchain:BUILD.llvm_repo")), -+ executable = False, -+ ) - - updated_attrs = _download_llvm(rctx) - - -From d8b3b71943486cea06b2d421419ddc0df945daed Mon Sep 17 00:00:00 2001 -From: Chris Brown -Date: Sun, 16 Jun 2024 23:36:56 -0400 -Subject: [PATCH 2/6] feat: windows build file - ---- - toolchain/BUILD.llvm_repo_windows | 140 ++++++++++++++++++++++++++++++ - 1 file changed, 140 insertions(+) - create mode 100644 toolchain/BUILD.llvm_repo_windows - -diff --git a/toolchain/BUILD.llvm_repo_windows b/toolchain/BUILD.llvm_repo_windows -new file mode 100644 -index 00000000..442ffdbb ---- /dev/null -+++ b/toolchain/BUILD.llvm_repo_windows -@@ -0,0 +1,140 @@ -+# Copyright 2021 The Bazel Authors. -+# -+# Licensed under the Apache License, Version 2.0 (the "License"); -+# you may not use this file except in compliance with the License. -+# You may obtain a copy of the License at -+# -+# http://www.apache.org/licenses/LICENSE-2.0 -+# -+# Unless required by applicable law or agreed to in writing, software -+# distributed under the License is distributed on an "AS IS" BASIS, -+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+# See the License for the specific language governing permissions and -+# limitations under the License. -+ -+package(default_visibility = ["//visibility:public"]) -+ -+# Some targets may need to directly depend on these files. -+exports_files(glob([ -+ "bin/*", -+ "lib/*", -+ "include/*", -+])) -+ -+## LLVM toolchain files -+ -+filegroup( -+ name = "clang", -+ srcs = [ -+ "bin/clang.exe", -+ "bin/clang++.exe", -+ "bin/clang-cpp.exe", -+ ], -+) -+ -+filegroup( -+ name = "ld", -+ srcs = glob(["bin/ld.lld.exe", "bin/ld64.lld.exe"]), -+) -+ -+filegroup( -+ name = "include", -+ srcs = glob([ -+ "include/**/c++/**", -+ "lib/clang/*/include/**", -+ ]), -+) -+ -+filegroup( -+ name = "all_includes", -+ srcs = glob(["include/**"]), -+) -+ -+filegroup( -+ name = "bin", -+ srcs = glob(["bin/**"]), -+) -+ -+filegroup( -+ name = "lib", -+ srcs = glob( -+ [ -+ "lib/**/lib*.a", -+ "lib/clang/*/lib/**/*.a", -+ "lib/clang/*/lib/**/*.dylib", -+ # clang_rt.*.o supply crtbegin and crtend sections. -+ "lib/**/clang_rt.*.o", -+ ], -+ exclude = [ -+ "lib/libLLVM*.a", -+ "lib/libclang*.a", -+ "lib/liblld*.a", -+ ], -+ ), -+ # Include the .dylib files in the linker sandbox even though they will -+ # not be available at runtime to allow sanitizers to work locally. -+ # Any library linked from the toolchain to be released should be linked statically. -+) -+ -+filegroup( -+ name = "ar", -+ srcs = ["bin/llvm-ar.exe"], -+) -+ -+filegroup( -+ name = "as", -+ srcs = [ -+ "bin/clang.exe", -+ "bin/llvm-as.exe", -+ ], -+) -+ -+filegroup( -+ name = "nm", -+ srcs = ["bin/llvm-nm.exe"], -+) -+ -+filegroup( -+ name = "objcopy", -+ srcs = ["bin/llvm-objcopy.exe"], -+) -+ -+filegroup( -+ name = "objdump", -+ srcs = ["bin/llvm-objdump.exe"], -+) -+ -+filegroup( -+ name = "profdata", -+ srcs = ["bin/llvm-profdata.exe"], -+) -+ -+filegroup( -+ name = "dwp", -+ srcs = ["bin/llvm-dwp.exe"], -+) -+ -+filegroup( -+ name = "ranlib", -+ srcs = ["bin/llvm-ranlib.exe"], -+) -+ -+filegroup( -+ name = "readelf", -+ srcs = ["bin/llvm-readelf.exe"], -+) -+ -+filegroup( -+ name = "strip", -+ srcs = ["bin/llvm-strip.exe"], -+) -+ -+filegroup( -+ name = "symbolizer", -+ srcs = ["bin/llvm-symbolizer.exe"], -+) -+ -+filegroup( -+ name = "clang-tidy", -+ srcs = ["bin/clang-tidy.exe"], -+) - -From 0c19342b0e7dd8c58163744ed98971e2fdcfe250 Mon Sep 17 00:00:00 2001 -From: Chris Brown -Date: Sun, 16 Jun 2024 23:52:19 -0400 -Subject: [PATCH 3/6] continue - ---- - toolchain/cc_toolchain_config.bzl | 8 ++++++++ - toolchain/internal/configure.bzl | 2 +- - 2 files changed, 9 insertions(+), 1 deletion(-) - -diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl -index c1b0d922..f5cc8b51 100644 ---- a/toolchain/cc_toolchain_config.bzl -+++ b/toolchain/cc_toolchain_config.bzl -@@ -89,6 +89,14 @@ def cc_toolchain_config( - "clang", - "glibc_unknown", - ), -+ "windows-x86_64": ( -+ "clang-x86_64-windows", -+ "k8", -+ "msvc", -+ "clang", -+ "windows_x86_64", -+ "windows_x86_64", -+ ), - }[target_os_arch_key] - - # Unfiltered compiler flags; these are placed at the end of the command -diff --git a/toolchain/internal/configure.bzl b/toolchain/internal/configure.bzl -index 21b72652..01512089 100644 ---- a/toolchain/internal/configure.bzl -+++ b/toolchain/internal/configure.bzl -@@ -336,7 +336,7 @@ def _cc_toolchain_str( - _join(sysroot_prefix, "/System/Library/Frameworks"), - ]) - else: -- fail("Unreachable") -+ pass - - cxx_builtin_include_directories.extend(toolchain_info.additional_include_dirs_dict.get(target_pair, [])) - - -From 95dfb67754a81fe8d66d2e07a447a7d89250b1e6 Mon Sep 17 00:00:00 2001 -From: Chris Brown -Date: Mon, 17 Jun 2024 06:50:38 -0400 -Subject: [PATCH 4/6] fix: address comments - ---- - toolchain/BUILD.llvm_repo_windows | 19 +++++++------------ - toolchain/internal/configure.bzl | 4 ++-- - toolchain/internal/release_name.bzl | 2 +- - 3 files changed, 10 insertions(+), 15 deletions(-) - -diff --git a/toolchain/BUILD.llvm_repo_windows b/toolchain/BUILD.llvm_repo_windows -index 442ffdbb..80b0cff6 100644 ---- a/toolchain/BUILD.llvm_repo_windows -+++ b/toolchain/BUILD.llvm_repo_windows -@@ -29,12 +29,14 @@ filegroup( - "bin/clang.exe", - "bin/clang++.exe", - "bin/clang-cpp.exe", -+ "bin/clang-cl.exe", - ], - ) - - filegroup( - name = "ld", -- srcs = glob(["bin/ld.lld.exe", "bin/ld64.lld.exe"]), -+ # a set of 4 identical binaries? -+ srcs = glob(["bin/ld.lld.exe", "bin/ld64.lld.exe", "lld-link.exe", "lld.exe"]), - ) - - filegroup( -@@ -59,21 +61,14 @@ filegroup( - name = "lib", - srcs = glob( - [ -- "lib/**/lib*.a", -- "lib/clang/*/lib/**/*.a", -- "lib/clang/*/lib/**/*.dylib", -- # clang_rt.*.o supply crtbegin and crtend sections. -- "lib/**/clang_rt.*.o", -+ "lib/**/*.lib", - ], - exclude = [ -- "lib/libLLVM*.a", -- "lib/libclang*.a", -- "lib/liblld*.a", -+ "lib/LLVM*.lib", -+ "lib/clang*.lib", -+ "lib/lld*.lib", - ], - ), -- # Include the .dylib files in the linker sandbox even though they will -- # not be available at runtime to allow sanitizers to work locally. -- # Any library linked from the toolchain to be released should be linked statically. - ) - - filegroup( -diff --git a/toolchain/internal/configure.bzl b/toolchain/internal/configure.bzl -index 01512089..6840d318 100644 ---- a/toolchain/internal/configure.bzl -+++ b/toolchain/internal/configure.bzl -@@ -544,7 +544,7 @@ cc_toolchain( - ) - - def _extension(os): -- if (os == "windows"): -+ if os == "windows": - return ".exe" - return "" - -@@ -574,7 +574,7 @@ cc_import( - - tool_target_strs = [] - for name in _aliased_tools: -- name = name+ext -+ name = name + ext - template = """ - native_binary( - name = "{name}", -diff --git a/toolchain/internal/release_name.bzl b/toolchain/internal/release_name.bzl -index 70a01a95..a56adabc 100755 ---- a/toolchain/internal/release_name.bzl -+++ b/toolchain/internal/release_name.bzl -@@ -47,7 +47,7 @@ def _darwin(llvm_version, arch): - - def _windows(llvm_version, arch): - major_llvm_version = _major_llvm_version(llvm_version) -- if (major_llvm_version >= 18 and arch.endswith("64")): -+ if major_llvm_version >= 18 and arch.endswith("64"): - arch = "x86_64" - suffix = "pc-windows-msvc" - return "clang+llvm-{llvm_version}-{arch}-{suffix}.tar.xz".format( - -From e0275438450ac0ce61887830f97273659695a464 Mon Sep 17 00:00:00 2001 -From: Chris Brown -Date: Mon, 17 Jun 2024 07:29:58 -0400 -Subject: [PATCH 5/6] fix: address comments - ---- - platforms/BUILD.bazel | 8 ++++ - toolchain/BUILD.llvm_repo_windows | 64 ++++++++++++++++++++++++------- - 2 files changed, 58 insertions(+), 14 deletions(-) - -diff --git a/platforms/BUILD.bazel b/platforms/BUILD.bazel -index d9c7140d..3d78b56a 100644 ---- a/platforms/BUILD.bazel -+++ b/platforms/BUILD.bazel -@@ -45,3 +45,11 @@ platform( - "@platforms//cpu:aarch64", - ], - ) -+ -+platform( -+ name = "windows-x86_64", -+ constraint_values = [ -+ "@platforms//os:windows", -+ "@platforms//cpu:x86_64", -+ ], -+) -diff --git a/toolchain/BUILD.llvm_repo_windows b/toolchain/BUILD.llvm_repo_windows -index 80b0cff6..1a85d38b 100644 ---- a/toolchain/BUILD.llvm_repo_windows -+++ b/toolchain/BUILD.llvm_repo_windows -@@ -23,6 +23,8 @@ exports_files(glob([ - - ## LLVM toolchain files - -+ALL_DLLS = glob(["bin/*.dll"]) -+ - filegroup( - name = "clang", - srcs = [ -@@ -30,13 +32,41 @@ filegroup( - "bin/clang++.exe", - "bin/clang-cpp.exe", - "bin/clang-cl.exe", -- ], -+ ] + ALL_DLLS, -+) -+ -+filegroup( -+ name = "clang-cl", -+ srcs = [ -+ "bin/clang-cl.exe", -+ ] + ALL_DLLS, -+) -+ -+filegroup( -+ name = "llvm-ml", -+ srcs = [ -+ "bin/llvm-ml.exe", -+ ] + ALL_DLLS, - ) - - filegroup( - name = "ld", - # a set of 4 identical binaries? -- srcs = glob(["bin/ld.lld.exe", "bin/ld64.lld.exe", "lld-link.exe", "lld.exe"]), -+ srcs = ["bin/ld.lld.exe", "bin/ld64.lld.exe", "lld-link.exe", "lld.exe"] + ALL_DLLS, -+) -+ -+filegroup( -+ name = "lld-link", -+ srcs = [ -+ "bin/lld-link.exe", -+ ] + ALL_DLLS, -+) -+ -+filegroup( -+ name = "llvm-lib", -+ srcs = [ -+ "bin/llvm-lib.exe", -+ ] + ALL_DLLS, - ) - - filegroup( -@@ -71,9 +101,14 @@ filegroup( - ), - ) - -+filegroup( -+ name = "dll", -+ srcs = ALL_DLLS, -+) -+ - filegroup( - name = "ar", -- srcs = ["bin/llvm-ar.exe"], -+ srcs = ["bin/llvm-ar.exe"] + ALL_DLLS, - ) - - filegroup( -@@ -81,55 +116,56 @@ filegroup( - srcs = [ - "bin/clang.exe", - "bin/llvm-as.exe", -- ], -+ ] + ALL_DLLS, - ) - - filegroup( - name = "nm", -- srcs = ["bin/llvm-nm.exe"], -+ srcs = ["bin/llvm-nm.exe"] + ALL_DLLS, - ) - - filegroup( - name = "objcopy", -- srcs = ["bin/llvm-objcopy.exe"], -+ srcs = ["bin/llvm-objcopy.exe"] + ALL_DLLS, -+ deps = [":dll"], - ) - - filegroup( - name = "objdump", -- srcs = ["bin/llvm-objdump.exe"], -+ srcs = ["bin/llvm-objdump.exe"] + ALL_DLLS, - ) - - filegroup( - name = "profdata", -- srcs = ["bin/llvm-profdata.exe"], -+ srcs = ["bin/llvm-profdata.exe"] + ALL_DLLS, - ) - - filegroup( - name = "dwp", -- srcs = ["bin/llvm-dwp.exe"], -+ srcs = ["bin/llvm-dwp.exe"] + ALL_DLLS, - ) - - filegroup( - name = "ranlib", -- srcs = ["bin/llvm-ranlib.exe"], -+ srcs = ["bin/llvm-ranlib.exe"] + ALL_DLLS, - ) - - filegroup( - name = "readelf", -- srcs = ["bin/llvm-readelf.exe"], -+ srcs = ["bin/llvm-readelf.exe"] + ALL_DLLS, - ) - - filegroup( - name = "strip", -- srcs = ["bin/llvm-strip.exe"], -+ srcs = ["bin/llvm-strip.exe"] + ALL_DLLS, - ) - - filegroup( - name = "symbolizer", -- srcs = ["bin/llvm-symbolizer.exe"], -+ srcs = ["bin/llvm-symbolizer.exe"] + ALL_DLLS, - ) - - filegroup( - name = "clang-tidy", -- srcs = ["bin/clang-tidy.exe"], -+ srcs = ["bin/clang-tidy.exe"] + ALL_DLLS, - ) - -From f2de4fc207ad0ad46da25969300e17b3ac7a2536 Mon Sep 17 00:00:00 2001 -From: Chris Brown -Date: Mon, 17 Jun 2024 15:24:24 -0400 -Subject: [PATCH 6/6] fix: typo - ---- - toolchain/BUILD.llvm_repo_windows | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/toolchain/BUILD.llvm_repo_windows b/toolchain/BUILD.llvm_repo_windows -index 1a85d38b..baca19e4 100644 ---- a/toolchain/BUILD.llvm_repo_windows -+++ b/toolchain/BUILD.llvm_repo_windows -@@ -127,7 +127,6 @@ filegroup( - filegroup( - name = "objcopy", - srcs = ["bin/llvm-objcopy.exe"] + ALL_DLLS, -- deps = [":dll"], - ) - - filegroup( \ No newline at end of file diff --git a/release/BUILD.bazel b/release/BUILD.bazel index 8afc24064..191b67b03 100644 --- a/release/BUILD.bazel +++ b/release/BUILD.bazel @@ -1,3 +1,4 @@ +load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load(":bazelisk_artifacts.bzl", "bazelisk_artifacts") load(":cli_brew_artifacts.bzl", "cli_brew_artifacts") @@ -10,6 +11,16 @@ multi_platform_binaries( tags = ["manual"], ) +platform_transition_filegroup( + name = "aspect_windows_amd64", + srcs = ["//cmd/aspect"], + target_platform = "@zig_sdk//platform:windows_x86_64", + target_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ] +) + version_file( name = "aspect_version", version_var = "STABLE_BUILD_SCM_TAG",