-
-
Notifications
You must be signed in to change notification settings - Fork 590
Support cross compilation from Linux to Windows #3120
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
base: v20
Are you sure you want to change the base?
Conversation
…tion (alvr-org#3100) Standardize all Windows API header includes to use lowercase filenames. This ensures compatibility when cross-compiling on case-sensitive filesystems (Linux with MinGW). (cherry picked from commit a992688)
* fix(server_openvr): Fix inputColorAdjust type
Fixes this build error with clang-cl 19.1.7
cpp/platform/win32/FrameRender.cpp(787,15): error: non-constant-expression cannot be narrowed from type 'int' to 'uint32_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
* fix(server_openvr): Remove useless D3D9Types.h include
* fix(server_openvr): Normalize Windows link libraries to lowercase for cross-compilation
Standardize all Windows API libraries to use lowercase filenames.
This ensures compatibility when cross-compiling on case-sensitive
filesystems (Linux with MinGW).
* fix(server_openvr): Force usage of UuidFromStringA()
RPC_CSTR isn't a wide string, so it the A version of UuidFromString()
can be called explicitly.
Fixes this build error with clang-cl 19.1.7
cpp/platform/win32/shared/d3drender.cpp(93,4): error: no matching function for call to 'UuidFromStringW'
93 | UuidFromString( ( RPC_CSTR ) "8c8f13b1-60eb-4b6a-a433-de86104115ac", &guid );
| ^~~~~~~~~~~~~~
.../kits/10/include/10.0.26100.0/shared/rpcdce.h(2775,24): note: expanded from macro 'UuidFromString'
2775 | #define UuidFromString UuidFromStringW
| ^~~~~~~~~~~~~~~
.../kits/10/include/10.0.26100.0/shared/rpcdce.h(2769,1): note: candidate function not viable: no known conversion from 'RPC_CSTR' (aka 'unsigned char *') to 'RPC_WSTR' (aka 'unsigned short *') for 1st argument
2769 | UuidFromStringW (
| ^
2770 | _In_opt_ RPC_WSTR StringUuid,
| ~~~~~~~~~~~~~~~~~~~
(cherry picked from commit aa72497)
Requires clang-cl and Windows SDK. The implementation introduces an alternative codepath with a lot of code duplication. The goal is to show that seems to be required to make the build system able to cross compile.
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.
This is a preliminary review.
You should rebase your branch because some changes were already merged.
Also, I think you could avoid duplicating the build code, making use of std::env:consts::OS, which should point to the destination compilation target, not the host
| pub vulkan_layer_manifest_dir: PathBuf, | ||
| pub launcher_root: Option<PathBuf>, | ||
|
|
||
| pub platform: Option<&'static str>, |
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.
Why should this be an Option?
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.
See my comment bellow. There is no valid reason, I just wanted to keep the existing build system untouched.
In this specific case, it allows me to override the defaut behavior of openvr_driver_lib_dir() with a new constructor new_cross_windows().
| alvr_filesystem::deps_dir().join("linux/x264/alvr_build") | ||
| } | ||
|
|
||
| fn cross_windows_build() { |
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.
if possible I would like to not duplicate the build code
I'm not familiar with this part of Rust, but actually this seems not to be true in I should have been more explicit about this part in the MR description. This is why I chose to create an alternate codepath to make it work, since I think some preliminary changes in the build system could be required at first. During my first try to add cross compilation support, I was triggering all the Linux build codepath, and I want tweaking all the conditional build tests, which lead to heavy changes.
I can open a new PR targeting
|
|
Ah I see, so |
|
You'll have to rebase this on top of master so that we can actually do anything with it, tho I can do that for you if you think that's too much for you. |
Description
Based on #3100 and #3116, here is an dirty implementation of cross compilation for Windows (tested from a Debian 12).
I chose to base my work on
v20branch to make sure I have a stable environment, which allow me to excursively focus on the build system.Also, the
build.rsfiles don't seem to be very cross-compilation friendly. Since I don't have a good knowledge of alvr build system, I decided to implement an alternative codepath with a lot of code duplication, just to create a proof of concept that can be a base for discussion. I'm pretty sure I missed a lot of details, but at least I managed to have something working.At the very end, I'm able to build with this simple command:
It requires some environment variables at first (more details bellow), but I managed to plug it in the existing command flow.
Known limitations
build.rsfor Dashboard hasn't been updated. Which means that the executable doesn't have its icon correctly configured.packagecommand not patchedEnvironment requirements
x86_64-pc-windows-msvcinstalledclang-clas a toolchain since it is compilant with Windows C++ ABIHow to build (only tested on Debian 12)
Install required Windows components
Where: in
msvc-winefolder.Note this may be improved, I discovered
msvc-winewhile working on this PR.Setup build env
Build
Output