-
Notifications
You must be signed in to change notification settings - Fork 541
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
Not able to cross-compile py_binary in Bazel 7 without a cc toolchain #1857
Comments
I previously thought that it is due to bazel version upgrade and not because of rules_python changes. Could somebody verify if the same bug exists in 0.30? I think that is the version before we switch to starlark rules, if that is broken in the same way, then I don't think there is anything we can do here. |
I agree this is due to Bazel version upgrade. But isn't rules_python responsible for making sure that itself work with latest Bazel? |
I tested with It seems that the problem is because we reference Not sure if there is a better way to do this, but the flipping of the toolchain resolution in bazel 7 indeed broke python binary rule cross-compilation. @rickeylev, do you know if there is a workaround here? At |
I don't think this is related to the flipping. |
You are correct, the offending commit is bazelbuild/bazel@1895585 I ran: @rickeylev looking at the list in bazelbuild/bazel#15897 it does not seem that this incompatibility was expected. |
Do you think I should move this bug to bazel? |
I am not sure where the code that needs to be fixed lives, it could be in both repos since the starlark implementation of rules python lives in rules_python as well.
Could you please move it to bazel, I think it may get the eyes of the right people sooner.
…On 19 April 2024 23:24:23 GMT+09:00, Zhongpeng Lin ***@***.***> wrote:
Do you think I should move this bug to bazel?
--
Reply to this email directly or view it on GitHub:
#1857 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
This all sounds a bit weird. Build output with The Bazel 6 java-implementation of the rules also depended on the CC toolchain, so I would expect that to have the same resolution logic. rules_python releases prior to 0.31.0 didn't enable the rules_python-based Starlark implementation, i.e. they use the Bazel-based Starlark implementation. So yeah, this does sound like something relating to the Starlark implementation, be it the one in Bazel itself or rules_python.
IIRC, the write_build_data codepath isn't active in rules_python/Bazel. But, that fact is a bit moot -- the way toolchain resolution works is it resolves all the rule's toolchains, even if one isn't used. I think we could do away with using cc_helper.find_cpp_toolchain. IIRC, it's logic is pretty simple, so should be OK to copy/paste or re-implement. I'm not sure if that'll help, though; if the issue is that there isn't a matching toolchain, then there isn't much we can do. We could make the CC toolchain optional. That should be possible. Our test matrix includes bazel 6, 7, and rolling releases, but doesn't attempt any cross-building. I'm surprised it ever worked. I don't have a working mac machine right now, and probably won't for another week. |
I think I ran into this with the RBE tests and the analysis test for precompiling. I think this can be repro'd on linux by building for another platform and trying to run the analysis tests.
I'm not sure where the toolchain lookup is happening, though. I started to comment out all the places where the cc toolchain is mentioned, but something is still trying to resolve the cc toolchain. Additionally, I noticed the cc toolchain is marked as optional. |
Aha, i think i found it: the implicit
I think the fix here is to have the launcher attribute point to a select. It's only used for windows. Other platforms should just point to a no-op dependency. This should be a pretty easy fix. My guess is, if we dig up the old Java code, we'll find this attribute was a one of those old dynamically-computed-at-the-java-level attributes and it got a null value for non-windows platforms. |
posterity: |
I'm pretty sure this was fixed by #1902; I fixed it as part of that PR since CI was failing there, too (it was also failing at main under the right circumstances). I moved the launcher to an alias with a select so that only windows has the launcher dependency. |
🐞 bug report
Affected Rule
The issue is caused by the rule: py_binaryIs this a regression?
Yes, the previous version in which this bug was not present was: Bazel 6.3.2Description
Cross-compiling py_binary from macOS arm64 to either macOS amd64 or Linux amd64 break when using Bazel 7. It was working in Bazel 6.
Not sure if this bug report belongs here or Bazel. Let me know if I should move it to Bazel.
🔬 Minimal Reproduction
Run
bazel build --incompatible_enable_cc_toolchain_resolution --platforms //:darwin_amd64 --enable_bzlmod //:hello
in the following workspace with Bazel 7 and Bazel 6:🔥 Exception or Error
🌍 Your Environment
Operating System:
macOS Sonoma 14.4.1 on Apple M1 Max
Output of
bazel version
:Rules_python version:
Anything else relevant?
The issue can be worked around with
--noincompatible_enable_cc_toolchain_resolution
in Bazel 7, although it worked in Bazel 6 with and without cc_toolchain resolution.This is the root cause for #1825
The text was updated successfully, but these errors were encountered: