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

Improve compatibility with mingw-w64 in generated headers #1200

Merged
merged 4 commits into from
Oct 13, 2022

Conversation

alvinhochun
Copy link
Contributor

This aims to make the generated headers usable by a Clang-based mingw-w64 toolchain. See mstorsjo/llvm-mingw#307

Note that, even with these changes, the headers does not work with llvm-mingw 15 out of the box, because there are some functions and definitions missing in mingw-w64's version of intrin.h. We will consider fixing this upstream.

…TY_BASES

The __declspec(empty_bases) attribute is only supported by MSVC or Clang
using the MSVC ABI to enable Empty Base Class Optimization (EBCO). GCC
or Clang using the MinGW ABI already perform EBCO and do not support
this attribute.
@alvinhochun
Copy link
Contributor Author

@microsoft-github-policy-service agree

@sylveon
Copy link
Contributor

sylveon commented Oct 12, 2022

These changes look fairly reasonable to me, though without some basic test coverage it's not impossible for it to break in the future.

Unfortunately the CI is out of our control so nothing you can do (a cppwinrt maintainer has to update them). Ideally the CI would eventually be migrated to a yml that's committed here so we can add basic coverage for clang-cl and mingw Clang.

@kennykerr
Copy link
Collaborator

Ideally the CI would eventually be migrated to a yml that's committed here so

I'd love to add a supplemental CI build using yml and GitHub Actions so that it is completely transparent - would appreciate such a contribution. The Azure build will probably stick around as its too complex to port to yml.

@alvinhochun
Copy link
Contributor Author

Thanks for the quick responses. I would love to have a CI build to check the llvm-mingw configuration, but first we need to add the missing stuff to mingw-w64 before we can try to implement the CI checks.

@kennykerr
Copy link
Collaborator

but first we need to add the missing stuff to mingw-w64 before we can try to implement the CI checks.

Well a failing CI build is a great way to validate that the changes are even necessary. I'm not doubting they are, but it provides a clean way to validate those additions.

@kennykerr
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Comment on lines 2 to 3
#include <intrin.h>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <intrin.h>
#include <intrin.h>

@kennykerr
Copy link
Collaborator

The build failed to compile all projects. Did you test this locally?

The attribute __declspec(novtable) is only supported by MSVC or Clang
using the MSVC ABI. Since this is only an optimization, we can leave it
out for MinGW ABI to allow it to compile.
This uses weak alias symbols to emulate the MSVC-specific
`/alternatename` linker feature.
@kennykerr
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alvinhochun
Copy link
Contributor Author

Sorry about that, I only tested the "test" project before so I did not realize how it breaks fast_forward.h ("test_fast" would reveal this).

(Full disclosure: I have to downgrade the projects to toolset v142 because I don't have VS2022 installed, and it fails to build "test_cpp20" and "test_old", so I still haven't been able to run these two tests.)

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kennykerr kennykerr merged commit 3d83c67 into microsoft:master Oct 13, 2022
@alvinhochun alvinhochun deleted the alvin/mingw-w64 branch December 11, 2022 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants