2
0
Fork 0
mirror of https://github.com/bazelbuild/rules_cc synced 2024-11-30 22:41:22 +00:00
Commit graph

58 commits

Author SHA1 Message Date
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
Yannic Bonenberger dbe8807224 Add optional tool_path_origin to Tools in C++ crosstool
This change adds an optional field to the C++ crosstool proto that
allows configuring the origin tool_path is relative to.

For now, the origin can be one of the following:
  - CROSSTOOL_PACKAGE: If tool_path is a relative path, it's assumed to
    be relative to the package of the crosstool top.
  - FILESYSTEM_ROOT: tool_path is an absolute path. This is checked by
    Bazel.
  - WORKSPACE_ROOT: tool_path must be a relative path and is assumed to
    be relative to the exec-root of the workspace (similar to other
    executables).

Updates bazelbuild/bazel#8438

Closes #10967.

PiperOrigin-RevId: 310142352
Change-Id: If6316ffa5d7d2713b197840b4aafb2f0cdbb0b96
2020-05-06 06:52:27 -07:00
Googler 4de26b53a6 Remove need for exported_by or linked_statically_by
For now we will restrict allowed exports to the same package. At the same time
static_deps should be used to take into account what should be linked into a
shared library.

RELNOTES:none
PiperOrigin-RevId: 294668451
Change-Id: Ia087519106983bfa9a980e471d3102ab391a53eb
2020-02-12 08:01:50 -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
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 7a628f3387 Make python scripts consistent with ctoolchain_comparator
This will simplify copybara export logic.

RELNOTES: None.
PiperOrigin-RevId: 238396543
2019-03-14 17:12:55 +01:00
cushon 64efe1299e Automated rollback of commit 2e79abf8ca.
PiperOrigin-RevId: 234756779
2019-02-20 01:41:00 -08:00
hlopko 2e79abf8ca Flip --incompatible_disable_expand_if_all_available_in_flag_set
FlagSets in the CROSSTOOL no longer accept expand_if_all_available field

Fixes #7008

RELNOTES: `--incompatible_disable_expand_if_all_available_in_flag_set` has been flipped (https://github.com/bazelbuild/bazel/issues/7008)
PiperOrigin-RevId: 234466411
2019-02-18 05:16:18 -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 281a8bc480 Add BUILD.third_party to rules_cc
Only to make //third_party a package

RELNOTES: None
PiperOrigin-RevId: 228316989
2019-01-09 08:59:30 +01:00
hlopko 246bff6d0e Add things needed for rules_cc to build & test in the open
* Adding .gitignore
* Referencing protobuf, absl, and six in the WORKSPACE
* Adding six.BUILD

RELNOTES: None
PiperOrigin-RevId: 228309963
2019-01-09 08:59:09 +01:00
hlopko 05d087e921 Make bazel option --collect_symbol_counts a noop
Our reasoning:
* it only works with gold
* it was broken for the last 3 months (since unknown commit) (silently did
nothing and nobody complained)
* we see almost zero usage of this option

RELNOTES: None.
PiperOrigin-RevId: 228116158
2019-01-09 08:58:26 +01:00
hlopko 37f9cc51a5 Add --incompatible_disable_expand_if_all_available_in_flag_set
Corresponding issue: https://github.com/bazelbuild/bazel/issues/7008

RELNOTES: None.
PiperOrigin-RevId: 227522028
2019-01-09 08:57:41 +01:00
hlopko 169818c32d Allow setting needsPic crosstool capability using feature
`needsPic` can now be expressed using 'pic' feature (should be enabled for it to take effect).

This cl is a step towards https://github.com/bazelbuild/bazel/issues/5883. Also
see the rollout doc here:
https://docs.google.com/document/d/1uv4c1zag6KvdI31qdx8C6jiTognXPQrxgsUpVefm9fM/edit#.

Flag removing legacy behavior is https://github.com/bazelbuild/bazel/issues/6861

RELNOTES: None.
PiperOrigin-RevId: 227134726
2019-01-09 08:57:31 +01:00
hlopko c8a8211959 Allow setting supports_embedded_runtimes crosstool capability using feature
`supports_embedded_runtimes` can now be expressed using 'static_link_cpp_runtimes' feature (should be enabled for it to take effect).

This cl allows toolchain owners to express that toolchain supports embedded runtimes in the same way as other crosstool capabilities are expressed.

This cl is a step towards https://github.com/bazelbuild/bazel/issues/5883. Also
see the rollout doc here:
https://docs.google.com/document/d/1uv4c1zag6KvdI31qdx8C6jiTognXPQrxgsUpVefm9fM/edit#.

Flag removing legacy behavior is https://github.com/bazelbuild/bazel/issues/6861

RELNOTES: None.
PiperOrigin-RevId: 227024509
2019-01-09 08:57:20 +01:00
hlopko 8062601195 Allow setting supports_fission crosstool capability using feature
`supports_fission` can now be expressed using 'per_object_debug_info' feature (should be enabled for it to take effect).

This cl is a step towards https://github.com/bazelbuild/bazel/issues/5883. Also
see the rollout doc here:
https://docs.google.com/document/d/1uv4c1zag6KvdI31qdx8C6jiTognXPQrxgsUpVefm9fM/edit#.

Flag removing legacy behavior is https://github.com/bazelbuild/bazel/issues/6861

RELNOTES: None.
PiperOrigin-RevId: 226950450
2019-01-09 08:57:10 +01:00
hlopko 392be757fe Cleanup uses of supports_dsym
Apparently it's not used, so removing traces of it.

RELNOTES: None.
PiperOrigin-RevId: 226486811
2019-01-09 08:56:59 +01:00
hlopko e327d70146 Mark unused crosstool fields
RELNOTES: None.
PiperOrigin-RevId: 226302225
2019-01-09 08:56:44 +01:00
hlopko 2c36045d81 Add --incompatible_disable_runtimes_filegroups
This change adds cc_toolchain.static_runtime_lib and
cc_toolchain.dynamic_runtime_lib attributes and an incompatible flag that
disables deprecated cc_toolchain.static_runtime_libs and
cc_toolchain.dynamic_runtime_libs.

Issue for the incompatible flag: #6942
Tracking issue for legacy crosstool fields removal: #5883

RELNOTES: Added --incompatible_disable_runtimes_filegroups
(https://github.com/bazelbuild/bazel/issues/6942).
PiperOrigin-RevId: 226165743
2019-01-09 08:56:32 +01:00
jingwen 3c88920d55 Correct misspelled English words in comments and printed messages in Bazel's src/... directory (and run fix)
RELNOTES: None.
PiperOrigin-RevId: 222473871
2019-01-09 08:55:49 +01:00
hlopko fccbfbf395 Do not use CROSSTOOL to select cc_toolchain
This is a preparation for flipping
--incompatible_disable_cc_toolchain_label_from_crosstool_proto, which will stop
reading default_toolchain fields from the crosstool and will rely on
cc_toolchain_suite.toolchains containing entries for cpu without compiler.

Migrations docs can be found here:
https://docs.bazel.build/versions/master/skylark/backward-compatibility.html#disallow-using-crosstool-to-select-the-cc_toolchain-label.

RELNOTES: None.
PiperOrigin-RevId: 216470358
2019-01-09 08:55:38 +01:00
hlopko 364065d6a5 Make CROSSTOOL.default_target_cpu optional
It's deprecated, and not used, there's no reason for it to be required.

RELNOTES: None.
PiperOrigin-RevId: 213639602
2019-01-09 08:55:27 +01:00
hlopko ce4d5692c2 Remove LipoMode and LipoModeFlags from CROSSTOOL
RELNOTES: None.
PiperOrigin-RevId: 200747338
2019-01-09 08:55:16 +01:00
rosica 2ea125ddd6 Remove supports_lipo field from DefaultCpuToolchain
RELNOTES: None.
PiperOrigin-RevId: 200399094
2019-01-09 08:55:06 +01:00
pcloudy d08ec26583 Refactor artifact_name_pattern in CROSSTOOL
Instead of using a string pattern, we replace it with a prefix and an
extension.

RELNOTES: NONE
PiperOrigin-RevId: 197132215
2019-01-09 08:54:54 +01:00
hlopko 358b48dc26 Remove traces of optional_flags from crosstool
AFAIK all uses have been migrated to features, so they are not needed anymore.

RELNOTES: CppRules: optional_compiler_flag was removed from CROSSTOOL, use features instead.
PiperOrigin-RevId: 192277764
2019-01-09 08:54:43 +01:00
hlopko ff0944a403 Remove optional_*_flag fields from crosstool
They are not used anyway. optional_compiler_flag will be removed once internal
migration is finished.

RELNOTES: CppRules: Remove optional_*_flag fields from CROSSTOOL, they are not
used, and could be expressed using features.
PiperOrigin-RevId: 190600731
2019-01-09 08:54:32 +01:00
Googler 87e4245462 Automatic code cleanup.
PiperOrigin-RevId: 183118434
2019-01-09 08:54:21 +01:00
Googler 851eed198a Allow conditioning flags on the _absence_ of a feature.
This allows a flag_set to emit one flag when a feature is enabled, and a
different flag when that feature is disabled.

And while I was in there, I noticed and fixed a couple other issues:

1. env_set didn't actually implement with_feature, despite having the field in
   its proto.
2. action_config implemented with_feature as an optional field, instead of
   repeated field.

RELNOTES: None
PiperOrigin-RevId: 176510960
2019-01-09 08:54:10 +01:00
cpeyser 199f7d9280 Allow an action_config to be activated by default.
PiperOrigin-RevId: 175531318
2019-01-09 08:53:59 +01:00
klimek 503f0a9868 Implement user experience for LIPO / ThinLTO users.
Add flag --convert_lipo_to_thinlto, which allows builds with LLVM to use
ThinLTO when the user specifies LIPO + FDO flags; if that flag is not set, and
the user requests a build with LLVM, the compile will now fail.

Add an attribute supports_lipo to the DefaultCpuToolchain crosstool proto and
skip default toolchains that do not support LIPO when the user has specified
LIPO flags in the toolchain selection; this enables CROSSTOOL files to cause
an implicit fallback to a hybrid / LIPO toolchain when using an LLVM toolchain
as the default.

Add a CrosstoolBuilder to MockCcSupport and add a new method
setupCrosstoolFromScratch that allows unit tests to fully control the setup.
The other methods available in MockCcSupport will always load in a default
CROSSTOOL file and may show different unit test results depending on the
content of that file.

RELNOTES: None.
PiperOrigin-RevId: 163819246
2019-01-09 08:53:47 +01:00
klimek 1fbdf51208 Typo fix.
PiperOrigin-RevId: 163191957
2019-01-09 08:53:37 +01:00
lberki 21b2542b61 Mark the default_target_cpu field in CROSSTOOL deprecated.
It hasn't been used since a while.

RELNOTES: None.
PiperOrigin-RevId: 162215841
2019-01-09 08:53:26 +01:00
hlopko 94ad5f559a Make C++ archiving use action_configs instead of hardcoded flags
RELNOTES: Use action_config in crosstool for static library archiving, remove ar_flag.
PiperOrigin-RevId: 157685703
2019-01-09 08:53:14 +01:00
jfield e975b380fb Automated rollback of commit 6dbdb050cb.
*** Reason for rollback ***

b/37401971

*** Original change description ***

Make C++ archiving use action_configs instead of hardcoded flags

RELNOTES: Use action_config in crosstool for static library archiving, remove ar_flag.
PiperOrigin-RevId: 153344597
2019-01-09 08:53:04 +01:00
hlopko 6dbdb050cb Make C++ archiving use action_configs instead of hardcoded flags
RELNOTES: Use action_config in crosstool for static library archiving, remove ar_flag.
PiperOrigin-RevId: 153046587
2019-01-09 08:52:53 +01:00
Googler ad6e1ca6c5 Add a boolean flag to a Feature to specify whether it is enabled by default.
This enables us to configure default features for each toolchain without having
to hard-code anything in class such as CcCommon.

PiperOrigin-RevId: 146904287
2019-01-09 08:52:42 +01:00
Googler fe7d55ba32 RELNOTES: Allow CROSSTOOL files to have linker flags specific to static shared libraries.
PiperOrigin-RevId: 146655595
2019-01-09 08:52:30 +01:00
Googler 120d8ee3a6 Create "target_os" option to make selecting on platform possible.
This flag is not meant to be set on the commandline but to be readable from a Crosstool. This makes it so //tool/cc_target_os:android and friends don't require a hardcoded Crosstool top

PiperOrigin-RevId: 144983864
2019-01-09 08:52:19 +01:00
hlopko 2aabbef2f1 Introduce expand_if_none_available to crosstool
This feature allows us to expand a flag_group when a build variable is not
available. This is helpful when migrating crosstools in a backward compatible
way (that works with released bazel as well as with bazel at HEAD).

RELNOTES: NONE.
PiperOrigin-RevId: 143955333
2019-01-09 08:52:09 +01:00
hlopko 9cc6bd0f71 Add expand_if_equal crosstool.proto message
This will be used by LibrariesToLinkValue to switch on many different types of
libraries.

RELNOTES: NONE.
PiperOrigin-RevId: 143438434
2019-01-09 08:51:57 +01:00
hlopko 460dbed363 Introduce FlagGroup.expandIfTrue, expandIfFalse
This cl adds support for expand_if_true and expand_if_false messages
to the flag_group, allowing more elegant design of build variables.
This cl also adds IntegerValue VariableValue subclass.

RELNOTES: NONE.
PiperOrigin-RevId: 140849578
2019-01-09 08:51:46 +01:00
hlopko e355a0b91c Introduce support for 'expand_if_all_available' for flag_groups in CROSSTOOL
With the recent addition of structured variables to CROSSTOOL we now need a way
how to conditionally expand various flag_groups depending on the presence of
particular build variable or its fields. This cl adds this support to flag
groups.

RELNOTES: NONE.
PiperOrigin-RevId: 139466070
2019-01-09 08:51:35 +01:00
hlopko b987fd2ae5 Introduce structured build variables in Crosstool
This cl adds a 3rd type of build variable - structs. Structs have fields, which
can hold any build variable type (including structs). In the CROSSTOOl, the
fields are accessed by the dot-notation, e.g.:

    flag_group {
      iterate_over: "libraries_to_link
      flag_group {
        iterate_over: "libraries_to_link.libraries"
        flag: "-L%{libraries_to_link.libraries.directory}"
      }
    }

As a memory optimization, we also add StructureSequences. These save us from
the overhead of individual StructureValue objects.

RELNOTES: NONE
PiperOrigin-RevId: 138851774
2019-01-09 08:51:24 +01:00
hlopko 63defbb3ed Introduce explicit iterate_over field for flag_group in Crosstool
Now flag_group can be marked with iterate_over field, that denotes for which
sequence variable the flag_group will be expanded repeatedly. This cl does that
in backwards compatible way as before, the iteration happened implicitly when the
used variable was found to be sequence at runtime. Because of that it adds some
extra code that will be removed once all the crosstools are migrated to the
explicit iteration.

RELNOTES: NONE
PiperOrigin-RevId: 138501033
2019-01-09 08:51:13 +01:00
cpeyser acfc773682 cxx_flags are not applied to objc compiles.
PiperOrigin-RevId: 134651940
2019-01-09 08:51:02 +01:00
lberki 497b184bfb Remove support for thin archives.
RELNOTES: None.
PiperOrigin-RevId: 130938527
2019-01-09 08:50:51 +01:00
cpeyser bff90cc138 Linker outputs can optionally be configured from the CROSSTOOL. Introduces infrastructure to allow other artifact categories (such as debug symbols or compiler outputs) to be defined in other changes.
PiperOrigin-RevId: 128495797
2019-01-09 08:50:40 +01:00
dmishe 5e3e5c8d64 Remove breakpad support from bazel
PiperOrigin-RevId: 125385321
2019-01-09 08:50:29 +01:00
cpeyser c3f9f8d68f Introduces action_config. Does this by:
1) Introducing the action_config message in the crosstool protobuf definition.  The only part of that definition that are implemented in this CL is the "tool" section, other parts will be implemented in future CLs.  The proto fields are here now to avoid being delayed by release cycles at each step of the implementation.

2) Refactoring the implementation of the "feature algebra" that computes the enabled features for a given toolchain.  An interface called "CrosstoolActivatable" is used to represent any participant int the feature algebra, and can be either a feature or an action_config.

PiperOrigin-RevId: 118943663
2019-01-09 08:50:19 +01:00