-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Fix support for hostbuild executables when cross-compiling to non-windows on windows hosts #437
Fix support for hostbuild executables when cross-compiling to non-windows on windows hosts #437
Conversation
tronical
commented
Sep 8, 2023
- Defer the determination of whether to apply a .exe suffix for the byproduct copying and imported location setting if possible
- Determine the .exe suffix first based on the existence of the hostbuild property and then fall back Rust_CARGO_TARGET_OS
This is an initial attempt at fixing the issue where we cross-compile on Windows to a non-Windows target but still build and call a host-build tool. I don't quite know how to best automate testing this, but this is what I did manually:
|
I've now been able to verify that the imported location bit also works. The "higher level" test case is to clone Slint from git, and from an ESP-IDF prompt change into |
According to the test failures in the CI here, it seems that this requires further work. |
Ahh, just |
@@ -321,7 +358,7 @@ function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_name car | |||
) | |||
endfunction() | |||
|
|||
function(_corrosion_call_copy_byproduct_deferred target_name output_dir_prop_name cargo_build_dir file_names) | |||
function(_corrosion_call_copy_byproduct_deferred target_name output_dir_prop_name cargo_build_dir file_names is_binary) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra parameter is rather ugly. I'm wondering if it's worth porting this over to cmake_parse_arguments
. But I guess latest in this function it would all have to be unpacked and packed again, so maybe not worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, maybe we could just remove all named parameters to this function and pass [[${ARGN}]] to the deferred function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I’ll try that.
) | ||
endif() | ||
if(pdb_byproduct) | ||
_corrosion_copy_byproducts( | ||
{target_name} PDB_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{pdb_byproduct}}\" | ||
{target_name} PDB_OUTPUT_DIRECTORY \"${{cargo_build_out_dir}}\" \"${{pdb_byproduct}}\" FALSE | ||
) | ||
endif() | ||
if(bin_byproduct) | ||
_corrosion_copy_byproducts( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reckon this will generally go wrong, as there's no suffix handling on the caller side here. What's the status of this code path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to remove the legacy generator for v0.5 and require a newer Cmake version (was thinking of 3.22 as in ubuntu 22.04). I could do it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m curious: is the newer cmake version requirement related to the removal of the generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The legacy Generator enabled CMake support for CMake < 3.19 (3.19 introduced JSON parsing support). There was also some Multi-Config related code which was conditionally enabled based on CMake 3.20 / 3.21, so I decided to declare CMake 3.22 as a minimum supported version to have a bit of wiggle-room, while still supporting ubuntu-22.04 out of the box.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, makes sense to me. Looking forward to the update :)
Regarding testing, perhaps this is reproducible to some extent in the CI by just doing say |
Yep, this is much easier to reproduce on Windows without ESP-IDF by simply adding |
I'm going to need guidance though how to extend test.yaml best, if it's required to cover this in the CI. |
Currently most of the CI logic sits in this action.yaml. But I would prefer to remove most of the logic from there and instead use CMake toolchain files. Currently, the action has the assumption that host_os == target_os (and that the OS is either windows, mac or linux), so at the very least that would need to be changed. But it would probably be simpler to do the refactoring towards toolchain files instead.
I would prefer if this would be tested, otherwise it's hard to ensure that it doesn't break again. |
Short update: I've experimented a bit with toolchain files + |
Sorry for the delay, this MR fell a bit off my radar.
Do you know what dependencies you need to install for the test and what parameters CMake needs to be configured with? |
Yes, I think it’s sufficient to add |
What about installing a cross c compiler for the linking? I think the Linux targets all still default to using cc as the linker and not lld. |
I think for all tests you'd indeed need a cross c compiler for linking. But for testing this particular issue I've just used this:
With master it fails:
But this PR it succeeds. |
…dows on windows hosts - Defer the determination of whether to apply a .exe suffix for the byproduct copying and imported location setting if possible - Determine the .exe suffix first based on the existence of the hostbuild property and then fall back Rust_CARGO_TARGET_OS
…actual bin byproduct and not .pdb files
Rebase pushed. |
Thanks! |
Any chances in backporting that in the 4.x branch and having a release? |
* Fix support for hostbuild executables when cross-compiling to non-windows on windows hosts - Defer the determination of whether to apply a .exe suffix for the byproduct copying and imported location setting if possible - Determine the .exe suffix first based on the existence of the hostbuild property and then fall back Rust_CARGO_TARGET_OS Cherry-picked from b8a6b26 * Attempt to limit deferred byproduct .exe suffix handling only to the actual bin byproduct and not .pdb files Cherry-picked from 85b8822 * Update RELEASES.md for v0.4.5 --------- Co-authored-by: Simon Hausmann <[email protected]>