Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible_disable_genrule_cc_toolchain_dependency: remove genrule's implicit dependency on the cc_toolchain #6867

Closed
katre opened this issue Dec 7, 2018 · 17 comments
Assignees
Labels
incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required) team-Rules-CPP Issues for C++ rules

Comments

@katre
Copy link
Member

katre commented Dec 7, 2018

Flag: --incompatible_disable_genrule_cc_toolchain_dependency
Available since: 0.22
Will be flipped in: 0.25

Currently, every genrule target has an implicit dependency on the cc_toolchain, caused by the ":cc_toolchain" late-bound attribute. With the recent migration to using the "toolchains" attribute to setting this dependency, the only remaining use of ":cc_toolchains" is to provide the CC_FLAGS Make variable.

In order to remove this dependency, a new rule will be added, cc_flags_supplier, that exists only to make the CC_FLAGS Make variable available to other targets.

Once users have migrated to using the new rule to provide CC_FLAGS, the old behavior will be removed. Also, CcToolchainProvider will stop providing the CC_FLAGS Make variable.

Migration notes:
To migrate, add a new toolchains dependency for any genrule target that accesses CC_FLAGS.

Example old behavior:

genrule(
  name = "display_flags",
  out = ["cc_flags.log"],
  cmd = "echo $(CC_FLAGS) > $@",
  toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"],
)

New behavior:

cc_flags_supplier(name = "cc_flags")
genrule(
  name = "display_flags",
  out = ["cc_flags.log"],
  cmd = "echo $(CC_FLAGS) > $@",
  toolchains = [":cc_flags", "@bazel_tools//tools/cpp:current_cc_toolchain"],
)
@katre katre added P1 I'll work on this now. (Assignee required) team-Rules-CPP Issues for C++ rules incompatible-change Incompatible/breaking change labels Dec 7, 2018
@katre katre self-assigned this Dec 7, 2018
bazel-io pushed a commit that referenced this issue Dec 11, 2018
…dency.

Part of #6867.

Future work will tie this into the actual genrule internals.

PiperOrigin-RevId: 225032807
@hlopko
Copy link
Member

hlopko commented Jan 25, 2019

@aehlig this issue didn't have correct labels, I just added them, FYI.
@katre can you make sure this flag is mentioned in the release notes? Thanks!

@hlopko
Copy link
Member

hlopko commented Jan 25, 2019

I also edited the issue description, the flag is not present in 0.21, only in 0.22. So the flag will be flipped in 0.23.

@katre
Copy link
Member Author

katre commented Jan 25, 2019

Thanks, I'll take care of the release notes.

@katre
Copy link
Member Author

katre commented Jan 25, 2019

Added the link to the release notes for 0.22, let me know if more detail is needed.

@philwo
Copy link
Member

philwo commented Feb 6, 2019

This flag was not flipped in time for the Bazel 0.23.0 release and will thus be postponed to Bazel 0.24.0.

@scottmin0r
Copy link

This flag doesn't appear in the output of bazel help build - should it?

Output of bazel help build | grep 'incompatible_disable_':

  --[no]incompatible_disable_expand_if_all_available_in_flag_set (a boolean; default: "false")
  --[no]incompatible_disable_legacy_crosstool_fields (a boolean; default: "false")
  --[no]incompatible_disable_runtimes_filegroups (a boolean; default: "false")
  --[no]incompatible_disable_deprecated_attr_params (a boolean; default: "false")
  --[no]incompatible_disable_objc_provider_resources (a boolean; default: "false")

Output of bazel help build | grep 'incompatible_disable_genrule':

<empty>

Output of bazel version:

Build label: 0.22.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Jan 28 12:58:08 2019 (1548680288)
Build timestamp: 1548680288
Build timestamp as int: 1548680288

@katre
Copy link
Member Author

katre commented Feb 6, 2019

I can change it to be documented, but not sure that can be added to the 0.23 release. I'm not really sure it's needed: it's a migration flag to help test the requirement to use @bazel_tools//tools/cpp:cc_flags instead of automatically getting $(CC_FLAGS).

@dslomov
Copy link
Contributor

dslomov commented Mar 6, 2019

Why did you remove migration-0.23 and migration-0.22 labels?

@katre
Copy link
Member Author

katre commented Mar 6, 2019

Because I misunderstood the directions. Trying to fix issues now.

