<div>Daniel,</div>
<div> </div>
<div>It worked find on a clean machine.</div>
<div> </div>
<div>Is there any chance you could step through getSystemRegistryString on that machine (with some test or source file that includes something like stdio.h, and see where it fails? I can't imagine why it wouldn't be working. The registry stuff is pretty consistent.</div>
<div> </div>
<div>-John<br><br></div>
<div class="gmail_quote">On Mon, Nov 23, 2009 at 9:52 AM, John Thompson <span dir="ltr"><<a href="mailto:john.thompson.jtsoftware@gmail.com">john.thompson.jtsoftware@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>Sorry about that. I don't know what's wrong yet, so I put back the hard-coded paths.</div>
<div> </div>
<div>Meanwhile, I'm setting up my spare machine, which is pretty clean, with VC9 and the needed tools and will see if it happens there.<br></div><font color="#888888">
<div>-John<br></div></font>
<div>
<div></div>
<div class="h5">
<div class="gmail_quote">On Sat, Nov 21, 2009 at 8:39 PM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel@zuster.org" target="_blank">daniel@zuster.org</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hi John,<br><br>It looks like this broke the windows buildbot, can you take a look, or<br>tell me what I should check (in the registry) to see what it is<br>
failing.<br><br>I recently upgraded the Windows box to be a very straightforward<br>out-of-the-box XP + VS 2009 install (+ gnuwin32), so this is<br>definitely a platform I would hope keeps working OOTB.<br><br> - Daniel<br>
<br>On Fri, Nov 20, 2009 at 4:15 PM, John Thompson<br><<a href="mailto:John.Thompson.JTSoftware@gmail.com" target="_blank">John.Thompson.JTSoftware@gmail.com</a>> wrote:<br>> Author: jtsoftware<br>> Date: Fri Nov 20 18:15:52 2009<br>
> New Revision: 89517<br>><br>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=89517&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=89517&view=rev</a><br>> Log:<br>> Revised Win32 include path to search highest version in registry, plus platform SDK path<br>
><br>> Modified:<br>> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp<br>><br>> Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp<br>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=89517&r1=89516&r2=89517&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=89517&r1=89516&r2=89517&view=diff</a><br>
><br>> ==============================================================================<br>> --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)<br>> +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Nov 20 18:15:52 2009<br>
> @@ -194,7 +194,15 @@<br>><br>> // FIXME: This probably should goto to some platform utils place.<br>> #ifdef _MSC_VER<br>> +<br>> // Read registry string.<br>> + // This also supports a means to look for high-versioned keys by use<br>
> + // of a $VERSION placeholder in the key path.<br>> + // $VERSION in the key path is a placeholder for the version number,<br>> + // causing the highest value path to be searched for and used.<br>> + // I.e. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION".<br>
> + // There can be additional characters in the component. Only the numberic<br>> + // characters are compared.<br>> bool getSystemRegistryString(const char *keyPath, const char *valueName,<br>> char *value, size_t maxLength) {<br>
> HKEY hRootKey = NULL;<br>> @@ -202,6 +210,7 @@<br>> const char* subKey = NULL;<br>> DWORD valueType;<br>> DWORD valueSize = maxLength - 1;<br>> + long lResult;<br>> bool returnValue = false;<br>
> if (strncmp(keyPath, "HKEY_CLASSES_ROOT\\", 18) == 0) {<br>> hRootKey = HKEY_CLASSES_ROOT;<br>> @@ -221,13 +230,80 @@<br>> }<br>> else<br>> return(false);<br>> - long lResult = RegOpenKeyEx(hRootKey, subKey, 0, KEY_READ, &hKey);<br>
> - if (lResult == ERROR_SUCCESS) {<br>> - lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,<br>> - (LPBYTE)value, &valueSize);<br>> - if (lResult == ERROR_SUCCESS)<br>> - returnValue = true;<br>
> - RegCloseKey(hKey);<br>> + const char *placeHolder = strstr(subKey, "$VERSION");<br>> + char bestName[256];<br>> + bestName[0] = '\0';<br>> + // If we have a $VERSION placeholder, do the highest-version search.<br>
> + if (placeHolder) {<br>> + const char *keyEnd = placeHolder - 1;<br>> + const char *nextKey = placeHolder;<br>> + // Find end of previous key.<br>> + while ((keyEnd > subKey) && (*keyEnd != '\\'))<br>
> + keyEnd--;<br>> + // Find end of key containing $VERSION.<br>> + while (*nextKey && (*nextKey != '\\'))<br>> + nextKey++;<br>> + size_t partialKeyLength = keyEnd - subKey;<br>
> + char partialKey[256];<br>> + if (partialKeyLength > sizeof(partialKey))<br>> + partialKeyLength = sizeof(partialKey);<br>> + strncpy(partialKey, subKey, partialKeyLength);<br>> + partialKey[partialKeyLength] = '\0';<br>
> + HKEY hTopKey = NULL;<br>> + lResult = RegOpenKeyEx(hRootKey, partialKey, 0, KEY_READ, &hTopKey);<br>> + if (lResult == ERROR_SUCCESS) {<br>> + char keyName[256];<br>> + int bestIndex = -1;<br>
> + double bestValue = 0.0;<br>> + DWORD index, size = sizeof(keyName) - 1;<br>> + for (index = 0; RegEnumKeyEx(hTopKey, index, keyName, &size, NULL,<br>> + NULL, NULL, NULL) == ERROR_SUCCESS; index++) {<br>
> + const char *sp = keyName;<br>> + while (*sp && !isdigit(*sp))<br>> + sp++;<br>> + if (!*sp)<br>> + continue;<br>> + const char *ep = sp + 1;<br>> + while (*ep && (isdigit(*ep) || (*ep == '.')))<br>
> + ep++;<br>> + char numBuf[32];<br>> + strncpy(numBuf, sp, sizeof(numBuf) - 1);<br>> + numBuf[sizeof(numBuf) - 1] = '\0';<br>> + double value = strtod(numBuf, NULL);<br>
> + if (value > bestValue) {<br>> + bestIndex = (int)index;<br>> + bestValue = value;<br>> + strcpy(bestName, keyName);<br>> + }<br>> + size = sizeof(keyName) - 1;<br>
> + }<br>> + // If we found the highest versioned key, open the key and get the value.<br>> + if (bestIndex != -1) {<br>> + // Append rest of key.<br>> + strncat(bestName, nextKey, sizeof(bestName) - 1);<br>
> + bestName[sizeof(bestName) - 1] = '\0';<br>> + // Open the chosen key path remainder.<br>> + lResult = RegOpenKeyEx(hTopKey, bestName, 0, KEY_READ, &hKey);<br>> + if (lResult == ERROR_SUCCESS) {<br>
> + lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,<br>> + (LPBYTE)value, &valueSize);<br>> + if (lResult == ERROR_SUCCESS)<br>> + returnValue = true;<br>
> + RegCloseKey(hKey);<br>> + }<br>> + }<br>> + RegCloseKey(hTopKey);<br>> + }<br>> + }<br>> + else {<br>> + lResult = RegOpenKeyEx(hRootKey, subKey, 0, KEY_READ, &hKey);<br>
> + if (lResult == ERROR_SUCCESS) {<br>> + lResult = RegQueryValueEx(hKey, valueName, NULL, &valueType,<br>> + (LPBYTE)value, &valueSize);<br>> + if (lResult == ERROR_SUCCESS)<br>> + returnValue = true;<br>
> + RegCloseKey(hKey);<br>> + }<br>> }<br>> return(returnValue);<br>> }<br>> @@ -240,35 +316,13 @@<br>><br>> // Get Visual Studio installation directory.<br>> bool getVisualStudioDir(std::string &path) {<br>
> + char vsIDEInstallDir[256];<br>> // Try the Windows registry first.<br>> - char vs80IDEInstallDir[256];<br>> - char vs90IDEInstallDir[256];<br>> - const char* vsIDEInstallDir = NULL;<br>> - bool has80 = getSystemRegistryString(<br>
> - "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0",<br>> - "InstallDir", vs80IDEInstallDir, sizeof(vs80IDEInstallDir) - 1);<br>> - bool has90 = getSystemRegistryString(<br>
> - "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0",<br>> - "InstallDir", vs90IDEInstallDir, sizeof(vs90IDEInstallDir) - 1);<br>> + bool hasVCDir = getSystemRegistryString(<br>
> + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\$VERSION",<br>> + "InstallDir", vsIDEInstallDir, sizeof(vsIDEInstallDir) - 1);<br>> // If we have both vc80 and vc90, pick version we were compiled with.<br>
> - if (has80 && has90) {<br>> - #ifdef _MSC_VER<br>> - #if (_MSC_VER >= 1500) // VC90<br>> - vsIDEInstallDir = vs90IDEInstallDir;<br>> - #elif (_MSC_VER == 1400) // VC80<br>
> - vsIDEInstallDir = vs80IDEInstallDir;<br>> - #else<br>> - vsIDEInstallDir = vs90IDEInstallDir;<br>> - #endif<br>> - #else<br>> - vsIDEInstallDir = vs90IDEInstallDir;<br>
> - #endif<br>> - }<br>> - else if (has90)<br>> - vsIDEInstallDir = vs90IDEInstallDir;<br>> - else if (has80)<br>> - vsIDEInstallDir = vs80IDEInstallDir;<br>> - if (vsIDEInstallDir && *vsIDEInstallDir) {<br>
> + if (hasVCDir && vsIDEInstallDir[0]) {<br>> char *p = (char*)strstr(vsIDEInstallDir, "\\Common7\\IDE");<br>> if (p)<br>> *p = '\0';<br>> @@ -307,6 +361,21 @@<br>> return(false);<br>
> }<br>><br>> + // Get Windows SDK installation directory.<br>> +bool getWindowsSDKDir(std::string &path) {<br>> + char windowsSDKInstallDir[256];<br>> + // Try the Windows registry.<br>> + bool hasSDKDir = getSystemRegistryString(<br>
> + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION",<br>> + "InstallationFolder", windowsSDKInstallDir, sizeof(windowsSDKInstallDir) - 1);<br>> + // If we have both vc80 and vc90, pick version we were compiled with.<br>
> + if (hasSDKDir && windowsSDKInstallDir[0]) {<br>> + path = windowsSDKInstallDir;<br>> + return(true);<br>> + }<br>> + return(false);<br>> +}<br>> +<br>> void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple) {<br>
> // FIXME: temporary hack: hard-coded paths.<br>> llvm::StringRef CIncludeDirs(C_INCLUDE_DIRS);<br>> @@ -324,29 +393,14 @@<br>> case llvm::Triple::Win32:<br>> {<br>> std::string VSDir;<br>
> + std::string WindowsSDKDir;<br>> if (getVisualStudioDir(VSDir)) {<br>> AddPath(VSDir + "\\VC\\include", System, false, false, false);<br>> - AddPath(VSDir + "\\VC\\PlatformSDK\\Include",<br>
> - System, false, false, false);<br>> - }<br>> - else {<br>> - // Default install paths.<br>> - AddPath("C:/Program Files/Microsoft Visual Studio 9.0/VC/include",<br>
> - System, false, false, false);<br>> - AddPath(<br>> - "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",<br>> - System, false, false, false);<br>
> - AddPath("C:/Program Files/Microsoft Visual Studio 8/VC/include",<br>> - System, false, false, false);<br>> - AddPath(<br>> - "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include",<br>
> - System, false, false, false);<br>> - // For some clang developers.<br>> - AddPath("G:/Program Files/Microsoft Visual Studio 9.0/VC/include",<br>> - System, false, false, false);<br>
> - AddPath(<br>> - "G:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",<br>> - System, false, false, false);<br>> + if (getWindowsSDKDir(WindowsSDKDir))<br>
> + AddPath(WindowsSDKDir, System, false, false, false);<br>> + else<br>> + AddPath(VSDir + "\\VC\\PlatformSDK\\Include",<br>> + System, false, false, false);<br>> }<br>
> }<br>> break;<br>><br>><br>> _______________________________________________<br>> cfe-commits mailing list<br>> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>><br></blockquote></div><br><br clear="all"><br></div></div>-- <br>
<div>
<div></div>
<div class="h5">John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com" target="_blank">John.Thompson.JTSoftware@gmail.com</a><br><br></div></div></blockquote></div><br><br clear="all"><br>-- <br>John Thompson<br>
<a href="mailto:John.Thompson.JTSoftware@gmail.com">John.Thompson.JTSoftware@gmail.com</a><br><br>