Commit Graph

52 Commits

Author SHA1 Message Date
Googler ab0be67e22 Update `cfg` values to make buildifier happy.
PiperOrigin-RevId: 449498641
Change-Id: I145fc5dfec522753deaa64ace04ca56546351ff5
2022-05-18 09:16:43 -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
Googler 40548a2974 Automatic code cleanup.
PiperOrigin-RevId: 355825197
Change-Id: I8acfc20228816c04fcf48bfcc435cbde2b1fb608
2021-02-05 04:30:09 -08:00
Googler ab2abd3ddc Automatic code cleanup.
PiperOrigin-RevId: 354218909
Change-Id: I223212c3b453e67f0563766e9533fda284aaeef6
2021-01-27 18:31:53 -08:00
Googler 991eb349bf Internal change
PiperOrigin-RevId: 340301767
Change-Id: Iccab5010d3fd6e77c08fcdc140cdc1e461185b0d
2020-11-02 13:19:59 -08:00
Googler 699ec52985 Internal change
PiperOrigin-RevId: 339925655
Change-Id: Icde35bf6acb72a382e0253fcf9fb5a10d80a5feb
2020-10-30 13:05:57 -07:00
Googler 16ad606329 Internal change
PiperOrigin-RevId: 339887089
Change-Id: Ic511ced72381f847f5d1b9159f299b6e474a47de
2020-10-30 09:41:38 -07:00
Googler 7fdc27c099 Automatic code cleanup.
PiperOrigin-RevId: 300062414
Change-Id: I0df6327b0a651aed821351f9aaff731ff6183aa6
2020-03-10 04:40:22 -07:00
Googler a636005ba2 Migrate rules_cc to python 3
PiperOrigin-RevId: 298802233
Change-Id: I55930fa7e8dd621afdef8586ba81752344aa1f99
2020-03-04 02:10:07 -08:00
Googler 31c46f250a Explicitly export files needed by other packages
Add an explicit export statement (with the same visibility) for
files that are currently only implicitly exported and used by other
pacakges. This prepares changing the visibility of implicitly-exported
files to be package private without causing a breakage.

PiperOrigin-RevId: 280171386
Change-Id: I083a9d4f82067b4d4c94d7b554013aeb91e401cc
2019-11-13 04:27:16 -08:00
Googler 262ebec3c2 Fix buildifier warnings in @rules_cc
Fixes:

* Enabled buildifier on the Bazel CI again
* Added Skydocs where missing
* Moved public files out of .../private/... (e.g. cc_toolchain_config_lib.bzl)
* Reformatted
* Removed unused loads
* Using relative labels for cc_configure related files
* Added development dependency on rules_proto
    * they're not in the federation yet, so hand rolling in rules_cc's WORKSPACE file
* Added development dependency on rules_python (from federation)
* Cleaned up copybara (notable change - not using @rules_cc in labels inside rules_cc repo)
* Made cc_flags_supplier usable internally
* Moved load statements to the top of the bzl file
* Moved runfiles to the tools directory
* Unified toolchain_utils.bzl and find_cc_toolchain.bzl

RELNOTES: None.
PiperOrigin-RevId: 276479521
Change-Id: I3196896061fa2ee61a3efb130c214d288782066a
2019-10-24 07:01:25 -07:00
Googler 401380cd22 Add a cc_toolchain_config_compare_test that compares 2 Starlark C++ toolchain configuration rules
With CROSSTOOL not existing anymore, the comparison script can continue being useful in refactoring Starlark toolchain config rules.

RELNOTES: None.
PiperOrigin-RevId: 262544859
Change-Id: I633fdc4c09c7643d6e5d1c10537efa3c9a82003c
2019-08-09 05:56:16 -07:00
Googler e68ae76a67 Allow the C++ toolchain config rules comparator script to not need toolchain_identifier argument when both --before and --after arguments are CToolchains (coming from Starlark rules instead of CROSSTOOL proto)
We don't need to select a toolchain by the identifier when we get the proto from Starlark rules because in that case the proto contains a single toolchain.
The difference in toolchain_identifier field between the first and the second proto file will be caught as any other field.

