[Qt-creator] MSVC-bundled SDKs are missed by the toolchain detection (this breaks XP targeting)

Ober, Jan J. ober.14 at buckeyemail.osu.edu
Tue Sep 8 22:48:39 CEST 2015


The MSVC toolchain detection seems to miss the SDKs bundled with MSVC compilers. For example, MSVC 2012 includes the 7.1A SDK. This SDK is used, for example, to target XP. But there's no SetEnv.cmd in modern SDKs, including 7.1.A, thus they will be ignored. The SDK should be detected as a slight modification to the compiler's environment - it is only usable with the base compiler.

To use a given SDK that doesn’t have SetEnv.cmd etc., with a given compiler, its path should be prepended to INCLUDE, PATH and LIB, e.g. for 7.1A from MSVC2012:

INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib;%LIB%
PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%

Such SDKs are included with MSVC2013 and MSVC2015 as well, to target previous Windows versions (mostly XP). 

Here’s what I propose:

1. Add a MsvcToolChain::Type::VSWindowsSDK to specify SDKs bundled with Visual Studio. They are enumerated in the registry, but specifically do not include SetEnv.cmd.

2. For each such bundled SDK version, there’s a range of MSVC versions that include it and can be used to compile code using them:

- v7.1A -> 2012, 2013, 2015
- v10 -> 2015 (optional SDK)

3. Generate a toolchain entry for each combination above that happens to exist.

Right now, the `MsvcToolChainFactory::autoDetect` code ignores SDKs that don’t have `SetEnv.cmd` in their `bin` folder. They’d be retained as bundled candidates iff they contain the include, lib and bin folders.  After the compiler list is generated as well, the product of the compilers and bundled candidates is limited to the combinations in #2.

The MsvcToolChain will have a m_bundledSdkPath that points to the SDK iff it is of the VSWindowsSDK type. The readEnvironmentSettings will proceed as if for Type::VS, and then prepend the bundled path’s Include, Lib and Bin folders to appropriate environment variables.

Even with bundled SDKs, the ABI is that of the compiler, so findAbiOfMsvc will treat MsvcToolChain::VSWindowsSDK and MsvcToolChain::VS the same. The `generateDisplayName` will combine the compiler and sdk names.

Does that make sense? If so, who should be reviewing this as I’d like to push it soon to gerrit.

— Kuba


More information about the Qt-creator mailing list