Index: lib/Support/CMakeLists.txt =================================================================== --- lib/Support/CMakeLists.txt +++ lib/Support/CMakeLists.txt @@ -1,5 +1,8 @@ set(system_libs) -if( NOT MSVC ) +if( MSVC ) + # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc. + set(system_libs ${system_libs} psapi shell32 ole32 uuid) +else() if( MINGW ) # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc. set(system_libs ${system_libs} psapi shell32 ole32 uuid) @@ -26,7 +29,7 @@ endif() set(system_libs ${system_libs} m) endif( MINGW ) -endif( NOT MSVC ) +endif( MSVC ) add_llvm_library(LLVMSupport APFloat.cpp Index: test/tools/llvm-config/cflags.test =================================================================== --- /dev/null +++ test/tools/llvm-config/cflags.test @@ -0,0 +1,7 @@ +RUN: llvm-config --cflags 2>&1 | FileCheck %s +RUN: llvm-config --cppflags 2>&1 | FileCheck %s +RUN: llvm-config --cxxflags 2>&1 | FileCheck %s +CHECK: -I +CHECK: {{[/\\]}}include +CHECK-NOT: error +CHECK-NOT: warning Index: test/tools/llvm-config/ldflags.test =================================================================== --- /dev/null +++ test/tools/llvm-config/ldflags.test @@ -0,0 +1,5 @@ +RUN: llvm-config --ldflags 2>&1 | FileCheck %s +CHECK: -L +CHECK: {{[/\\]}}lib +CHECK-NOT: error +CHECK-NOT: warning Index: test/tools/llvm-config/libs.test =================================================================== --- /dev/null +++ test/tools/llvm-config/libs.test @@ -0,0 +1,5 @@ +RUN: llvm-config --libs core 2>&1 | FileCheck %s +CHECK: LLVMCore +CHECK: LLVMSupport +CHECK-NOT: error +CHECK-NOT: warning Index: test/tools/llvm-config/system-libs.test =================================================================== --- /dev/null +++ test/tools/llvm-config/system-libs.test @@ -0,0 +1,4 @@ +RUN: llvm-config --system-libs 2>&1 | FileCheck %s +CHECK: -l +CHECK-NOT: error +CHECK-NOT: warning Index: tools/llvm-config/llvm-config.cpp =================================================================== --- tools/llvm-config/llvm-config.cpp +++ tools/llvm-config/llvm-config.cpp @@ -79,7 +79,8 @@ bool IncludeNonInstalled, bool GetComponentNames, const std::function *GetComponentLibraryPath, - std::vector *Missing) { + std::vector *Missing, + const std::string &DirSep) { // Lookup the component. AvailableComponent *AC = ComponentMap.lookup(Name); assert(AC && "Invalid component name!"); @@ -98,7 +99,7 @@ for (unsigned i = 0; AC->RequiredLibraries[i]; ++i) { VisitComponent(AC->RequiredLibraries[i], ComponentMap, VisitedComponents, RequiredLibs, IncludeNonInstalled, GetComponentNames, - GetComponentLibraryPath, Missing); + GetComponentLibraryPath, Missing, DirSep); } if (GetComponentNames) { @@ -110,6 +111,9 @@ if (AC->Library) { if (Missing && GetComponentLibraryPath) { std::string path = (*GetComponentLibraryPath)(AC->Library); + if (DirSep == "\\") { + std::replace(path.begin(), path.end(), '/', '\\'); + } if (!sys::fs::exists(path)) Missing->push_back(path); } @@ -125,12 +129,11 @@ /// \param IncludeNonInstalled - Whether non-installed components should be /// reported. /// \param GetComponentNames - True if one would prefer the component names. -static std::vector -ComputeLibsForComponents(const std::vector &Components, - bool IncludeNonInstalled, bool GetComponentNames, - const std::function - *GetComponentLibraryPath, - std::vector *Missing) { +static std::vector ComputeLibsForComponents( + const std::vector &Components, bool IncludeNonInstalled, + bool GetComponentNames, const std::function + *GetComponentLibraryPath, + std::vector *Missing, const std::string &DirSep) { std::vector RequiredLibs; std::set VisitedComponents; @@ -155,7 +158,7 @@ VisitComponent(ComponentLower, ComponentMap, VisitedComponents, RequiredLibs, IncludeNonInstalled, GetComponentNames, - GetComponentLibraryPath, Missing); + GetComponentLibraryPath, Missing, DirSep); } // The list is now ordered with leafs first, we want the libraries to printed @@ -220,7 +223,8 @@ /// \brief Expand the semi-colon delimited LLVM_DYLIB_COMPONENTS into /// the full list of components. std::vector GetAllDyLibComponents(const bool IsInDevelopmentTree, - const bool GetComponentNames) { + const bool GetComponentNames, + const std::string &DirSep) { std::vector DyLibComponents; StringRef DyLibComponentsStr(LLVM_DYLIB_COMPONENTS); @@ -238,7 +242,7 @@ return ComputeLibsForComponents(DyLibComponents, /*IncludeNonInstalled=*/IsInDevelopmentTree, - GetComponentNames, nullptr, nullptr); + GetComponentNames, nullptr, nullptr, DirSep); } int main(int argc, char **argv) { @@ -347,15 +351,26 @@ /// in the first place. This can't be done at configure/build time. StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt, - StaticPrefix, StaticDir = "lib"; + StaticPrefix, StaticDir = "lib", DirSep = "/"; const Triple HostTriple(Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE)); if (HostTriple.isOSWindows()) { SharedExt = "dll"; SharedVersionedExt = LLVM_DYLIB_VERSION ".dll"; - StaticExt = "a"; + if (HostTriple.isOSCygMing()) { + StaticExt = "a"; + StaticPrefix = SharedPrefix = "lib"; + } else { + StaticExt = "lib"; + DirSep = "\\"; + std::replace(ActiveObjRoot.begin(), ActiveObjRoot.end(), '/', '\\'); + std::replace(ActivePrefix.begin(), ActivePrefix.end(), '/', '\\'); + std::replace(ActiveBinDir.begin(), ActiveBinDir.end(), '/', '\\'); + std::replace(ActiveLibDir.begin(), ActiveLibDir.end(), '/', '\\'); + std::replace(ActiveIncludeOption.begin(), ActiveIncludeOption.end(), '/', + '\\'); + } SharedDir = ActiveBinDir; StaticDir = ActiveLibDir; - StaticPrefix = SharedPrefix = "lib"; } else if (HostTriple.isOSDarwin()) { SharedExt = "dylib"; SharedVersionedExt = LLVM_DYLIB_VERSION ".dylib"; @@ -394,7 +409,11 @@ bool LinkDyLib = (std::strcmp(LLVM_LINK_DYLIB, "ON") == 0); if (BuiltDyLib) { - DyLibExists = sys::fs::exists(SharedDir + "/" + DyLibName); + std::string path((SharedDir + DirSep + DyLibName).str()); + if (DirSep == "\\") { + std::replace(path.begin(), path.end(), '/', '\\'); + } + DyLibExists = sys::fs::exists(path); if (!DyLibExists) { // The shared library does not exist: don't error unless the user // explicitly passes --link-shared. @@ -429,15 +448,12 @@ /// Maps Unixizms to the host platform. auto GetComponentLibraryFileName = [&](const StringRef &Lib, const bool Shared) { - std::string LibFileName = Lib; - StringRef LibName; - if (GetComponentLibraryNameSlice(Lib, LibName)) { - if (Shared) { - LibFileName = (SharedPrefix + LibName + "." + SharedExt).str(); - } else { - // default to static - LibFileName = (StaticPrefix + LibName + "." + StaticExt).str(); - } + std::string LibFileName; + if (Shared) { + LibFileName = (SharedPrefix + Lib + "." + SharedExt).str(); + } else { + // default to static + LibFileName = (StaticPrefix + Lib + "." + StaticExt).str(); } return LibFileName; @@ -446,9 +462,9 @@ auto GetComponentLibraryPath = [&](const StringRef &Name, const bool Shared) { auto LibFileName = GetComponentLibraryFileName(Name, Shared); if (Shared) { - return (SharedDir + "/" + LibFileName).str(); + return (SharedDir + DirSep + LibFileName).str(); } else { - return (StaticDir + "/" + LibFileName).str(); + return (StaticDir + DirSep + LibFileName).str(); } }; @@ -496,10 +512,14 @@ Components.push_back(AvailableComponents[j].Name); if (AvailableComponents[j].Library && !IsInDevelopmentTree) { - if (DyLibExists && - !sys::fs::exists(GetComponentLibraryPath( - AvailableComponents[j].Library, false))) { - Components = GetAllDyLibComponents(IsInDevelopmentTree, true); + std::string path( + GetComponentLibraryPath(AvailableComponents[j].Library, false)); + if (DirSep == "\\") { + std::replace(path.begin(), path.end(), '/', '\\'); + } + if (DyLibExists && !sys::fs::exists(path)) { + Components = + GetAllDyLibComponents(IsInDevelopmentTree, true, DirSep); std::sort(Components.begin(), Components.end()); break; } @@ -577,7 +597,7 @@ std::vector RequiredLibs = ComputeLibsForComponents( Components, /*IncludeNonInstalled=*/IsInDevelopmentTree, false, - &GetComponentLibraryPathFunction, &MissingLibs); + &GetComponentLibraryPathFunction, &MissingLibs, DirSep); if (!MissingLibs.empty()) { switch (LinkMode) { case LinkModeShared: @@ -607,7 +627,7 @@ if (PrintSharedMode) { std::unordered_set FullDyLibComponents; std::vector DyLibComponents = - GetAllDyLibComponents(IsInDevelopmentTree, false); + GetAllDyLibComponents(IsInDevelopmentTree, false, DirSep); for (auto &Component : DyLibComponents) { FullDyLibComponents.insert(Component); Index: utils/llvm-build/llvmbuild/main.py =================================================================== --- utils/llvm-build/llvmbuild/main.py +++ utils/llvm-build/llvmbuild/main.py @@ -413,7 +413,7 @@ if library_name is None: library_name_as_cstr = 'nullptr' else: - library_name_as_cstr = '"lib%s.a"' % library_name + library_name_as_cstr = '"%s"' % library_name if is_installed: is_installed_as_cstr = 'true' else: