You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a raw_allowlist_include_directories cc_toolchain top argument
Copybara Import from #450
BEGIN_PUBLIC
Add a raw_allowlist_include_directories cc_toolchain top argument (#450)
Apple toolchain declaration in bazel are inherently non-hermetic from a bazel perspective, as they rely on the system's Xcode installation. As a result, apple_support currently make use of
cxx_builtin_include_directories to add known system directories, as seen in the toolchain declaration here:
https://github.com/bazelbuild/apple_support/blob/master/crosstool/osx_cc_configure.bzl#L136
This currently cannot be done in rules based toolchain, as the allowlist_include_directories argument in cc_args() requires a DirectoryInfo provider.
In this change, we're adding a new top-level
raw_allowlist_include_directories parameter to the cc_toolchain() macro and to the underlying cc_toolchain_config() rule. This parameter will act just like the existing one, but will accept raw strings that will be added directly to cxx_builtin_include_directories.
Fixes#242Closes#450
END_PUBLIC
COPYBARA_INTEGRATE_REVIEW=#450 from ma-oli:raw_allowlist_include_directories d4076e4
PiperOrigin-RevId: 794358089
Change-Id: I92e622b549fb38fd1f798efaeb119afcefc4ccb7
Copy file name to clipboardExpand all lines: cc/toolchains/cc_toolchain_info.bzl
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,7 @@ ArgsInfo = provider(
108
108
"files": "(depset[File]) Files required for the args",
109
109
"env": "(dict[str, str]) Environment variables to apply",
110
110
"allowlist_include_directories": "(depset[DirectoryInfo]) Include directories implied by these arguments that should be allowlisted in Bazel's include checker",
111
+
"allowlist_absolute_include_directories": "(depset[str]) Absolute include directories implied by these arguments that should be allowlisted in Bazel's include checker",
111
112
},
112
113
)
113
114
ArgsListInfo=provider(
@@ -119,6 +120,7 @@ ArgsListInfo = provider(
119
120
"files": "(depset[File]) The files required for all of the arguments",
120
121
"by_action": "(Sequence[struct(action=ActionTypeInfo, args=List[ArgsInfo], files=depset[Files])]) Relevant information about the args keyed by the action type.",
121
122
"allowlist_include_directories": "(depset[DirectoryInfo]) Include directories implied by these arguments that should be allowlisted in Bazel's include checker",
123
+
"allowlist_absolute_include_directories": "(depset[str]) Absolute include directories implied by these arguments that should be allowlisted in Bazel's include checker",
122
124
},
123
125
)
124
126
@@ -137,6 +139,7 @@ FeatureInfo = provider(
137
139
"overridable": "(bool) Whether the feature is an overridable feature.",
138
140
"overrides": "(Optional[FeatureInfo]) The feature that this overrides. Must be a known feature",
139
141
"allowlist_include_directories": "(depset[DirectoryInfo]) Include directories implied by this feature that should be allowlisted in Bazel's include checker",
142
+
"allowlist_absolute_include_directories": "(depset[str]) Absolute include directories implied by these arguments that should be allowlisted in Bazel's include checker",
"make_variables": "Sequence[MakeVariableInfo] Make variable substitutions for this toolchain",
222
225
"files": "(dict[ActionTypeInfo, depset[File]]) Files required for the toolchain, keyed by the action type.",
223
226
"allowlist_include_directories": "(depset[DirectoryInfo]) Built-in include directories implied by this toolchain's args and tools that should be allowlisted in Bazel's include checker",
227
+
"allowlist_absolute_include_directories": "(List[str]) Built-in include directories allowed the sandbox. Use with care",
Action-specific arguments for use with a [`cc_toolchain`](#cc_toolchain).
@@ -659,6 +660,7 @@ For more extensive examples, see the usages here:
659
660
| <aid="cc_args-name"></a>name | (str) The name of the target. | none |
660
661
| <aid="cc_args-actions"></a>actions | (List[Label]) A list of labels of [`cc_action_type`](#cc_action_type) or [`cc_action_type_set`](#cc_action_type_set) rules that dictate which actions these arguments should be applied to. |`None`|
661
662
| <a id="cc_args-allowlist_include_directories"></a>allowlist_include_directories | (List[Label]) A list of include paths that are implied by using this rule. These must point to a skylib [directory](https://github.com/bazelbuild/bazel-skylib/tree/main/docs/directory_doc.md#directory) or [subdirectory](https://github.com/bazelbuild/bazel-skylib/tree/main/docs/directory_subdirectory_doc.md#subdirectory) rule. Some flags (e.g. --sysroot) imply certain include paths are available despite not explicitly specifying a normal include path flag (`-I`, `-isystem`, etc.). Bazel checks that all included headers are properly provided by a dependency or allowlisted through this mechanism.<br><br>As a rule of thumb, only use this if Bazel is complaining about absolute paths in your toolchain and you've ensured that the toolchain is compiling with the `-no-canonical-prefixes` and/or `-fno-canonical-system-headers` arguments.<br><br>This can help work around errors like: `the source file 'main.c' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain)`. | `None` |
663
+
| <aid="cc_args-allowlist_absolute_include_directories"></a>allowlist_absolute_include_directories | (List[str]) Allowlists absolute include directories, preventing Bazel from emitting errors when an #include of local system files in the directory occurs. Be careful when adding directories to this list, as it inherently causes leaks in hermeticity. Prefer to reserve use of this for cases like Xcode, where the conventional expectation is to allowlist well-known system-absolute include paths rather than redistributing the SDK. |`None`|
662
664
| <aid="cc_args-args"></a>args | (List[str]) The command-line arguments that are applied by using this rule. This is mutually exclusive with [nested](#cc_args-nested). |`None`|
663
665
| <aid="cc_args-data"></a>data | (List[Label]) A list of runtime data dependencies that are required for these arguments to work as intended. |`None`|
664
666
| <aid="cc_args-env"></a>env | (Dict[str, str]) Environment variables that should be set when the tool is invoked. |`None`|
0 commit comments