Define build_platform and pass it to conda-build and rattler-build - #2622
Conversation
|
You can just install the win-64 version of rattler-build on a win-arm64 machine. I don't see why this is necessary. |
|
This is necesary because win-64 rattler-build will default to a build environment that is win-64 instead of arm64. |
Which is exactly what we want. |
|
This is my understanding: We have a bit of a boostrapping problem. We want to use native win-arm64 runners. We need The solution we discussed in the last conda meeting was to enable using But, @jaimergp Is this correct? |
That's what we are doing, but as Bas said:
100% spot on.
No, because in that case we have I also considered creating a separate |
|
Ill try this with |
This should be fixed instead of being worked around by a hack. Maybe change |
|
But I don't see it as a hack 🤔 The |
|
Ok after talking with Isuru I've understood why there's a problem with this approach: Putting this in draft until then. |
|
Ok, there seems to be a way to pass the desired target architecture for the subprocess on Windows: |
|
But does that mean that if a win-64 process starts a sub-process in emulation that that subprocess also runs under win-64? |
Yes, this is true universally. For eg: Rosetta 2 and qemu userspace. |
|
So after some investigation I think this is false. Launching cmd.exe does not make it inherently win-64. On a Windows-on-ARM machine, resolving C:\Windows\System32\cmd.exe normally launches the native ARM64 (or Arm64X) system cmd.exe; However, vars.insert(var.to_string(), std::env::var(var).ok());So an emulated win-64 rattler-build could pass along |
How though? If you have an executable that is only available as arm64, rosetta would have to convert arm64 to x64 and back? |
Most binaries on Apple silicon are fat and have both arm64 and x86_64 slices. |
I retract that statement after trying it, I think you're right |
But is this really a problem for now? We would use this to build the low level packages and can switch to completely native after that. The compiler activations etc are still properly targeting win-arm64 (as can be seen a few lines up in the logs) which I think is what really matters. |
|
Ok, as per the results in https://github.com/jaimergp/windows-11-arm-tests/actions/runs/29523869103/job/87707238242, there's a way to do it with # /b keeps it headless, /wait propagates the exit code
native_wrapper = f"start /b /wait /machine arm64 cmd.exe BATCH_FILE_HERE"
# shell=True because 'start' is a cmd.exe built-in
result = subprocess.run(
native_wrapper,
shell=True,
capture_output=True,
text=True
) |
|
Not specifically about the win-arm64 migration (and I'll admit I'm not up to speed with the fat binary vs. emulation vs. xyz stuff), I think we should just generally pass the |
|
So as we stand, I think this PR still has merit, but both conda-build and rattler-build need to patch how CMD is invoked: |
|
It seems like we get We should first fix that in conda, so that the build_platform reported is correct. Otherwise you get platform == win-arm64 on a win-64 installation of conda. cc @zooba |
|
rattler/rattler-build doesn't have this problem because it correctly uses the rust functions and not python |
The answer here is what I was saying in the linked issue - either you're querying the "architecture of subprocesses that can be launched on this machine" ( Windows applies emulation layers at every process boundary, so every time you launch a new process it'll check the executable file and see which subsystem it should run under. This has been the design since 16/32-bit were the options, and has been the same for 64/32-bit and now for ARM64/64/32 (on ARM processors). It's always layered for maximum compatibility. My recommendation would be to always specify the architecture something should build for (CLI arg or env var of your own design), allow overriding it (probably the same arg but exposed to the user/CI script), and default to All the Windows compilers are cross-compiling all the time, which is largely why you don't see special support for it - either it's so transparent that it's ignored/forgotten, or it's trivially supported with a single flag, and occasionally it requires a flag and a directory. Swapping the x86 built compiler (the default) for the x64 one makes no difference to the output unless you tell it to build for x64 (which So assume that you need to always specify the target platform, use |
|
Upstream PRs in conda and conda-build are now merged and scheduled for the July release in the coming days. Marking this as ready again, and will come in full effect once the tools have new releases. This only impacts win-arm64 PRs so I guess we can merge before tools are ready though, and included it in the next smithy release. |
Do we need to raise the lower bounds for conda/conda-build here? |
Checklist
newsentry with any new deprecations added to theDeprecatedsection.python -m conda_smithy.schema)python -m conda_smithy.linter.messages)Comes from conda-forge/conda-forge.github.io#1940 (comment).
Changes:
%BUILD_PLATFORM%directly from GHA/AZP job matrixconda-build, we exportCONDA_SUBDIR=%BUILD_PLATFORM%rattler-build, we pass--build-platform %BUILD_PLATFORM%Needs these PRs for full effect:
start /machinelauncher conda/conda-build#6047build_platformarchitecture when running emulated prefix-dev/rattler-build#2664