Commit Graph

218 Commits

Author SHA1 Message Date
Googler 7c2883f3b1 Implement runtime_library_search_directories as cc_args
BEGIN_PUBLIC

Implement runtime_library_search_directories as cc_args

Implements the runtime_library_search_directories feature as cc_args rules.

END_PUBLIC

PiperOrigin-RevId: 671773775
Change-Id: I703824dee8ceb62ac1597e42cc74de0162952386
2024-09-06 08:49:49 -07:00
Googler 4bf8bb1f7d Implement shared_flag as cc_args
BEGIN_PUBLIC

Implement shared_flag as cc_args

Implements the shared_flag feature as cc_args rules.

END_PUBLIC

PiperOrigin-RevId: 671765792
Change-Id: I0c13873ef2b5c19908cbed13c1b88b5fc957c4cd
2024-09-06 08:25:09 -07:00
Googler 98ab8334e7 Implement force_pic_flags as cc_args
BEGIN_PUBLIC

Implement force_pic_flags as cc_args

Implements the force_pic_flags feature as cc_args rules.

END_PUBLIC

PiperOrigin-RevId: 671764316
Change-Id: I7f04bbf46027007fc47d230d49d3334b1a6ddfac
2024-09-06 08:20:51 -07:00
Googler cf6ccb93f4 Implement linker_param_file as cc_args
BEGIN_PUBLIC

Implement linker_param_file as cc_args

Implements the linker_param_file feature as cc_args rules.

END_PUBLIC

PiperOrigin-RevId: 671762576
Change-Id: Ic6bd3ad3b059599c796680cdb4e2b63f6929b8a9
2024-09-06 08:14:11 -07:00
Googler 9333569bc8 Add support for the `mandatory` param to `find_cc_toolchain` in `@rules_cc`
PiperOrigin-RevId: 671758214
Change-Id: I37d0ca1f9b083513cb5933984153e1ba608313ca
2024-09-06 07:59:59 -07:00
Googler 8b63556334 Fix buildifier finding in rules_cc
BEGIN_PUBLIC

Fix buildifier finding in rules_cc

Fixes an out-of-order dictionary entry identified by the rules_cc Bazel CI.

END_PUBLIC

PiperOrigin-RevId: 671626223
Change-Id: Ib33fa36db879a5cd89cb2d01bb5b671e706de77b
2024-09-05 22:08:07 -07:00
Googler f999a8e23b Implement archiver_flags as cc_args
BEGIN_PUBLIC

Implement archiver_flags as cc_args

This is the first change in a series that will reimplement the legacy
features defined in Bazel's Java code using the new toolchain rules. These implementations are redefined as raw arguments using the new toolchain rules, which allows for the definition shared and reused across different contexts.

This first change implements archiver_flags, which is used to produce the arguments for the archiver tool used by `cc_library`.

This CL also adds a test that compares the feature implementation produced by
the new rules to the feature implementation defined in Bazel's Java
code. This should make it easier to review the final result and ensure it
is functionally equivalent to the Java implementation.

END_PUBLIC

PiperOrigin-RevId: 671403834
Change-Id: I2d4f15b49619a11995a50c86439340ea532e360e
2024-09-05 09:36:58 -07:00
Googler 66613ac5d9 Add support for implicit include directories to rule-based toolchains
BEGIN_PUBLIC

Add support for implicit include directories to rule-based toolchains

Reorients the `cc_toolchain.cxx_builtin_include_directories` attribute so it is expressed as an attribute on `cc_args` and `cc_tool` to signify that the tools or arguments imply include directories that Bazel's include path checker should allowlist. This moves the allowlist to the source of truth that implies these directories.

END_PUBLIC

PiperOrigin-RevId: 671393376
Change-Id: Ide8cae548783726835168adcd3f705028a1f4308
2024-09-05 09:06:15 -07:00
Googler 391170f339 Export a few utility functions from `@builtins` to `rules_cc`
PiperOrigin-RevId: 670979420
Change-Id: I37ce050f747a0dbc5ab0039fd32a84d7be7e1ed4
2024-09-04 08:25:21 -07:00
Googler a778282a15 Fix action label evaluation in cc_sysroot
BEGIN_PUBLIC

Fix action label evaluation in cc_sysroot

Explicitly converts action labels in cc_sysroot to Label objects to address issues where the labels were being evaluated as relative to the module instantiating cc_sysroot rules.

END_PUBLIC

PiperOrigin-RevId: 667520654
Change-Id: Ia64306cc172dfaa747ef28a92390bcd90296b109
2024-08-26 03:09:37 -07:00
Googler 2480c90525 Replace sysroot with a cc_sysroot macro.
BEGIN_PUBLIC
Replace sysroot with a cc_sysroot macro.

This is part of what amontanez@ and I discussed about making C++ toolchains less "magic".
I'd like to do the same for cxx_builtin_include_directories, but that will require significantly more effort.

END_PUBLIC

PiperOrigin-RevId: 666607531
Change-Id: Ic9cfb157e892c05a9c875f240c0ed9a1048dea19
2024-08-22 20:36:02 -07:00
Googler f5eb3c0c4a Integrate cc_tool_map into rule-based toolchains
BEGIN_PUBLIC

Integrate cc_tool_map into rule-based toolchains

Integrates cc_tool_map as a new attribute of cc_toolchain, completely replacing cc_action_type_config.

END_PUBLIC

PiperOrigin-RevId: 666365739
Change-Id: Iac74a31736dad66ac3dc75b4478ab4d4d2412181
2024-08-22 08:46:18 -07:00
Googler 3a62fd3f5b Make enabled_features functionally equivalent to cc_feature(..., enabled=True)
BEGIN_PUBLIC
Make enabled_features functionally equivalent to cc_feature(..., enabled=True)

This should allow you to disable an enabled feature elsewhere in the toolchain.

Fixes #233
END_PUBLIC

PiperOrigin-RevId: 666318466
Change-Id: I0b820cb2033d4ce8b141ff74dcd6516b8157c2b4
2024-08-22 06:06:56 -07:00
Googler 84fceed887 Disallow features from specifying whether they are enabled by default or not.
BEGIN_PUBLIC
Disallow features from specifying whether they are enabled by default or not.

Such a decision shouldn't be made by the feature, but instead by the toolchain author.
END_PUBLIC

PiperOrigin-RevId: 658621275
Change-Id: I4dae8ee1acc349a0ff6f09e6cf68e15fdc481a48
2024-08-01 19:19:51 -07:00
Googler af926372c5 Replace toolchain_features with known_features and enabled_features.
BEGIN_PUBLIC
Replace toolchain_features with known_features and enabled_features.

This should allow for the deprecation of action_type_config, as `implies` there is no longer required.
END_PUBLIC

PiperOrigin-RevId: 658620044
Change-Id: Idda9bd77edad1be1fd26d5a655e3b9084d38bca8
2024-08-01 19:14:33 -07:00
Googler dcf1dc1680 Create a new cc_tool_config rule which will, in the future, replace cc_action_type_config.
PiperOrigin-RevId: 658426046
Change-Id: Ie90cec7049b3bddf7f022d188a0765ffeb1dcf1d
2024-08-01 09:20:43 -07:00
Googler dde7ad4094 Replace execution_requirements with the standardized field "tags".
PiperOrigin-RevId: 657777523
Change-Id: If803f20aebba7126b70bcc9c483b9d03989104bc
2024-07-30 16:57:06 -07:00
Googler f97190f039 Remove feature requirements from tools.
BEGIN_PUBLIC
Remove feature requirements from tools.

It's such a niche use case, adds a fair amount of complexity, and there are multiple alternatives available:
* Now that we're using rule based things, you should just be able to add a bazel flag and select on it in your tool definition.
* If you really want precisely that behaviour, you can make your feature add "--use-foo-tool" to the args, and make your tool a wrapper tool that reads the command-line argument, and if provided, invokes a different tool.
END_PUBLIC

PiperOrigin-RevId: 657383729
Change-Id: Idb4f3ad66dc92d48ef81a1e8875bf6d3ba215aa4
2024-07-29 17:37:10 -07:00
Googler e1c7ebb858 Add support for select'ing on cc_args(args=...).
This CL is an alternative to unknown commit. I left the other CL seperately, because I wasn't 100% sure that we'd agree to this, since this is an API change.
I did it this way because I believe it's much less hacky, and it also allows us to format things that aren't variables.

BEGIN_PUBLIC
Add support for select'ing on cc_args(args=...).

This is quite tricky because the one parameter was being split into two in a macro, one of type label and the other of type string.

For example, `args = ["--foo", format_arg("--bar=%s", "//path/to:bar")]` was rewritten by the macro to `args = [json.encode(struct(format_type="raw", format="foo")), json.encode(struct(format_type="format_arg", format="--bar=%s", value=0))], variables = ["//path/to:bar"]`.
To allow it to work with selects, we need to ensure that we don't perform post-processing on the inside of the select. To solve this, we:
* Ensure that args only take strings
* Provide a seperate parameter for substitutions.

This new mechanism also has the useful property that we can now format things that are not variables. For example, I can do the following:

```
directory(name = "sysroot", ...)
cc_args(
    name = "sysroot_arg",
    args = ["--sysroot={sysroot}"],
    format = {
        ":sysroot": "sysroot"
    }
)
```

END_PUBLIC

PiperOrigin-RevId: 656211278
Change-Id: If83f1ea5a99090c18f2a561c51ec6d39ce9fe419
2024-07-25 20:13:42 -07:00
Googler 0d1b084cfa Update toolchain variable definitions to allow static linking
BEGIN_PUBLIC
Update toolchain variable definitions to allow static linking

Updates the rules-based-toolchain variable definitions to reflect the how the variables are used in Bazel's CppActionConfigs.java Java implementation, particularly with respect to static linking.
END_PUBLIC

PiperOrigin-RevId: 647301605
Change-Id: I7ff87a75f9654d70ea160282ba66e99363c79ce5
2024-06-27 06:55:51 -07:00
Googler 280d3ad603 Allow creation of sentinel features in rule-based toolchains
BEGIN_PUBLIC
Makes the `args` attribute of `cc_feature` optional so that users may declare sentinel features that do not have any inherent arguments.
END_PUBLIC

PiperOrigin-RevId: 646545838
Change-Id: I470a496aec951608f21cc8ea693387c5b551c8a9
2024-06-25 11:23:34 -07:00
Googler 9ff1d1b6fd No public description
PiperOrigin-RevId: 646508523
Change-Id: I7f45474a8c0052e3693aceca6ed2436396f13829
2024-06-25 09:37:32 -07:00
Googler 94d34d7954 Restructure rules_cc
BEGIN_PUBLIC
Restructure rules_cc

Design doc: https://docs.google.com/document/d/1L1JFgjpZ7SrBinb24DC_5nTIELeYDacikcme-YcA7xs/edit
END_PUBLIC

PiperOrigin-RevId: 643879458
Change-Id: Id3fd760fde1c1145cb5044fff9020b61652d2f25
2024-06-16 22:40:48 -07:00
Googler 5e848c1434 Remove the "data" attribute from cc_action_type_config.
BEGIN_PUBLIC
Remove the "data" attribute from cc_action_type_config.

Technically speaking, data shouldn't be associated with action types. Instead, data should be associated with either a tool or a set of flags.

For example, instead of the cc_compile action having the header files as a data dependency, the "include_paths" cc_arg should instead declare `data = <header files>`.

This will allow us to, once we have a fully starlark-ified c++ toolchain, do much finer-grained dependencies. This will allow us to, for example, not provide header files to the action when the user enables the feature "nostdlib".
END_PUBLIC

PiperOrigin-RevId: 642434412
Change-Id: Id16fe05a1c86bbaf4718cd36a15f8a9d6afb0163
2024-06-11 16:44:42 -07:00
Googler ac3f19bac7 Remove support for args from action_type_config.
BEGIN_PUBLIC
Remove support for args from action_type_config.

Args in individual action type configs result in redundant configuration, where both the cc_args and the cc_action_type_config control which actions they're enabled for. Instead of:
```
cc_args(name = "compile_args", action_types = [":c_compile", ":cpp_compile])
cc_action_type_config(name = "c_compile_config", actions = [":c_compile"], args = [":compile_args"])
cc_action_type_config(name = "cpp_compile_config", actions = [":cpp_compile"], args = [":compile_args"])
cc_toolchain(action_type_configs = [":c_compile_config", ":cpp_compile_config"])
```

We should force users to write the following:
```
cc_args(name = "compile_args", action_types = [":c_compile", ":cpp_compile])
cc_action_type_config(name = "c_compile_config", actions = [":c_compile"])
cc_action_type_config(name = "cpp_compile_config", actions = [":cpp_compile"])
cc_toolchain(action_type_configs = [":c_compile_config", ":cpp_compile_config"], args = [":compile_args"])
```
END_PUBLIC

PiperOrigin-RevId: 642432029
Change-Id: I1aa7c1752f4d915d8c84c17a06314ae9ad2c69f0
2024-06-11 16:35:03 -07:00
Googler 1cf35f02db Make output_file accessible from strip.
BEGIN_PUBLIC
Make output_file accessible from strip.

See https://github.com/bazelbuild/bazel/pull/22638
END_PUBLIC

PiperOrigin-RevId: 640622335
Change-Id: I96fdca9494e5043f546b588490d692d67f94ee2b
2024-06-05 13:03:51 -07:00
Googler 531c9951a8 Remove legacy toolchain flags.
BEGIN_PUBLIC
Remove legacy toolchain flags.

This will allow us to enforce that users of the rule based toolchain are not using legacy toolchain resolution, and simplify toolchain creation.
END_PUBLIC

PiperOrigin-RevId: 640017209
Change-Id: I6ea4fad8ddf1a06ad17d706d82e54eb7f05aa6c6
2024-06-03 21:59:53 -07:00
Googler 0069837ab5 Create a cc_directory_tool rule.
BEGIN_PUBLIC
Create a cc_directory_tool rule.

This should allow for easy definition of tools from the sysroot. For example:
cc_directory_tool(
  name = "clang",
  directory = "@sysroot//:sysroot",
  executable = "usr/bin/clang",
)
END_PUBLIC

PiperOrigin-RevId: 639947945
Change-Id: I4c211eb9c0b5fdc6457d9d32ef9250b5384a4ef3
2024-06-03 16:24:27 -07:00
Googler 2351aa42b1 Make toolchains use directory markers instead of strings.
BEGIN_PUBLIC
Make toolchains use directory markers instead of strings.

You now refer to this instead of a string containing the repo mapped path.
END_PUBLIC

PiperOrigin-RevId: 639946886
Change-Id: I409be7b7002252b06562a2982a2568e79811877d
2024-06-03 16:20:34 -07:00
Googler 1acf5213b6 Disable exec_transition_for_inputs in rule-based toolchains
BEGIN_PUBLIC

Doing a transition to the exec platform in rule-based toolchains was causing unusual behaviors when attempting to restrict compatibility. This changes most of the toolchain rules to be evaluated from the target platform configuration, only transitioning to the exec configuration when explicitly requested.

END_PUBLIC

PiperOrigin-RevId: 634411095
Change-Id: I8716b9a517d9f3be306cdf96dafb98a868a3f83b
2024-05-16 08:43:58 -07:00
Googler 71d9e52bdb Do not require deprecated create_cc_toolchain_config_info attrs
BEGIN_PUBLIC

In create_cc_toolchain_config_info, the target_system_name, target_cpu, and target_libc attributes are documented as required and deprecated. In practice, these may safely be `None`. This updates the cc_toolchain rule implementation to no longer require that these attributes are set to arbitrary values.

END_PUBLIC

PiperOrigin-RevId: 633149160
Change-Id: Ief1d3236ead9299b307ce9ace68cd295536a7b3b
2024-05-13 03:16:03 -07:00
Googler f88663dc50 Provide a default toolchain_identifier.
BEGIN_PUBLIC
Provide a default toolchain_identifier.

END_PUBLIC

PiperOrigin-RevId: 626172528
Change-Id: I2d23d79b82f4268b462dac79edc4f69a7f865e00
2024-04-18 15:47:16 -07:00
Googler 6e490f79ee Implement flag_group in the new rule-based toolchain.
BEGIN_PUBLIC
Implement flag_group in the new rule-based toolchain.
END_PUBLIC

PiperOrigin-RevId: 622107179
Change-Id: I9e1971e279f313ce85537c899bcf80860616f8b7
2024-04-05 01:47:45 -07:00
Googler 54677903cf Fix the load broken by a new version of buildifier.
BEGIN_PUBLIC
Fix the load broken by a new version of buildifier.

Apparently the native-cc lint has been split into native-cc and native-cc-proto. This meant that our native.cc_proto_library was getting incorrectly turned into cc_proto_library when copybara invoked buildifier.
END_PUBLIC

PiperOrigin-RevId: 622097522
Change-Id: Idb89a5f9facae20f490ac8f83a5adf2859cd52ab
2024-04-05 00:59:04 -07:00
Googler 1361256a68 Gather variable metadata for the new rule-based toolchain.
BEGIN_PUBLIC
Gather variable metadata for the new rule-based toolchain.
END_PUBLIC

PiperOrigin-RevId: 622000877
Change-Id: I5b2ea6c363fc43fd44e60ffc8fa7ae041545337e
2024-04-04 16:13:02 -07:00
Googler 510c6dc9da Remove out of order load lint warnings.
The copybara configuration has been broken by []

PiperOrigin-RevId: 621998904
Change-Id: I47e6b7b95bc9d8086547ae928065f67ac3f0006a
2024-04-04 16:05:24 -07:00
Googler 4a62c69330 Add additional actions that are not specified in action_names.bzl.
BEGIN_PUBLIC
Add additional actions that are not specified in action_names.bzl.

These are mostly taken from https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionNames.java.

These also include some actions that have explicitly been removed from CppActionNames, because those actions are still in use elsewhere (eg. 9a333bc59e/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java (L974)).
END_PUBLIC

PiperOrigin-RevId: 619420983
Change-Id: I1f5eb1c0e43fb1563db9065ebc46f70bf8d06fc5
2024-03-26 22:50:35 -07:00
Googler 991cdf09a9 Implement provides in rule based toolchain.
BEGIN_PUBLIC
Implement provides in rule based toolchain.
END_PUBLIC

PiperOrigin-RevId: 619082926
Change-Id: I938640981bd10f0e3d41402d211672a45264df1a
2024-03-25 23:44:03 -07:00
Googler 61def7a42c Improve errors in variable definitions by adding labels to the variables.
BEGIN_PUBLIC
Improve errors in variable definitions by adding labels to the variables.
END_PUBLIC

PiperOrigin-RevId: 618984216
Change-Id: I5d6d11ba2b72f426b9f01bcbb528b0914c98c964
2024-03-25 15:53:13 -07:00
Googler 7c0a3bbee1 Refactor action sets for consistency and simplicity
BEGIN_PUBLIC
Refactor action sets for consistency and simplicity

* Remove the "CC" prefix on some of the actions, as we're already within the scope of rules_cc.
* Remove the "all" prefix, since the plural "actions" should already imply this.
* Ensure all action types sets end with "_actions"
* Refactor some action type sets to be constructed from other (eg. link actions = link executables + link dynamic libraries).
* Remove the redundant "all_compile_actions", since it was equivalent to "all_cc_compile_actions"
END_PUBLIC

PiperOrigin-RevId: 617985242
Change-Id: I9a3621a9d613ff604efdc5c86ba52e5c77f06731
2024-03-21 15:45:05 -07:00
Googler 17143d150d Add strictly typed variables toolchain rules.
BEGIN_PUBLIC
Add strictly typed variables to toolchain rules.

This should allow us to implement a proper replacement for flag_group
END_PUBLIC

PiperOrigin-RevId: 617338607
Change-Id: I7f3058578cb5eb17ecc1aa38d2e1459e0742aee9
2024-03-19 17:05:03 -07:00
Googler aa19278bbd Rename ExpandArgs to NestedArgs
After discussion with @amontanez in unknown commit, we decided that NestedArgs was a more appropriate name.

BEGIN_PUBLIC
Rename ExpandArgs to NestedArgs
END_PUBLIC

PiperOrigin-RevId: 617085672
Change-Id: I1d7190cac79f8fa953d23be7d0db3b028a84cf30
2024-03-19 01:09:56 -07:00
Googler bbb0615a87 Refactor AddArgsInfo into ExpandArgsInfo
BEGIN_PUBLIC
Refactor AddArgsInfo into ExpandArgsInfo

This allows us to create a similar mechanism to the current toolchain, while maintaining type safety.
END_PUBLIC

PiperOrigin-RevId: 615939056
Change-Id: I9b6763150194f8a76dfd8da730a3e2d45accbe20
2024-03-14 16:28:07 -07:00
Googler 69c9748afb BEGIN_PUBLIC
Fix problem with the toolchain definition.

A test for this will be added later in the form of an example toolchain.
END_PUBLIC

PiperOrigin-RevId: 615416990
Change-Id: I1f7fd1640e88b446597768b4f75c2154b630074f
2024-03-13 07:56:07 -07:00
Googler 59cf8ff109 Rename additional_files to data.
BEGIN_PUBLIC
Rename additional_files to data.

This is more consistent with other rules.
END_PUBLIC

PiperOrigin-RevId: 615364332
Change-Id: Ic27ec8c8e72d290e72074034f85a34b38401599b
2024-03-13 04:22:40 -07:00
Googler e658433e23 No public description
PiperOrigin-RevId: 613579953
Change-Id: I4aea8af1b3db8eb532c7c9296fc4dfa0c2ff9481
2024-03-07 07:40:02 -08:00
Googler 1ff1af662e Implement the cc_toolchain macro.
BEGIN_PUBLIC
Implement the cc_toolchain macro.

Things should be working at this point. This will be followed up with an example.
END_PUBLIC

PiperOrigin-RevId: 613436885
Change-Id: I1fc4a1e3a71c4f819998b69c73922821322d2991
2024-03-06 20:31:55 -08:00
Googler de4aaa6472 Allow cc_toolchain_info rule to be used as a parameter to pass into native.cc_toolchain(config = ...)
BEGIN_PUBLIC
Allow cc_toolchain_info rule to be used as a parameter to pass into native.cc_toolchain(config = ...)
END_PUBLIC

PiperOrigin-RevId: 613000772
Change-Id: I8348e2cbb4aa7d0a523341dcaf1e2c2bc647f640
2024-03-05 16:04:53 -08:00
Googler 94d4760a89 Implement cc_toolchain_config rule and cc_legacy_file_group rule.
BEGIN_PUBLIC
Implement cc_toolchain_config rule and cc_legacy_file_group rule.

Note that this rule is in the impl/ directory because we require users to use the cc_toolchain_config rule via the cc_toolchain macro that we will define later, to ensure that parameters such as `compile_files` are passed correctly.
END_PUBLIC

PiperOrigin-RevId: 612998387
Change-Id: I986d11775e368c4386a930ab2ce8663956a57f9d
2024-03-05 15:58:06 -08:00
Googler 7250ef4352 BEGIN_PUBLIC
Implement ToolchainConfigInfo.

Add support to create the toolchain from feature, action config, and args targets, and validate it to ensure correctness.
END_PUBLIC

PiperOrigin-RevId: 612985448
Change-Id: I7d9086dd1dde07eb0c2484414c9c28c1b8bfb427
2024-03-05 15:15:39 -08:00
Googler 9befdcd90e Remove macros wrapping rules that take in features.
Based on the comments in unknown commit, I created this CL

BEGIN_PUBLIC
Remove macros wrapping rules that take in features.
END_PUBLIC

PiperOrigin-RevId: 612979047
Change-Id: I5690717b164432c9cecebf87ef9dda41f9fa846f
2024-03-05 14:55:21 -08:00
Googler 4eccbe17c8 BEGIN_PUBLIC
Implement builtin CC toolchain features.

This will allow you to override builtin features
END_PUBLIC

PiperOrigin-RevId: 610887686
Change-Id: I30e928c116386ec703dff24a97f925481c395b06
2024-02-27 15:07:57 -08:00
Googler db087578f7 BEGIN_PUBLIC
Implement cc_feature_set and cc_feature_constraint.
END_PUBLIC

PiperOrigin-RevId: 610713183
Change-Id: Ia009ac536b71cd9aa44578f823f13361c1580e37
2024-02-27 04:49:36 -08:00
Googler 2b6cdcfe88 BEGIN_PUBLIC
Implement cc_feature for the rule based toolchain.
END_PUBLIC

PiperOrigin-RevId: 610712498
Change-Id: I2539825f0f4cf7f234a2310de6af0662aeb0ea2c
2024-02-27 04:45:26 -08:00
Googler c5493f9b2c BEGIN_PUBLIC
Implement cc_action_type_config.

Rename it from cc_action_config, to make it clear that we are not configuring an action, but rather configuring a type of action.
END_PUBLIC

PiperOrigin-RevId: 610518142
Change-Id: Ic10755952ee786d30a3a5564aa09a8dc16499f3a
2024-02-26 13:58:42 -08:00
Googler 0d68da5d50 BEGIN_PUBLIC
Implement cc_args_list.

It's completely unneccesary to implement it this early, but collecting args lists is also required for cc_feature.
END_PUBLIC

PiperOrigin-RevId: 609833962
Change-Id: I369a929af4280c0a7ebbe2e13159b640c1968209
2024-02-23 14:14:27 -08:00
Googler 837caeca75 BEGIN_PUBLIC
Pull more info into ArgsListInfo.

This allows us to make queries such as "get me all the flags / files required for this specific action". This will allow us to implement cc_action_config more easily and efficiently.
END_PUBLIC

PiperOrigin-RevId: 609828504
Change-Id: Ie3978674c5027f892d2e5e4c8d937a52c59fde5d
2024-02-23 13:54:41 -08:00
Googler 916074ec32 BEGIN_PUBLIC
Implement cc_tool
END_PUBLIC

PiperOrigin-RevId: 609307150
Change-Id: I2e135a59e06a56ca8ec071254d340ac4b984b234
2024-02-22 03:06:06 -08:00
Googler 35fe45e91b BEGIN_PUBLIC
Implement cc_args.

Also change cc_flag_set / cc_flag_group to cc_args / cc_arg_group. This is to lean into the idea that this is roughly equivalent to ctx.actions.args()
END_PUBLIC

PiperOrigin-RevId: 608804069
Change-Id: I74ea883b14219f904aaafc4eab902b96a1fb3e3d
2024-02-20 17:58:39 -08:00
Googler 2e780ceda9 BEGIN_PUBLIC
Add support for testing rules_cc's new toolchains with rules_testing.
END_PUBLIC

PiperOrigin-RevId: 608769646
Change-Id: I1a698355e5e977cc86eedc7cf6e8e0f888593cb8
2024-02-20 15:54:10 -08:00
Googler 833f17060c Implement action types for the configurable cc toolchain.
This does nothing on its own, but is required for other types.

PiperOrigin-RevId: 606441930
Change-Id: I94dbbd760be856f28370a61edcf815eecb16f339
2024-02-12 18:54:59 -08:00
Googler 8857ebcb47 Add documentation for rule-based bazel toolchain configuration
PiperOrigin-RevId: 606434760
Change-Id: Ie238b5513144e4289186af470e7503f05dd87890
2024-02-12 18:22:13 -08:00
Googler e221babe8d Add providers for rule-based toolchain configuration.
Similar to the previous CL, this CL is to ensure that we agree on the relationship between each different type.

This will also allow for developing two things in parallel:
* The rules that generate these providers.
* Toolchain validation, and conversion to the cc_toolchain_config_lib providers.

PiperOrigin-RevId: 606391257
Change-Id: I9c2a9895d71ed987e85eb60f908d9833b838d9f8
2024-02-12 15:52:59 -08:00
Ezekiel Warren b4071d7181
add emscripten compiler config_setting 2023-09-20 13:23:09 -07:00
Googler eef16ef276 Create toolchain types for proto_library and lang_proto_library
BEGIN_PUBLIC
Create toolchain types for proto_library and lang_proto_library

This handles only lang_proto_libraries defined in Bazel: Java, Java lite, Python, C++.

Design doc: https://docs.google.com/document/d/1CE6wJHNfKbUPBr7-mmk_0Yo3a4TaqcTPE0OWNuQkhPs/edit#heading=h.5mcn15i0e1ch
Issue: https://github.com/bazelbuild/rules_proto/issues/179
END_PUBLIC
PiperOrigin-RevId: 566380737
Change-Id: I49b132f861bc7a871d98bbd333271d540faaf737
2023-09-18 12:30:14 -07:00
Googler 1583313f41 Fix licensing errors and add default condition for `local_defines`.
PiperOrigin-RevId: 548995629
Change-Id: I0734ca5b64cf37401ec74a339a67f3044321aa7c
2023-07-18 07:27:57 -07:00
Copybara-Service 5d8ef91731 Merge pull request #167 from fmeum:add-compiler-settings
PiperOrigin-RevId: 548940888
Change-Id: Id69973c5014cfe59729cab2d983df24b7422602d
2023-07-18 02:38:23 -07:00
Googler 5a8cab742c Add support for expand_if_available for env_entry
PiperOrigin-RevId: 548694860
Change-Id: I90f46902058fe1ac3a75bb25bddbbf6e181fbabd
2023-07-17 08:12:34 -07:00
Fabian Meumertzheim 4e72e665a3 Add well-known compiler `config_setting`s
As of Bazel 6.0.0, all Bazel-provided toolchains report consistent
compiler names that can be matched on with `select`. Having a central
place for `config_setting`s that can be used for this purpose makes it
so that rulesets don't have to define them themselves and moving the
compiler flag out of `@bazel_tools` becomes easier as it is no longer
referenced directly.

Also includes minor fixes to `//tests/...` so that it can be enabled in
CI.
2023-07-10 16:39:33 +02:00
Googler 1dbb691712 Get rid of unused objcpp_executable type
PiperOrigin-RevId: 539637641
Change-Id: I80f65a738e77b58054121bfe19a47659fb50fc42
2023-06-12 06:53:11 -07:00
Googler 7f0992b0bd Remove `cc_host_toolchain_alias` target.
Right now there should be no difference between `cc_host_toolchain_alias` and `cc_toolchain_alias` rules.
This is a potentially breaking change for Bazel, if something was depending on `current_cc_host_toolchain` try depending on `current_cc_toolchain` instead.

PiperOrigin-RevId: 528762965
Change-Id: Id2d211c61fa06a578a838c054682c3507aa48261
2023-05-02 06:19:53 -07:00
Googler 2e4313aeba Automated rollback of commit 06e9dcf4b7.
*** Reason for rollback ***

Breaking tap/blaze. Example failure: []

*** Original change description ***

Sort action lists to make diffing easier.

***

PiperOrigin-RevId: 523671424
Change-Id: I475ff02bf8efd3c56e489e2de3ba2c3a5639c32e
2023-04-12 05:19:20 -07:00
Googler 06e9dcf4b7 Sort action lists to make diffing easier.
PiperOrigin-RevId: 523639362
Change-Id: I8a43799f58ad1ed5b19ec074fa9cb9a567591f36
2023-04-12 02:07:04 -07:00
Yannic 507f49698a Update cc_toolchain_config_lib.bzl for bazelbuild/bazel#10967 2023-02-16 10:19:56 -08:00
Googler ad1830946d Remove redundant "# copybara-use-repo-external-label"
Remove redundant tags for copybara to replace labels with labels including the
repository, where there are no labels to substitute after 2f8c04c044.

PiperOrigin-RevId: 510103824
Change-Id: I9b65a6b7f9b48885aec4df5f4723273633be4860
2023-02-16 04:17:58 -08:00
Googler d8dfa8b829 Introduce flag --@rules_cc//:link_extra_libs
Numerous tools override --custom_malloc to add debugging or monitoring runtimes
(see e.g. sanitizers). While this is fine for cases where the tool must also
override malloc to function, in other cases it's simply misuse of
--custom_malloc where no other mechanism exists to link an extra library.

This becomes especially problematic where a runtime library is supposed to be
added in certain configurations that should run in production or other
performance sensitive builds. In these cases, we should _not_ override malloc,
which may also be specified by a cc_binary target. Doing so would introduce
unwanted changes, potentially affecting performance negatively.

This is the @rules_cc counterpart to the equivalent Bazel tools flag
--@bazel_tools//tools/cpp:link_extra_libs. Users that use @rules_cc to build
their C++ projects may use both flags interchangably, however, the @rules_cc
flag should be preferred.

PiperOrigin-RevId: 510103352
Change-Id: Iafccd00ffdb65cb4f953d5acadc451cffc134533
2023-02-16 04:15:10 -08:00
Copybara-Service c7849af112 Merge pull request #154 from keith:ks/move-apple-toolchain-setup-to-apple_support
PiperOrigin-RevId: 502796914
Change-Id: I2cd0481a244db416ec2abb06e05dee0f783b72b5
2023-01-18 00:42:02 -08:00
Copybara-Service d7c11265cb Merge pull request #166 from fmeum:patch-1
PiperOrigin-RevId: 501245941
Change-Id: Ic064d20847215c65bf01fda2e1941cb497d949bf
2023-01-11 04:34:10 -08:00
Fabian Meumertzheim 66cf3048e9 Copybara Merge: https://github.com/bazelbuild/rules_cc/pull/165
BEGIN_PUBLIC
Copybara import of the project:

--
56e69b82484f1a9fb55d8173cc112f9f608f3581 by Fabian Meumertzheim <fabian@meumertzhe.im>:

Simplify WORKSPACE setup and update ancient deps

By removing a single unused `bzl_library` target, rules_cc no longer has
any dependencies that would need to be loaded by a dependency macro. The
existing macro is made a no-op.

The few needed Bazel Federation dependencies are inlined and, in the
case of bazel_skylib and abseil-py, updated to modern versions.

Also reorders `WORKSPACE` to list direct dependencies first and keeps
`MODULE.bazel` in sync with the dependency versions used in WORKSPACE.

The `ubuntu1604` CI pipeline is removed as the version of Python used by
it is no longer supported and the distribution is EOL. Instead, a new
pipeline is added to check the Bzlmod build.

END_PUBLIC

COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/rules_cc/pull/165 from fmeum:fix-workspace-module 56e69b82484f1a9fb55d8173cc112f9f608f3581
PiperOrigin-RevId: 501245864
Change-Id: Ib71ad910705807a00929a76774387a38d2da0f9f
2023-01-11 04:33:23 -08:00
Googler bc665f9271 Automated rollback of commit 48881f1f45.
*** Reason for rollback ***

Broke a test

*** Original change description ***

The auto-configured toolchains provided by Bazel itself have diverged heavily from the version maintained in this repo. There is no need to maintain this duplication until Starlarkification has progressed succiciently for rules_cc to be the source of truth for them.

This is particularly relevant for Bzlmod, which currently uses the toolchains defined in rules_cc. As a result, Bazel C++ builds will use subtly different toolchains depending on whether --enable_bzlmod is used or not. This is fixed...

***

PiperOrigin-RevId: 501228335
Change-Id: I858dc3ea44df7ae70b5603f6dc2e082b4540c42a
2023-01-11 02:48:25 -08:00
Fabian Meumertzheim 48881f1f45 The auto-configured toolchains provided by Bazel itself have diverged heavily from the version maintained in this repo. There is no need to maintain this duplication until Starlarkification has progressed succiciently for rules_cc to be the source of truth for them.
This is particularly relevant for Bzlmod, which currently uses the toolchains defined in rules_cc. As a result, Bazel C++ builds will use subtly different toolchains depending on whether --enable_bzlmod is used or not. This is fixed by loading toolchain detection logic from @bazel_tools in the module extension.

Closes #163

PiperOrigin-RevId: 501199523
Change-Id: I01f263d37495d0c5dd070c8a32945898d1d639c5
2023-01-11 00:12:08 -08:00
Keith Smiley 404bb430e7
Remove entire macOS toolchain
This defaults to C++, and the previous setup will be moved to
apple_support
2023-01-10 08:43:46 -08:00
Keith Smiley 52f5feaf1d
Move Apple toolchain setup to apple_support
Mirrors https://github.com/bazelbuild/bazel/pull/16619
2023-01-10 08:43:45 -08:00
Fabian Meumertzheim cbf01d28ec Delete `cc/version.bzl`
The version has never been updated since the first release and since rules_cc is currently a slim wrapper around Bazel-provided rules, version detection shouldn't be necessary.
2023-01-10 11:02:51 +01:00
Fabian Meumertzheim 06112c7d9e The targets in the old package were either not publicly visible or testonly dependencies and had diverged heavily from @bazel_tools.
Instead, add an alias to the Bazel-provided runfiles library under //cc/runfiles, following https://bazel.build/rules/deploying.

Closes #162

PiperOrigin-RevId: 500929486
Change-Id: I3290c2b836af2313fbf45459c81af24fbde877d0
2023-01-10 02:00:52 -08:00
Googler 7673ce6438 Delete objc_archive action type
PiperOrigin-RevId: 499061707
Change-Id: Ia2a79f33c991a9c517c2fa940ff25c959ca35d65
2023-01-02 12:08:25 -08:00
Keith Smiley 99df95ba02
Apply upstream libtool_check_unique fix
This ports 48dd159808
2022-11-01 10:05:26 -07:00
Ivo List 13d212d39b Merge pull request #146 from bazelbuild:meteorcloudy-patch-1
PiperOrigin-RevId: 475272913
Change-Id: Id75eee2933ee396ae5fc5cbe4941369b813b2c8e
2022-09-19 13:51:00 +00:00
Tony Aiuto 3b4549ed94 Update WORKSPACE:
- point to bazelbuild/platforms for @platforms
- Use a newer version of rules_go for our internal rules.
- Make a bzl file used in a test visible to the tests.

I believe this fixes a build breakage in bazel at head and 5.3.0
2022-08-26 15:46:53 -04:00
Googler 2f8c04c044 Automatic code cleanup.
PiperOrigin-RevId: 456494185
Change-Id: I9aaefff0976cca2b68646970c8d4675c8e122d19
2022-06-22 06:02:29 -07:00
Googler 8bb0eb5c5c Add a use_cc_toolchain helper to rules_cc.
Part of github.com/bazelbuild/bazel/issues/14727.

PiperOrigin-RevId: 449499388
Change-Id: I9fb5fecd1059b0d48a26e89d1c25d54fd2348b55
2022-05-18 09:20:17 -07:00
Christopher Peterson Sauer e0dad88a07 Move examples from deprecated @rules_cc//cc:find_cpp_toolchain -> @bazel_tools//tools/cpp:toolchain_utils.bzl 2022-04-11 16:38:30 -07:00
Googler 58f8e026c0 Add xcode_configure in cc_configure module extension
This is needed by cc toolchain on macOS.

PiperOrigin-RevId: 435328319
Change-Id: I505b18d6058daf2cbb479f454f299b7b4a92bd84
2022-03-17 06:25:24 -07:00
Googler 3eaa3c7f88 Remove unnecessary tests from rules_cc
They are now part of the bazelbuild/bazel repository.

Copies buildifier changes contributed by Keith in https://github.com/bazelbuild/rules_cc/pull/128

RELNOTES:none
PiperOrigin-RevId: 435312636
Change-Id: I4d5d2f58d90026c0cdfb5c0a90709de7c28c6ccd
2022-03-17 04:50:16 -07:00
Yun Peng 8e7357c5cc Move extensions.bzl to //cc to make buildifier happy 2021-11-05 12:21:01 +01:00
Googler 426f721323 Automatic code cleanup.
PiperOrigin-RevId: 407085810
Change-Id: I6cac435d8e0e89f97405c7b3923d1891da78740b
2021-11-02 08:13:14 -07:00
Googler f846566869 Update rules_cc doc references for inclusive-language-fixit-2
PiperOrigin-RevId: 405732925
Change-Id: If700320f2e8f3e45f2fbdf08e945ea94dfe32887
2021-10-26 14:16:20 -07:00
Lizan Zhou 4b46a7a447 Add -g in `per_object_debug_info` for Clang 12 and GCC 11 2021-09-27 12:20:58 -07:00
UebelAndre 0913abc3be Added `bzl_srcs` targets which only contain `.bzl` files for use in stardoc 2021-08-12 07:14:28 -07:00
Keith Smiley 03b5d84aa7 Add armeabi_cc_toolchain_config.bzl to macOS config
This is required since https://github.com/bazelbuild/bazel/pull/13449
2021-05-27 13:36:41 -07:00