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

0.25 gratuitously breaks cc_common.compile/link #8226

Closed
shahms opened this issue May 2, 2019 · 18 comments
Closed

0.25 gratuitously breaks cc_common.compile/link #8226

shahms opened this issue May 2, 2019 · 18 comments
Assignees
Labels
breakage P1 I'll work on this now. (Assignee required) team-Rules-CPP Issues for C++ rules

Comments

@shahms
Copy link

shahms commented May 2, 2019

Description of the problem / feature request:

Commit 976876d changed the API for cc_common.compile and cc_common.link in a backwards incompatible way (fine), but also entirely removed the implementation. This would be sort of fine had that deleted implementation not persisted into a release version, but it has done so.

This has broken a number of Kythe tests with no recourse but to blacklist 0.25.

Feature requests: what underlying problem are you trying to solve with this feature?

Not gratuitously breaking users of older in-the-progress-of-changing APIs with no recourse but to blacklist that release.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Take a previously working use of the old API (say https://github.com/kythe/kythe/blob/8cd2434b921b32bc2f941431c563cfabc6b384f9/tools/build_rules/verifier_test/cc_indexer_test.bzl#L152) and update it to the new API. Watch as the rule fails with:

method invocation returned None, please file a bug report: compile(actions for<aspect context for /..., <13 more arguments>)

What operating system are you running Bazel on?

Debian GNU/Linux rodete

What's the output of bazel info release?

release 0.25.0

Have you found anything relevant by searching the web?

Yes, I found the commit which broke things.

@oquenchil
Copy link
Contributor

oquenchil commented May 3, 2019

Hi Shams,

this was under an experimental flag and was never supported. Unfortunately, from what I can see there was a bug in the flag implementation that let you use this in aspects. To fix it, change:

    compile_protos_cc_info = cc_common.compile(
        ctx = ctx,
        cc_toolchain = cc_toolchain,
        srcs = sources,
        hdrs = headers,
        feature_configuration = feature_configuration,
        compilation_contexts = [provider.compilation_context for provider in cc_info_providers],
    )
    linking_info = cc_common.link(
        ctx = ctx,
        cc_toolchain = cc_toolchain,
        cc_compilation_outputs = compile_protos_cc_info.cc_compilation_outputs,
        feature_configuration = feature_configuration,
        linking_contexts = [provider.linking_context for provider in cc_info_providers],
    )

to:

    (compilation_context, compilation_outputs) = cc_common.compile(
        actions = ctx.actions,
        cc_toolchain = cc_toolchain,
        srcs = sources,
        public_hdrs = headers,
        feature_configuration = feature_configuration,
        compilation_contexts = [provider.compilation_context for provider in cc_info_providers],
    )
    (linking_context, linking_outputs) = cc_common.link(
        actions = ctx.actions,
        cc_toolchain = cc_toolchain,
        compilation_outputs = compilation_outputs,
        feature_configuration = feature_configuration,
        linking_contexts = [provider.linking_context for provider in cc_info_providers],
   )

0.25 still has the whitelisting and there are some bugs. But that example in particular should be fine. You will have to pass the flag --experimental_cc_skylark_api_enabled_packages followed by any packages that you want to allow this in.

This is easy to change and we won't be delaying the release because of this.

@oquenchil oquenchil reopened this May 3, 2019
@shahms
Copy link
Author

shahms commented May 3, 2019

--experimental_cc_skylark_api_enabled_packages does not help because the functions do not have an implementation any more. It is not a matter of being properly whitelisted or the flag being implemented properly.

@oquenchil
Copy link
Contributor

The functions do exist with a different signature. See my reply above.

@shahms
Copy link
Author

shahms commented May 3, 2019

Yes, making those changes and passing the command line argument results in:
method invocation returned None, please file a bug report: compile(actions for<aspect context for /..., <13 more arguments>)

@shahms
Copy link
Author

shahms commented May 3, 2019

Because the body of the function being invoked consists of return null;

@shahms
Copy link
Author

shahms commented May 3, 2019

(For the record, the changes in your reply had all ready been attempted prior to filing the bug, hence the "method invocation returned None" in the original bug description)

@oquenchil
Copy link
Contributor

I see, you are right. Those API methods were not supposed to be usable in Bazel at all, they were experimental. I'm sorry you were bit by this. I'm afraid you will have to wait for the next release.

@shahms
Copy link
Author

shahms commented May 3, 2019

Intentional or not, they have been available since at least 0.22 and not documented as requiring any flag for use (or even marked experimental): https://docs.bazel.build/versions/0.22.0/skylark/lib/cc_common.html#compile

While we've come to accept Bazel's inherent instability at this stage of development, the wholesale removal of documented, working (if deprecated) APIs with no warning or compatibility is unprecedented so far and downright hostile.

@oquenchil
Copy link
Contributor

The flag was there. As I said this was due to a bug. You didn't see the error message when trying this from a rule and not an aspect?

@shahms
Copy link
Author

shahms commented May 3, 2019

I don't doubt that the flag was there but the flag, unlike the API itself, is never mentioned in any documentation. As we only ever had need of the cc_common utilities outside of an aspect we never attempted to use them from a rule.

@dkelmer
Copy link
Contributor

dkelmer commented May 3, 2019

hey @shahms, we're working on creating a patch release to fix this issue, hang tight :)

@kamahen
Copy link

kamahen commented May 3, 2019

It appears that 0.24.1 has been removed from the PPA ... could you at least restore that, please? (My apt-fu isn't good, so I might have missed something; but apt list -a bazel shows only 0.25.0; apt-cache shows something similar.)

@dkelmer
Copy link
Contributor

dkelmer commented May 3, 2019

@kamahen, this is a known issue. Feel free to ping #4947 or #6824

@haberman
Copy link
Contributor

haberman commented May 6, 2019

I also got the method invocation returned None error above, and I can't figure out how to work around it.

I tried reducing it to a minimal test case and got the same crash even when using it from a rule instead of an aspect:

#build_defs.bzl
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")

def _foo_rule_impl(ctx):
    src = ctx.new_file(ctx.genfiles_dir, "foo.c")
    hdr = ctx.new_file(ctx.genfiles_dir, "foo.h")
    toolchain = find_cpp_toolchain(ctx)
    feature_configuration = cc_common.configure_features(
        cc_toolchain = toolchain,
        requested_features = ctx.features,
        unsupported_features = ctx.disabled_features,
    )
    (compilation_context, compilation_outputs) = cc_common.compile(
        actions = ctx.actions,
        name = "foo",
        feature_configuration = feature_configuration,
        cc_toolchain = toolchain,
        srcs = [src],
        public_hdrs = [hdr],
        compilation_contexts = [],
    )
    return []

foo_rule = rule(
    output_to_genfiles = True,
    implementation = _foo_rule_impl,
    attrs = {
        "_cc_toolchain": attr.label(default = "@bazel_tools//tools/cpp:current_cc_toolchain"),
        "deps": attr.label_list(),
    },
)


# WORKSPACE
workspace(name = "foo_project")  

# BUILD
load(":build_defs.bzl", "foo_rule")

foo_rule(name = "foo") 

Output:

method invocation returned None, please file a bug report: compile(actions for<rule context for //:..., <13 more arguments>)

Will the patch release fix this issue also?

@lberki lberki added the P1 I'll work on this now. (Assignee required) label May 6, 2019
bazel-io pushed a commit that referenced this issue May 7, 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
   + 2ab3866:
     Release 0.25.0 (2019-05-01)
   + ed48a4a5fddbd93b057c3aa726e15720d79dcf8f:
     Add implementation to removed methods to address
     #8226
   + 81aefe7:
     Remove unsupported cpu attribute from cc_toolchains.

Adding a commit which reintroduces the implementation for cc_common.compile and cc_common.link #8226
@kamahen
Copy link

kamahen commented May 7, 2019

Part of the problem is that there are some "experimental" flags that are widely used and unlikely to disappear; for example, ----experimental_action_listener.

@hlopko
Copy link
Member

hlopko commented May 8, 2019

(unrelated to the issue at hand)

@kamahen: Experimental flags that are widely used are a problem. https://docs.bazel.build/versions/master/backward-compatibility.html is very clear that:

...
6) APIs and behavior guarded by an --experimental_* flag can change at any time.
7) Users should never run their production builds with --experimental_* or --incompatible_* flags.

And Bazel team follows this policy, very likely to your disadvantage. Therefore the right procedure is to work with the experimental flag owner to stabilize the behavior and remove the flag.

@hlopko
Copy link
Member

hlopko commented May 9, 2019

It seems this issue can be closed now that 0.25.1 with the fix is already released?

@shahms
Copy link
Author

shahms commented May 9, 2019

Yeah, I've migrated Kythe for the relevant changes and that part works. Currently fighting some unrelated JDK issues.

@shahms shahms closed this as completed May 9, 2019
dkelmer pushed a commit that referenced this issue May 10, 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
   + 2ab3866:
     Release 0.25.0 (2019-05-01)
   + ed48a4a5fddbd93b057c3aa726e15720d79dcf8f:
     Add implementation to removed methods to address
     #8226
   + 81aefe7:
     Remove unsupported cpu attribute from cc_toolchains.

Adding a commit which reintroduces the implementation for cc_common.compile and cc_common.link #8226
bazel-io pushed a commit that referenced this issue May 10, 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
   + 2ab3866:
     Release 0.25.0 (2019-05-01)
   + ed48a4a5fddbd93b057c3aa726e15720d79dcf8f:
     Add implementation to removed methods to address
     #8226
   + 81aefe7:
     Remove unsupported cpu attribute from cc_toolchains.
   + cccced1:
     Release 0.25.1 (2019-05-07)
   + 0900660d67b53a56a13d1fa16a788e4cecbb1c0e:
     Use package identifier instead of package name
   + 85a5a2b:
     Configure @androidsdk//:emulator_x86 and :emulator_arm to point
     to the unified emulator binary

* Add fix for #8254
* Add fix for #8280
bung-wg2 pushed a commit to bung-wg2/bazel that referenced this issue May 15, 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
   + 2ab3866:
     Release 0.25.0 (2019-05-01)
   + ed48a4a5fddbd93b057c3aa726e15720d79dcf8f:
     Add implementation to removed methods to address
     bazelbuild#8226
   + 81aefe7:
     Remove unsupported cpu attribute from cc_toolchains.
   + cccced1:
     Release 0.25.1 (2019-05-07)
   + 0900660d67b53a56a13d1fa16a788e4cecbb1c0e:
     Use package identifier instead of package name
   + 85a5a2b:
     Configure @androidsdk//:emulator_x86 and :emulator_arm to point
     to the unified emulator binary

* Add fix for bazelbuild#8254
* Add fix for bazelbuild#8280
bazel-io pushed a commit that referenced this issue May 23, 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
   + 2ab3866:
     Release 0.25.0 (2019-05-01)
   + ed48a4a5fddbd93b057c3aa726e15720d79dcf8f:
     Add implementation to removed methods to address
     #8226
   + 81aefe7:
     Remove unsupported cpu attribute from cc_toolchains.
   + cccced1:
     Release 0.25.1 (2019-05-07)
   + 0900660d67b53a56a13d1fa16a788e4cecbb1c0e:
     Use package identifier instead of package name
   + 85a5a2b:
     Configure @androidsdk//:emulator_x86 and :emulator_arm to point
     to the unified emulator binary
   + 6549ac5:
     Release 0.25.2 (2019-05-10)
   + 0ff19c6:
     Fix StandaloneTestStrategy.appendStderr

Incompatible changes:

  - Flip --incompatible_windows_escape_jvm_flags to true. See
    #7486

This release contains contributions from many people at Google, as well as George Gensure, Keith Smiley, Robert Sayre.
irengrig pushed a commit to irengrig/bazel that referenced this issue Jun 18, 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
   + 2ab3866:
     Release 0.25.0 (2019-05-01)
   + ed48a4a5fddbd93b057c3aa726e15720d79dcf8f:
     Add implementation to removed methods to address
     bazelbuild#8226
   + 81aefe7:
     Remove unsupported cpu attribute from cc_toolchains.
   + cccced1:
     Release 0.25.1 (2019-05-07)
   + 0900660d67b53a56a13d1fa16a788e4cecbb1c0e:
     Use package identifier instead of package name
   + 85a5a2b:
     Configure @androidsdk//:emulator_x86 and :emulator_arm to point
     to the unified emulator binary

* Add fix for bazelbuild#8254
* Add fix for bazelbuild#8280
irengrig pushed a commit to irengrig/bazel that referenced this issue Jun 18, 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
   + 2ab3866:
     Release 0.25.0 (2019-05-01)
   + ed48a4a5fddbd93b057c3aa726e15720d79dcf8f:
     Add implementation to removed methods to address
     bazelbuild#8226
   + 81aefe7:
     Remove unsupported cpu attribute from cc_toolchains.
   + cccced1:
     Release 0.25.1 (2019-05-07)
   + 0900660d67b53a56a13d1fa16a788e4cecbb1c0e:
     Use package identifier instead of package name
   + 85a5a2b:
     Configure @androidsdk//:emulator_x86 and :emulator_arm to point
     to the unified emulator binary
   + 6549ac5:
     Release 0.25.2 (2019-05-10)
   + 0ff19c6:
     Fix StandaloneTestStrategy.appendStderr

Incompatible changes:

  - Flip --incompatible_windows_escape_jvm_flags to true. See
    bazelbuild#7486

This release contains contributions from many people at Google, as well as George Gensure, Keith Smiley, Robert Sayre.
irengrig pushed a commit to irengrig/bazel that referenced this issue Jul 15, 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
   + 2ab3866:
     Release 0.25.0 (2019-05-01)
   + ed48a4a5fddbd93b057c3aa726e15720d79dcf8f:
     Add implementation to removed methods to address
     bazelbuild#8226
   + 81aefe7:
     Remove unsupported cpu attribute from cc_toolchains.
   + cccced1:
     Release 0.25.1 (2019-05-07)
   + 0900660d67b53a56a13d1fa16a788e4cecbb1c0e:
     Use package identifier instead of package name
   + 85a5a2b:
     Configure @androidsdk//:emulator_x86 and :emulator_arm to point
     to the unified emulator binary
   + 6549ac5:
     Release 0.25.2 (2019-05-10)
   + 0ff19c6:
     Fix StandaloneTestStrategy.appendStderr

Incompatible changes:

  - Flip --incompatible_windows_escape_jvm_flags to true. See
    bazelbuild#7486

This release contains contributions from many people at Google, as well as George Gensure, Keith Smiley, Robert Sayre.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakage 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

8 participants