From 3a31712f9fce3c4e7163370666144e625bf76a12 Mon Sep 17 00:00:00 2001 From: martin4861 Date: Fri, 4 Jul 2025 12:20:20 +0200 Subject: [PATCH 1/5] First shot with Claude --- cc/constraints/BUILD.bazel | 5 + cc/repositories.bzl | 54 + cc/toolchains/llvm20/BUILD.bazel | 11 + .../llvm20/aarch64-darwin/BUILD.bazel | 152 ++ .../llvm20/aarch64-darwin/wrappers/clang | 64 + .../llvm20/aarch64-darwin/wrappers/clang-cpp | 64 + .../llvm20/aarch64-darwin/wrappers/llvm-cov | 64 + .../llvm20/aarch64-darwin/wrappers/llvm-nm | 64 + .../aarch64-darwin/wrappers/llvm-objcopy | 64 + .../aarch64-darwin/wrappers/llvm-objdump | 64 + .../aarch64-darwin/wrappers/llvm-profdata | 64 + .../llvm20/aarch64-darwin/wrappers/llvm-strip | 64 + .../llvm20/aarch64-darwin/wrappers/wrapper | 64 + .../llvm20/aarch64-linux/BUILD.bazel | 179 ++ .../llvm20/aarch64-linux/wrappers/clang | 58 + .../llvm20/aarch64-linux/wrappers/clang-cpp | 58 + .../llvm20/aarch64-linux/wrappers/ld.lld | 58 + .../llvm20/aarch64-linux/wrappers/llvm-ar | 58 + .../llvm20/aarch64-linux/wrappers/llvm-cov | 58 + .../llvm20/aarch64-linux/wrappers/llvm-nm | 58 + .../aarch64-linux/wrappers/llvm-objcopy | 58 + .../aarch64-linux/wrappers/llvm-objdump | 58 + .../aarch64-linux/wrappers/llvm-profdata | 58 + .../llvm20/aarch64-linux/wrappers/llvm-strip | 58 + .../llvm20/aarch64-linux/wrappers/wrapper | 58 + cc/toolchains/llvm20/cc_toolchain_config.bzl | 205 +++ cc/toolchains/llvm20/llvm.BUILD.bzl | 140 ++ cc/toolchains/llvm20/llvm.patch | 49 + .../llvm20/swift_custom_features.bzl | 422 +++++ cc/toolchains/llvm20/target_triplets.bzl | 10 + .../llvm20/unix_cc_toolchain_config.bzl | 1570 +++++++++++++++++ .../llvm20/x86_64-aarch64-linux/BUILD.bazel | 182 ++ .../x86_64-aarch64-linux/wrappers/clang | 58 + .../x86_64-aarch64-linux/wrappers/clang-cpp | 58 + .../x86_64-aarch64-linux/wrappers/ld.lld | 58 + .../x86_64-aarch64-linux/wrappers/llvm-ar | 58 + .../x86_64-aarch64-linux/wrappers/llvm-cov | 58 + .../x86_64-aarch64-linux/wrappers/llvm-nm | 58 + .../wrappers/llvm-objcopy | 58 + .../wrappers/llvm-objdump | 58 + .../wrappers/llvm-profdata | 58 + .../x86_64-aarch64-linux/wrappers/llvm-strip | 58 + .../x86_64-aarch64-linux/wrappers/wrapper | 58 + .../llvm20/x86_64-darwin/BUILD.bazel | 152 ++ .../llvm20/x86_64-darwin/wrappers/clang | 58 + .../llvm20/x86_64-darwin/wrappers/clang-cpp | 58 + .../llvm20/x86_64-darwin/wrappers/ld.lld | 58 + .../llvm20/x86_64-darwin/wrappers/llvm-ar | 58 + .../llvm20/x86_64-darwin/wrappers/llvm-cov | 58 + .../llvm20/x86_64-darwin/wrappers/llvm-nm | 58 + .../x86_64-darwin/wrappers/llvm-objcopy | 58 + .../x86_64-darwin/wrappers/llvm-objdump | 58 + .../x86_64-darwin/wrappers/llvm-profdata | 58 + .../llvm20/x86_64-darwin/wrappers/llvm-strip | 58 + .../llvm20/x86_64-darwin/wrappers/wrapper | 58 + cc/toolchains/llvm20/x86_64-linux/BUILD.bazel | 197 +++ .../llvm20/x86_64-linux/wrappers/clang | 64 + .../llvm20/x86_64-linux/wrappers/clang-cpp | 64 + .../llvm20/x86_64-linux/wrappers/ld.lld | 64 + .../llvm20/x86_64-linux/wrappers/llvm-ar | 64 + .../llvm20/x86_64-linux/wrappers/llvm-cov | 64 + .../llvm20/x86_64-linux/wrappers/llvm-nm | 64 + .../llvm20/x86_64-linux/wrappers/llvm-objcopy | 64 + .../llvm20/x86_64-linux/wrappers/llvm-objdump | 64 + .../x86_64-linux/wrappers/llvm-profdata | 64 + .../llvm20/x86_64-linux/wrappers/llvm-strip | 64 + .../llvm20/x86_64-linux/wrappers/wrapper | 64 + platforms/BUILD.bazel | 41 + 68 files changed, 6563 insertions(+) create mode 100644 cc/toolchains/llvm20/BUILD.bazel create mode 100644 cc/toolchains/llvm20/aarch64-darwin/BUILD.bazel create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/clang create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip create mode 100755 cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper create mode 100644 cc/toolchains/llvm20/aarch64-linux/BUILD.bazel create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/clang create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip create mode 100755 cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper create mode 100644 cc/toolchains/llvm20/cc_toolchain_config.bzl create mode 100755 cc/toolchains/llvm20/llvm.BUILD.bzl create mode 100644 cc/toolchains/llvm20/llvm.patch create mode 100644 cc/toolchains/llvm20/swift_custom_features.bzl create mode 100644 cc/toolchains/llvm20/target_triplets.bzl create mode 100644 cc/toolchains/llvm20/unix_cc_toolchain_config.bzl create mode 100644 cc/toolchains/llvm20/x86_64-aarch64-linux/BUILD.bazel create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip create mode 100755 cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper create mode 100644 cc/toolchains/llvm20/x86_64-darwin/BUILD.bazel create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/clang create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip create mode 100755 cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper create mode 100644 cc/toolchains/llvm20/x86_64-linux/BUILD.bazel create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/clang create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip create mode 100755 cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper diff --git a/cc/constraints/BUILD.bazel b/cc/constraints/BUILD.bazel index a46ca43..c517a5a 100644 --- a/cc/constraints/BUILD.bazel +++ b/cc/constraints/BUILD.bazel @@ -14,6 +14,11 @@ constraint_value( constraint_setting = ":toolchain", ) +constraint_value( + name = "llvm20_toolchain", + constraint_setting = ":toolchain", +) + constraint_value( name = "yocto_generic_toolchain", constraint_setting = ":toolchain", diff --git a/cc/repositories.bzl b/cc/repositories.bzl index 828671c..75d5dd4 100644 --- a/cc/repositories.bzl +++ b/cc/repositories.bzl @@ -20,6 +20,15 @@ AARCH64_LINUX_LLVM = "https://github.com/llvm/llvm-project/releases/download/llv X86_64_LINUX_LLVM = "https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang%2Bllvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz" +# LLVM 20.1.7 URLs +AARCH64_DARWIN_LLVM20 = "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.7/LLVM-20.1.7-macOS-ARM64.tar.xz" + +X86_64_DARWIN_LLVM20 = "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.7/LLVM-20.1.7-macOS-X64.tar.xz" + +AARCH64_LINUX_LLVM20 = "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.7/LLVM-20.1.7-Linux-ARM64.tar.xz" + +X86_64_LINUX_LLVM20 = "https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.7/LLVM-20.1.7-Linux-X64.tar.xz" + X86_64_LINUX_UCRT_LLVM_MINGW = "https://github.com/mstorsjo/llvm-mingw/releases/download/20241203/llvm-mingw-20241203-ucrt-ubuntu-20.04-x86_64.tar.xz" AARCH64_LINUX_MUSL = "https://github.com/swift-nav/swift-toolchains/releases/download/musl-cross-11.2.0/aarch64-linux-musl-cross.tar.gz" @@ -85,6 +94,44 @@ def swift_cc_toolchain(): sha256 = "61582215dafafb7b576ea30cc136be92c877ba1f1c31ddbbd372d6d65622fef5", ) +def swift_cc_toolchain_llvm20(): + """Define LLVM 20.1.7 toolchain repositories.""" + maybe( + http_archive, + name = "aarch64-darwin-llvm20", + build_file = Label("@rules_swiftnav//cc/toolchains/llvm20:llvm.BUILD.bzl"), + url = AARCH64_DARWIN_LLVM20, + strip_prefix = "LLVM-20.1.7-macOS-ARM64", + # TODO: Add sha256 hash for integrity + ) + + maybe( + http_archive, + name = "x86_64-darwin-llvm20", + build_file = Label("@rules_swiftnav//cc/toolchains/llvm20:llvm.BUILD.bzl"), + url = X86_64_DARWIN_LLVM20, + strip_prefix = "LLVM-20.1.7-macOS-X64", + # TODO: Add sha256 hash for integrity + ) + + maybe( + http_archive, + name = "aarch64-linux-llvm20", + build_file = Label("@rules_swiftnav//cc/toolchains/llvm20:llvm.BUILD.bzl"), + url = AARCH64_LINUX_LLVM20, + strip_prefix = "LLVM-20.1.7-Linux-ARM64", + # TODO: Add sha256 hash for integrity + ) + + maybe( + http_archive, + name = "x86_64-linux-llvm20", + build_file = Label("@rules_swiftnav//cc/toolchains/llvm20:llvm.BUILD.bzl"), + url = X86_64_LINUX_LLVM20, + strip_prefix = "LLVM-20.1.7-Linux-X64", + # TODO: Add sha256 hash for integrity + ) + def aarch64_sysroot(): maybe( http_archive, @@ -124,6 +171,13 @@ def register_swift_cc_toolchains(): native.register_toolchains("@rules_swiftnav//cc/toolchains/llvm/x86_64-aarch64-linux:cc-toolchain-aarch64-bullseye-graviton2") native.register_toolchains("@rules_swiftnav//cc/toolchains/llvm/x86_64-aarch64-linux:cc-toolchain-aarch64-bullseye-graviton3") +def register_swift_cc_toolchains_llvm20(): + """Register LLVM 20.1.7 toolchains.""" + native.register_toolchains("@rules_swiftnav//cc/toolchains/llvm20/aarch64-darwin:cc-toolchain-aarch64-darwin") + native.register_toolchains("@rules_swiftnav//cc/toolchains/llvm20/x86_64-darwin:cc-toolchain-x86_64-darwin") + native.register_toolchains("@rules_swiftnav//cc/toolchains/llvm20/aarch64-linux:cc-toolchain-aarch64-linux") + native.register_toolchains("@rules_swiftnav//cc/toolchains/llvm20/x86_64-linux:cc-toolchain-x86_64-linux") + def aarch64_linux_musl_toolchain(): http_archive( name = "aarch64-linux-musl", diff --git a/cc/toolchains/llvm20/BUILD.bazel b/cc/toolchains/llvm20/BUILD.bazel new file mode 100644 index 0000000..1589485 --- /dev/null +++ b/cc/toolchains/llvm20/BUILD.bazel @@ -0,0 +1,11 @@ +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +package(default_visibility = ["//visibility:public"]) diff --git a/cc/toolchains/llvm20/aarch64-darwin/BUILD.bazel b/cc/toolchains/llvm20/aarch64-darwin/BUILD.bazel new file mode 100644 index 0000000..0d77910 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/BUILD.bazel @@ -0,0 +1,152 @@ +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +load("@rules_swiftnav//cc/toolchains/llvm20:cc_toolchain_config.bzl", "cc_toolchain_config") +load("@rules_swiftnav//cc/toolchains/llvm20:target_triplets.bzl", "AARCH64_DARWIN") + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "wrappers", + srcs = glob([ + "wrappers/**", + ]), + visibility = ["//visibility:public"], +) + +filegroup( + name = "ar_files", + srcs = [ + ":wrappers", + "@aarch64-darwin-llvm20//:ar", + ], +) + +filegroup( + name = "as_files", + srcs = [ + ":wrappers", + "@aarch64-darwin-llvm20//:as", + ], +) + +filegroup( + name = "compiler_files", + srcs = [ + ":wrappers", + "@aarch64-darwin-llvm20//:clang", + "@aarch64-darwin-llvm20//:include", + ], +) + +filegroup( + name = "dwp_files", + srcs = [ + ":wrappers", + "@aarch64-darwin-llvm20//:dwp", + ], +) + +filegroup( + name = "linker_files", + srcs = [ + ":wrappers", + "@aarch64-darwin-llvm20//:ar", + "@aarch64-darwin-llvm20//:clang", + "@aarch64-darwin-llvm20//:lib", + ], +) + +filegroup( + name = "objcopy_files", + srcs = [ + ":wrappers", + "@aarch64-darwin-llvm20//:objcopy", + ], +) + +filegroup( + name = "strip_files", + srcs = [ + ":wrappers", + "@aarch64-darwin-llvm20//:strip", + ], +) + +filegroup( + name = "all_files", + srcs = [ + "linker_files", + ":compiler_files", + "@aarch64-darwin-llvm20//:bin", + ], +) + +cc_toolchain_config( + name = "local-aarch64-darwin", + abi_libc_version = "darwin_aarch64", + abi_version = "darwin_aarch64", + builtin_sysroot = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk", + compiler = "clang", + cxx_builtin_include_directories = [ + "%sysroot%/usr/include", + "%sysroot%/System/Library/Frameworks", + ], + host_system_name = AARCH64_DARWIN, + is_darwin = True, + target_cpu = "darwin", + target_libc = "macosx", + target_system_name = AARCH64_DARWIN, + tool_paths = { + "ar": "/usr/bin/libtool", + "cpp": "wrappers/clang-cpp", + "gcc": "wrappers/clang", + "gcov": "wrappers/llvm-profdata", + "llvm-cov": "wrappers/llvm-cov", + "llvm-profdata": "wrappers/llvm-profdata", + "ld": "/usr/bin/ld", + "nm": "wrappers/llvm-nm", + "objcopy": "wrappers/llvm-objcopy", + "objdump": "wrappers/llvm-objdump", + "strip": "wrappers/llvm-strip", + }, + toolchain_identifier = "clang-aarch64-darwin", + toolchain_path_prefix = "external/aarch64-darwin-llvm20", + use_lld = False, +) + +cc_toolchain( + name = "cc-clang-aarch64-darwin", + all_files = ":all_files", + ar_files = ":ar_files", + as_files = ":as_files", + compiler_files = ":compiler_files", + dwp_files = ":dwp_files", + linker_files = ":linker_files", + objcopy_files = ":objcopy_files", + strip_files = ":strip_files", + toolchain_config = ":local-aarch64-darwin", +) + +toolchain( + name = "cc-toolchain-aarch64-darwin", + exec_compatible_with = [ + "@platforms//cpu:aarch64", + "@platforms//os:macos", + ], + target_compatible_with = [ + "@platforms//cpu:aarch64", + "@platforms//os:macos", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + target_settings = None, + toolchain = ":cc-clang-aarch64-darwin", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper b/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper new file mode 100755 index 0000000..e6ebae7 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/aarch64-darwin-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/BUILD.bazel b/cc/toolchains/llvm20/aarch64-linux/BUILD.bazel new file mode 100644 index 0000000..dd8a4ff --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/BUILD.bazel @@ -0,0 +1,179 @@ +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +load("@rules_swiftnav//cc/toolchains/llvm20:cc_toolchain_config.bzl", "cc_toolchain_config") +load("@rules_swiftnav//cc/toolchains/llvm20:target_triplets.bzl", "AARCH64_LINUX") + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "wrappers", + srcs = glob([ + "wrappers/**", + ]), + visibility = ["//visibility:public"], +) + +filegroup( + name = "ar_files", + srcs = [ + ":wrappers", + "@aarch64-linux-llvm20//:ar", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@aarch64-sysroot"], + }), +) + +filegroup( + name = "as_files", + srcs = [ + ":wrappers", + "@aarch64-linux-llvm20//:as", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@aarch64-sysroot"], + }), +) + +filegroup( + name = "compiler_files", + srcs = [ + ":wrappers", + "@aarch64-linux-llvm20//:clang", + "@aarch64-linux-llvm20//:include", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@aarch64-sysroot"], + }), +) + +filegroup( + name = "dwp_files", + srcs = [ + ":wrappers", + "@aarch64-linux-llvm20//:dwp", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@aarch64-sysroot"], + }), +) + +filegroup( + name = "linker_files", + srcs = [ + ":wrappers", + "@aarch64-linux-llvm20//:ar", + "@aarch64-linux-llvm20//:clang", + "@aarch64-linux-llvm20//:ld", + "@aarch64-linux-llvm20//:lib", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@aarch64-sysroot"], + }), +) + +filegroup( + name = "objcopy_files", + srcs = [ + ":wrappers", + "@aarch64-linux-llvm20//:objcopy", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@aarch64-sysroot"], + }), +) + +filegroup( + name = "strip_files", + srcs = [ + ":wrappers", + "@aarch64-linux-llvm20//:strip", + ], +) + +filegroup( + name = "all_files", + srcs = [ + "linker_files", + ":compiler_files", + "@aarch64-linux-llvm20//:bin", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@aarch64-sysroot"], + }), +) + +cc_toolchain_config( + name = "local-aarch64-linux", + abi_libc_version = "glibc_unknown", + abi_version = "clang", + builtin_sysroot = select({ + "@rules_swiftnav//cc:_use_libcpp": None, + "//conditions:default": "external/aarch64-sysroot", + }), + compiler = "clang", + cxx_builtin_include_directories = select({ + "@rules_swiftnav//cc:_use_libcpp": [ + "/include", + "/usr/include", + "/usr/local/include", + ], + "//conditions:default": ["%sysroot%/usr/include"], + }), + host_system_name = AARCH64_LINUX, + target_cpu = "k8", + target_libc = "glibc_unknown", + target_system_name = AARCH64_LINUX, + tool_paths = { + "ar": "wrappers/llvm-ar", + "cpp": "wrappers/clang-cpp", + "gcc": "wrappers/clang", + "gcov": "wrappers/llvm-profdata", + "llvm-cov": "wrappers/llvm-cov", + "llvm-profdata": "wrappers/llvm-profdata", + "ld": "wrappers/ld.ldd", + "nm": "wrappers/llvm-nm", + "objcopy": "wrappers/llvm-objcopy", + "objdump": "wrappers/llvm-objdump", + "strip": "wrappers/llvm-strip", + }, + toolchain_identifier = "clang-aarch64-linux", + toolchain_path_prefix = "external/aarch64-linux-llvm20", +) + +cc_toolchain( + name = "cc-clang-aarch64-linux", + all_files = ":all_files", + ar_files = ":ar_files", + as_files = ":as_files", + compiler_files = ":compiler_files", + dwp_files = ":dwp_files", + linker_files = ":linker_files", + objcopy_files = ":objcopy_files", + strip_files = ":strip_files", + toolchain_config = ":local-aarch64-linux", +) + +toolchain( + name = "cc-toolchain-aarch64-linux", + exec_compatible_with = [ + "@platforms//cpu:aarch64", + "@platforms//os:linux", + ], + target_compatible_with = [ + "@platforms//cpu:aarch64", + "@platforms//os:linux", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + target_settings = None, + toolchain = ":cc-clang-aarch64-linux", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/clang b/cc/toolchains/llvm20/aarch64-linux/wrappers/clang new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/clang @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp b/cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld b/cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper b/cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper new file mode 100755 index 0000000..cd1ef78 --- /dev/null +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/aarch64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/aarch64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/cc_toolchain_config.bzl b/cc/toolchains/llvm20/cc_toolchain_config.bzl new file mode 100644 index 0000000..647451f --- /dev/null +++ b/cc/toolchains/llvm20/cc_toolchain_config.bzl @@ -0,0 +1,205 @@ +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +load("@rules_swiftnav//cc/toolchains/llvm:target_triplets.bzl", "is_target_triplet") +load( + "unix_cc_toolchain_config.bzl", + unix_cc_toolchain_config = "cc_toolchain_config", +) + +def cc_toolchain_config( + name, + host_system_name, + toolchain_identifier, + toolchain_path_prefix, + target_cpu, + target_libc, + compiler, + abi_version, + abi_libc_version, + cxx_builtin_include_directories, + tool_paths, + target_system_name, + builtin_sysroot = None, + extra_copts = [], + is_darwin = False, + use_lld = True): + if not is_target_triplet(host_system_name): + fail(host_system_name + " is not a target tripplet") + + if not is_target_triplet(target_system_name): + fail(target_system_name + " is not a target tripplet") + + is_cross_compile = host_system_name != target_system_name + + # Default compiler flags: + compile_flags = [ + "--target=" + target_system_name, + # Security + "-U_FORTIFY_SOURCE", # https://github.com/google/sanitizers/issues/247 + "-fstack-protector", + "-fno-omit-frame-pointer", + # Math + # This controls whether the compiler allows contracting floating point operations. + # It was flipped from off to on in clang-14. + # For now we'd like to preserve the legacy behavior. + # See [BUILD-666] for more details. + "-ffp-contract=off", + # Diagnostics + "-fcolor-diagnostics", + ] + extra_copts + + # -fstandalone-debug disables options that optimize + # the size of the debug info. + # https://clang.llvm.org/docs/UsersManual.html#cmdoption-fstandalone-debug + dbg_compile_flags = ["-g", "-fstandalone-debug"] + + opt_compile_flags = [ + # No debug symbols. + "-g0", + + # Aggressive optimizations, can increase binary size. + "-O3", + + # Security hardening on by default. + "-D_FORTIFY_SOURCE=1", + + # Removal of unused code and data at link time (can this increase + # binary size in some cases?). + "-ffunction-sections", + "-fdata-sections", + ] + + cxx_flags = select({ + "@rules_swiftnav//cc:global_cxx17": ["-std=c++17"], + "@rules_swiftnav//cc:global_cxx20": ["-std=c++20"], + "@rules_swiftnav//cc:global_cxx23": ["-std=c++23"], + "//conditions:default": ["-std=c++14"], + }) + + link_flags = [ + "--target=" + target_system_name, + "-lm", + "-no-canonical-prefixes", + ] + + # Similar to link_flags, but placed later in the command line such that + # unused symbols are not stripped. + link_libs = [] + + if is_darwin: + # For the time being we still support ld64 on aarch64 darwin + if use_lld: + link_flags.extend([ + "-fuse-ld=lld", + "-headerpad_max_install_names", + ]) + else: + link_flags.extend([ + "-headerpad_max_install_names", + "-Wl,-no_warn_duplicate_libraries", + ]) + else: + link_flags.extend([ + "-fuse-ld=lld", + "-Wl,--build-id=md5", + "-Wl,--hash-style=gnu", + "-Wl,-z,relro,-z,now", + ]) + + if not is_darwin: + link_flags.extend([ + # To support libunwind + # It's ok to assume posix when using this toolchain + "-lpthread", + "-ldl", + ]) + else: + # The comments below were copied directly from: + # https://github.com/grailbio/bazel-toolchain/blob/795d76fd03e0b17c0961f0981a8512a00cba4fa2/toolchain/cc_toolchain_config.bzl#L202 + + # 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(builtin_sysroot), + "-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), + ]) + + # lld/linux only + opt_link_flags = ["-Wl,--gc-sections"] if not is_darwin else [] + + # Unfiltered compiler flags; these are placed at the end of the command + # line, so take precendence over any user supplied flags through --copts or + # such. + unfiltered_compile_flags = [ + # Do not resolve our symlinked resource prefixes to real paths. + "-no-canonical-prefixes", + # Reproducibility + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + # Grailbio uses this but in not sure it's necessary, given clang seems to respect PWD. + # Will need to validate with some testing. + #"-fdebug-prefix-map={}=__bazel_toolchain_llvm_repo__/".format(toolchain_path_prefix), + ] + + # Coverage flags: + coverage_compile_flags = ["-fprofile-instr-generate", "-fcoverage-mapping"] + coverage_link_flags = ["-fprofile-instr-generate"] + + supports_start_end_lib = use_lld + + unix_cc_toolchain_config( + name = name, + cpu = target_cpu, + compiler = compiler, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_libc = target_libc, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + cxx_builtin_include_directories = cxx_builtin_include_directories, + tool_paths = tool_paths, + compile_flags = compile_flags, + dbg_compile_flags = dbg_compile_flags, + opt_compile_flags = opt_compile_flags, + cxx_flags = cxx_flags, + link_flags = link_flags, + link_libs = link_libs, + opt_link_flags = opt_link_flags, + unfiltered_compile_flags = unfiltered_compile_flags, + coverage_compile_flags = coverage_compile_flags, + coverage_link_flags = coverage_link_flags, + supports_start_end_lib = supports_start_end_lib, + builtin_sysroot = builtin_sysroot, + use_libtool = not use_lld, + ) diff --git a/cc/toolchains/llvm20/llvm.BUILD.bzl b/cc/toolchains/llvm20/llvm.BUILD.bzl new file mode 100755 index 0000000..c525b56 --- /dev/null +++ b/cc/toolchains/llvm20/llvm.BUILD.bzl @@ -0,0 +1,140 @@ +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +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", + "bin/clang++", + "bin/clang-cpp", + ], +) + +filegroup( + name = "ld", + # Hack to workaround us not building lld + # for aarch64-darwin. + srcs = glob([ + "bin/ld.lld", + # Required on mac + "bin/ld64.lld", + ]), +) + +filegroup( + name = "include", + srcs = glob([ + "include/**/c++/**", + "lib/clang/*/include/**", + ]), +) + +filegroup( + name = "bin", + srcs = glob(["bin/**"]), +) + +filegroup( + name = "lib", + srcs = glob( + [ + "lib/**/lib*.a", + "lib/clang/*/lib/**/*.a", + # clang_rt.*.o supply crtbegin and crtend sections. + "lib/**/clang_rt.*.o", + ], + exclude = [ + "lib/libLLVM*.a", + "lib/libclang*.a", + "lib/liblld*.a", + ], + ), + # 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 + # be linked statically. +) + +filegroup( + name = "ar", + srcs = ["bin/llvm-ar"], +) + +filegroup( + name = "as", + srcs = [ + "bin/clang", + ], +) + +filegroup( + name = "nm", + srcs = ["bin/llvm-nm"], +) + +filegroup( + name = "objcopy", + srcs = ["bin/llvm-objcopy"], +) + +filegroup( + name = "objdump", + srcs = ["bin/llvm-objdump"], +) + +filegroup( + name = "profdata", + srcs = ["bin/llvm-profdata"], +) + +filegroup( + name = "dwp", + srcs = ["bin/llvm-dwp"], +) + +filegroup( + name = "ranlib", + srcs = ["bin/llvm-ranlib"], +) + +filegroup( + name = "readelf", + srcs = ["bin/llvm-readelf"], +) + +filegroup( + name = "strip", + srcs = ["bin/llvm-strip"], +) + +filegroup( + name = "symbolizer", + srcs = ["bin/llvm-symbolizer"], +) + +filegroup( + name = "clang-tidy", + srcs = ["bin/clang-tidy"], +) + +filegroup( + name = "clang-format", + srcs = ["bin/clang-format"], +) diff --git a/cc/toolchains/llvm20/llvm.patch b/cc/toolchains/llvm20/llvm.patch new file mode 100644 index 0000000..2406faf --- /dev/null +++ b/cc/toolchains/llvm20/llvm.patch @@ -0,0 +1,49 @@ +diff --git a/include/c++/v1/__config b/include/c++/v1/__config +index 458d0c1..cd0c6f5 100644 +--- a/include/c++/v1/__config ++++ b/include/c++/v1/__config +@@ -1341,6 +1341,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( + + #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) + #define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS ++#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION + #define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS + #define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS + #define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR +diff --git a/include/c++/v1/__memory/allocator.h b/include/c++/v1/__memory/allocator.h +index 708bd82..912924a 100644 +--- a/include/c++/v1/__memory/allocator.h ++++ b/include/c++/v1/__memory/allocator.h +@@ -26,27 +26,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD + + template class allocator; + +-#if _LIBCPP_STD_VER <= 17 ++#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION) + template <> + class _LIBCPP_TEMPLATE_VIS allocator + { ++#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) + public: + _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type; + + template struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; ++#endif + }; + + template <> + class _LIBCPP_TEMPLATE_VIS allocator + { ++#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) + public: + _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type; + + template struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; ++#endif + }; + #endif + diff --git a/cc/toolchains/llvm20/swift_custom_features.bzl b/cc/toolchains/llvm20/swift_custom_features.bzl new file mode 100644 index 0000000..c330bad --- /dev/null +++ b/cc/toolchains/llvm20/swift_custom_features.bzl @@ -0,0 +1,422 @@ +"""Swiftnav custom toolchain features + +Our unix_cc_toolchain_config.bzl is a fork of upstream at: + https://github.com/bazelbuild/bazel/blob/master/tools/cpp/unix_cc_toolchain_config.bzl + +For the time being we would like to keep this a super set of the features defined there +or pull in fixes and new features without upgrading bazel. + +In order to keep this maintainable all of our custom additions will be added +to this file under the swift_ prefix. + +Bug fixes, ports of features from newer versions, etc.. should be put as they +appear in upstream in unix_cc_toolchain_config.bzl. +""" + +load( + "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "feature", + "flag_group", + "flag_set", + "with_feature_set", +) +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") + +_all_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, + ACTION_NAMES.lto_backend, +] + +_all_cpp_compile_actions = [ + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, +] + +_preprocessor_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, +] + +_codegen_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, +] + +_all_link_actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, +] + +_lto_index_actions = [ + ACTION_NAMES.lto_index_for_executable, + ACTION_NAMES.lto_index_for_dynamic_library, + ACTION_NAMES.lto_index_for_nodeps_dynamic_library, +] + +gnu_extensions_feature = feature(name = "gnu_extensions") + +c89_standard_feature = feature( + name = "c89", + provides = ["c_standard"], + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=c89"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=gnu89"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +c90_standard_feature = feature( + name = "c90", + provides = ["c_standard"], + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=c90"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=gnu90"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +c99_standard_feature = feature( + name = "c99", + provides = ["c_standard"], + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=c99"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=gnu99"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +c11_standard_feature = feature( + name = "c11", + provides = ["c_standard"], + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=c11"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=gnu11"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +c17_standard_feature = feature( + name = "c17", + provides = ["c_standard"], + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=c17"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = [ACTION_NAMES.c_compile], + flag_groups = ([ + flag_group( + flags = ["-std=gnu17"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +cxx98_standard_feature = feature( + name = "c++98", + provides = ["cxx_standard"], + flag_sets = [ + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=c++98"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=gnu++98"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +cxx11_standard_feature = feature( + name = "c++11", + provides = ["cxx_standard"], + flag_sets = [ + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=c++0x"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=gnu++0x"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +cxx14_standard_feature = feature( + name = "c++14", + provides = ["cxx_standard"], + flag_sets = [ + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=c++14"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=gnu++14"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +cxx17_standard_feature = feature( + name = "c++17", + provides = ["cxx_standard"], + flag_sets = [ + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=c++17"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=gnu++17"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + ], +) + +cxx20_standard_feature = feature( + name = "c++20", + provides = ["cxx_standard"], + flag_sets = [ + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=c++20"], + ), + ]), + with_features = [ + with_feature_set(not_features = ["gnu_extensions"]), + ], + ), + flag_set( + actions = _all_cpp_compile_actions, + flag_groups = ([ + flag_group( + flags = ["-std=gnu++20"], + ), + ]), + with_features = [ + with_feature_set(features = ["gnu_extensions"]), + ], + ), + # clang is aggresive about removing features from the standard. + flag_set( + actions = _preprocessor_compile_actions, + flag_groups = ([ + flag_group( + flags = [ + # This is a workaround for memory_resource being experimental only + # in the llvm-14 libc++ impelmentation. + "-DSWIFTNAV_EXPERIMENTAL_MEMORY_RESOURCE", + "-D_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES", + ], + ), + ]), + with_features = [ + with_feature_set(features = ["libcpp"]), + ], + ), + ], +) + +swift_relwdbg_feature = feature( + name = "relwdbg", + flag_sets = [ + flag_set( + actions = _all_compile_actions, + flag_groups = [flag_group(flags = ["-O2", "-g"])], + ), + ], +) + +# Clang has a set of warnings that are always enabled by default +# which gets noisey for third party code. This feature allows disabling +# these warnings for code we likely never intend to patch to focus on +# warnings we care about. +swift_no_default_warnings = feature( + name = "no_default_warnings", + flag_sets = [ + flag_set( + actions = _all_compile_actions, + flag_groups = [flag_group(flags = [ + "-Wno-fortify-source", + "-Wno-absolute-value", + "-Wno-format", + "-Wno-deprecated-declarations", + "-Wno-unused-but-set-variable", + "-Wno-pointer-bool-conversion", + "-Wno-unused-variable", + "-Wno-incompatible-pointer-types-discards-qualifiers", + "-Wno-implicit-const-int-float-conversion", + "-Wno-implicit-function-declaration", + "-Wno-mismatched-new-delete", + ])], + ), + ], +) diff --git a/cc/toolchains/llvm20/target_triplets.bzl b/cc/toolchains/llvm20/target_triplets.bzl new file mode 100644 index 0000000..421143c --- /dev/null +++ b/cc/toolchains/llvm20/target_triplets.bzl @@ -0,0 +1,10 @@ +X86_64_LINUX = "x86_64-unknown-linux-gnu" +AARCH64_LINUX = "aarch64-unknown-linux-gnu" +X86_64_DARWIN = "x86_64-apple-macosx" +AARCH64_DARWIN = "aarch64-apple-macosx" + +def is_target_triplet(target): + return target != X86_64_LINUX or \ + target != AARCH64_LINUX or \ + target != X86_64_DARWIN or \ + target != AARCH64_DARWIN diff --git a/cc/toolchains/llvm20/unix_cc_toolchain_config.bzl b/cc/toolchains/llvm20/unix_cc_toolchain_config.bzl new file mode 100644 index 0000000..44f0890 --- /dev/null +++ b/cc/toolchains/llvm20/unix_cc_toolchain_config.bzl @@ -0,0 +1,1570 @@ +# Copyright 2019 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (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. + +"""A Starlark cc_toolchain configuration rule""" + +load( + "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "action_config", + "artifact_name_pattern", + "feature", + "feature_set", + "flag_group", + "flag_set", + "tool", + "tool_path", + "variable_with_value", + "with_feature_set", +) +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") +load( + "swift_custom_features.bzl", + "c11_standard_feature", + "c17_standard_feature", + "c89_standard_feature", + "c90_standard_feature", + "c99_standard_feature", + "cxx11_standard_feature", + "cxx14_standard_feature", + "cxx17_standard_feature", + "cxx20_standard_feature", + "cxx98_standard_feature", + "gnu_extensions_feature", + "swift_no_default_warnings", + "swift_relwdbg_feature", +) + +def _target_os_version(ctx): + platform_type = ctx.fragments.apple.single_arch_platform.platform_type + xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig] + return xcode_config.minimum_os_for_platform_type(platform_type) + +def layering_check_features(compiler): + if compiler != "clang": + return [] + return [ + feature( + name = "use_module_maps", + requires = [feature_set(features = ["module_maps"])], + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = [ + flag_group( + flags = [ + "-fmodule-name=%{module_name}", + "-fmodule-map-file=%{module_map_file}", + ], + ), + ], + ), + ], + ), + + # Tell blaze we support module maps in general, so they will be generated + # for all c/c++ rules. + # Note: not all C++ rules support module maps; thus, do not imply this + # feature from other features - instead, require it. + feature(name = "module_maps", enabled = True), + feature( + name = "layering_check", + implies = ["use_module_maps"], + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = [ + flag_group(flags = [ + "-fmodules-strict-decluse", + "-Wprivate-header", + ]), + flag_group( + iterate_over = "dependent_module_map_files", + flags = [ + "-fmodule-map-file=%{dependent_module_map_files}", + ], + ), + ], + ), + ], + ), + ] + +all_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, + ACTION_NAMES.lto_backend, +] + +all_cpp_compile_actions = [ + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, +] + +preprocessor_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, +] + +codegen_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, +] + +all_link_actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, +] + +lto_index_actions = [ + ACTION_NAMES.lto_index_for_executable, + ACTION_NAMES.lto_index_for_dynamic_library, + ACTION_NAMES.lto_index_for_nodeps_dynamic_library, +] + +def _sanitizer_feature(name = "", specific_compile_flags = [], specific_link_flags = []): + return feature( + name = name, + flag_sets = [ + flag_set( + actions = all_compile_actions, + flag_groups = [ + flag_group(flags = [ + "-fno-omit-frame-pointer", + "-fno-sanitize-recover=all", + ] + specific_compile_flags), + ], + with_features = [ + with_feature_set(features = [name]), + ], + ), + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group(flags = specific_link_flags), + ], + with_features = [ + with_feature_set(features = [name]), + ], + ), + ], + ) + +def _impl(ctx): + tool_paths = [ + tool_path(name = name, path = path) + for name, path in ctx.attr.tool_paths.items() + ] + action_configs = [] + + is_linux = ctx.attr.target_libc != "macosx" + + llvm_cov_action = action_config( + action_name = ACTION_NAMES.llvm_cov, + tools = [ + tool( + path = ctx.attr.tool_paths["llvm-cov"], + ), + ], + ) + + action_configs.append(llvm_cov_action) + + supports_pic_feature = feature( + name = "supports_pic", + enabled = True, + ) + supports_start_end_lib_feature = feature( + name = "supports_start_end_lib", + enabled = True, + ) + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_compile_actions, + flag_groups = [ + flag_group( + # Security hardening requires optimization. + # We need to undef it as some distributions now have it enabled by default. + flags = ["-U_FORTIFY_SOURCE"], + ), + ], + with_features = [ + with_feature_set( + not_features = ["thin_lto"], + ), + ], + ), + flag_set( + actions = all_compile_actions, + flag_groups = ([ + flag_group( + flags = ctx.attr.compile_flags, + ), + ] if ctx.attr.compile_flags else []), + ), + flag_set( + actions = all_compile_actions, + flag_groups = ([ + flag_group( + flags = ctx.attr.dbg_compile_flags, + ), + ] if ctx.attr.dbg_compile_flags else []), + with_features = [with_feature_set(features = ["dbg"])], + ), + flag_set( + actions = all_compile_actions, + flag_groups = ([ + flag_group( + flags = ctx.attr.opt_compile_flags, + ), + ] if ctx.attr.opt_compile_flags else []), + with_features = [with_feature_set(features = ["opt"])], + ), + flag_set( + actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend], + flag_groups = ([ + flag_group( + flags = ctx.attr.cxx_flags, + ), + ] if ctx.attr.cxx_flags else []), + ), + ], + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = ([ + flag_group( + flags = ctx.attr.link_flags, + ), + ] if ctx.attr.link_flags else []), + ), + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = ([ + flag_group( + flags = ctx.attr.opt_link_flags, + ), + ] if ctx.attr.opt_link_flags else []), + with_features = [with_feature_set(features = ["opt"])], + ), + ] + ([flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = ([ + flag_group( + flags = [ + # implies static linking. + "-l:libc++.a", + "-l:libc++abi.a", + "-l:libunwind.a", + "-rtlib=compiler-rt", + ], + ), + ]), + with_features = [with_feature_set(features = ["libcpp"])], + )] if is_linux else []), + ) + + dbg_feature = feature(name = "dbg") + + opt_feature = feature(name = "opt") + + sysroot_feature = feature( + name = "sysroot", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ] + all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = ["--sysroot=%{sysroot}"], + expand_if_available = "sysroot", + ), + ], + ), + ], + ) + + fdo_optimize_feature = feature( + name = "fdo_optimize", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [ + flag_group( + flags = [ + "-fprofile-use=%{fdo_profile_path}", + "-fprofile-correction", + ], + expand_if_available = "fdo_profile_path", + ), + ], + ), + ], + provides = ["profile"], + ) + + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + user_compile_flags_feature = feature( + name = "user_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_compile_actions, + flag_groups = [ + flag_group( + flags = ["%{user_compile_flags}"], + iterate_over = "user_compile_flags", + expand_if_available = "user_compile_flags", + ), + ], + ), + ], + ) + + unfiltered_compile_flags_feature = feature( + name = "unfiltered_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_compile_actions, + flag_groups = ([ + flag_group( + flags = ctx.attr.unfiltered_compile_flags, + ), + ] if ctx.attr.unfiltered_compile_flags else []), + ), + ], + ) + + library_search_directories_feature = feature( + name = "library_search_directories", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = ["-L%{library_search_directories}"], + iterate_over = "library_search_directories", + expand_if_available = "library_search_directories", + ), + ], + ), + ], + ) + + static_libgcc_feature = feature( + name = "static_libgcc", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.lto_index_for_executable, + ACTION_NAMES.lto_index_for_dynamic_library, + ], + flag_groups = [flag_group(flags = ["-static-libgcc"])], + with_features = [ + with_feature_set(features = ["static_link_cpp_runtimes"]), + ], + ), + ], + ) + + pic_feature = feature( + name = "pic", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = [ + flag_group(flags = ["-fPIC"], expand_if_available = "pic"), + ], + ), + ], + ) + + per_object_debug_info_feature = feature( + name = "per_object_debug_info", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_codegen, + ], + flag_groups = [ + flag_group( + flags = ["-gsplit-dwarf", "-g"], + expand_if_available = "per_object_debug_info_file", + ), + ], + ), + ], + ) + + preprocessor_defines_feature = feature( + name = "preprocessor_defines", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = ["-D%{preprocessor_defines}"], + iterate_over = "preprocessor_defines", + ), + ], + ), + ], + ) + + cs_fdo_optimize_feature = feature( + name = "cs_fdo_optimize", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.lto_backend], + flag_groups = [ + flag_group( + flags = [ + "-fprofile-use=%{fdo_profile_path}", + "-Wno-profile-instr-unprofiled", + "-Wno-profile-instr-out-of-date", + "-fprofile-correction", + ], + expand_if_available = "fdo_profile_path", + ), + ], + ), + ], + provides = ["csprofile"], + ) + + autofdo_feature = feature( + name = "autofdo", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [ + flag_group( + flags = [ + "-fauto-profile=%{fdo_profile_path}", + "-fprofile-correction", + ], + expand_if_available = "fdo_profile_path", + ), + ], + ), + ], + provides = ["profile"], + ) + + runtime_library_search_directories_feature = feature( + name = "runtime_library_search_directories", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + iterate_over = "runtime_library_search_directories", + flag_groups = [ + flag_group( + flags = [ + "-Xlinker", + "-rpath", + "-Xlinker", + "$EXEC_ORIGIN/%{runtime_library_search_directories}", + ], + expand_if_true = "is_cc_test", + ), + flag_group( + flags = [ + "-Xlinker", + "-rpath", + "-Xlinker", + "$ORIGIN/%{runtime_library_search_directories}", + ], + expand_if_false = "is_cc_test", + ), + ], + expand_if_available = + "runtime_library_search_directories", + ), + ], + with_features = [ + with_feature_set(features = ["static_link_cpp_runtimes"]), + ], + ), + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + iterate_over = "runtime_library_search_directories", + flag_groups = [ + flag_group( + flags = [ + "-Xlinker", + "-rpath", + "-Xlinker", + "$ORIGIN/%{runtime_library_search_directories}", + ], + ), + ], + expand_if_available = + "runtime_library_search_directories", + ), + ], + with_features = [ + with_feature_set( + not_features = ["static_link_cpp_runtimes"], + ), + ], + ), + ], + ) + + fission_support_feature = feature( + name = "fission_support", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = ["-Wl,--gdb-index"], + expand_if_available = "is_using_fission", + ), + ], + ), + ], + ) + + shared_flag_feature = feature( + name = "shared_flag", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.lto_index_for_dynamic_library, + ACTION_NAMES.lto_index_for_nodeps_dynamic_library, + ], + flag_groups = [flag_group(flags = ["-shared"])], + ), + ], + ) + + random_seed_feature = feature( + name = "random_seed", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = [ + flag_group( + flags = ["-frandom-seed=%{output_file}"], + expand_if_available = "output_file", + ), + ], + ), + ], + ) + + includes_feature = feature( + name = "includes", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ], + flag_groups = [ + flag_group( + flags = ["-include", "%{includes}"], + iterate_over = "includes", + expand_if_available = "includes", + ), + ], + ), + ], + ) + + fdo_instrument_feature = feature( + name = "fdo_instrument", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ] + all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = [ + "-fprofile-generate=%{fdo_instrument_path}", + "-fno-data-sections", + ], + expand_if_available = "fdo_instrument_path", + ), + ], + ), + ], + provides = ["profile"], + ) + + cs_fdo_instrument_feature = feature( + name = "cs_fdo_instrument", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.lto_backend, + ] + all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = [ + "-fcs-profile-generate=%{cs_fdo_instrument_path}", + ], + expand_if_available = "cs_fdo_instrument_path", + ), + ], + ), + ], + provides = ["csprofile"], + ) + + include_paths_feature = feature( + name = "include_paths", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ], + flag_groups = [ + flag_group( + flags = ["-iquote", "%{quote_include_paths}"], + iterate_over = "quote_include_paths", + ), + flag_group( + flags = ["-I%{include_paths}"], + iterate_over = "include_paths", + ), + flag_group( + flags = ["-isystem", "%{system_include_paths}"], + iterate_over = "system_include_paths", + ), + ], + ), + ], + ) + + external_include_paths_feature = feature( + name = "external_include_paths", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ], + flag_groups = [ + flag_group( + flags = ["-isystem", "%{external_include_paths}"], + iterate_over = "external_include_paths", + expand_if_available = "external_include_paths", + ), + ], + ), + ], + ) + + symbol_counts_feature = feature( + name = "symbol_counts", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = [ + "-Wl,--print-symbol-counts=%{symbol_counts_output}", + ], + expand_if_available = "symbol_counts_output", + ), + ], + ), + ], + ) + + strip_debug_symbols_feature = feature( + name = "strip_debug_symbols", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = ["-Wl,-S"], + expand_if_available = "strip_debug_symbols", + ), + ], + ), + ], + ) + + build_interface_libraries_feature = feature( + name = "build_interface_libraries", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.lto_index_for_dynamic_library, + ACTION_NAMES.lto_index_for_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = [ + "%{generate_interface_library}", + "%{interface_library_builder_path}", + "%{interface_library_input_path}", + "%{interface_library_output_path}", + ], + expand_if_available = "generate_interface_library", + ), + ], + with_features = [ + with_feature_set( + features = ["supports_interface_shared_libraries"], + ), + ], + ), + ], + ) + + libraries_to_link_feature = feature( + name = "libraries_to_link", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + iterate_over = "libraries_to_link", + flag_groups = [ + flag_group( + flags = ["-Wl,--start-lib"], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file_group", + ), + ), + flag_group( + flags = ["-Wl,-whole-archive"], + expand_if_true = + "libraries_to_link.is_whole_archive", + ), + flag_group( + flags = ["%{libraries_to_link.object_files}"], + iterate_over = "libraries_to_link.object_files", + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file_group", + ), + ), + flag_group( + flags = ["%{libraries_to_link.name}"], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file", + ), + ), + flag_group( + flags = ["%{libraries_to_link.name}"], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "interface_library", + ), + ), + flag_group( + flags = ["%{libraries_to_link.name}"], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "static_library", + ), + ), + flag_group( + flags = ["-l%{libraries_to_link.name}"], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "dynamic_library", + ), + ), + flag_group( + flags = ["-l:%{libraries_to_link.name}"], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "versioned_dynamic_library", + ), + ), + flag_group( + flags = ["-Wl,-no-whole-archive"], + expand_if_true = "libraries_to_link.is_whole_archive", + ), + flag_group( + flags = ["-Wl,--end-lib"], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file_group", + ), + ), + ], + expand_if_available = "libraries_to_link", + ), + flag_group( + flags = ["-Wl,@%{thinlto_param_file}"], + expand_if_true = "thinlto_param_file", + ), + ], + ), + ], + ) + + user_link_flags_feature = feature( + name = "user_link_flags", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = ["%{user_link_flags}"], + iterate_over = "user_link_flags", + expand_if_available = "user_link_flags", + ), + ], + ), + ], + ) + + default_link_libs_feature = feature( + name = "default_link_libs", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [flag_group(flags = ctx.attr.link_libs)] if ctx.attr.link_libs else [], + ), + ], + ) + + fdo_prefetch_hints_feature = feature( + name = "fdo_prefetch_hints", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.lto_backend, + ], + flag_groups = [ + flag_group( + flags = [ + "-mllvm", + "-prefetch-hints-file=%{fdo_prefetch_hints_path}", + ], + expand_if_available = "fdo_prefetch_hints_path", + ), + ], + ), + ], + ) + + linkstamps_feature = feature( + name = "linkstamps", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = ["%{linkstamp_paths}"], + iterate_over = "linkstamp_paths", + expand_if_available = "linkstamp_paths", + ), + ], + ), + ], + ) + + archiver_flags_feature = feature( + name = "archiver_flags", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group(flags = ["rcsD"]), + flag_group( + flags = ["%{output_execpath}"], + expand_if_available = "output_execpath", + ), + ], + with_features = [ + with_feature_set( + not_features = ["libtool"], + ), + ], + ), + flag_set( + actions = [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group(flags = ["-no_warning_for_no_symbols", "-static", "-s"]), + flag_group( + flags = ["-o", "%{output_execpath}"], + expand_if_available = "output_execpath", + ), + ], + with_features = [ + with_feature_set( + features = ["libtool"], + ), + ], + ), + flag_set( + actions = [ACTION_NAMES.cpp_link_static_library], + flag_groups = [ + flag_group( + iterate_over = "libraries_to_link", + flag_groups = [ + flag_group( + flags = ["%{libraries_to_link.name}"], + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file", + ), + ), + flag_group( + flags = ["%{libraries_to_link.object_files}"], + iterate_over = "libraries_to_link.object_files", + expand_if_equal = variable_with_value( + name = "libraries_to_link.type", + value = "object_file_group", + ), + ), + ], + expand_if_available = "libraries_to_link", + ), + ], + ), + flag_set( + actions = [ACTION_NAMES.cpp_link_static_library], + flag_groups = ([ + flag_group( + flags = ctx.attr.archive_flags, + ), + ] if ctx.attr.archive_flags else []), + ), + ], + ) + + force_pic_flags_feature = feature( + name = "force_pic_flags", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.lto_index_for_executable, + ], + flag_groups = [ + flag_group( + flags = ["-pie"], + expand_if_available = "force_pic", + ), + ], + ), + ], + ) + + dependency_file_feature = feature( + name = "dependency_file", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = ["-MD", "-MF", "%{dependency_file}"], + expand_if_available = "dependency_file", + ), + ], + ), + ], + ) + + serialized_diagnostics_file_feature = feature( + name = "serialized_diagnostics_file", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = ["--serialize-diagnostics", "%{serialized_diagnostics_file}"], + expand_if_available = "serialized_diagnostics_file", + ), + ], + ), + ], + ) + + dynamic_library_linker_tool_feature = feature( + name = "dynamic_library_linker_tool", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.lto_index_for_dynamic_library, + ACTION_NAMES.lto_index_for_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = [" + cppLinkDynamicLibraryToolPath + "], + expand_if_available = "generate_interface_library", + ), + ], + with_features = [ + with_feature_set( + features = ["supports_interface_shared_libraries"], + ), + ], + ), + ], + ) + + output_execpath_flags_feature = feature( + name = "output_execpath_flags", + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = ["-o", "%{output_execpath}"], + expand_if_available = "output_execpath", + ), + ], + ), + ], + ) + + # Note that we also set --coverage for c++-link-nodeps-dynamic-library. The + # generated code contains references to gcov symbols, and the dynamic linker + # can't resolve them unless the library is linked against gcov. + coverage_feature = feature( + name = "coverage", + provides = ["profile"], + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ], + flag_groups = ([ + flag_group(flags = ctx.attr.coverage_compile_flags), + ] if ctx.attr.coverage_compile_flags else []), + ), + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = ([ + flag_group(flags = ctx.attr.coverage_link_flags), + ] if ctx.attr.coverage_link_flags else []), + ), + ], + ) + + thinlto_feature = feature( + name = "thin_lto", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ] + all_link_actions + lto_index_actions, + flag_groups = [ + flag_group(flags = ["-flto=thin"]), + flag_group( + expand_if_available = "lto_indexing_bitcode_file", + flags = [ + "-Xclang", + "-fthin-link-bitcode=%{lto_indexing_bitcode_file}", + ], + ), + ], + ), + flag_set( + actions = [ACTION_NAMES.linkstamp_compile], + flag_groups = [flag_group(flags = ["-DBUILD_LTO_TYPE=thin"])], + ), + flag_set( + actions = lto_index_actions, + flag_groups = [ + flag_group(flags = [ + "-flto=thin", + "-Wl,-plugin-opt,thinlto-index-only%{thinlto_optional_params_file}", + "-Wl,-plugin-opt,thinlto-emit-imports-files", + "-Wl,-plugin-opt,thinlto-prefix-replace=%{thinlto_prefix_replace}", + ]), + flag_group( + expand_if_available = "thinlto_object_suffix_replace", + flags = [ + "-Wl,-plugin-opt,thinlto-object-suffix-replace=%{thinlto_object_suffix_replace}", + ], + ), + flag_group( + expand_if_available = "thinlto_merged_object_file", + flags = [ + "-Wl,-plugin-opt,obj-path=%{thinlto_merged_object_file}", + ], + ), + ], + ), + flag_set( + actions = [ACTION_NAMES.lto_backend], + flag_groups = [ + flag_group(flags = [ + "-c", + "-fthinlto-index=%{thinlto_index}", + "-o", + "%{thinlto_output_object_file}", + "-x", + "ir", + "%{thinlto_input_bitcode_file}", + ]), + ], + ), + ], + ) + + treat_warnings_as_errors_feature = feature( + name = "treat_warnings_as_errors", + flag_sets = [ + flag_set( + actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile], + flag_groups = [flag_group(flags = ["-Werror"])], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["-Wl,-fatal-warnings"])], + ), + ], + ) + + archive_param_file_feature = feature( + name = "archive_param_file", + enabled = True, + ) + + asan_feature = _sanitizer_feature( + name = "asan", + specific_compile_flags = [ + "-fsanitize=address", + "-fno-common", + ], + specific_link_flags = [ + "-fsanitize=address", + ], + ) + + tsan_feature = _sanitizer_feature( + name = "tsan", + specific_compile_flags = [ + "-fsanitize=thread", + ], + specific_link_flags = [ + "-fsanitize=thread", + ], + ) + + ubsan_feature = _sanitizer_feature( + name = "ubsan", + specific_compile_flags = [ + "-fsanitize=undefined", + ], + specific_link_flags = [ + "-fsanitize=undefined", + ], + ) + + macos_minimum_os_feature = feature( + name = "macos_minimum_os", + enabled = True, + flag_sets = [ + flag_set( + actions = all_compile_actions + all_link_actions, + flag_groups = [flag_group(flags = ["-mmacos-version-min={}".format(_target_os_version(ctx))])], + ), + ], + ) + + libtool_feature = feature( + name = "libtool", + enabled = ctx.attr.use_libtool, + ) + + swift_stdlib_feature = feature( + name = "stdlib", + enabled = True, + # The default is libstdc++, with the option to use libc++ instead. + flag_sets = [ + flag_set( + actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend], + flag_groups = ([ + flag_group( + flags = [ + "-stdlib=libstdc++", + ], + ), + ]), + with_features = [with_feature_set(not_features = ["libcpp"])], + ), + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = ([ + flag_group( + flags = [ + # link statically for now + "-l:libstdc++.a", + ], + ), + ]), + with_features = [with_feature_set(not_features = ["libcpp"])], + ), + flag_set( + actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend], + flag_groups = ([ + flag_group( + flags = ["-stdlib=libc++"], + ), + ]), + with_features = [with_feature_set(features = ["libcpp"])], + ), + ], + ) + + swift_libcpp_feature = feature( + name = "libcpp", + # libc++ is the default on macos. + enabled = not is_linux, + ) + + # TODO(#8303): Mac crosstool should also declare every feature. + if is_linux: + # Linux artifact name patterns are the default. + artifact_name_patterns = [] + features = [ + dependency_file_feature, + serialized_diagnostics_file_feature, + random_seed_feature, + pic_feature, + per_object_debug_info_feature, + preprocessor_defines_feature, + includes_feature, + include_paths_feature, + external_include_paths_feature, + fdo_instrument_feature, + cs_fdo_instrument_feature, + cs_fdo_optimize_feature, + thinlto_feature, + fdo_prefetch_hints_feature, + autofdo_feature, + build_interface_libraries_feature, + dynamic_library_linker_tool_feature, + symbol_counts_feature, + shared_flag_feature, + linkstamps_feature, + output_execpath_flags_feature, + runtime_library_search_directories_feature, + library_search_directories_feature, + libtool_feature, + archiver_flags_feature, + force_pic_flags_feature, + fission_support_feature, + strip_debug_symbols_feature, + coverage_feature, + supports_pic_feature, + asan_feature, + tsan_feature, + ubsan_feature, + ] + ( + [ + supports_start_end_lib_feature, + ] if ctx.attr.supports_start_end_lib else [] + ) + [ + default_compile_flags_feature, + default_link_flags_feature, + libraries_to_link_feature, + user_link_flags_feature, + default_link_libs_feature, + static_libgcc_feature, + fdo_optimize_feature, + supports_dynamic_linker_feature, + dbg_feature, + opt_feature, + user_compile_flags_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + treat_warnings_as_errors_feature, + archive_param_file_feature, + ] + layering_check_features(ctx.attr.compiler) + [ + # append swiftnavs custom features here. + gnu_extensions_feature, + c89_standard_feature, + c90_standard_feature, + c99_standard_feature, + c11_standard_feature, + c17_standard_feature, + cxx98_standard_feature, + cxx11_standard_feature, + cxx14_standard_feature, + cxx17_standard_feature, + cxx20_standard_feature, + swift_no_default_warnings, + swift_stdlib_feature, + swift_libcpp_feature, + swift_relwdbg_feature, + ] + else: + # macOS artifact name patterns differ from the defaults only for dynamic + # libraries. + artifact_name_patterns = [ + artifact_name_pattern( + category_name = "dynamic_library", + prefix = "lib", + extension = ".dylib", + ), + ] + features = [ + libtool_feature, + archiver_flags_feature, + supports_pic_feature, + asan_feature, + tsan_feature, + ubsan_feature, + macos_minimum_os_feature, + ] + ( + [ + supports_start_end_lib_feature, + ] if ctx.attr.supports_start_end_lib else [] + ) + [ + coverage_feature, + default_compile_flags_feature, + default_link_flags_feature, + user_link_flags_feature, + default_link_libs_feature, + external_include_paths_feature, + fdo_optimize_feature, + supports_dynamic_linker_feature, + dbg_feature, + opt_feature, + user_compile_flags_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + treat_warnings_as_errors_feature, + archive_param_file_feature, + ] + layering_check_features(ctx.attr.compiler) + [ + # append swiftnavs custom features here + gnu_extensions_feature, + c89_standard_feature, + c90_standard_feature, + c99_standard_feature, + c11_standard_feature, + c17_standard_feature, + cxx98_standard_feature, + cxx11_standard_feature, + cxx14_standard_feature, + cxx17_standard_feature, + cxx20_standard_feature, + swift_no_default_warnings, + swift_stdlib_feature, + swift_libcpp_feature, + swift_relwdbg_feature, + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = ctx.attr.cxx_builtin_include_directories, + toolchain_identifier = ctx.attr.toolchain_identifier, + host_system_name = ctx.attr.host_system_name, + target_system_name = ctx.attr.target_system_name, + target_cpu = ctx.attr.cpu, + target_libc = ctx.attr.target_libc, + compiler = ctx.attr.compiler, + abi_version = ctx.attr.abi_version, + abi_libc_version = ctx.attr.abi_libc_version, + tool_paths = tool_paths, + builtin_sysroot = ctx.attr.builtin_sysroot, + ) + +cc_toolchain_config = rule( + implementation = _impl, + attrs = { + "cpu": attr.string(mandatory = True), + "compiler": attr.string(mandatory = True), + "toolchain_identifier": attr.string(mandatory = True), + "host_system_name": attr.string(mandatory = True), + "target_system_name": attr.string(mandatory = True), + "target_libc": attr.string(mandatory = True), + "abi_version": attr.string(mandatory = True), + "abi_libc_version": attr.string(mandatory = True), + "cxx_builtin_include_directories": attr.string_list(), + "tool_paths": attr.string_dict(), + "compile_flags": attr.string_list(), + "dbg_compile_flags": attr.string_list(), + "opt_compile_flags": attr.string_list(), + "cxx_flags": attr.string_list(), + "link_flags": attr.string_list(), + "archive_flags": attr.string_list(), + "link_libs": attr.string_list(), + "opt_link_flags": attr.string_list(), + "unfiltered_compile_flags": attr.string_list(), + "coverage_compile_flags": attr.string_list(), + "coverage_link_flags": attr.string_list(), + "supports_start_end_lib": attr.bool(), + "builtin_sysroot": attr.string(), + "use_libtool": attr.bool(), + "_xcode_config": attr.label(default = configuration_field( + fragment = "apple", + name = "xcode_config_label", + )), + }, + fragments = ["apple"], + provides = [CcToolchainConfigInfo], +) diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/BUILD.bazel b/cc/toolchains/llvm20/x86_64-aarch64-linux/BUILD.bazel new file mode 100644 index 0000000..2218380 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/BUILD.bazel @@ -0,0 +1,182 @@ +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +load("@rules_swiftnav//cc/toolchains/llvm20:cc_toolchain_config.bzl", "cc_toolchain_config") +load("@rules_swiftnav//cc/toolchains/llvm20:target_triplets.bzl", "AARCH64_LINUX", "X86_64_LINUX") + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "wrappers", + srcs = glob([ + "wrappers/**", + ]), + visibility = ["//visibility:public"], +) + +filegroup( + name = "ar_files", + srcs = [ + ":wrappers", + "@aarch64-sysroot", + "@x86_64-linux-llvm20//:ar", + ], +) + +filegroup( + name = "as_files", + srcs = [ + ":wrappers", + "@aarch64-sysroot", + "@x86_64-linux-llvm20//:as", + ], +) + +filegroup( + name = "compiler_files", + srcs = [ + ":wrappers", + "@aarch64-sysroot", + "@x86_64-linux-llvm20//:clang", + "@x86_64-linux-llvm20//:include", + ], +) + +filegroup( + name = "dwp_files", + srcs = [ + ":wrappers", + "@aarch64-sysroot", + "@x86_64-linux-llvm20//:dwp", + ], +) + +filegroup( + name = "linker_files", + srcs = [ + ":wrappers", + "@aarch64-sysroot", + "@x86_64-linux-llvm20//:ar", + "@x86_64-linux-llvm20//:clang", + "@x86_64-linux-llvm20//:ld", + "@x86_64-linux-llvm20//:lib", + ], +) + +filegroup( + name = "objcopy_files", + srcs = [ + ":wrappers", + "@aarch64-sysroot", + "@x86_64-linux-llvm20//:objcopy", + ], +) + +filegroup( + name = "strip_files", + srcs = [ + ":wrappers", + "@x86_64-linux-llvm20//:strip", + ], +) + +filegroup( + name = "all_files", + srcs = [ + "linker_files", + ":compiler_files", + "@aarch64-sysroot", + "@x86_64-linux-llvm20//:bin", + ], +) + +cc_toolchain_config( + name = "local-x86_64-aarch64-linux", + abi_libc_version = "glibc_unknown", + abi_version = "clang", + builtin_sysroot = "external/aarch64-sysroot", + compiler = "clang", + cxx_builtin_include_directories = [ + "%sysroot%/usr/include", + ], + extra_copts = select({ + "@rules_swiftnav//cc/constraints:graviton2": ["-mcpu=neoverse-n1"], + "@rules_swiftnav//cc/constraints:graviton3": ["-mcpu=neoverse-512tvb"], + "//conditions:default": [], + }), + host_system_name = X86_64_LINUX, + target_cpu = "k8", + target_libc = "glibc_unknown", + target_system_name = AARCH64_LINUX, + tool_paths = { + "ar": "wrappers/llvm-ar", + "cpp": "wrappers/clang-cpp", + "gcc": "wrappers/clang", + "gcov": "wrappers/llvm-profdata", + "llvm-cov": "wrappers/llvm-cov", + "llvm-profdata": "wrappers/llvm-profdata", + "ld": "wrappers/ld.ldd", + "nm": "wrappers/llvm-nm", + "objcopy": "wrappers/llvm-objcopy", + "objdump": "wrappers/llvm-objdump", + "strip": "wrappers/llvm-strip", + }, + toolchain_identifier = "clang-x86_64-linux", + toolchain_path_prefix = "external/x86_64-linux-llvm20", +) + +cc_toolchain( + name = "cc-clang-x86_64-aarch64-linux", + all_files = ":all_files", + ar_files = ":ar_files", + as_files = ":as_files", + compiler_files = ":compiler_files", + dwp_files = ":dwp_files", + linker_files = ":linker_files", + objcopy_files = ":objcopy_files", + strip_files = ":strip_files", + toolchain_config = ":local-x86_64-aarch64-linux", +) + +toolchain( + name = "cc-toolchain-aarch64-bullseye-graviton2", + exec_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + ], + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:aarch64", + "@rules_swiftnav//cc/constraints:glibc_2_31", + "@rules_swiftnav//cc/constraints:graviton2", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + target_settings = None, + toolchain = ":cc-clang-x86_64-aarch64-linux", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cc-toolchain-aarch64-bullseye-graviton3", + exec_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + ], + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:aarch64", + "@rules_swiftnav//cc/constraints:glibc_2_31", + "@rules_swiftnav//cc/constraints:graviton3", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + target_settings = None, + toolchain = ":cc-clang-x86_64-aarch64-linux", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper new file mode 100755 index 0000000..1465808 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/BUILD.bazel b/cc/toolchains/llvm20/x86_64-darwin/BUILD.bazel new file mode 100644 index 0000000..8170ce5 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/BUILD.bazel @@ -0,0 +1,152 @@ +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +load("@rules_swiftnav//cc/toolchains/llvm20:cc_toolchain_config.bzl", "cc_toolchain_config") +load("@rules_swiftnav//cc/toolchains/llvm20:target_triplets.bzl", "X86_64_DARWIN") + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "wrappers", + srcs = glob([ + "wrappers/**", + ]), + visibility = ["//visibility:public"], +) + +filegroup( + name = "ar_files", + srcs = [ + ":wrappers", + "@x86_64-darwin-llvm20//:ar", + ], +) + +filegroup( + name = "as_files", + srcs = [ + ":wrappers", + "@x86_64-darwin-llvm20//:as", + ], +) + +filegroup( + name = "compiler_files", + srcs = [ + ":wrappers", + "@x86_64-darwin-llvm20//:clang", + "@x86_64-darwin-llvm20//:include", + ], +) + +filegroup( + name = "dwp_files", + srcs = [ + ":wrappers", + "@x86_64-darwin-llvm20//:dwp", + ], +) + +filegroup( + name = "linker_files", + srcs = [ + ":wrappers", + "@x86_64-darwin-llvm20//:ar", + "@x86_64-darwin-llvm20//:clang", + "@x86_64-darwin-llvm20//:ld", + "@x86_64-darwin-llvm20//:lib", + ], +) + +filegroup( + name = "objcopy_files", + srcs = [ + ":wrappers", + "@x86_64-darwin-llvm20//:objcopy", + ], +) + +filegroup( + name = "strip_files", + srcs = [ + ":wrappers", + "@x86_64-darwin-llvm20//:strip", + ], +) + +filegroup( + name = "all_files", + srcs = [ + "linker_files", + ":compiler_files", + "@x86_64-darwin-llvm20//:bin", + ], +) + +cc_toolchain_config( + name = "local-x86_64-darwin", + abi_libc_version = "darwin_x86_64", + abi_version = "darwin_x86_64", + builtin_sysroot = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk", + compiler = "clang", + cxx_builtin_include_directories = [ + "%sysroot%/usr/include", + "%sysroot%/System/Library/Frameworks", + ], + host_system_name = X86_64_DARWIN, + is_darwin = True, + target_cpu = "darwin", + target_libc = "macosx", + target_system_name = X86_64_DARWIN, + tool_paths = { + "ar": "wrappers/llvm-ar", + "cpp": "wrappers/clang-cpp", + "gcc": "wrappers/clang", + "gcov": "wrappers/llvm-profdata", + "llvm-cov": "wrappers/llvm-cov", + "llvm-profdata": "wrappers/llvm-profdata", + "ld": "wrappers/ld.lld", + "nm": "wrappers/llvm-nm", + "objcopy": "wrappers/llvm-objcopy", + "objdump": "wrappers/llvm-objdump", + "strip": "wrappers/llvm-strip", + }, + toolchain_identifier = "clang-x86_64-darwin", + toolchain_path_prefix = "external/x86_64-darwin-llvm20", +) + +cc_toolchain( + name = "cc-clang-x86_64-darwin", + all_files = ":all_files", + ar_files = ":ar_files", + as_files = ":as_files", + compiler_files = ":compiler_files", + dwp_files = ":dwp_files", + linker_files = ":linker_files", + objcopy_files = ":objcopy_files", + strip_files = ":strip_files", + toolchain_config = ":local-x86_64-darwin", +) + +toolchain( + name = "cc-toolchain-x86_64-darwin", + exec_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:macos", + ], + target_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:macos", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + target_settings = None, + toolchain = ":cc-clang-x86_64-darwin", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang b/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp b/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld b/cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper b/cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper new file mode 100755 index 0000000..e8a60c3 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +toolchain_bindir=external/x86_64-darwin-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/BUILD.bazel b/cc/toolchains/llvm20/x86_64-linux/BUILD.bazel new file mode 100644 index 0000000..c746740 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/BUILD.bazel @@ -0,0 +1,197 @@ +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +load("@rules_swiftnav//cc/toolchains/llvm20:cc_toolchain_config.bzl", "cc_toolchain_config") +load("@rules_swiftnav//cc/toolchains/llvm20:target_triplets.bzl", "X86_64_LINUX") + +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "wrappers", + srcs = glob([ + "wrappers/**", + ]), + visibility = ["//visibility:public"], +) + +filegroup( + name = "ar_files", + srcs = [ + ":wrappers", + "@x86_64-linux-llvm20//:ar", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@x86_64-sysroot"], + }), +) + +filegroup( + name = "as_files", + srcs = [ + ":wrappers", + "@x86_64-linux-llvm20//:as", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@x86_64-sysroot"], + }), +) + +filegroup( + name = "compiler_files", + srcs = [ + ":wrappers", + "@x86_64-linux-llvm20//:clang", + "@x86_64-linux-llvm20//:include", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@x86_64-sysroot"], + }), +) + +filegroup( + name = "dwp_files", + srcs = [ + ":wrappers", + "@x86_64-linux-llvm20//:dwp", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@x86_64-sysroot"], + }), +) + +filegroup( + name = "linker_files", + srcs = [ + ":wrappers", + "@x86_64-linux-llvm20//:ar", + "@x86_64-linux-llvm20//:clang", + "@x86_64-linux-llvm20//:ld", + "@x86_64-linux-llvm20//:lib", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@x86_64-sysroot"], + }), +) + +filegroup( + name = "objcopy_files", + srcs = [ + ":wrappers", + "@x86_64-linux-llvm20//:objcopy", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@x86_64-sysroot"], + }), +) + +filegroup( + name = "strip_files", + srcs = [ + ":wrappers", + "@x86_64-linux-llvm20//:strip", + ], +) + +filegroup( + name = "all_files", + srcs = [ + "linker_files", + ":compiler_files", + "@x86_64-linux-llvm20//:bin", + ] + select({ + "@rules_swiftnav//cc:_use_libcpp": [], + "//conditions:default": ["@x86_64-sysroot"], + }), +) + +cc_toolchain_config( + name = "local-x86_64-linux", + abi_libc_version = "glibc_unknown", + abi_version = "clang", + builtin_sysroot = select({ + "@rules_swiftnav//cc:_use_libcpp": None, + # Remove once bzlmod is enabled by default + "@rules_swiftnav//cc:_enable_bzlmod": "external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-sysroot", + "//conditions:default": "external/x86_64-sysroot", + }), + compiler = "clang", + cxx_builtin_include_directories = select({ + "@rules_swiftnav//cc:_use_libcpp": [ + "/include", + "/usr/include", + "/usr/local/include", + ], + "//conditions:default": ["%sysroot%/usr/include"], + }), + host_system_name = X86_64_LINUX, + target_cpu = "k8", + target_libc = "glibc_unknown", + target_system_name = X86_64_LINUX, + tool_paths = { + "ar": "wrappers/llvm-ar", + "cpp": "wrappers/clang-cpp", + "gcc": "wrappers/clang", + "gcov": "wrappers/llvm-profdata", + "llvm-cov": "wrappers/llvm-cov", + "llvm-profdata": "wrappers/llvm-profdata", + "ld": "wrappers/ld.ldd", + "nm": "wrappers/llvm-nm", + "objcopy": "wrappers/llvm-objcopy", + "objdump": "wrappers/llvm-objdump", + "strip": "wrappers/llvm-strip", + }, + toolchain_identifier = "clang-x86_64-linux", + toolchain_path_prefix = "external/x86_64-linux-llvm20", +) + +cc_toolchain( + name = "cc-clang-x86_64-linux", + all_files = ":all_files", + ar_files = ":ar_files", + as_files = ":as_files", + compiler_files = ":compiler_files", + dwp_files = ":dwp_files", + linker_files = ":linker_files", + objcopy_files = ":objcopy_files", + strip_files = ":strip_files", + toolchain_config = ":local-x86_64-linux", +) + +toolchain( + name = "cc-toolchain-x86_64-linux", + exec_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + ], + target_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + target_settings = None, + toolchain = ":cc-clang-x86_64-linux", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cc-toolchain-intel-mkl", + exec_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + ], + target_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + "//third_party:intel_mkl", + ], + target_settings = None, + toolchain = ":cc-clang-x86_64-linux", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld b/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper b/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper new file mode 100755 index 0000000..0d01e26 --- /dev/null +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright (C) 2022 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +# Locates the actual tool paths relative to the location this script is +# executed from. +# +# This is necessary because we download the toolchain using +# http_archive, which bazel places in _execroot_/external/_repo_name_. +# +# Unfortunately we cannot provide this location as the argument of tool_path +# when configuring the toolchain, because tool_path only takes a relative path. +# +# This is the fairly common workaround to handle this. +# +# TODO: [BUILD-549] - Remove need for wrapper files +# +# Recent versions of Bazel may have introduced a mechanism that removes +# the need for this workaround: https://github.com/bazelbuild/bazel/issues/7746 + +set -e + +# Use --actionv_env=SWIFTNAV_VERBOSE_TOOLCHAIN to enable +if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then + set -x +fi + +tool_name=$(basename "${BASH_SOURCE[0]}") +# In case the tool label is changed, a change in here is very likely needed +# This establishes backwards compatibility with the old WORKSPACE file +toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin + +if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir}"/"${tool_name}" "$@" +elif [[ -f "${toolchain_bindir_as_bzlmod}"/"${tool_name}" ]]; then + # We're running under _execroot_, call the real tool. + exec "${toolchain_bindir_as_bzlmod}"/"${tool_name}" "$@" +elif [[ "${BASH_SOURCE[0]}" == "/"* ]]; then + # This branch exists because some users of the toolchain, + # namely rules_foreign_cc, will change CWD and call $CC (this script) + # with its absolute path. + # + # To deal with this we find the tool relative to this script, which is at + # _execroot_/external/rules_swiftnav/cc/toolchain/llvm/x86_64-linux/wrappers/wrapper. + # + # If the wrapper is relocated then this line needs to be adjusted. + execroot_path="${BASH_SOURCE[0]%/*/*/*/*/*/*/*/*}" + tool="${execroot_path}/${toolchain_bindir}/${tool_name}" + exec "${tool}" "${@}" +else + >&2 echo "ERROR: could not find ${tool_name}; PWD=\"$(pwd)\"; PATH=\"${PATH}\"." + exit 5 +fi + diff --git a/platforms/BUILD.bazel b/platforms/BUILD.bazel index a7990e9..fde54ec 100644 --- a/platforms/BUILD.bazel +++ b/platforms/BUILD.bazel @@ -170,3 +170,44 @@ platform( ], visibility = ["//visibility:public"], ) + +# LLVM 20 Platforms +platform( + name = "x86_64_linux_llvm20", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + visibility = ["//visibility:public"], +) + +platform( + name = "aarch64_linux_llvm20", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:aarch64", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + visibility = ["//visibility:public"], +) + +platform( + name = "x86_64_darwin_llvm20", + constraint_values = [ + "@platforms//os:macos", + "@platforms//cpu:x86_64", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + visibility = ["//visibility:public"], +) + +platform( + name = "aarch64_darwin_llvm20", + constraint_values = [ + "@platforms//os:macos", + "@platforms//cpu:aarch64", + "@rules_swiftnav//cc/constraints:llvm20_toolchain", + ], + visibility = ["//visibility:public"], +) From c9c6672c1657a6d0c563e1be88c252dfe8b00ba5 Mon Sep 17 00:00:00 2001 From: martin4861 Date: Fri, 4 Jul 2025 13:35:38 +0200 Subject: [PATCH 2/5] Fix wrappers --- cc/toolchains/llvm20/aarch64-darwin/wrappers/clang | 4 ++-- cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp | 4 ++-- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov | 4 ++-- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm | 4 ++-- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy | 4 ++-- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump | 4 ++-- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata | 4 ++-- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip | 4 ++-- cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper | 4 ++-- cc/toolchains/llvm20/aarch64-linux/wrappers/clang | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip | 2 +- cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper | 2 +- cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang | 2 +- cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp | 2 +- cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld | 2 +- cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar | 2 +- cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov | 2 +- cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm | 2 +- .../llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy | 2 +- .../llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump | 2 +- .../llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata | 2 +- cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip | 2 +- cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/clang | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip | 2 +- cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/clang | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip | 4 ++-- cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper | 4 ++-- 53 files changed, 73 insertions(+), 73 deletions(-) diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper b/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper index e6ebae7..41b9e87 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/aarch64-darwin-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm/bin +toolchain_bindir=external/aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/clang b/cc/toolchains/llvm20/aarch64-linux/wrappers/clang index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/clang +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/clang @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp b/cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/clang-cpp @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld b/cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/ld.lld @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-ar @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-cov @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-nm @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objcopy @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-objdump @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-profdata @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/llvm-strip @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper b/cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper index cd1ef78..a93edd7 100755 --- a/cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper +++ b/cc/toolchains/llvm20/aarch64-linux/wrappers/wrapper @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/aarch64-linux-llvm/bin +toolchain_bindir=external/aarch64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/clang-cpp @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/ld.lld @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-ar @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-cov @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-nm @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objcopy @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-objdump @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-profdata @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/llvm-strip @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper index 1465808..c3f8eee 100755 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/wrappers/wrapper @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang b/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp b/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/clang-cpp @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld b/cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/ld.lld @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-ar @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-cov @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-nm @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objcopy @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-objdump @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-profdata @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/llvm-strip @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper b/cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper index e8a60c3..4859e21 100755 --- a/cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper +++ b/cc/toolchains/llvm20/x86_64-darwin/wrappers/wrapper @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then fi tool_name=$(basename "${BASH_SOURCE[0]}") -toolchain_bindir=external/x86_64-darwin-llvm/bin +toolchain_bindir=external/x86_64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld b/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper b/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper index 0d01e26..615febb 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper @@ -36,8 +36,8 @@ fi tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file -toolchain_bindir=external/x86_64-linux-llvm/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm/bin +toolchain_bindir=external/x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. From bdffc5b9524ed0b89bba5f7706d55ed002f80e1f Mon Sep 17 00:00:00 2001 From: martin4861 Date: Fri, 4 Jul 2025 13:39:29 +0200 Subject: [PATCH 3/5] Remove unused file --- cc/toolchains/llvm20/llvm.patch | 49 --------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 cc/toolchains/llvm20/llvm.patch diff --git a/cc/toolchains/llvm20/llvm.patch b/cc/toolchains/llvm20/llvm.patch deleted file mode 100644 index 2406faf..0000000 --- a/cc/toolchains/llvm20/llvm.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/include/c++/v1/__config b/include/c++/v1/__config -index 458d0c1..cd0c6f5 100644 ---- a/include/c++/v1/__config -+++ b/include/c++/v1/__config -@@ -1341,6 +1341,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( - - #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) - #define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS -+#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION - #define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS - #define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS - #define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR -diff --git a/include/c++/v1/__memory/allocator.h b/include/c++/v1/__memory/allocator.h -index 708bd82..912924a 100644 ---- a/include/c++/v1/__memory/allocator.h -+++ b/include/c++/v1/__memory/allocator.h -@@ -26,27 +26,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD - - template class allocator; - --#if _LIBCPP_STD_VER <= 17 -+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION) - template <> - class _LIBCPP_TEMPLATE_VIS allocator - { -+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) - public: - _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type; - - template struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; -+#endif - }; - - template <> - class _LIBCPP_TEMPLATE_VIS allocator - { -+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) - public: - _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; - _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type; - - template struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; -+#endif - }; - #endif - From 3b1211b3d567e7eed61f2573271bf4597d8fea66 Mon Sep 17 00:00:00 2001 From: martin4861 Date: Fri, 4 Jul 2025 14:05:35 +0200 Subject: [PATCH 4/5] Fix paths --- cc/toolchains/llvm20/aarch64-darwin/wrappers/clang | 2 +- cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp | 2 +- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov | 2 +- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm | 2 +- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy | 2 +- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump | 2 +- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata | 2 +- cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip | 2 +- cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/clang | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip | 2 +- cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/clang-cpp @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-cov @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-nm @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objcopy @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-objdump @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-profdata @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/llvm-strip @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper b/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper index 41b9e87..e19e365 100755 --- a/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper +++ b/cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/aarch64-darwin-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~aarch64-darwin-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~aarch64-darwin-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/clang-cpp @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld b/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/ld.lld @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-ar @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-cov @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-nm @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objcopy @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-objdump @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-profdata @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/llvm-strip @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. diff --git a/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper b/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper index 615febb..b37acbc 100755 --- a/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper +++ b/cc/toolchains/llvm20/x86_64-linux/wrappers/wrapper @@ -37,7 +37,7 @@ tool_name=$(basename "${BASH_SOURCE[0]}") # In case the tool label is changed, a change in here is very likely needed # This establishes backwards compatibility with the old WORKSPACE file toolchain_bindir=external/x86_64-linux-llvm20/bin -toolchain_bindir_as_bzlmod=external/rules_swiftnav\~\~swift_cc_toolchain_extension\~x86_64-linux-llvm20/bin +toolchain_bindir_as_bzlmod=external/rules_swiftnav~~swift_cc_toolchain_extension~x86_64-linux-llvm20/bin if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then # We're running under _execroot_, call the real tool. From edc794d1643ecf4fcd90bfe90404a6241b1c49bb Mon Sep 17 00:00:00 2001 From: martin4861 Date: Mon, 7 Jul 2025 15:32:49 +0200 Subject: [PATCH 5/5] more fixes --- cc/repositories.bzl | 6 ++-- .../llvm20/x86_64-aarch64-linux/BUILD.bazel | 29 ++----------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/cc/repositories.bzl b/cc/repositories.bzl index 75d5dd4..ef6ff6e 100644 --- a/cc/repositories.bzl +++ b/cc/repositories.bzl @@ -111,7 +111,7 @@ def swift_cc_toolchain_llvm20(): build_file = Label("@rules_swiftnav//cc/toolchains/llvm20:llvm.BUILD.bzl"), url = X86_64_DARWIN_LLVM20, strip_prefix = "LLVM-20.1.7-macOS-X64", - # TODO: Add sha256 hash for integrity + sha256 = "8494c98a774051a40bfe1187a2d6442f4bc107598998bbe1673d9bb1572cfd6f" ) maybe( @@ -120,7 +120,7 @@ def swift_cc_toolchain_llvm20(): build_file = Label("@rules_swiftnav//cc/toolchains/llvm20:llvm.BUILD.bzl"), url = AARCH64_LINUX_LLVM20, strip_prefix = "LLVM-20.1.7-Linux-ARM64", - # TODO: Add sha256 hash for integrity + sha256 = "832f2802a29457dc758f56e26e98558c6cd0e45fcd07186f540cb6e7f4e59385", ) maybe( @@ -129,7 +129,7 @@ def swift_cc_toolchain_llvm20(): build_file = Label("@rules_swiftnav//cc/toolchains/llvm20:llvm.BUILD.bzl"), url = X86_64_LINUX_LLVM20, strip_prefix = "LLVM-20.1.7-Linux-X64", - # TODO: Add sha256 hash for integrity + sha256 = "8494c98a774051a40bfe1187a2d6442f4bc107598998bbe1673d9bb1572cfd6f", ) def aarch64_sysroot(): diff --git a/cc/toolchains/llvm20/x86_64-aarch64-linux/BUILD.bazel b/cc/toolchains/llvm20/x86_64-aarch64-linux/BUILD.bazel index 2218380..1bb4ffc 100644 --- a/cc/toolchains/llvm20/x86_64-aarch64-linux/BUILD.bazel +++ b/cc/toolchains/llvm20/x86_64-aarch64-linux/BUILD.bazel @@ -106,13 +106,8 @@ cc_toolchain_config( cxx_builtin_include_directories = [ "%sysroot%/usr/include", ], - extra_copts = select({ - "@rules_swiftnav//cc/constraints:graviton2": ["-mcpu=neoverse-n1"], - "@rules_swiftnav//cc/constraints:graviton3": ["-mcpu=neoverse-512tvb"], - "//conditions:default": [], - }), host_system_name = X86_64_LINUX, - target_cpu = "k8", + target_cpu = "aarch64", target_libc = "glibc_unknown", target_system_name = AARCH64_LINUX, tool_paths = { @@ -146,7 +141,7 @@ cc_toolchain( ) toolchain( - name = "cc-toolchain-aarch64-bullseye-graviton2", + name = "cc-toolchain-aarch64-linux", exec_compatible_with = [ "@platforms//cpu:x86_64", "@platforms//os:linux", @@ -154,26 +149,6 @@ toolchain( target_compatible_with = [ "@platforms//os:linux", "@platforms//cpu:aarch64", - "@rules_swiftnav//cc/constraints:glibc_2_31", - "@rules_swiftnav//cc/constraints:graviton2", - "@rules_swiftnav//cc/constraints:llvm20_toolchain", - ], - target_settings = None, - toolchain = ":cc-clang-x86_64-aarch64-linux", - toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", -) - -toolchain( - name = "cc-toolchain-aarch64-bullseye-graviton3", - exec_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_compatible_with = [ - "@platforms//os:linux", - "@platforms//cpu:aarch64", - "@rules_swiftnav//cc/constraints:glibc_2_31", - "@rules_swiftnav//cc/constraints:graviton3", "@rules_swiftnav//cc/constraints:llvm20_toolchain", ], target_settings = None,