mach: Fix cross-compiling from windows to non windows#36070
mach: Fix cross-compiling from windows to non windows#36070jschwe merged 1 commit intoservo:mainfrom
Conversation
Since we switched to using `aws-lc-rs` instead of `ring`, cross-compiling on windows (to non-windows) had been broken. Using the default MSVC Generator results in CMake erroneously being configured for the host platform, with failing compiler checks. Switching to Ninja fixes that issue. The CMake build rules of aws-lc-rs also make use of `tr` and assume it is installed, hence we provide a helpful error message suggesting to try using mach from `git bash` which does provide the `tr` command. Signed-off-by: Jonathan Schwender <[email protected]>
| if sys.platform == 'win32' and 'windows' not in self.target.triple(): | ||
| # aws-lc-rs only supports the Ninja Generator when cross-compiling on windows hosts to non-windows. | ||
| env['TARGET_CMAKE_GENERATOR'] = "Ninja" | ||
| if shutil.which('ninja') is None: | ||
| print("Error: Cross-compiling servo on windows requires the Ninja tool to be installed and in PATH.") | ||
| print("Hint: Ninja-build is available on github at: https://github.com/ninja-build/ninja/releases") | ||
| exit(1) | ||
| # `tr` is also required by the CMake build rules of `aws-lc-rs` | ||
| if shutil.which('tr') is None: | ||
| print("Error: Cross-compiling servo on windows requires the `tr` tool, which was not found.") | ||
| print("Hint: Try running ./mach from `git bash` instead of powershell.") | ||
| exit(1) | ||
|
|
There was a problem hiding this comment.
This is unfortunate, because it adds one more place where Servo depends on mach to build properly. Could we modify the build to always require and install ninja and tr by default, and set the environment variable via Cargo?
There was a problem hiding this comment.
I think building servo for OpenHarmony via just cargo already works perfectly fine - you "just" need to source a bash file which exports all the same environment variables we are setting here in mach. The advantage of setting environment variables via python is that it doesn't depend on the shell.
We could add ninja to the bootstrap, but I thought our current policy was to only install tools in bootstrap that are needed to build servo for the host platform. For tr - it's a unix tool, so I don't think we can really force its availability. Ideally aws-lc-rs wouldn't use tr on windows, but I suspect it isn't too simple.
…#41748) I never forget that day: @dependabot updates aws-lc-rs, and cross-compilation Servo from Windows fails. We were left with two options: 1. Get a local clone of aws-lc-rs, and modify it in a hacky way 2. Use Git Bash, but still has to set up MSYS2 etc. Later, we've been restricted since #36070 to only use option 2 due to restrictions imposed here. But the system is innocent, and it is aws-lc-rs's responsibility to fix the rules. Still, @d-desiatkin and I believed that day would come, when we would return justice to the victim. Freedom is better served late than never. It is now working normally since aws-lc-rs has fixed the rules. Signed-off-by: Euclid Ye <[email protected]>
Since we switched to using
aws-lc-rsinstead ofring, cross-compiling on windows (to non-windows) had been broken. Using the default MSVC Generator results in CMake erroneously being configured for the host platform, with failing compiler checks. Switching to Ninja fixes that issue.The CMake build rules of aws-lc-rs also make use of
trand assume it is installed, hence we provide a helpful error message suggesting to try using mach fromgit bashwhich does provide thetrcommand../mach build -ddoes not report any errors./mach test-tidydoes not report any errors