-
Notifications
You must be signed in to change notification settings - Fork 182
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
Pkg_rpm fails to build packages targeted to platforms other than the execution host machine. #727
Comments
Like #661, but this has some more detail. IIRC, the issue applies not to the host (where Bazel itself is running), but to the exec platform (where Bazel is executing commands). They are often the same, but can be different in the case of remote build execution. |
ISTM that we need to think about this in a full remote build situation to reason about the right behavior.
As part of that, we need to get
Should indeed fail (but maybe with a different error), because the target platform and the architecture field do not agree. It should be more like
Or... an entirely different way to approach this is to allow There is a case for having both ways of doing it. It's very useful for some people to have distinct targets (and thus distinct target names) for x86 and arm packages, so they can do a @ogalbxela What does your company tend to do for release pushing? |
@aiuto Thank you very much for sharing your thoughts on this. I agree we need think more on right approach. As I mentioned, I omitted cross compilation part in the sample to simplify it. In fact, for our use case we compile it as: bazel build --platforms=@custom_platforms//:linux-x86_64 //pkg:sample-rpm
bazel build --platforms=@custom_platforms//:linux-aarch64 //pkg:sample-rpm
bazel build --platforms=@custom_platforms//:linux-ppc64 //pkg:sample-rpm
bazel build --platforms=@custom_platforms//:linux-ppc64le //pkg:sample-rpm And we intend to call rpm_pkg as: pkg_rpm(
name = "sample-rpm",
srcs = [
":sample-data",
],
description = "Description",
license = "Apache 2.0",
release = BUILD_NUMBER,
summary = "Summary",
architecture = select(
{
"@custom_platforms//:linux-aarch64": "aarch64",
"@custom_platforms//:linux-ppc64": "ppc64",
"@custom_platforms//:linux-ppc64le": "ppc64le",
"@custom_platforms//:linux-x86_64": "x86_64",
"//conditions:default": "UNSUPPORTED",
},
),
target_compatible_with = select({
"@custom_platforms//:linux-all": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
version = VERSION,
) which would make the issue to show up. I agree that we can simply refer to target achitecture as the "target". If you have suggestions for a more effective approach to addressing these concerns, please don't hesitate to share. I'm open to considering alternative solutions. As for the proposal I've submitted, it aligns well with the requirements of my project up to this point. However, if we come across a superior solution that could also benefit the wider community, I'm more than willing to incorporate it into my implementation. |
Yes, when I mentioned 'host,' I was referring to the machine that is used to run the 'rpmbuild'. Thank you for paying attention to this. I have made adjustments to the title and description to make them more accurate. |
Let's presume your sample use case is good enough. I would like it to be easier to auto-set what arch it is automatically from the platform constraints, but that can happen later. I'm comparing it to the code in the PR and wondering about But this is all confusing:
The first sentence is fine. Add the second, and no other words, and I read that to mean there is no notion of cross compilation in rpmbuild. So, my early thoughts about cross compilation and RBE reduce to,
Let's continue in the PR. |
The current version of the "pkg_rpm" rule exposes an "architecture"-argument, which is meant to indicate the package's intended platform. It is being used to define the "BuildArch" option in the generated RPM spec file.
However, as per RPM packaging guide (https://rpm-packaging-guide.github.io/):
"'BuildArch' should be used if the package is not architecture dependent. For example, if written entirely in an interpreted programming language, set this to BuildArch: noarch. If not set, the package automatically inherits the Architecture of the machine on which it is built".
It appears that BuildArch is intended to represent either architecture of execution host machine or "noarch". Any efforts to designate an "alien" platform as a value for this field lead to a failure in the "rpmbuild"-utility, accompanied by an error message stating: "error: No compatible architectures found for build."
Possible solution to address this concern is to pass the value of "architecture"-argument to the "rpmbuild"-utility as the value for the "--target" option. However, it may break backward compatibility as "architecture"-argument might already be in use by someone who relies on current behavior. Introducing brand new "target_architecture"-argument may also be an option to consider.
Please consider possible fix #729. Please note that proposed patch attempts to address back compatibility concern.
Below is a "synthetic" example aimed to demonstrate concern. Note: in order to reduce sample size, I omitted cross compilation part just providing binary pre-compiled for aarch64.
Versions are: bazel: 6.0.0; rules_pkg: 0.9.1; host: ubuntu 20.04.2 x86_64; target: linux-aarch64
sample.zip
The text was updated successfully, but these errors were encountered: