diff --git a/.github/workflows/release_notes_template.txt b/.github/workflows/release_notes_template.txt index 62f28ef9..e0efd9a2 100644 --- a/.github/workflows/release_notes_template.txt +++ b/.github/workflows/release_notes_template.txt @@ -1,4 +1,4 @@ -Minimum bazel version: **6.0.0** (6.1.0 if using blzmod) +Minimum bazel version: **7.0.0** If you're using `bzlmod`, add the following to `MODULE.bazel`: @@ -53,19 +53,3 @@ load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") llvm_register_toolchains() ``` - -And add the following section to your .bazelrc file: - -```sh -# Not needed after https://github.com/bazelbuild/bazel/issues/7260 is closed -build --incompatible_enable_cc_toolchain_resolution - -# For macOS only: - -# Needed for Bazel versions before 7. -# Without this, one can use `--linkopt='-undefined dynamic_lookup'`. -# This feature is intentionally not supported on macOS. -build --features=-supports_dynamic_linker -# Not needed after https://github.com/bazel-contrib/toolchains_llvm/pull/229. -build --features=-libtool -``` diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index de1c4850..ddab6e2f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,14 +28,8 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest] - bazel_version: [6.0.0, 6.1.0, latest] + bazel_version: [7.0.0, latest] # Minimum supported Bazel version is 7.0.0. bzlmod: [true, false] - # bzlmod needs 6.1.0 (issue unrelated to this project) - exclude: - - bazel_version: 6.0.0 - bzlmod: true - - bazel_version: 6.1.0 - bzlmod: false runs-on: ${{ matrix.os }} steps: - if: startsWith(matrix.os, 'ubuntu') diff --git a/MODULE.bazel b/MODULE.bazel index 4030a220..47b2880b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,6 +16,7 @@ module( name = "toolchains_llvm", version = "0.0.0", compatibility_level = 0, + bazel_compatibility = [">=7.0.0"], ) bazel_dep(name = "bazel_skylib", version = "1.4.2") diff --git a/README.md b/README.md index 77329483..ab7c4451 100644 --- a/README.md +++ b/README.md @@ -98,9 +98,6 @@ For specifying unregistered toolchains on the command line, please use the `--extra_toolchains` flag. For example, `--extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux`. -We no longer support the `--crosstool_top=@llvm_toolchain//:toolchain` flag, -and instead rely on the `--incompatible_enable_cc_toolchain_resolution` flag. - ### Bring Your Own LLVM The following mechanisms are available for using an LLVM toolchain: diff --git a/tests/.bazelrc b/tests/.bazelrc index 5c87221d..e2f73a47 100644 --- a/tests/.bazelrc +++ b/tests/.bazelrc @@ -1,2 +1 @@ -build --incompatible_enable_cc_toolchain_resolution build --features=layering_check diff --git a/tests/scripts/bazel.sh b/tests/scripts/bazel.sh index 6339ea7d..b9639cca 100644 --- a/tests/scripts/bazel.sh +++ b/tests/scripts/bazel.sh @@ -40,27 +40,16 @@ common_args=( "--enable_bzlmod=${USE_BZLMOD:-false}" ) +# shellcheck disable=SC2034 common_test_args=( "${common_args[@]}" "--symlink_prefix=/" - "--incompatible_enable_cc_toolchain_resolution" "--color=yes" "--show_progress_rate_limit=30" "--keep_going" "--test_output=errors" ) -if [[ ${short_uname} == 'Darwin' ]]; then - common_test_args+=( - # Needed for Bazel versions before 7. - # Without this, one can use `--linkopt='-undefined dynamic_lookup'`. - # This feature is intentionally not supported on macOS. - --features=-supports_dynamic_linker - # Not needed after https://github.com/bazel-contrib/toolchains_llvm/pull/229. - --features=-libtool - ) -fi - # Do not run autoconf to configure local CC toolchains. export BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 diff --git a/tests/scripts/run_xcompile_tests.sh b/tests/scripts/run_xcompile_tests.sh index f06477f7..c76dc432 100755 --- a/tests/scripts/run_xcompile_tests.sh +++ b/tests/scripts/run_xcompile_tests.sh @@ -29,13 +29,13 @@ check_with_image() { return fi local image="$1" - docker run --rm --mount "type=bind,source=${binpath},target=/stdlib_test" "${image}" /stdlib_test + docker run --rm -it --platform=linux/amd64 \ + --mount "type=bind,source=${binpath},target=/stdlib_test" "${image}" /stdlib_test } echo "" echo "Testing static linked user libraries and dynamic linked system libraries" build_args=( - --incompatible_enable_cc_toolchain_resolution --platforms=@toolchains_llvm//platforms:linux-x86_64 --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux --symlink_prefix=/ @@ -44,7 +44,7 @@ build_args=( ) "${bazel}" --bazelrc=/dev/null build "${build_args[@]}" //:stdlib_test file "${binpath}" | tee /dev/stderr | grep -q ELF -check_with_image "frolvlad/alpine-glibc" # Need glibc image for system libraries. +check_with_image "gcr.io/distroless/cc-debian11" # Need glibc image for system libraries. echo "" echo "Testing static linked user and system libraries" @@ -53,4 +53,4 @@ build_args+=( ) "${bazel}" --bazelrc=/dev/null build "${build_args[@]}" //:stdlib_test file "${binpath}" | tee /dev/stderr | grep -q ELF -check_with_image "alpine" +check_with_image "gcr.io/distroless/static-debian11" diff --git a/tests/transitions.bzl b/tests/transitions.bzl index 8d3a0196..23db8d31 100644 --- a/tests/transitions.bzl +++ b/tests/transitions.bzl @@ -95,5 +95,4 @@ dwp_file = rule( default = "@bazel_tools//tools/allowlists/function_transition_allowlist", ), }, - incompatible_use_toolchain_transition = True, ) diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl index d58388a2..579e267c 100644 --- a/toolchain/cc_toolchain_config.bzl +++ b/toolchain/cc_toolchain_config.bzl @@ -263,7 +263,7 @@ def cc_toolchain_config( # The tool names come from [here](https://github.com/bazelbuild/bazel/blob/c7e58e6ce0a78fdaff2d716b4864a5ace8917626/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java#L76-L90): # NOTE: Ensure these are listed in toolchain_tools in toolchain/internal/common.bzl. tool_paths = { - "ar": tools_path_prefix + "llvm-ar", + "ar": tools_path_prefix + ("llvm-ar" if (host_os != "darwin" or is_xcompile) else "llvm-libtool-darwin"), "cpp": tools_path_prefix + "clang-cpp", "dwp": tools_path_prefix + "llvm-dwp", "gcc": wrapper_bin_prefix + "cc_wrapper.sh", diff --git a/toolchain/internal/common.bzl b/toolchain/internal/common.bzl index 492df952..8f3503fa 100644 --- a/toolchain/internal/common.bzl +++ b/toolchain/internal/common.bzl @@ -14,7 +14,7 @@ SUPPORTED_TARGETS = [("linux", "x86_64"), ("linux", "aarch64"), ("darwin", "x86_64"), ("darwin", "aarch64")] -toolchain_tools = [ +_toolchain_tools = [ "clang-cpp", "ld.lld", "llvm-ar", @@ -27,6 +27,10 @@ toolchain_tools = [ "llvm-strip", ] +_toolchain_tools_darwin = [ + "llvm-libtool-darwin", +] + def host_os_key(rctx): (os, version, arch) = os_version_arch(rctx) if version == "": @@ -191,6 +195,12 @@ def attr_dict(attr): return dict(tuples) +def toolchain_tools(os): + tools = list(_toolchain_tools) + if os == "darwin": + tools.extend(_toolchain_tools_darwin) + return tools + def _get_host_tool_info(rctx, tool_path, tool_key = None): if tool_key == None: tool_key = tool_path diff --git a/toolchain/internal/configure.bzl b/toolchain/internal/configure.bzl index 3cd385a8..02839af9 100644 --- a/toolchain/internal/configure.bzl +++ b/toolchain/internal/configure.bzl @@ -105,11 +105,12 @@ def llvm_register_toolchains(): # symlinked path from the wrapper. wrapper_bin_prefix = "bin/" tools_path_prefix = "bin/" - for tool_name in _toolchain_tools: + tools = _toolchain_tools(os) + for tool_name in tools: rctx.symlink(llvm_dist_rel_path + "bin/" + tool_name, tools_path_prefix + tool_name) symlinked_tools_str = "".join([ - "\n" + (" " * 8) + "\"" + tools_path_prefix + name + "\"," - for name in _toolchain_tools + "\n" + (" " * 8) + "\"" + tools_path_prefix + tool_name + "\"," + for tool_name in tools ]) else: llvm_dist_rel_path = llvm_dist_path_prefix