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

COM can't be used on non-Windows platforms #3083

Closed
sivadeilra opened this issue Jun 9, 2024 · 7 comments · Fixed by #3135
Closed

COM can't be used on non-Windows platforms #3083

sivadeilra opened this issue Jun 9, 2024 · 7 comments · Fixed by #3135
Labels
enhancement New feature or request

Comments

@sivadeilra
Copy link
Collaborator

Summary

I'm working on several cross-platform codebases, such as DWriteCore, which are based heavily on COM. Currently I'm using the old com-rs crate, which is no longer supported. I've converted everything in my codebase to use windows-rs, but currently compilation (linking, specifically) fails due to platform dependencies for Windows.

The first blocking issue I've hit is that the code generated for calling COM methods calls GetErrorInfo, which is only defined on Windows.

Crate manifest

No response

Crate code

No response

@sivadeilra sivadeilra added the bug Something isn't working label Jun 9, 2024
@kennykerr kennykerr added enhancement New feature or request and removed bug Something isn't working labels Jun 9, 2024
@kennykerr
Copy link
Collaborator

Note that non-Windows support has never been in scope. While I have no intention to block such support, this would definitely be considered a new feature, not a bug. Existing test coverage exists merely to support cross-compilation and to ease cross-platform development.

My general philosophy here continues to be that I am ok with enabling cross-platform support so long as it doesn't substantially impact the complexity and primacy of Windows support.

@MarijnS95
Copy link
Contributor

@sivadeilra this is awesome! It may one day help us migrate hassle-rs off of Microsoft's deprecated and unmaintained com-rs and onto windows-rs, while getting autogenerated/auto-maintained bindings for free!

Note that you'll face a lot of pushback, see for example #1874 which @riverar already linked to you in #3082. Though a lot of folks will be very thankful if you do manage to sit this through to the end 🤞


For the specific linker-error case, I did however manage to get at least #1863 merged. This allows you to define symbols like GetErrorInfo in your own codebase, to provide a fallback when the symbol isn't defined by "the OS". For example: MarijnS95@e595cda#diff-1be65c4aa0a07017c9575e418540179c2b2f7638f022c867c0ba42d39e435e9bR63-R67
(But it's hacky and I hope you can come up with something better)

@sivadeilra
Copy link
Collaborator Author

To be clear, I do not want this to become something like WINE. I don't want additional functionality that tries to bridge the gap between Windows and other platforms. I just want the subset of windows-core and windows crates that can sensibly used on other platforms.

COM is the big one, for me. And that doesn't mean any runtime functions at all, it just means IUnknown, HRESULT, and the ability to use the #[implement] and #[interface] macros.

@MarijnS95
Copy link
Contributor

To be clear, hassle-rs's requirements (for using libdxcompiler.so) are identical to that.

@youyuanwu
Copy link

FYI: We use COM on linux for service-fabric-rs. mssf-pal crate supplies a subset of win32 api to make it work.

@MarijnS95
Copy link
Contributor

@youyuanwu cool, thanks for linking. That looks to be using the exact functionality proposed in #1863 🙂

@kennykerr
Copy link
Collaborator

I took a stab at pulling out the COM support in windows-core into its own crate but so much of the code generation depends on certain facilities living in windows-core that it's not very practical. My next experiment is to see how much of the bells and whistles that have crept into windows-core can be moved out. I'm thinking of variant support moving into the windows crate as an extension and string support moving into its own windows-strings crate.

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

Successfully merging a pull request may close this issue.

4 participants