@meteorcloudy
Copy link
Member

TensorFlow still needs migration for this flag. The reason is one of its dependency doesn't work anymore.

$ bazel build --nobuild --config=opt tensorflow/tools/pip_package:build_pip_package --incompatible_disable_legacy_cc_provider --incompatible_disable_genrule_cc_toolchain_dependency
INFO: Build option --incompatible_disable_genrule_cc_toolchain_dependency has changed, discarding analysis cache.
ERROR: /usr/local/google/home/pcloudy/.cache/bazel/_bazel_pcloudy/d2f15366e3b15100d3593f2d595721a3/external/com_github_googlecloudplatform_google_cloud_cpp/google/cloud/BUILD:31:11: in cmd attribute of genrule rule @com_github_googlecloudplatform_google_cloud_cpp//google/cloud:generate_build_info: $(CC) not defined
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: Analysis of target '@com_github_googlecloudplatform_google_cloud_cpp//google/cloud:generate_build_info' failed; build aborted

To reproduce

git clone https://github.com/googleapis/google-cloud-cpp.git
cd google-cloud-cpp/
bazel build //google/cloud:generate_build_info  --incompatible_disable_genrule_cc_toolchain_dependency

@katre
Copy link
Member Author

katre commented Mar 28, 2019

Yes, I am working to upgrade google-cloud-cpp (internal change not exported yet). Once that is done and they release I will update TF.

@katre
Copy link
Member Author

katre commented Mar 28, 2019

Unfortunately I think this means I can't flip this flag before 0.25 is cut, unless the process goes surprisingly fast in the next day or so.

@meteorcloudy
Copy link
Member

Thanks for doing the fix!

@hlopko
Copy link
Member

hlopko commented Mar 28, 2019

I wouldn't dismiss the option of disabling TF on downstream for a few days and flip this flag tomorrow. We know they will be migrated, we have the fix, so there is no risk of unforseen bugs.

I'd take this option :) And @meteorcloudy said he'd be fine with it too.

@katre
Copy link
Member Author

katre commented Mar 29, 2019

Re-opening until the flag is verified and the code is removed.

@katre katre reopened this Mar 29, 2019
@katre
Copy link
Member Author

katre commented Apr 3, 2019

Re-closing because I still don't understand the incompatible flag workflow.

@katre katre closed this as completed Apr 3, 2019
bazel-io pushed a commit that referenced this issue May 1, 2019
Baseline: 0366246

Cherry picks:

   + 3f7f255:
     Windows: fix native test wrapper's arg. escaping
   + afeb8d0:
     Flip --incompatible_windows_escape_jvm_flags
   + 4299b65:
     Sort DirectoryNode children to ensure validity.
   + 231270c:
     Conditionally use deprecated signature for initWithContentsOfURL
   + 75a3a53:
     Add http_archive entries for testing with various JDK versions.
   + 4a6354a:
     Now that ubuntu1804 uses JDK 11, remove explicit
     ubuntu1804_java11 tests.
   + ae102fb:
     Fix wrong name of ubuntu1804_javabase9 task.
   + 0020a97:
     Remove @executable_path/Frameworks from rpaths
   + 130f86d:
     Download stderr/stdout to a temporary FileOutErr

Incompatible changes:

  - (Starlark rules) The legacy "py" provider can no longer be passed
    to or produced by native Python rules; use
    [PyInfo](https://docs.bazel.build/versions/master/skylark/lib/PyIn
    fo.html) instead. See
    [#7298](#7298) for more
    information.
  - (Python rules) The `default_python_version` attribute of the
    `py_binary` and `py_test` rules has been renamed to
    `python_version`. Also, the `--force_python` flag has been
    renamed to `--python_version`. See
    [#7308](#7308) for more
    information.
  - (Python rules) The python version now changes to whatever version
    is specified in a `py_binary` or `py_test`'s `python_version`
    attribute, instead of being forced to the value set by a command
    line flag. You can temporarily revert this change with
    `--incompatible_allow_python_version_transitions=false`. See
    [#7307](#7307) for more
    information.
  - --incompatible_disable_third_party_license_checking` is enabled
    by default
  - Introduced --incompatible_use_python_toolchains, which supersedes
    --python_top/--python_path. See #7899 and #7375 for more
    information.
  - Python 3 is now the default Python version (for `py_binary` and
    `py_test` targets that don't specify the `python_version`
    attribute). Targets that are built for Python 3 will no longer
    have their output put in a separate `-py3` directory; instead
    there is now a separate `-py2` directory for Python 2 targets.
    See #7359 and #7593 for more information.
  - objc_library resource attributes are now disabled by default.
    Please migrate them to data instead. See
    #7594 for more info.
  - Flip --incompatible_windows_escape_jvm_flags to true. See
    #7486

New features:

  - genrules now support a $(RULEDIR) variable that resolves to the
    directory where the outputs of the rule are put.
  - Added --incompatible_windows_native_test_wrapper flag: enables
    using the Bash-less test wrapper on Windows. (No-op on other
    platforms.)

Important changes:

  - incompatible_use_jdk11_as_host_javabase: makes JDK 11 the default
    --host_javabase for remote jdk
    (#7219)
  - Makes genquery somepath output deterministic.
  - Tristate attributes of native rules now reject True/False (use
    1/0)
  - Rollback of "Tristate attributes of native rules now reject
    True/False (use 1/0)"
  - Tristate attributes of native rules now reject True/False (use
    1/0)
  - Added -incompatible_do_not_split_linking_cmdline flag. See #7670
  - Tristate attributes of native rules now temporarily accept
    True/False again
  - `--incompatible_disable_legacy_crosstool_fields` has been flipped
    (#6861)
    `--incompatible_disable_expand_if_all_available_in_flag_set` has
    been flipped (#7008)
  - `--incompatible_disable_legacy_crosstool_fields` has been flipped
    (#6861)
    `--incompatible_disable_expand_if_all_available_in_flag_set...
    RELNOTES: None.
  - --incompatible_no_transitive_loads is enabled by default.
  - Makes TreeArtifact deterministic.
  - --incompatible_no_transitive_loads is enabled by default.
  - Android NDK C++ toolchain is now configured in Starlark. This
    should be a backwards compatible change, but in case of bugs
    blame unknown commit.
  - `--incompatible_disable_legacy_crosstool_fields` has been flipped
    (#6861)
    `--incompatible_disable_expand_if_all_available_in_flag_set` has
    been flipped (#7008)
  - --incompatible_no_transitive_loads is enabled by default.
  - --incompatible_bzl_disallow_load_after_statement is enabled
  - Added `--incompatible_require_ctx_in_configure_features`, see
    #7793 for details.
  - Flag --incompatible_merge_genfiles_directory is flipped. This
    removes the directory `bazel-genfiles` in favor of `bazel-bin`.
  - previously deprecated flag --experimental_remote_spawn_cache was
    removed
  - `--incompatible_disallow_load_labels_to_cross_package_boundaries`
    is enabled by default
  - Fix an issue where the Android resource processor did not surface
    errors from aapt2 compile and link actions.
  - --incompatible_no_attr_license is enabled by default
  - `--incompatible_disable_crosstool_file` has been flipped
    (#7320)
  - A new flag `--incompatible_string_join_requires_strings` is
    introduced. The sequence argument of `string.join` must contain
    only string elements.
  - --incompatible_symlinked_sandbox_expands_tree_artifacts_in_runfile
    s_tree has been flipped
  - Incompatible flag `--incompatible_disable_legacy_cc_provider` has
    been flipped (see #7036
    for details).
  - Don't drop the analysis cache when the same --define flag is set
    multiple times and the last value is the same (e.g. if the
    current invocation was run with "--define foo=bar" and the
    previous one was run with "--define foo=baz --define foo=bar").
  - The --incompatible_disable_genrule_cc_toolchain_dependency flag
    has been flipped (see
    #6867 for details).
  - Incompatible change
    `--incompatible_remove_cpu_and_compiler_attributes_from_cc_toolcha
    in` has been flipped (see
    #7075 for details).
  - --noexperimental_java_coverage is a no-op flag.
  - --experimental_java_coverage/--incompatible_java_coverage flag was
    removed. See #7425.
  - incompatible_use_toolchain_providers_in_java_common: pass
    JavaToolchainInfo and JavaRuntimeInfo providers to java_common
    APIs instead of configured targets
    (#7186.)
  - --incompatible_remote_symlinks has been flipped. The remote
    caching and execution protocol will now represent symlinks in
    outputs as such. See
    #7917 for more details.
  - Bazel is now ~20MiB smaller, from unbundling the Android rules'
    runtime dependencies.

This release contains contributions from many people at Google, as well as Andreas Herrmann, Andrew Suffield, Andy Scott, Benjamin Peterson, Ed Baunton, George Gensure, Ian McGinnis, Ity Kaul, Jingwen Chen, John Millikin, Keith Smiley, Marwan Tammam, Mike Fourie, Oscar Bonilla, perwestling, petros, Robert Sayre, Ryan Beasley, silvergasp, Stanimir Mladenov, Travis Cline, Vladimir Chebotarev, ??.
dkelmer pushed a commit that referenced this issue May 6, 2019
Baseline: 0366246

Cherry picks:

   + 3f7f255:
     Windows: fix native test wrapper's arg. escaping
   + afeb8d0:
     Flip --incompatible_windows_escape_jvm_flags
   + 4299b65:
     Sort DirectoryNode children to ensure validity.
   + 231270c:
     Conditionally use deprecated signature for initWithContentsOfURL
   + 75a3a53:
     Add http_archive entries for testing with various JDK versions.
   + 4a6354a:
     Now that ubuntu1804 uses JDK 11, remove explicit
     ubuntu1804_java11 tests.
   + ae102fb:
     Fix wrong name of ubuntu1804_javabase9 task.
   + 0020a97:
     Remove @executable_path/Frameworks from rpaths
   + 130f86d:
     Download stderr/stdout to a temporary FileOutErr

Incompatible changes:

  - (Starlark rules) The legacy "py" provider can no longer be passed
    to or produced by native Python rules; use
    [PyInfo](https://docs.bazel.build/versions/master/skylark/lib/PyIn
    fo.html) instead. See
    [#7298](#7298) for more
    information.
  - (Python rules) The `default_python_version` attribute of the
    `py_binary` and `py_test` rules has been renamed to
    `python_version`. Also, the `--force_python` flag has been
    renamed to `--python_version`. See
    [#7308](#7308) for more
    information.
  - (Python rules) The python version now changes to whatever version
    is specified in a `py_binary` or `py_test`'s `python_version`
    attribute, instead of being forced to the value set by a command
    line flag. You can temporarily revert this change with
    `--incompatible_allow_python_version_transitions=false`. See
    [#7307](#7307) for more
    information.
  - --incompatible_disable_third_party_license_checking` is enabled
    by default
  - Introduced --incompatible_use_python_toolchains, which supersedes
    --python_top/--python_path. See #7899 and #7375 for more
    information.
  - Python 3 is now the default Python version (for `py_binary` and
    `py_test` targets that don't specify the `python_version`
    attribute). Targets that are built for Python 3 will no longer
    have their output put in a separate `-py3` directory; instead
    there is now a separate `-py2` directory for Python 2 targets.
    See #7359 and #7593 for more information.
  - objc_library resource attributes are now disabled by default.
    Please migrate them to data instead. See
    #7594 for more info.
  - Flip --incompatible_windows_escape_jvm_flags to true. See
    #7486

New features:

  - genrules now support a $(RULEDIR) variable that resolves to the
    directory where the outputs of the rule are put.
  - Added --incompatible_windows_native_test_wrapper flag: enables
    using the Bash-less test wrapper on Windows. (No-op on other
    platforms.)

Important changes:

  - incompatible_use_jdk11_as_host_javabase: makes JDK 11 the default
    --host_javabase for remote jdk
    (#7219)
  - Makes genquery somepath output deterministic.
  - Tristate attributes of native rules now reject True/False (use
    1/0)
  - Rollback of "Tristate attributes of native rules now reject
    True/False (use 1/0)"
  - Tristate attributes of native rules now reject True/False (use
    1/0)
  - Added -incompatible_do_not_split_linking_cmdline flag. See #7670
  - Tristate attributes of native rules now temporarily accept
    True/False again
  - `--incompatible_disable_legacy_crosstool_fields` has been flipped
    (#6861)
    `--incompatible_disable_expand_if_all_available_in_flag_set` has
    been flipped (#7008)
  - `--incompatible_disable_legacy_crosstool_fields` has been flipped
    (#6861)
    `--incompatible_disable_expand_if_all_available_in_flag_set...
    RELNOTES: None.
  - --incompatible_no_transitive_loads is enabled by default.
  - Makes TreeArtifact deterministic.
  - --incompatible_no_transitive_loads is enabled by default.
  - Android NDK C++ toolchain is now configured in Starlark. This
    should be a backwards compatible change, but in case of bugs
    blame unknown commit.
  - `--incompatible_disable_legacy_crosstool_fields` has been flipped
    (#6861)
    `--incompatible_disable_expand_if_all_available_in_flag_set` has
    been flipped (#7008)
  - --incompatible_no_transitive_loads is enabled by default.
  - --incompatible_bzl_disallow_load_after_statement is enabled
  - Added `--incompatible_require_ctx_in_configure_features`, see
    #7793 for details.
  - Flag --incompatible_merge_genfiles_directory is flipped. This
    removes the directory `bazel-genfiles` in favor of `bazel-bin`.
  - previously deprecated flag --experimental_remote_spawn_cache was
    removed
  - `--incompatible_disallow_load_labels_to_cross_package_boundaries`
    is enabled by default
  - Fix an issue where the Android resource processor did not surface
    errors from aapt2 compile and link actions.
  - --incompatible_no_attr_license is enabled by default
  - `--incompatible_disable_crosstool_file` has been flipped
    (#7320)
  - A new flag `--incompatible_string_join_requires_strings` is
    introduced. The sequence argument of `string.join` must contain
    only string elements.
  - --incompatible_symlinked_sandbox_expands_tree_artifacts_in_runfile
    s_tree has been flipped
  - Incompatible flag `--incompatible_disable_legacy_cc_provider` has
    been flipped (see #7036
    for details).
  - Don't drop the analysis cache when the same --define flag is set
    multiple times and the last value is the same (e.g. if the
    current invocation was run with "--define foo=bar" and the
    previous one was run with "--define foo=baz --define foo=bar").
  - The --incompatible_disable_genrule_cc_toolchain_dependency flag
    has been flipped (see
    #6867 for details).
  - Incompatible change
    `--incompatible_remove_cpu_and_compiler_attributes_from_cc_toolcha
    in` has been flipped (see
    #7075 for details).
  - --noexperimental_java_coverage is a no-op flag.
  - --experimental_java_coverage/--incompatible_java_coverage flag was
    removed. See #7425.
  - incompatible_use_toolchain_providers_in_java_common: pass
    JavaToolchainInfo and JavaRuntimeInfo providers to java_common
    APIs instead of configured targets
    (#7186.)
  - --incompatible_remote_symlinks has been flipped. The remote
    caching and execution protocol will now represent symlinks in
    outputs as such. See
    #7917 for more details.
  - Bazel is now ~20MiB smaller, from unbundling the Android rules'
    runtime dependencies.

This release contains contributions from many people at Google, as well as Andreas Herrmann, Andrew Suffield, Andy Scott, Benjamin Peterson, Ed Baunton, George Gensure, Ian McGinnis, Ity Kaul, Jingwen Chen, John Millikin, Keith Smiley, Marwan Tammam, Mike Fourie, Oscar Bonilla, perwestling, petros, Robert Sayre, Ryan Beasley, silvergasp, Stanimir Mladenov, Travis Cline, Vladimir Chebotarev, ??.
aherrmann-da pushed a commit to digital-asset/daml that referenced this issue May 17, 2019
guibou added a commit to tweag/rules_haskell that referenced this issue Jun 25, 2019
guibou added a commit to tweag/rules_haskell that referenced this issue Jun 26, 2019
guibou added a commit to tweag/rules_haskell that referenced this issue Jun 26, 2019
guibou added a commit to tweag/rules_haskell that referenced this issue Jun 26, 2019
guibou added a commit to tweag/rules_haskell that referenced this issue Jun 26, 2019
guibou added a commit to tweag/rules_haskell that referenced this issue Jun 26, 2019
guibou added a commit to tweag/rules_haskell that referenced this issue Jun 27, 2019
luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
…ain_dependency

    Flip --incompatible_disable_genrule_cc_toolchain_dependency flag.

    Fixes bazelbuild/bazel#6867.

    Removes and updates several tests of the old behavior.

    RELNOTES: The --incompatible_disable_genrule_cc_toolchain_dependency flag has been flipped (see bazelbuild/bazel#6867 for details).

    Closes #7878.

    PiperOrigin-RevId: 240993385
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required) team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

No branches or pull requests

6 participants