RELNOTES: None.
PiperOrigin-RevId: 262543753
Change-Id: I1e66ee302bf551ade883c217f6269f44382393c0
2019-08-09 05:43:22 -07:00
Googler f678ef5279 Automatic code cleanup.
PiperOrigin-RevId: 245027760
2019-04-24 05:30:15 -07:00
rosica 2312d72134 Fix allowed values in 'compiler' attribute of cc_toolchain_config rule.
When cpu value is not enough to distinguish between two toolchains, we use the compiler value. In that case, the user needs to specify the compiler value for all cc_toolchain_config rules, even for the ones with unique cpu. This cl fixes the allowed values in the compiler attribute to account for the values from unique toolchains.

Issue #5380
RELNOTES: None.
PiperOrigin-RevId: 239396228
2019-03-20 07:55:12 -07:00
rosica 943183cae8 Fix load("//tools/cpp:cc_toolchain_config_lib.bzl") to load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl")
And add a test checking the full output from the migrator for a simple CROSSTOOL.

Issue #5380
RELNOTES: None.
PiperOrigin-RevId: 239153961
2019-03-19 02:46:26 -07:00
rosica 3b89ccfbe7 Remove linter warnings that a feature or action_config may not be declared by setting it to None instead.
Also rename the rule from cc_toolchain_config_rule to cc_toolchain_config

Issue #5380

RELNOTES: None.
PiperOrigin-RevId: 238945434
2019-03-18 01:50:26 -07:00
hlopko 0c017ebc6d Do not condition linker_flags from DYNAMIC linking_mode_flags for transitive dynamic libraries on dynamic_linking_mode feature
https://github.com/bazelbuild/bazel/issues/6861

RELNOTES: None.
PiperOrigin-RevId: 238941083
2019-03-18 01:04:18 -07:00
hlopko 10f38e16da Fix migrator to correctly migrate dynamic linking mode linker_flags
This would have not introduced the osx crosstool bug in 2d0e27e8bc which was then fixed in unknown commit.

RELNOTES: None.
PiperOrigin-RevId: 238699176
2019-03-15 13:25:11 -07:00
hlopko b844e0c4b8 Replace scrubbing with copybara-comment-this-out-please in copybara
This will make sure the copybara export is reversible, which is needed for setting up copybara workflow for importing github PRs.

RELNOTES: None.
PiperOrigin-RevId: 238445502
2019-03-14 17:13:28 +01:00
hlopko 0b8e7b5940 Use is_using_fission in legacy_fields_migrator
Since unknown commit is submitted, the principled variable to use in per_object_debug_info is is_using_fission, not per_object_debug_info_file (in case of thinlto build, the former is present also for thinlto bitcode compile, the latter only for backend compile).

RELNOTES: None.
PiperOrigin-RevId: 237192121
2019-03-07 00:02:00 -08:00
hlopko 7e835b273a Clear dynamic_library_linker_flag in legacy_fields_migrator
RELNOTES: None.
PiperOrigin-RevId: 234748020
2019-02-20 00:25:12 -08:00
hlopko 7caec85c2c Improve rules_cc copybara
* # copybara-scrub suffix now works in BUILD and bzl files
* //tools/cpp is rewritten to @bazel_build//tools/cpp **in any filetype**
* //third_party/bazel_rules/rules_cc is rewritten to // **in any filetype**

PiperOrigin-RevId: 233919400
2019-02-14 13:22:37 +01:00
hlopko d485e267a5 Enable features that were previously enabled by Bazel in legacy_fields_migrator
https://github.com/bazelbuild/bazel/issues/6861

RELNOTES: None.
PiperOrigin-RevId: 233735389
2019-02-13 05:40:50 -08:00
hlopko 49a6c21b32 Do not use static_linking_mode for dynamic libraries and objc rules
Another dark corner corner of crosstools appeared, and apparently we didn't enable MOSTLY STATIC linking mode flags for dynamic libraries or objc. This cl addresses that in the legacy fields migrator.

RELNOTES: None.
PiperOrigin-RevId: 233397974
2019-02-11 06:47:26 -08:00
hlopko dfb180b486 Migrate repeated expand_if_(all|none)_available into nested flag_groups
Crosstool in Starlark assumes these fields as singular, not collections. This cl updates the migration script to prepare crosstool in proto for this.

https://github.com/bazelbuild/bazel/issues/6861
https://github.com/bazelbuild/bazel/issues/5883

RELNOTES: None.
PiperOrigin-RevId: 233041028
2019-02-08 04:53:52 -08:00
rosica 903ad72c43 Make CToolchain comparator ignore differences in CToolchain.Tool.tool_path and CToolcain.ToolPath.path when one is "" and the other "NOT_USED"
Starlark constructors for tool_path and tool do not allow empty strings for the path field. Therefore the migrator replaces the "" with "NOT_USED". We should ignore this difference when comparing the CToolchains.

#5380

PiperOrigin-RevId: 232827179
2019-02-07 01:04:52 -08:00
rosica d4fef61119 Add feature declaration tests
And fix an error where we added previously unseen action_names to the dictionary of familiar ACTION_NAMES, so later when we would encounter them, we would treat them as variables, not as string literals
eg
env_set {
  action = "a"
}
would translate to
env_set(
  actions = [a],
)
which is, obviously wrong.

Issue #5380

PiperOrigin-RevId: 232817515
2019-02-06 23:50:49 -08:00
rosica e02152f86e Remove fail("Unreachable") from features' and action_configs' declaration statements
If toolchain A and B need feature f, but toolchain C doesn't, the generated declaration statement for feature f would be:
if ctx.attr.cpu == 'A.cpu':
   f = feature(...)
elif ctx.attr.cpu == "B.cpu" and ctx.attr.compiler == "B.compiler":
   f = feature(...)
else:
   fail("Unreachable")

This will break the rule implementation in the case of toolchain C because it will reach the  fail("Unreachable") although it doesn't need to declare feature f

This cl fixes that

Issue #5380

PiperOrigin-RevId: 232683639
2019-02-06 08:56:10 -08:00
rosica de27916485 Fix action_config names
If an action_config's name doesn't appear in the action_names.bzl, eg action-a.b+c, in it's assignments statement we would declare it as:
action_a.b+c_action = action_config( ...

This cl fixes it to create the action_config variable with the +, - and .
It also adds tests for action_config

Issue #5380

PiperOrigin-RevId: 232681355
2019-02-06 08:41:22 -08:00
rosica 9432a5a6e8 Make crosstool to starlark converter error out if it comes across multiple expand_if_all_available or expand_if_none_available in a single flag_group
PiperOrigin-RevId: 232499399
2019-02-05 09:20:21 -08:00
rosica 1576db8e94 Fix paths resolving for --crosstool and --output_location.
This is to make the script usable from bazel run

PiperOrigin-RevId: 232472300
2019-02-05 06:09:25 -08:00
rosica ba06942f95 Fix flag parsing
PiperOrigin-RevId: 232470483
2019-02-05 05:57:20 -08:00
Googler f76ab4888a Migrate Apple CROSSTOOL to starlark.
RELNOTES: None.
PiperOrigin-RevId: 231209609
2019-01-28 06:40:54 -08:00
rosica b3a83d701a Add a script for converting CROSSTOOL files to Starlark rules
Progress towards issue #5380

RELNOTES: None
PiperOrigin-RevId: 230795058
2019-01-24 14:54:38 -08:00
hlopko ddf13fe1da Don't require supports_fission to be set in the crosstool
Having a 'per_object_debug_data' feature enabled is giving the same signal as having supports_fission enabled. This is a safe change because all crosstools that have supports_fission: true have per_object_debug_info disabled, and with the legacy crosstool fields migration we will migrate this feature to be enabled by default for these crosstools.

https://github.com/bazelbuild/bazel/issues/6861
https://github.com/bazelbuild/bazel/issues/5883

RELNOTES: None.
PiperOrigin-RevId: 230701029
2019-01-24 04:55:15 -08:00
hlopko a9932b3939 Make ctoolchain_compare.bzl more robust by using ctx.label.name as generated files name.
This ensures that the generated files will be unique in the package and therefore there won't be action conflict.

RELNOTES: None.
PiperOrigin-RevId: 230514342
2019-01-23 05:42:09 -08:00
Googler da4639bd1f Actually cause the comparator / test to fail when there is an error reading one
of the toolchains.

Cosmetic spacing fixes for strings that will be concatenated and fixed a typo.

PiperOrigin-RevId: 229961708
2019-01-18 11:20:25 -08:00
Googler dc71ef6ea6 Make it possible to test multiple configs in the same BUILD file.
PiperOrigin-RevId: 229960389
2019-01-18 11:13:22 -08:00
rosica 0627ae379c Create a test rule that compares CToolchains from CROSSTOOL file and from Starlark rule
Work towards issue #5380
RELNOTES: None
PiperOrigin-RevId: 229928313
2019-01-18 07:56:03 -08:00
rosica f64680e017 Make ctoolchain_comparator.py throw exit(1) when CToolchains differ
While here, Also fix _read_crosstool_or_ctoolchain_proto to actually return the CToolchain found in the CROSSTOOL file, and add some missing \n.

RELNOTES: None.
PiperOrigin-RevId: 229926500
2019-01-18 07:37:16 -08:00
hlopko f9cdb36627 Always put linker_flags from linking_mode_flags.DYNAMIC to nodeps-dynamic-library
This cl fixes a bug in the migrator where it didn't pass mentioned flags to c++-nodeps-dynamic-library unconditionally (it only passed them as with feature { feature: 'dynamic_linking_mode' }, which is incorrect, the feature doesn't not apply to nodeps-dynamic-library, only to transitive linking actions.

https://github.com/bazelbuild/bazel/issues/6861
https://github.com/bazelbuild/bazel/issues/5883

RELNOTES: None.
PiperOrigin-RevId: 229692958
2019-01-17 00:07:27 -08:00
hlopko 0fd5bb9b75 Rename/remove fields referencing legacy features in legacy_fields_migrator
When renaming legacy_*_flags to default_*_flags, also rename other fields such as requires.

We're intentionally not replacing the implies line, just removing it, because default_*_features are enabled by default, so they don't need to be implied (Implied field is older than enabled field, so there are uses of it where enabled would work just fine. The only semantic difference is that implied features cannot be disabled, whereas enabled can. But since the standard style of writing crosstools seems to prefer enabled, I'm doing the same here.)

https://github.com/bazelbuild/bazel/issues/6861
https://github.com/bazelbuild/bazel/issues/5883

RELNOTES: None.
PiperOrigin-RevId: 229518029
2019-01-16 01:41:22 -08:00
hlopko 04195ada17 Fix legacy_fields_migrator
Another round of fixes:

* if the toolchain contains legacy_compile_flags or legacy_link_flags, replace the feature with default_compile_flags or default_link_flags. This is to ensure the location of the flags stays intact.
* it fixes the order of compilation flags, the correct order is:
  1) compiler_flag
  2) compilation_mode_flags.compiler_flag
  3) cxx_flag
  4) compilation_mode_flags.cxx_flag
* We don't add cxx_flags to assemble and preprocess-assemble actions
* We don't add sysroot to assemble action

https://github.com/bazelbuild/bazel/issues/6861
https://github.com/bazelbuild/bazel/issues/5883

RELNOTES: None.
PiperOrigin-RevId: 229336027
2019-01-15 02:09:19 -08:00
hlopko c0ac741cbe Improve legacy_fields_migrator to work properly for objc crosstools
https://github.com/bazelbuild/bazel/issues/5883
https://github.com/bazelbuild/bazel/issues/6861

RELNOTES: None.
PiperOrigin-RevId: 228839863
2019-01-11 00:11:34 -08:00
rosica 175f81c847 Add a script for comparing CToolchian built from different CROSSTOOL/Ctoolchain proto text files
Progress towards #5380

RELNOTES: None.
PiperOrigin-RevId: 228312688
2019-01-09 08:59:20 +01:00
hlopko 63003094c9 Make cc_embed_data.bzl forward compatible with removal of legacy crosstool fields
RELNOTES: None
PiperOrigin-RevId: 228301880
2019-01-09 08:58:59 +01:00
hlopko f835b8bea2 Fix legacy_fields_migrator
This cl fixes:

* clears 'supports_embedded_runtimes'
* adds user_compile_flags and sysroot feature
  * these are needed to appear before unfiltered_compile_flags

Progress towards:
https://github.com/bazelbuild/bazel/issues/6861
https://github.com/bazelbuild/bazel/issues/5883

RELNOTES: None.
PiperOrigin-RevId: 228299172
2019-01-09 08:58:48 +01:00
hlopko 30e32836fa Add --inline option to legacy_fields_migrator
https://github.com/bazelbuild/bazel/issues/5883

RELNOTES: None.
PiperOrigin-RevId: 227827560
2019-01-09 08:58:04 +01:00
hlopko b809b1312f Fix edge cases of legacy crosstool migrator
https://github.com/bazelbuild/bazel/issues/5883

RELNOTES: None.
PiperOrigin-RevId: 227688115
2019-01-09 08:57:53 +01:00