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 features (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_filerandom_seedmodule_mapsmodule_map_home_cwdheader_module_compileinclude_paths,picpreprocessor_defines
This list contains all the legacy fields and how they will be migrated:
static_runtimes_filegroupwill not be used once https://github.com/bazelbuild/bazel/issues/6942 is flipped. Usecc_toolchain.static_runtime_libinstead.dynamic_runtimes_filegroupwill not be used once https://github.com/bazelbuild/bazel/issues/6942 is flipped. Usecc_toolchain.dynamic_runtime_libinstead.compiler_flagis replaced by features. Flags fromcompiler_flagshould appear before any other legacy field, and should be passed to all compilation actions.optional_compiler_flagis not used.cxx_flagis replaced by features. Flags fromcxx_flagshould appear aftercompiler_flags, and should be passed to all compilation actions exceptc-compile.optional_cxx_flagis not used.unfiltered_cxx_flagis replaced by features. Flags from feature namedunfiltered_compile_flagsare not subject to nocopts filtering.optional_unfiltered_cxx_flagis not used.linker_flagis replaced by features. Flags fromlinker_flagshould appear before any other legacy field, and should be passed to all linking actions (except the misnamed archiving actionc++-link-static-library)optional_linker_flagis not used.dynamic_library_linker_flagis replaced by features. Flags fromdynamic_library_linker_flagshould appear afterlinker_flagfields fromlinking_mode_flags, and should be only present when linking dynamic libraries.optional_dynamic_library_linker_flagis not used.test_only_linker_flagis replaced by features.test_only_linker_flagshould appear afterdynamic_library_linker_flag, and only for tests.objcopy_embed_flagis replaced by features.ld_embed_flagis replaced by features.ar_flagis not used.ar_thin_archives_flagis not used.gcc_plugin_compiler_flagis not used.compilation_mode_flagsare replaced by features. Features namedopt,dbg, andfastbuildare automatically enabled for given compilation mode. Flags from innercompiler_flagshould appear after top-levelcxx_flags. Flags from innercxx_flagshould appear after innercompiler_flag. Flags fromlinker_flagshould appear after top-levellinker_flagfields, before flags fromlinking_mode_flags.lipo_mode_flagsis not used.linking_mode_flagsare replaced by features. ModeCOVERAGEis not used. ModeFULLY_STATIChas been replaced byfully_static_linkfeature and therefore unused. ModeMOSTLY_STATICis replaced bystatic_linking_modefeature and modeDYNAMICis replaced bydynamic_linking_modefeature. Both are enabled by rules explicitly.gcc_plugin_header_directoryis not used.mao_plugin_header_directoryis not used.default_python_topis not used.default_python_versionis not used.python_preload_swigdepsis not used.supports_gold_linkeris only used for--symbol_countsand will be removed.supports_thin_archivesis not used or user.supports_start_end_libis replaced by feature namedsupports_start_end_libthat should be enabled by the toolchain or user.supports_interface_shared_objectsis replaced by feature namedsupports_interface_shared_librariesthat should be enabled by the toolchain or user.supports_embedded_runtimesis replaced by feature namedstatic_link_cpp_runtimesthat should be enabled by the toolchain or user.supports_incremental_linkeris not used.supports_normalizing_aris not used.supports_fissionis replaced by feature namedper_object_debug_infothat should be enabled by the toolchain or user.supports_dsymis not used.needsPicis replaced by feature namedsupports_picthat should be enabled by the toolchain or user. Before Bazel always requrestedpicfeature, and verified thatpicfeature is enabled whenneedsPicwas true or when--force_picoption was passed. With this change, Bazel will only requestsupports_picwhen--force_picis passed, and it verify thatsupports_picis enabled only when--force_picis passed. When--force_picis not passed, Bazel will not requestsupports_picexplicitly, and it will assume that whensupports_picis enabled by the toolchain or user, it means PIC is needed for shared libraries.picandforce_picbuild 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_ORIGINis not used whenstatic_link_cpp_runtimesis disabled, this is unlikely to affect Bazel users. If it does affect you, the fix was to addruntime_library_search_directoriesto 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_flagsfeature to the top of the crosstool, to stay backwards compatible. This fix does affect every user that doesn’t specifyno_legacy_featuresfeature. Migrator fixed accordingly. - January 17th: Migrator fix for
nodeps_dynamic_library. - February 5th: Migrator fix to replace repeated
expand_if_(all|none)_availablewith nesting (preparation for Crosstool in Starlark migration). - February 8th: Replaced
cmd_line_differwithaquery_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_changesis 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_readyso 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.