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

Add a translation option to require a specific version (or version range) for MSVC tool when building on Windows #199

Open
PathogenDavid opened this issue Jul 5, 2021 · 1 comment
Labels
Area-Translation Issues concerning the translation from libclang into Biohazrd

Comments

@PathogenDavid
Copy link
Member

Right now generator authors can pin to a specific MSVC tool version or Windows SDK version either by:

  • Running their generator from a Visual Studio Developer Command Prompt with a specific -vcvars_ver/-winsdk_version
  • Setting the VCToolsInstallDir/WindowsSdkDir environment variables before building the library, IE:
Environment.SetEnvironmentVariable("VCToolsInstallDir", @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\");

However this is not super intuitive or discoverable, it'd be nice if Biohazrd provided official means of specifying a MSVC tools version preference.

We already do this for the Windows SDK in the private Win32 and DirectX generators, see InfectedWin32.Generator.WindowsSdkHelper.

This would enable a handful of useful features:

When we fix this, we should remove the workaround added in #98 and change things to avoid the affected versions and error if they're the only ones available. (Could probably be a warning, but the issue affects most non-trivial libraries and having it be noticeable is probably better than not.)

@PathogenDavid PathogenDavid added the Area-Translation Issues concerning the translation from libclang into Biohazrd label Jul 5, 2021
@PathogenDavid
Copy link
Member Author

For the sake of limiting bus factor, here's WindowsSdkHelper mentioned above: https://gist.github.com/PathogenDavid/29794af32ac1c88fdd489d27a2debb39

It doesn't actually override what Clang uses using environment variables but instead uses --no-standard-includes and -isystem based on the logic Clang uses internally.

Usage looks like this:

// We currently target Windows SDK 10.0.14393.0, which is Windows 10 1607
WindowsSdkHelper sdk = new("10.0.14393.0");
TranslatedLibraryBuilder builder = new()
{
    Options = new TranslationOptions()
    {
        SystemHeadersAreAlwaysOutOfScope = false
    }
};
sdk.ConfigureBuilder(builder);

builder.AddFile(sdk.GetHeaderFilePath("um", "Windows.h"));
builder.AddFile(sdk.GetHeaderFilePath("um", "ShellScalingApi.h"));
// ... etc

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
Projects
None yet
Development

No branches or pull requests

1 participant