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

(Remove) Workaround for STL#1300 intrin0.h issues #98

Open
PathogenDavid opened this issue Nov 24, 2020 · 2 comments
Open

(Remove) Workaround for STL#1300 intrin0.h issues #98

PathogenDavid opened this issue Nov 24, 2020 · 2 comments
Labels
Area-Translation Issues concerning the translation from libclang into Biohazrd Workaround

Comments

@PathogenDavid
Copy link
Member

PathogenDavid commented Nov 24, 2020

Note: This workaround has been implemented, but is not considered something we want to keep long term. This issue is open to remind us to remove it eventually.

There exists an external issue where intrin.h and some headers which indirectly include it do not work correctly with libclang-based tools like Biohazrd. Attempting to compile code including these headers will result in an error similar to the following:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29515\include\intrin.h:56:1: error: expected function body after function declarator

It will be fixed in Visual Studio 2019 16.9 Preview 2, which is not currently public. To avoid requiring people to run older or preview versions of Visual Studio, Biohazrd will support automatically applying the necessary patch when it is applicable.

For more details:

@PathogenDavid PathogenDavid added Bug Area-Translation Issues concerning the translation from libclang into Biohazrd labels Nov 24, 2020
@PathogenDavid PathogenDavid changed the title Create workaround for STL#1300 intrin0.h issues Workaround for STL#1300 intrin0.h issues Nov 24, 2020
@PathogenDavid
Copy link
Member Author

Workaround implemented in 4fbcddb, it's mostly contained within __HACK__Stl1300Workaround.

I wanted to avoid including a pre-patched intrin0.h since it's not licensed to be distributed (despite the issue in the STL repo, this file is not actually part of the open source portion of the MSVC standard library.) It's also unclear if this file is identical in all affected versions of Visual Studio and I didn't want to worry about this workaround causing issues with future versions of Visual Studio.

In short, it uses logic similar to Clang's to locate the specific intrin0.h that should be used by Clang, automatically patches it, and gives it to Clang as an unsaved file.

It will only do this if the Visual Studio version that'll be used by Clang is between 16.8 and 16.9 Preview 1, inclusive. If this affects your generator, you will get a parsing warning stating that the workaround was used. (This warning can be ignored, but I wanted to make it obvious Biohazrd has overridden one of your system headers so you know to come blame me if things go wrong rather than Visual Studio or Clang.)

Biohazrd will output the patched intrin0.h as intrin0.patched.h to the working directory. This file is purely for debugging purposes. You do not need to (and should not) distribute it.

Note that if you have the MSVC build tools on your PATH or run Biohazrd from a Visual Studio Developer Command Prompt, Clang will use that version instead but Biohazrd won't patch that version if it isn't the latest version. This shouldn't be an issue unless you have multiple affected versions of Visual Studio and the one in your environment is one of them but isn't the latest.

@PathogenDavid PathogenDavid changed the title Workaround for STL#1300 intrin0.h issues (Remove) Workaround for STL#1300 intrin0.h issues Nov 25, 2020
@PathogenDavid
Copy link
Member Author

Christmas came a little early this year and Visual Studio 16.9 Preview 2 was released today. I can confirm the deactivation logic included in this workaround worked as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Translation Issues concerning the translation from libclang into Biohazrd Workaround
Projects
None yet
Development

No branches or pull requests

1 participant