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

Working around STL1000 on Windows #252

Open
gibbed opened this issue Feb 20, 2025 · 2 comments
Open

Working around STL1000 on Windows #252

gibbed opened this issue Feb 20, 2025 · 2 comments
Labels
Area-Translation Issues concerning the translation from libclang into Biohazrd Platform-Windows Issues specific to Windows TechDebt Workaround

Comments

@gibbed
Copy link

gibbed commented Feb 20, 2025

I'm attempting to make use of Biohazrd to do the relevant generator bits for an SDK I'm interested in consuming in C#.

Unfortunately, it seems like Clang is drawing upon the installed headers from my MSVC install, which is a problem since it seems Biohazrd is still using Clang 14.0:

==============================================================================
Parsing Diagnostics
==============================================================================
Note: Successfully late-instantiated 100 template specializations.
Error at yvals_core.h:894: error: static_assert failed "error STL1000: Unexpected compiler version, expected Clang 17.0.0 or newer."

Is there a way to point Biohazrd to a specific directory for those system headers rather than trying to use MSVC's?

@PathogenDavid
Copy link
Member

Thanks for the heads up! I've been meaning to find time to update libclang so this'll help put pressure on that.

Locating the standard library is something handled by Clang itself, and it prefers the MSVC STL on Windows since it's the native default.

The easiest but somewhat incorrect workaround is to just disable the version check by defining _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH, IE:

libraryBuilder.AddCommandLineArgument("-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH");

The more correct workaround is to use an older version of the MSVC toolset which supports Clang 14. Clang looks for the VCToolsInstallDir environment variable before searching for the toolset on its own, so you can just set it before creating your TranslatedLibrary. IE:

Environment.SetEnvironmentVariable("VCToolsInstallDir", @"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.29.30133\"); // (Substitute your Visual Studio install path as appropriate.)
TranslatedLibrary library = libraryBuilder.Create();

You'll need to install the older toolchain using Visual Studio Installer. That example uses the "MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.29-16.11)" component. (You don't need Visual Studio 2019, just this component.)

You can also run the generator from a Visual Studio Developer Command Prompt and Clang will use the ambient configuration from it. (You can use VC\Auxiliary\Build\vcvarsall x64 -vcvars_ver=14.29 from a developer command prompt to set the MSVC toolchain version, or just use the VS2019 command prompt if you have that.)

In theory you can also use something other than the MSVC STL (like libc++) but I've never tested it and would generally recommend against it.

@PathogenDavid PathogenDavid changed the title Clang usage of installed MSVC headers? Working around STL1000 on Windows due to Biohazrd's usage of Clang 14 Feb 20, 2025
@PathogenDavid PathogenDavid pinned this issue Feb 20, 2025
@PathogenDavid PathogenDavid changed the title Working around STL1000 on Windows due to Biohazrd's usage of Clang 14 Working around STL1000 on Windows Feb 20, 2025
@PathogenDavid PathogenDavid added Area-Translation Issues concerning the translation from libclang into Biohazrd Workaround Platform-Windows Issues specific to Windows TechDebt labels Feb 20, 2025
@gibbed
Copy link
Author

gibbed commented Feb 20, 2025

Thanks, that's exactly the information I was looking for. I'll give the workarounds a shot and let you know if I end up having any trouble with it.

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 Platform-Windows Issues specific to Windows TechDebt Workaround
Projects
None yet
Development

No branches or pull requests

2 participants