Skip to content
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

Support building vmfirmwareigvm_dll on non-Windows platforms #314

Open
daprilik opened this issue Nov 13, 2024 · 2 comments
Open

Support building vmfirmwareigvm_dll on non-Windows platforms #314

daprilik opened this issue Nov 13, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@daprilik
Copy link
Contributor

daprilik commented Nov 13, 2024

With the currently documented set of required dependencies + implemented flowey build logic, the vmfirmwareigvm_dll can only be compiled on Windows platforms.

It seems likely that, given the right set of dependencies / environment variables, it should be possible to get it compiling on other platforms (notably, via WSL2).


Alternatively, Roman suggested rewriting vmfirmwareigvm_dll to instead be a standalone tool which simply crafts a DLL file "out of thin air", using something like the object crate to build a PE executable from scratch. See #291 (comment)

This is certainly an option as well, though it comes with its own set of tradeoffs and complexity spirals.

Notably: we would need to "precompile" the resources.rc file + patch it during the build (unless we wanted to try and rewrite a subset of rc.exe functionality, which seems... unwise). EDIT: Roman pointed out that x86_64-w64-mingw32-windres exists for this purpose.

@romank-msft
Copy link
Contributor

No need to re-write rc.exe, there is x86_64-w64-mingw32-windres on Linux to compile an .rc file into the .res one

@romank-msft
Copy link
Contributor

While waiting for the build, took a gander at https://docs.rs/embed-resource/latest/embed_resource/, and that says

It is possible to embed resources in Windows executables built on non-Windows hosts. There are two ways to do this:

When targetting *-pc-windows-gnu, *-w64-mingw32-windres is attempted by default, for *-pc-windows-msvc it’s llvm-rc, this can be overriden by setting RC_$TARGET, RC_${TARGET//-/_}, or RC environment variables.

When compiling with LLVM-RC, an external C compiler is used to preprocess the resource, preloaded with configuration from cc.

llvm-rc seems to be able to handle our resource script:

llvm-rc /home/krom/src/hvlite-ms/oss/openhcl/vmfirmwareigvm_dll/resources.rc

ll ./oss/openhcl/vmfirmwareigvm_dll/resources.res
-rw-r--r-- 1 krom krom 20M Nov 13 12:08 ./oss/openhcl/vmfirmwareigvm_dll/resources.res

so hopefully no "bit-banging" with use object might be needed for the dll. Hopefully, setting the env var RC=llvm-rc (after installing LLVM) will be enough to build on Linux when someone gets to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants