From 5578bdf156d480316bc144343f9287dd9aae2858 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 10 Jun 2026 16:29:17 -0700 Subject: [PATCH] Remove macOS support from default toolchain Since this toolchain moved out of bazel, and bazel directly depends on apple_support, there's no reason to have a separate toolchain supporting the same platform. On top of that the macOS support in this toolchain isn't fully hermetic, and would require a lot of copy pasting from the apple_support toolchain to get there, for seemingly no benefit. --- .../toolchain/generate_system_module_map.sh | 17 +- cc/private/toolchain/osx_cc_wrapper.sh.tpl | 163 ------ cc/private/toolchain/unix_cc_configure.bzl | 50 +- .../toolchain/unix_cc_toolchain_config.bzl | 508 ++++++------------ 4 files changed, 183 insertions(+), 555 deletions(-) delete mode 100644 cc/private/toolchain/osx_cc_wrapper.sh.tpl diff --git a/cc/private/toolchain/generate_system_module_map.sh b/cc/private/toolchain/generate_system_module_map.sh index 6bcbd8564..c980cdd62 100755 --- a/cc/private/toolchain/generate_system_module_map.sh +++ b/cc/private/toolchain/generate_system_module_map.sh @@ -17,19 +17,10 @@ set -eu echo 'module "crosstool" [system] {' -if [[ "$OSTYPE" == darwin* ]]; then - for dir in $@; do - find "$dir" -type f \( -name "*.h" -o -name "*.def" -o -path "*/c++/*" \) \ - | LANG=C sort -u | while read -r header; do - echo " textual header \"${header}\"" - done +for dir in $@; do + find -L "${dir}" -type f 2>/dev/null | LANG=C sort -u | while read -r header; do + echo " textual header \"${header}\"" done -else - for dir in $@; do - find -L "${dir}" -type f 2>/dev/null | LANG=C sort -u | while read -r header; do - echo " textual header \"${header}\"" - done - done -fi +done echo "}" diff --git a/cc/private/toolchain/osx_cc_wrapper.sh.tpl b/cc/private/toolchain/osx_cc_wrapper.sh.tpl deleted file mode 100644 index 62f5ff68d..000000000 --- a/cc/private/toolchain/osx_cc_wrapper.sh.tpl +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/sh -# -# Copyright 2015 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# OS X relpath is not really working. This is a wrapper script around gcc -# to simulate relpath behavior. -# -# This wrapper uses install_name_tool to replace all paths in the binary -# (bazel-out/.../path/to/original/library.so) by the paths relative to -# the binary. It parses the command line to behave as rpath is supposed -# to work. -# -# See https://blogs.oracle.com/dipol/entry/dynamic_libraries_rpath_and_mac -# on how to set those paths for Mach-O binaries. -# -set -eu - -LIBS= -LIB_PATHS= -LIB_DIRS= -RPATHS= -OUTPUT= - -XCRUN=/usr/bin/xcrun -[ -x "$XCRUN" ] || XCRUN="xcrun" - -DIRNAME=/usr/bin/dirname -[ -x "$DIRNAME" ] || DIRNAME="dirname" - -BASENAME=/usr/bin/basename -[ -x "$BASENAME" ] || BASENAME="basename" - -READLINK=/usr/bin/readlink -[ -x "$READLINK" ] || READLINK="readlink" - -SED=/usr/bin/sed -[ -x "$SED" ] || SED="sed" - -parse_option() { - opt=$1 - if [ "$OUTPUT" = "1" ]; then - OUTPUT=$opt - elif [ "${opt#-l}" != "$opt" ]; then - LIBS="${opt#-l} $LIBS" - elif [ "${opt%.so}" != "$opt" ]; then - LIB_PATHS="$opt $LIB_PATHS" - elif [ "${opt%.dylib}" != "$opt" ]; then - LIB_PATHS="$opt $LIB_PATHS" - elif [ "${opt#-L}" != "$opt" ]; then - LIB_DIRS="${opt#-L} $LIB_DIRS" - elif [ "${opt#@loader_path/}" != "$opt" ]; then - RPATHS="${opt#@loader_path/} $RPATHS" - elif [ "$opt" = "-o" ]; then - # output is coming - OUTPUT=1 - fi -} - -# let parse the option list -for i in "$@"; do - case $i in - @*) - file=${i#@} - if [ -r "$file" ]; then - while IFS= read -r opt; do - parse_option "$opt" - done < "$file" || exit 1 - fi - ;; - *) - parse_option "$i" - ;; - esac -done - -# Set-up the environment -%{env} - -# Call the C++ compiler -%{cc} "$@" - -# Generate an empty file if header processing succeeded. -case $OUTPUT in - *.h.processed) - : > "$OUTPUT" - ;; -esac - -get_library_path() { - lib=$1 - for libdir in $LIB_DIRS; do - if [ -f "$libdir/lib$lib.so" ]; then - echo "$libdir/lib$lib.so" - return - elif [ -f "$libdir/lib$lib.dylib" ]; then - echo "$libdir/lib$lib.dylib" - return - fi - done -} - -# A convenient method to return the actual path even for non symlinks -# and multi-level symlinks. -get_realpath() { - previous=$1 - next=$($READLINK "$previous" 2>/dev/null || true) - while [ -n "$next" ]; do - previous=$next - next=$($READLINK "$previous" 2>/dev/null || true) - done - echo "$previous" -} - -# Get the path of a lib inside a tool -get_otool_path() { - # the lib path is the path of the original lib relative to the workspace - get_realpath "$1" | $SED 's|^.*/bazel-out/|bazel-out/|' -} - -call_install_name() { - $XCRUN install_name_tool -change "$(get_otool_path "$1")" \ - "@loader_path/$2/$3" "$OUTPUT" -} - -# Do replacements in the output -for rpath in $RPATHS; do - for lib in $LIBS; do - libname= - if [ -f "$($DIRNAME "$OUTPUT")/$rpath/lib$lib.so" ]; then - libname="lib$lib.so" - elif [ -f "$($DIRNAME "$OUTPUT")/$rpath/lib$lib.dylib" ]; then - libname="lib$lib.dylib" - fi - # ${libname-} --> return $libname if defined, or undefined otherwise. This is to make - # this set -e friendly - if [ -n "$libname" ]; then - libpath=$(get_library_path "$lib") - if [ -n "$libpath" ]; then - call_install_name "$libpath" "$rpath" "$libname" - fi - fi - done - for libpath in $LIB_PATHS; do - if [ -f "$libpath" ]; then - libname=$($BASENAME "$libpath") - if [ -f "$($DIRNAME "$OUTPUT")/$rpath/$libname" ]; then - call_install_name "$libpath" "$rpath" "$libname" - fi - fi - done -done diff --git a/cc/private/toolchain/unix_cc_configure.bzl b/cc/private/toolchain/unix_cc_configure.bzl index b85a2e8a6..9f2cf21ed 100644 --- a/cc/private/toolchain/unix_cc_configure.bzl +++ b/cc/private/toolchain/unix_cc_configure.bzl @@ -163,9 +163,6 @@ def _is_linker_option_supported(repository_ctx, cc, force_linker_flags, option, ]) return result.stderr.find(pattern) == -1 -def _is_oso_prefix_supported(repository_ctx, ld): - return repository_ctx.execute([ld, "-v", "-oso_prefix", "."]).return_code == 0 - def _find_linker_path(repository_ctx, cc, linker, is_clang): """Checks if a given linker is supported by the C compiler. @@ -255,14 +252,14 @@ def get_env(repository_ctx): else: return "" -def _coverage_flags(repository_ctx, darwin): +def _coverage_flags(repository_ctx): use_llvm_cov = "1" == get_env_var( repository_ctx, "BAZEL_USE_LLVM_NATIVE_COVERAGE", default = "0", enable_warning = False, ) - if darwin or use_llvm_cov: + if use_llvm_cov: compile_flags = '"-fprofile-instr-generate", "-fcoverage-mapping"' link_flags = '"-fprofile-instr-generate"' else: @@ -353,7 +350,6 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): ) repository_ctx.file("tools/cpp/empty.cc", "int main() {}") - darwin = cpu_value.startswith("darwin") bsd = cpu_value == "freebsd" or cpu_value == "openbsd" cc = _find_generic(repository_ctx, "gcc", "CC", overridden_tools) @@ -392,25 +388,11 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): warn = True, silent = True, ) - if darwin: - overridden_tools["gcc"] = "cc_wrapper.sh" - overridden_tools["ar"] = _find_generic(repository_ctx, "libtool", "LIBTOOL", overridden_tools) - xcrun = repository_ctx.which("xcrun") - if xcrun: - for tool_name in ["llvm-cov", "llvm-profdata"]: - if overridden_tools.get(tool_name) == None: - xcrun_result = repository_ctx.execute([xcrun, "--find", tool_name]) - if xcrun_result.return_code == 0: - overridden_tools[tool_name] = xcrun_result.stdout.strip() auto_configure_warning_maybe(repository_ctx, "CC used: " + str(cc)) tool_paths = _get_tool_paths(repository_ctx, overridden_tools) tool_paths["cpp-module-deps-scanner"] = "deps_scanner_wrapper.sh" - toolchain_features = [] - if darwin and _is_oso_prefix_supported(repository_ctx, tool_paths["ld"]): - toolchain_features.append("macos_reproducible") - # The parse_header tool needs to be a wrapper around the compiler as it has # to touch the output file. tool_paths["parse_headers"] = "cc_wrapper.sh" @@ -427,19 +409,15 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): paths["@rules_cc//cc/private/toolchain:validate_static_library.sh.tpl"], { "%{c++filt}": escape_string(str(repository_ctx.path(tool_paths["c++filt"]))), - # Certain weak symbols are otherwise listed with type T in the output of nm on macOS. - "%{nm_extra_args}": "--no-weak" if darwin else "", + "%{nm_extra_args}": "", "%{nm}": escape_string(str(repository_ctx.path(tool_paths["nm"]))), }, ) tool_paths["validate_static_library"] = "validate_static_library.sh" - cc_wrapper_src = ( - "@rules_cc//cc/private/toolchain:osx_cc_wrapper.sh.tpl" if darwin else "@rules_cc//cc/private/toolchain:linux_cc_wrapper.sh.tpl" - ) repository_ctx.template( "cc_wrapper.sh", - paths[cc_wrapper_src], + paths["@rules_cc//cc/private/toolchain:linux_cc_wrapper.sh.tpl"], { "%{cc}": escape_string(str(cc)), "%{env}": escape_string(get_env(repository_ctx)), @@ -503,10 +481,9 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): if gold_or_lld_linker_path: force_linker_flags.append("-fuse-ld=" + gold_or_lld_linker_path) - # TODO: It's unclear why these flags aren't added on macOS. - if bin_search_flags and not darwin: + if bin_search_flags: force_linker_flags.extend(bin_search_flags) - use_libcpp = darwin or bsd + use_libcpp = bsd is_as_needed_supported = _is_linker_option_supported( repository_ctx, cc, @@ -551,7 +528,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): bazel_linklibs, False, ), ":") - coverage_compile_flags, coverage_link_flags = _coverage_flags(repository_ctx, darwin) + coverage_compile_flags, coverage_link_flags = _coverage_flags(repository_ctx) print_resource_dir_supported = _is_compiler_option_supported( repository_ctx, cc, @@ -588,10 +565,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): cc, "-xc++", cxx_opts + no_canonical_prefixes_opt + ["-stdlib=libc++"], - ) + - # Always included in case the user has Xcode + the CLT installed, both - # paths can be used interchangeably - (["/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"] if darwin else []), + ), ) generate_modulemap = is_clang @@ -697,8 +671,6 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): "-z", ) + ( [ - "-headerpad_max_install_names", - ] if darwin else [ # Gold linker only? Can we enable this by default? # "-Wl,--warn-execstack", # "-Wl,--detect-odr-violations" @@ -739,7 +711,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): ], ), "%{opt_link_flags}": get_starlark_list( - ["-Wl,-dead_strip"] if darwin else _add_linker_option_if_supported( + _add_linker_option_if_supported( repository_ctx, cc, force_linker_flags, @@ -754,14 +726,14 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overridden_tools): "-Wl,--start-lib", "--start-lib", ) else "False", - "%{toolchain_features}": get_starlark_list(toolchain_features), + "%{toolchain_features}": get_starlark_list([]), "%{target_cpu}": escape_string(get_env_var( repository_ctx, "BAZEL_TARGET_CPU", cpu_value, False, )), - "%{target_libc}": "macosx" if darwin else escape_string(get_env_var( + "%{target_libc}": escape_string(get_env_var( repository_ctx, "BAZEL_TARGET_LIBC", "local", diff --git a/cc/private/toolchain/unix_cc_toolchain_config.bzl b/cc/private/toolchain/unix_cc_toolchain_config.bzl index 6a5643175..301a3651d 100644 --- a/cc/private/toolchain/unix_cc_toolchain_config.bzl +++ b/cc/private/toolchain/unix_cc_toolchain_config.bzl @@ -34,12 +34,7 @@ load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_cc//cc/toolchains:cc_toolchain_config_info.bzl", "CcToolchainConfigInfo") load("@rules_cc//cc/toolchains:feature_injection.bzl", "FeatureInfo", "convert_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, extra_flags_per_feature, is_macos): +def layering_check_features(compiler, extra_flags_per_feature): if compiler != "clang": return [] return [ @@ -56,10 +51,8 @@ def layering_check_features(compiler, extra_flags_per_feature, is_macos): ], flag_groups = [ flag_group( - # macOS requires -Xclang because of a bug in Apple Clang - flags = (["-Xclang"] if is_macos else []) + [ + flags = [ "-fmodule-name=%{module_name}", - ] + (["-Xclang"] if is_macos else []) + [ "-fmodule-map-file=%{module_map_file}", ] + extra_flags_per_feature.get("use_module_maps", []), ), @@ -91,7 +84,7 @@ def layering_check_features(compiler, extra_flags_per_feature, is_macos): ]), flag_group( iterate_over = "dependent_module_map_files", - flags = (["-Xclang"] if is_macos else []) + [ + flags = [ "-fmodule-map-file=%{dependent_module_map_files}", ], ), @@ -237,7 +230,6 @@ def _sanitizer_feature(name = "", specific_compile_flags = [], specific_link_fla ) def _impl(ctx): - is_linux = ctx.attr.target_libc != "macosx" profile_correction_flags = get_profile_correction_flags(ctx) tool_paths = [ @@ -485,18 +477,6 @@ def _impl(ctx): with_features = [with_feature_set(features = ["opt"])], ), ], - env_sets = [ - env_set( - actions = all_link_actions + lto_index_actions + [ACTION_NAMES.cpp_link_static_library], - env_entries = ([ - env_entry( - # Required for hermetic links on macOS - key = "ZERO_AR_DATE", - value = "1", - ), - ]), - ), - ], ) fastbuild_feature = feature(name = "fastbuild") @@ -826,134 +806,88 @@ def _impl(ctx): provides = ["profile"], ) - if is_linux: - 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"], - ), - ], - ), - ], - ) - set_install_name_feature = feature( - name = "set_soname", - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, - ], - flag_groups = [ - flag_group( - flags = [ - "-Wl,-soname,%{runtime_solib_name}", - ], - expand_if_available = "runtime_solib_name", - ), - ], - ), - ], - ) - else: - 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", - "@loader_path/%{runtime_library_search_directories}", - ], - ), - ], - expand_if_available = "runtime_library_search_directories", - ), - ], - ), - ], - ) - set_install_name_feature = feature( - name = "set_install_name", - enabled = getattr(ctx.fragments.cpp, "do_not_use_macos_set_install_name", True), - flag_sets = [ - flag_set( - actions = [ - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, - ], - flag_groups = [ - flag_group( - flags = [ - "-Wl,-install_name,@rpath/%{runtime_solib_name}", - ], - expand_if_available = "runtime_solib_name", - ), - ], - ), - ], - ) + 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"], + ), + ], + ), + ], + ) + set_install_name_feature = feature( + name = "set_soname", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = [ + "-Wl,-soname,%{runtime_solib_name}", + ], + expand_if_available = "runtime_solib_name", + ), + ], + ), + ], + ) fission_support_feature = feature( name = "fission_support", @@ -1377,7 +1311,7 @@ def _impl(ctx): libtool_feature = feature( name = "libtool", - enabled = not is_linux, + enabled = False, ) archiver_flags_feature = feature( @@ -1388,7 +1322,7 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "rcsD" if is_linux else "rcs", + "rcsD", "%{output_execpath}", ], expand_if_available = "output_execpath", @@ -1574,7 +1508,7 @@ def _impl(ctx): flag_groups = [ flag_group( flags = [ - "-Wl,-Map=%{output_execpath}.map" if is_linux else "-Wl,-map,%{output_execpath}.map", + "-Wl,-Map=%{output_execpath}.map", ], expand_if_available = "output_execpath", ), @@ -1707,7 +1641,7 @@ def _impl(ctx): flag_set( actions = all_link_actions, flag_groups = [flag_group( - flags = ["-Wl,-fatal-warnings"] if is_linux else ["-Wl,-fatal_warnings"], + flags = ["-Wl,-fatal-warnings"], )], ), ], @@ -1760,51 +1694,6 @@ def _impl(ctx): ], ) - # If you have Xcode + the CLT installed the version defaults can be - # too old for some standard C apis such as thread locals - 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 = ["-mmacosx-version-min={}".format(_target_os_version(ctx))])], - ), - ], - ) - - macos_reproducible_feature = feature( - name = "macos_reproducible", - enabled = "macos_reproducible" in ctx.features, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = [flag_group(flags = ["-ffile-compilation-dir=."])], - ), - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = ["-Wl,-oso_prefix,."])], - ), - ], - ) - - # Kept for backwards compatibility with the crosstool that moved. Without - # linking the objc runtime binaries don't link CoreFoundation for free, - # which breaks abseil. - macos_default_link_flags_feature = feature( - name = "macos_default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions, - flag_groups = [flag_group(flags = [ - "-no-canonical-prefixes", - "-fobjc-link-runtime", - ])], - ), - ], - ) - # Tell bazel we support C++ modules now cpp_modules_feature = feature( name = "cpp_modules", @@ -1860,141 +1749,84 @@ def _impl(ctx): skip_virtual_includes_feature = feature(name = "skip_virtual_includes") - # TODO(#8303): Mac crosstool should also declare every feature. - if is_linux: - # Linux artifact name patterns are the default. - artifact_name_patterns = [ - artifact_name_pattern( - category_name = "cpp_module", - prefix = "", - extension = ".pcm", - ), - ] - features = [ - cpp_modules_feature, - cpp_module_modmap_file_feature, - cpp20_module_compile_flags_feature, - 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, - no_use_lto_indexing_bitcode_file_feature, - use_lto_native_object_directory_feature, - thinlto_feature, - fdo_prefetch_hints_feature, - autofdo_feature, - build_interface_libraries_feature, - dynamic_library_linker_tool_feature, - generate_linkmap_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, - prefer_pic_for_opt_binaries_feature, - asan_feature, - lsan_feature, - tsan_feature, - ubsan_feature, - gcc_quoting_for_param_files_feature, - static_link_cpp_runtimes_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, - fastbuild_feature, - dbg_feature, - opt_feature, - user_compile_flags_feature, - sysroot_feature, - compiler_input_flags_feature, - compiler_output_flags_feature, - unfiltered_compile_flags_feature, - treat_warnings_as_errors_feature, - archive_param_file_feature, - set_install_name_feature, - no_dotd_file_feature, - skip_virtual_includes_feature, - ] + layering_check_features(ctx.attr.compiler, ctx.attr.extra_flags_per_feature, is_macos = False) - 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 = [ - cpp_modules_feature, - cpp_module_modmap_file_feature, - cpp20_module_compile_flags_feature, - macos_minimum_os_feature, - macos_reproducible_feature, - macos_default_link_flags_feature, - dependency_file_feature, - runtime_library_search_directories_feature, - set_install_name_feature, - libtool_feature, - archiver_flags_feature, - asan_feature, - lsan_feature, - tsan_feature, - ubsan_feature, - gcc_quoting_for_param_files_feature, - static_link_cpp_runtimes_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, - includes_feature, - include_paths_feature, - external_include_paths_feature, - fdo_optimize_feature, - dbg_feature, - opt_feature, - user_compile_flags_feature, - sysroot_feature, - compiler_input_flags_feature, - compiler_output_flags_feature, - unfiltered_compile_flags_feature, - treat_warnings_as_errors_feature, - archive_param_file_feature, - generate_linkmap_feature, - no_dotd_file_feature, - skip_virtual_includes_feature, - ] + layering_check_features(ctx.attr.compiler, ctx.attr.extra_flags_per_feature, is_macos = True) + # Linux artifact name patterns are the default. + artifact_name_patterns = [ + artifact_name_pattern( + category_name = "cpp_module", + prefix = "", + extension = ".pcm", + ), + ] + features = [ + cpp_modules_feature, + cpp_module_modmap_file_feature, + cpp20_module_compile_flags_feature, + 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, + no_use_lto_indexing_bitcode_file_feature, + use_lto_native_object_directory_feature, + thinlto_feature, + fdo_prefetch_hints_feature, + autofdo_feature, + build_interface_libraries_feature, + dynamic_library_linker_tool_feature, + generate_linkmap_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, + prefer_pic_for_opt_binaries_feature, + asan_feature, + lsan_feature, + tsan_feature, + ubsan_feature, + gcc_quoting_for_param_files_feature, + static_link_cpp_runtimes_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, + fastbuild_feature, + dbg_feature, + opt_feature, + user_compile_flags_feature, + sysroot_feature, + compiler_input_flags_feature, + compiler_output_flags_feature, + unfiltered_compile_flags_feature, + treat_warnings_as_errors_feature, + archive_param_file_feature, + set_install_name_feature, + no_dotd_file_feature, + skip_virtual_includes_feature, + ] + layering_check_features(ctx.attr.compiler, ctx.attr.extra_flags_per_feature) parse_headers_action_configs, parse_headers_features = parse_headers_support( parse_headers_tool_path = ctx.attr.tool_paths.get("parse_headers"), @@ -2074,11 +1906,7 @@ This is only offered as a migration bridge for projects transitioning to rule-ba "tool_paths": attr.string_dict(), "toolchain_identifier": attr.string(mandatory = True), "unfiltered_compile_flags": attr.string_list(), - "_xcode_config": attr.label(default = configuration_field( - fragment = "apple", - name = "xcode_config_label", - )), }, - fragments = ["apple", "cpp"], + fragments = ["cpp"], provides = [CcToolchainConfigInfo], )