From ad7235fd45f89d7ce3c6ac2bcf7365626934d7b2 Mon Sep 17 00:00:00 2001 From: Martin Kosiba Date: Mon, 20 Apr 2026 14:42:17 +0100 Subject: [PATCH] feat: Add extra_linker_files These are similar to extra_compiler_files, but available in link actions. --- toolchain/internal/configure.bzl | 8 +++++++- toolchain/internal/repo.bzl | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/toolchain/internal/configure.bzl b/toolchain/internal/configure.bzl index e0ad59e8a..be7da7c83 100644 --- a/toolchain/internal/configure.bzl +++ b/toolchain/internal/configure.bzl @@ -179,6 +179,7 @@ def llvm_config_impl(rctx): unfiltered_compile_flags_dict = rctx.attr.unfiltered_compile_flags, llvm_version = llvm_version, extra_compiler_files = rctx.attr.extra_compiler_files, + extra_linker_files = rctx.attr.extra_linker_files, extra_exec_compatible_with = rctx.attr.extra_exec_compatible_with, extra_target_compatible_with = rctx.attr.extra_target_compatible_with, extra_compile_flags_dict = rctx.attr.extra_compile_flags, @@ -488,7 +489,10 @@ filegroup( filegroup( name = "linker-components-{suffix}", - srcs = [":sysroot-components-{suffix}"], + srcs = [ + ":sysroot-components-{suffix}", + {extra_linker_files} + ], ) filegroup( @@ -534,6 +538,7 @@ filegroup( "{llvm_dist_label_prefix}ar", "{llvm_dist_label_prefix}{lib_label}", ":sysroot-components-{suffix}", + {extra_linker_files} ], ) @@ -640,6 +645,7 @@ cc_toolchain( cxx_builtin_include_label = "cxx_builtin_include" if bazel_features.rules.merkle_cache_v2 else "include", lib_label = "lib" if bazel_features.rules.merkle_cache_v2 else "lib_legacy", extra_compiler_files = ("\"%s\"," % str(toolchain_info.extra_compiler_files)) if toolchain_info.extra_compiler_files else "", + extra_linker_files = ("\"%s\"," % str(toolchain_info.extra_linker_files)) if toolchain_info.extra_linker_files else "", major_llvm_version = major_llvm_version, extra_exec_compatible_with_specific = toolchain_info.extra_exec_compatible_with.get(target_pair, []), extra_target_compatible_with_specific = toolchain_info.extra_target_compatible_with.get(target_pair, []), diff --git a/toolchain/internal/repo.bzl b/toolchain/internal/repo.bzl index 4ab592b6b..70f94039b 100644 --- a/toolchain/internal/repo.bzl +++ b/toolchain/internal/repo.bzl @@ -368,6 +368,11 @@ _compiler_configuration_attrs = { "Mostly useful for providing files containing lists of flags, e.g. " + "sanitizer ignorelists."), ), + "extra_linker_files": attr.label( + mandatory = False, + doc = ("Files to be made available in the sandbox for link actions. " + + "Useful for providing files such as linker scripts."), + ), "extra_enabled_features": attr.label_list( mandatory = False, doc = ("Extra `cc_feature` features to add to this toolchain in an initially " +