bazel: incompatible_disable_legacy_crosstool_fields: Disable legacy crosstool fields
Flag: --incompatible_disable_legacy_crosstool_fields
Available since: 0.22 (January 2019 release)
Will be flipped in: 0.25 (April 2019 release)
Tracking issue: https://github.com/bazelbuild/bazel/issues/5883
Rollout doc: https://docs.google.com/document/d/1uv4c1zag6KvdI31qdx8C6jiTognXPQrxgsUpVefm9fM/edit#
Motivation
CROSSTOOL grew much bigger than it was expected in 2011 when it was first introduced. There are many fields that are no longer used (e.g. mao_plugin_header_directory
), or there are fields that are superseded by feature
s (e.g. compiler_flag
). There are fields that specify toolchain capabilities (e.g. supports_embedded_runtimes
) but cannot participate in the feature configuration (and there are user requests for these). All in all, CROSSTOOL needs a revamp, and this change achieves that.
Caveats
This is a big incompatible change, and https://github.com/bazelbuild/bazel/issues/5380 will be comparably big one. We advice users to use the migration tool provided for --incompatible_disable_legacy_crosstool_fields
as the final step of their CROSSTOOL generating pipeline, and wait with hand-tweaking for the migration tool that will be provided for https://github.com/bazelbuild/bazel/issues/5380. --incompatible_disable_legacy_crosstool_fields
will not be flipped before https://github.com/bazelbuild/bazel/issues/5380 is fixed.
Migration
Please use the legacy_fields_migrator
tool provided at rules_cc repository. To verify the correctness of your build, use the command line diffing tool provided at tools/aquery_differ
(bazel aquery, that the differ uses, is being improved daily as of January 2019, e.g. 1, so if you don’t use bazel > 0.23, we advice to build your own bazel from HEAD for testing the migrated crosstool). As mentioned above, we advice not to hand-tune the CROSSTOOL without also migrating for https://github.com/bazelbuild/bazel/issues/5380 (automated migrator to starlark will be provided).
Detailed change description
These features were previously enabled by Bazel, but they will no longer be, so they need to be enabled in the crosstool:
dependency_file
random_seed
module_maps
module_map_home_cwd
header_module_compile
include_paths
,pic
preprocessor_defines
This list contains all the legacy fields and how they will be migrated:
static_runtimes_filegroup
will not be used once https://github.com/bazelbuild/bazel/issues/6942 is flipped. Usecc_toolchain.static_runtime_lib
instead.dynamic_runtimes_filegroup
will not be used once https://github.com/bazelbuild/bazel/issues/6942 is flipped. Usecc_toolchain.dynamic_runtime_lib
instead.compiler_flag
is replaced by features. Flags fromcompiler_flag
should appear before any other legacy field, and should be passed to all compilation actions.optional_compiler_flag
is not used.cxx_flag
is replaced by features. Flags fromcxx_flag
should appear aftercompiler_flag
s, and should be passed to all compilation actions exceptc-compile
.optional_cxx_flag
is not used.unfiltered_cxx_flag
is replaced by features. Flags from feature namedunfiltered_compile_flags
are not subject to nocopts filtering.optional_unfiltered_cxx_flag
is not used.linker_flag
is replaced by features. Flags fromlinker_flag
should appear before any other legacy field, and should be passed to all linking actions (except the misnamed archiving actionc++-link-static-library
)optional_linker_flag
is not used.dynamic_library_linker_flag
is replaced by features. Flags fromdynamic_library_linker_flag
should appear afterlinker_flag
fields fromlinking_mode_flags
, and should be only present when linking dynamic libraries.optional_dynamic_library_linker_flag
is not used.test_only_linker_flag
is replaced by features.test_only_linker_flag
should appear afterdynamic_library_linker_flag
, and only for tests.objcopy_embed_flag
is replaced by features.ld_embed_flag
is replaced by features.ar_flag
is not used.ar_thin_archives_flag
is not used.gcc_plugin_compiler_flag
is not used.compilation_mode_flags
are replaced by features. Features namedopt
,dbg
, andfastbuild
are automatically enabled for given compilation mode. Flags from innercompiler_flag
should appear after top-levelcxx_flags
. Flags from innercxx_flag
should appear after innercompiler_flag
. Flags fromlinker_flag
should appear after top-levellinker_flag
fields, before flags fromlinking_mode_flags
.lipo_mode_flags
is not used.linking_mode_flags
are replaced by features. ModeCOVERAGE
is not used. ModeFULLY_STATIC
has been replaced byfully_static_link
feature and therefore unused. ModeMOSTLY_STATIC
is replaced bystatic_linking_mode
feature and modeDYNAMIC
is replaced bydynamic_linking_mode
feature. Both are enabled by rules explicitly.gcc_plugin_header_directory
is not used.mao_plugin_header_directory
is not used.default_python_top
is not used.default_python_version
is not used.python_preload_swigdeps
is not used.supports_gold_linker
is only used for--symbol_counts
and will be removed.supports_thin_archives
is not used or user.supports_start_end_lib
is replaced by feature namedsupports_start_end_lib
that should be enabled by the toolchain or user.supports_interface_shared_objects
is replaced by feature namedsupports_interface_shared_libraries
that should be enabled by the toolchain or user.supports_embedded_runtimes
is replaced by feature namedstatic_link_cpp_runtimes
that should be enabled by the toolchain or user.supports_incremental_linker
is not used.supports_normalizing_ar
is not used.supports_fission
is replaced by feature namedper_object_debug_info
that should be enabled by the toolchain or user.supports_dsym
is not used.needsPic
is replaced by feature namedsupports_pic
that should be enabled by the toolchain or user. Before Bazel always requrestedpic
feature, and verified thatpic
feature is enabled whenneedsPic
was true or when--force_pic
option was passed. With this change, Bazel will only requestsupports_pic
when--force_pic
is passed, and it verify thatsupports_pic
is enabled only when--force_pic
is passed. When--force_pic
is not passed, Bazel will not requestsupports_pic
explicitly, and it will assume that whensupports_pic
is enabled by the toolchain or user, it means PIC is needed for shared libraries.pic
andforce_pic
build variables are still passed in their corresponding configurations.
A really good place to see exactly what is migrated and how is to see the tests for legacy_fields_migrator.
Changelog
- January 3rd: Implemented cmd_line_differ
- January 7th: Bazel 0.22, which contains this flag, was cut
- January 7th: Fixed broken interface library input detection (https://github.com/bazelbuild/bazel/commit/a4529dba3b5a9fa9f7a62431f9795df52a59bbc7), this is unlikely to affect Bazel users.
- January 7th: Discovered the issue where
$EXEC_ORIGIN
is not used whenstatic_link_cpp_runtimes
is disabled, this is unlikely to affect Bazel users. If it does affect you, the fix was to addruntime_library_search_directories
to the crosstool and not relying on Bazel to patch it in. - January 11th: Open-sourced legacy_fields_migrator
- January 15th: Bazel fix to move
default_compile_flags
feature to the top of the crosstool, to stay backwards compatible. This fix does affect every user that doesn’t specifyno_legacy_features
feature. Migrator fixed accordingly. - January 17th: Migrator fix for
nodeps_dynamic_library
. - February 5th: Migrator fix to replace repeated
expand_if_(all|none)_available
with nesting (preparation for Crosstool in Starlark migration). - February 8th: Replaced
cmd_line_differ
withaquery_differ
, which is a more general aquery output diffing tool. (https://github.com/bazelbuild/bazel/commit/3575797c8cc9aa1bbb09f4c0ab11780b0b528cc9) - February 13th: Updated the migrator to auto-enable some features that were previously enabled by Bazel
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 30 (30 by maintainers)
Commits related to this issue
- Allow setting supports_start_end_lib crosstool field using feature This cl allows toolchain owners to express that toolchain supports --start-lib/--end-lib using enabled feature "supports_start_end_l... — committed to bazelbuild/bazel by hlopko 6 years ago
- Allow setting supports_interface_shared_objects crosstool field using feature This cl allows toolchain owners to express that toolchain supports creating interface shared libraries. This cl is a ste... — committed to bazelbuild/bazel by hlopko 6 years ago
- Allow setting supports_dynamic_linker crosstool capability using feature This cl allows toolchain owners to express that toolchain supports creating dynamic libraries. This is in theory a breaking c... — committed to bazelbuild/bazel by hlopko 6 years ago
- 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 ... — committed to bazelbuild/bazel by hlopko 6 years ago
- 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 tak... — committed to bazelbuild/bazel by hlopko 6 years ago
- Add --incompatible_disable_legacy_crosstool_fields Incompatible flag issue: https://github.com/bazelbuild/bazel/issues/6861 Tracking issue: https://github.com/bazelbuild/bazel/issues/5883 RELNOTES: ... — committed to bazelbuild/bazel by hlopko 6 years ago
- Do not enable random features in cc_common.configure_features This change removes some hardcoded feature names when https://github.com/bazelbuild/bazel/issues/6861 is flipped. RELNOTES: None. PiperO... — committed to bazelbuild/bazel by hlopko 6 years ago
- 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/... — committed to bazelbuild/bazel by hlopko 6 years ago
- Do not require passing legacy fields to CppActionConfigs 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/1... — committed to bazelbuild/bazel by hlopko 5 years ago
- Don't rely on supports_interface_shared_objects for toolchain inputs Progress towards: https://github.com/bazelbuild/bazel/issues/6861 https://github.com/bazelbuild/bazel/issues/5883 RELNOTES: None.... — committed to bazelbuild/bazel by hlopko 5 years ago
- Move legacy_fields_migrator to rules_cc Needed for --incompatible_disable_legacy_crosstool_fields migration: https://github.com/bazelbuild/bazel/issues/6861 Tracking issue: https://github.com/bazelbu... — committed to bazelbuild/rules_cc by hlopko 6 years ago
- 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 ... — committed to bazelbuild/rules_cc by hlopko 6 years ago
- 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 tak... — committed to bazelbuild/rules_cc by hlopko 6 years ago
- 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/... — committed to bazelbuild/rules_cc by hlopko 6 years ago
- 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... — committed to bazelbuild/rules_cc by hlopko 5 years ago
- 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:... — committed to bazelbuild/rules_cc by hlopko 5 years ago
- Do not disable static_link_cpp_runtimes when toolchain.supportsEmbeddedRuntimes is not set Before, Bazel explicitly added static_link_cpp_runtimes to disabled features, when toolchain didn't set supp... — committed to bazelbuild/bazel by hlopko 5 years ago
- Also move default_compile_flags to the top of the crosstool Currently we move legacy_compile_flags to the top of the crosstool, and the same behavior is needed for migrated crosstools in case of defa... — committed to bazelbuild/bazel by hlopko 5 years ago
- 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 i... — committed to bazelbuild/rules_cc by hlopko 5 years ago
- 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 replaci... — committed to bazelbuild/rules_cc by hlopko 5 years ago
There is the label
migration-0.22
, this means I am supposed to test this flag when I use Bazel 0.22? It fails even on trivial projects:Regarding
--all_incompatible_changes
, the flag is not perfect, but I like to use it as a rough approximation of what I shall fix. I’ll be happy to have a more precise replacement.Thanks for the additional clarifications Marcel, It does seem that
--all_incompatible_changes
is not what we need (and does not seem to make too much sense to have that option). However, I do think there is value to having some flag of the sort--all_incompatible_changes_that_are_migration_ready
so that rule owners and project owners that want to make sure that all upcoming changes will be compatible with their code can test before an upcoming release.