mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
llvm-config: Add preliminary Windows support
Summary: This patch adds Windows support for a few of the llvm-config commands, including cflags, ldflags, libs, and system-libs. Currently llvm-config is untested, so this patch adds tests for the commands that it fixes as well. Reviewers: rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16762 llvm-svn: 260263
This commit is contained in:
parent
cfc837ef51
commit
48aefced4b
@ -1,32 +1,30 @@
|
|||||||
set(system_libs)
|
set(system_libs)
|
||||||
if( NOT MSVC )
|
if( MSVC OR MINGW )
|
||||||
if( MINGW )
|
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
|
||||||
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
|
set(system_libs ${system_libs} psapi shell32 ole32 uuid)
|
||||||
set(system_libs ${system_libs} psapi shell32 ole32 uuid)
|
elseif( CMAKE_HOST_UNIX )
|
||||||
elseif( CMAKE_HOST_UNIX )
|
if( HAVE_LIBRT )
|
||||||
if( HAVE_LIBRT )
|
set(system_libs ${system_libs} rt)
|
||||||
set(system_libs ${system_libs} rt)
|
endif()
|
||||||
|
if( HAVE_LIBDL )
|
||||||
|
set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
|
||||||
|
endif()
|
||||||
|
if(LLVM_ENABLE_TERMINFO)
|
||||||
|
if(HAVE_TERMINFO)
|
||||||
|
set(system_libs ${system_libs} ${TERMINFO_LIBS})
|
||||||
endif()
|
endif()
|
||||||
if( HAVE_LIBDL )
|
endif()
|
||||||
set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
|
if( LLVM_ENABLE_THREADS AND HAVE_LIBATOMIC )
|
||||||
endif()
|
set(system_libs ${system_libs} atomic)
|
||||||
if(LLVM_ENABLE_TERMINFO)
|
endif()
|
||||||
if(HAVE_TERMINFO)
|
if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
|
||||||
set(system_libs ${system_libs} ${TERMINFO_LIBS})
|
set(system_libs ${system_libs} pthread)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
|
||||||
if( LLVM_ENABLE_THREADS AND HAVE_LIBATOMIC )
|
set(system_libs ${system_libs} z)
|
||||||
set(system_libs ${system_libs} atomic)
|
endif()
|
||||||
endif()
|
set(system_libs ${system_libs} m)
|
||||||
if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
|
endif( MSVC OR MINGW )
|
||||||
set(system_libs ${system_libs} pthread)
|
|
||||||
endif()
|
|
||||||
if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
|
|
||||||
set(system_libs ${system_libs} z)
|
|
||||||
endif()
|
|
||||||
set(system_libs ${system_libs} m)
|
|
||||||
endif( MINGW )
|
|
||||||
endif( NOT MSVC )
|
|
||||||
|
|
||||||
add_llvm_library(LLVMSupport
|
add_llvm_library(LLVMSupport
|
||||||
APFloat.cpp
|
APFloat.cpp
|
||||||
|
7
test/tools/llvm-config/cflags.test
Normal file
7
test/tools/llvm-config/cflags.test
Normal file
@ -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
|
5
test/tools/llvm-config/ldflags.test
Normal file
5
test/tools/llvm-config/ldflags.test
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
RUN: llvm-config --ldflags 2>&1 | FileCheck %s
|
||||||
|
CHECK: -L
|
||||||
|
CHECK: {{[/\\]}}lib
|
||||||
|
CHECK-NOT: error
|
||||||
|
CHECK-NOT: warning
|
5
test/tools/llvm-config/libs.test
Normal file
5
test/tools/llvm-config/libs.test
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
RUN: llvm-config --libs core 2>&1 | FileCheck %s
|
||||||
|
CHECK: LLVMCore
|
||||||
|
CHECK: LLVMSupport
|
||||||
|
CHECK-NOT: error
|
||||||
|
CHECK-NOT: warning
|
5
test/tools/llvm-config/system-libs.test
Normal file
5
test/tools/llvm-config/system-libs.test
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
RUN: llvm-config --system-libs 2>&1 | FileCheck %s
|
||||||
|
UNSUPPORTED: system-windows
|
||||||
|
CHECK: -l
|
||||||
|
CHECK-NOT: error
|
||||||
|
CHECK-NOT: warning
|
6
test/tools/llvm-config/system-libs.windows.test
Normal file
6
test/tools/llvm-config/system-libs.windows.test
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
RUN: llvm-config --system-libs 2>&1 | FileCheck %s
|
||||||
|
REQUIRED: system-windows
|
||||||
|
CHECK-NOT: -l
|
||||||
|
CHECK: psapi.lib shell32.lib ole32.lib uuid.lib
|
||||||
|
CHECK-NOT: error
|
||||||
|
CHECK-NOT: warning
|
@ -11,7 +11,11 @@ add_llvm_tool(llvm-config
|
|||||||
# Compute the substitution values for various items.
|
# Compute the substitution values for various items.
|
||||||
get_property(LLVM_SYSTEM_LIBS_LIST TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
|
get_property(LLVM_SYSTEM_LIBS_LIST TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
|
||||||
foreach(l ${LLVM_SYSTEM_LIBS_LIST})
|
foreach(l ${LLVM_SYSTEM_LIBS_LIST})
|
||||||
set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
|
if(MSVC)
|
||||||
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}.lib")
|
||||||
|
else()
|
||||||
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
string(REPLACE ";" " " SYSTEM_LIBS "${SYSTEM_LIBS}")
|
string(REPLACE ";" " " SYSTEM_LIBS "${SYSTEM_LIBS}")
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@ static void VisitComponent(const std::string &Name,
|
|||||||
bool IncludeNonInstalled, bool GetComponentNames,
|
bool IncludeNonInstalled, bool GetComponentNames,
|
||||||
const std::function<std::string(const StringRef &)>
|
const std::function<std::string(const StringRef &)>
|
||||||
*GetComponentLibraryPath,
|
*GetComponentLibraryPath,
|
||||||
std::vector<std::string> *Missing) {
|
std::vector<std::string> *Missing,
|
||||||
|
const std::string &DirSep) {
|
||||||
// Lookup the component.
|
// Lookup the component.
|
||||||
AvailableComponent *AC = ComponentMap.lookup(Name);
|
AvailableComponent *AC = ComponentMap.lookup(Name);
|
||||||
assert(AC && "Invalid component name!");
|
assert(AC && "Invalid component name!");
|
||||||
@ -98,7 +99,7 @@ static void VisitComponent(const std::string &Name,
|
|||||||
for (unsigned i = 0; AC->RequiredLibraries[i]; ++i) {
|
for (unsigned i = 0; AC->RequiredLibraries[i]; ++i) {
|
||||||
VisitComponent(AC->RequiredLibraries[i], ComponentMap, VisitedComponents,
|
VisitComponent(AC->RequiredLibraries[i], ComponentMap, VisitedComponents,
|
||||||
RequiredLibs, IncludeNonInstalled, GetComponentNames,
|
RequiredLibs, IncludeNonInstalled, GetComponentNames,
|
||||||
GetComponentLibraryPath, Missing);
|
GetComponentLibraryPath, Missing, DirSep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetComponentNames) {
|
if (GetComponentNames) {
|
||||||
@ -110,6 +111,9 @@ static void VisitComponent(const std::string &Name,
|
|||||||
if (AC->Library) {
|
if (AC->Library) {
|
||||||
if (Missing && GetComponentLibraryPath) {
|
if (Missing && GetComponentLibraryPath) {
|
||||||
std::string path = (*GetComponentLibraryPath)(AC->Library);
|
std::string path = (*GetComponentLibraryPath)(AC->Library);
|
||||||
|
if (DirSep == "\\") {
|
||||||
|
std::replace(path.begin(), path.end(), '/', '\\');
|
||||||
|
}
|
||||||
if (!sys::fs::exists(path))
|
if (!sys::fs::exists(path))
|
||||||
Missing->push_back(path);
|
Missing->push_back(path);
|
||||||
}
|
}
|
||||||
@ -125,12 +129,11 @@ static void VisitComponent(const std::string &Name,
|
|||||||
/// \param IncludeNonInstalled - Whether non-installed components should be
|
/// \param IncludeNonInstalled - Whether non-installed components should be
|
||||||
/// reported.
|
/// reported.
|
||||||
/// \param GetComponentNames - True if one would prefer the component names.
|
/// \param GetComponentNames - True if one would prefer the component names.
|
||||||
static std::vector<std::string>
|
static std::vector<std::string> ComputeLibsForComponents(
|
||||||
ComputeLibsForComponents(const std::vector<StringRef> &Components,
|
const std::vector<StringRef> &Components, bool IncludeNonInstalled,
|
||||||
bool IncludeNonInstalled, bool GetComponentNames,
|
bool GetComponentNames, const std::function<std::string(const StringRef &)>
|
||||||
const std::function<std::string(const StringRef &)>
|
*GetComponentLibraryPath,
|
||||||
*GetComponentLibraryPath,
|
std::vector<std::string> *Missing, const std::string &DirSep) {
|
||||||
std::vector<std::string> *Missing) {
|
|
||||||
std::vector<std::string> RequiredLibs;
|
std::vector<std::string> RequiredLibs;
|
||||||
std::set<AvailableComponent *> VisitedComponents;
|
std::set<AvailableComponent *> VisitedComponents;
|
||||||
|
|
||||||
@ -155,7 +158,7 @@ ComputeLibsForComponents(const std::vector<StringRef> &Components,
|
|||||||
|
|
||||||
VisitComponent(ComponentLower, ComponentMap, VisitedComponents,
|
VisitComponent(ComponentLower, ComponentMap, VisitedComponents,
|
||||||
RequiredLibs, IncludeNonInstalled, GetComponentNames,
|
RequiredLibs, IncludeNonInstalled, GetComponentNames,
|
||||||
GetComponentLibraryPath, Missing);
|
GetComponentLibraryPath, Missing, DirSep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The list is now ordered with leafs first, we want the libraries to printed
|
// The list is now ordered with leafs first, we want the libraries to printed
|
||||||
@ -220,7 +223,8 @@ std::string GetExecutablePath(const char *Argv0) {
|
|||||||
/// \brief Expand the semi-colon delimited LLVM_DYLIB_COMPONENTS into
|
/// \brief Expand the semi-colon delimited LLVM_DYLIB_COMPONENTS into
|
||||||
/// the full list of components.
|
/// the full list of components.
|
||||||
std::vector<std::string> GetAllDyLibComponents(const bool IsInDevelopmentTree,
|
std::vector<std::string> GetAllDyLibComponents(const bool IsInDevelopmentTree,
|
||||||
const bool GetComponentNames) {
|
const bool GetComponentNames,
|
||||||
|
const std::string &DirSep) {
|
||||||
std::vector<StringRef> DyLibComponents;
|
std::vector<StringRef> DyLibComponents;
|
||||||
|
|
||||||
StringRef DyLibComponentsStr(LLVM_DYLIB_COMPONENTS);
|
StringRef DyLibComponentsStr(LLVM_DYLIB_COMPONENTS);
|
||||||
@ -238,7 +242,7 @@ std::vector<std::string> GetAllDyLibComponents(const bool IsInDevelopmentTree,
|
|||||||
|
|
||||||
return ComputeLibsForComponents(DyLibComponents,
|
return ComputeLibsForComponents(DyLibComponents,
|
||||||
/*IncludeNonInstalled=*/IsInDevelopmentTree,
|
/*IncludeNonInstalled=*/IsInDevelopmentTree,
|
||||||
GetComponentNames, nullptr, nullptr);
|
GetComponentNames, nullptr, nullptr, DirSep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@ -347,15 +351,26 @@ int main(int argc, char **argv) {
|
|||||||
/// in the first place. This can't be done at configure/build time.
|
/// in the first place. This can't be done at configure/build time.
|
||||||
|
|
||||||
StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt,
|
StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt,
|
||||||
StaticPrefix, StaticDir = "lib";
|
StaticPrefix, StaticDir = "lib", DirSep = "/";
|
||||||
const Triple HostTriple(Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE));
|
const Triple HostTriple(Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE));
|
||||||
if (HostTriple.isOSWindows()) {
|
if (HostTriple.isOSWindows()) {
|
||||||
SharedExt = "dll";
|
SharedExt = "dll";
|
||||||
SharedVersionedExt = LLVM_DYLIB_VERSION ".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;
|
SharedDir = ActiveBinDir;
|
||||||
StaticDir = ActiveLibDir;
|
StaticDir = ActiveLibDir;
|
||||||
StaticPrefix = SharedPrefix = "lib";
|
|
||||||
} else if (HostTriple.isOSDarwin()) {
|
} else if (HostTriple.isOSDarwin()) {
|
||||||
SharedExt = "dylib";
|
SharedExt = "dylib";
|
||||||
SharedVersionedExt = LLVM_DYLIB_VERSION ".dylib";
|
SharedVersionedExt = LLVM_DYLIB_VERSION ".dylib";
|
||||||
@ -394,7 +409,11 @@ int main(int argc, char **argv) {
|
|||||||
bool LinkDyLib = (std::strcmp(LLVM_LINK_DYLIB, "ON") == 0);
|
bool LinkDyLib = (std::strcmp(LLVM_LINK_DYLIB, "ON") == 0);
|
||||||
|
|
||||||
if (BuiltDyLib) {
|
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) {
|
if (!DyLibExists) {
|
||||||
// The shared library does not exist: don't error unless the user
|
// The shared library does not exist: don't error unless the user
|
||||||
// explicitly passes --link-shared.
|
// explicitly passes --link-shared.
|
||||||
@ -429,15 +448,12 @@ int main(int argc, char **argv) {
|
|||||||
/// Maps Unixizms to the host platform.
|
/// Maps Unixizms to the host platform.
|
||||||
auto GetComponentLibraryFileName = [&](const StringRef &Lib,
|
auto GetComponentLibraryFileName = [&](const StringRef &Lib,
|
||||||
const bool Shared) {
|
const bool Shared) {
|
||||||
std::string LibFileName = Lib;
|
std::string LibFileName;
|
||||||
StringRef LibName;
|
if (Shared) {
|
||||||
if (GetComponentLibraryNameSlice(Lib, LibName)) {
|
LibFileName = (SharedPrefix + Lib + "." + SharedExt).str();
|
||||||
if (Shared) {
|
} else {
|
||||||
LibFileName = (SharedPrefix + LibName + "." + SharedExt).str();
|
// default to static
|
||||||
} else {
|
LibFileName = (StaticPrefix + Lib + "." + StaticExt).str();
|
||||||
// default to static
|
|
||||||
LibFileName = (StaticPrefix + LibName + "." + StaticExt).str();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return LibFileName;
|
return LibFileName;
|
||||||
@ -446,9 +462,9 @@ int main(int argc, char **argv) {
|
|||||||
auto GetComponentLibraryPath = [&](const StringRef &Name, const bool Shared) {
|
auto GetComponentLibraryPath = [&](const StringRef &Name, const bool Shared) {
|
||||||
auto LibFileName = GetComponentLibraryFileName(Name, Shared);
|
auto LibFileName = GetComponentLibraryFileName(Name, Shared);
|
||||||
if (Shared) {
|
if (Shared) {
|
||||||
return (SharedDir + "/" + LibFileName).str();
|
return (SharedDir + DirSep + LibFileName).str();
|
||||||
} else {
|
} else {
|
||||||
return (StaticDir + "/" + LibFileName).str();
|
return (StaticDir + DirSep + LibFileName).str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -475,7 +491,8 @@ int main(int argc, char **argv) {
|
|||||||
} else if (Arg == "--cxxflags") {
|
} else if (Arg == "--cxxflags") {
|
||||||
OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
|
OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
|
||||||
} else if (Arg == "--ldflags") {
|
} else if (Arg == "--ldflags") {
|
||||||
OS << "-L" << ActiveLibDir << ' ' << LLVM_LDFLAGS << '\n';
|
OS << ((HostTriple.isWindowsMSVCEnvironment()) ? "-LIBPATH:" : "-L")
|
||||||
|
<< ActiveLibDir << ' ' << LLVM_LDFLAGS << '\n';
|
||||||
} else if (Arg == "--system-libs") {
|
} else if (Arg == "--system-libs") {
|
||||||
PrintSystemLibs = true;
|
PrintSystemLibs = true;
|
||||||
} else if (Arg == "--libs") {
|
} else if (Arg == "--libs") {
|
||||||
@ -496,10 +513,14 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
Components.push_back(AvailableComponents[j].Name);
|
Components.push_back(AvailableComponents[j].Name);
|
||||||
if (AvailableComponents[j].Library && !IsInDevelopmentTree) {
|
if (AvailableComponents[j].Library && !IsInDevelopmentTree) {
|
||||||
if (DyLibExists &&
|
std::string path(
|
||||||
!sys::fs::exists(GetComponentLibraryPath(
|
GetComponentLibraryPath(AvailableComponents[j].Library, false));
|
||||||
AvailableComponents[j].Library, false))) {
|
if (DirSep == "\\") {
|
||||||
Components = GetAllDyLibComponents(IsInDevelopmentTree, true);
|
std::replace(path.begin(), path.end(), '/', '\\');
|
||||||
|
}
|
||||||
|
if (DyLibExists && !sys::fs::exists(path)) {
|
||||||
|
Components =
|
||||||
|
GetAllDyLibComponents(IsInDevelopmentTree, true, DirSep);
|
||||||
std::sort(Components.begin(), Components.end());
|
std::sort(Components.begin(), Components.end());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -577,7 +598,7 @@ int main(int argc, char **argv) {
|
|||||||
std::vector<std::string> RequiredLibs = ComputeLibsForComponents(
|
std::vector<std::string> RequiredLibs = ComputeLibsForComponents(
|
||||||
Components,
|
Components,
|
||||||
/*IncludeNonInstalled=*/IsInDevelopmentTree, false,
|
/*IncludeNonInstalled=*/IsInDevelopmentTree, false,
|
||||||
&GetComponentLibraryPathFunction, &MissingLibs);
|
&GetComponentLibraryPathFunction, &MissingLibs, DirSep);
|
||||||
if (!MissingLibs.empty()) {
|
if (!MissingLibs.empty()) {
|
||||||
switch (LinkMode) {
|
switch (LinkMode) {
|
||||||
case LinkModeShared:
|
case LinkModeShared:
|
||||||
@ -607,7 +628,7 @@ int main(int argc, char **argv) {
|
|||||||
if (PrintSharedMode) {
|
if (PrintSharedMode) {
|
||||||
std::unordered_set<std::string> FullDyLibComponents;
|
std::unordered_set<std::string> FullDyLibComponents;
|
||||||
std::vector<std::string> DyLibComponents =
|
std::vector<std::string> DyLibComponents =
|
||||||
GetAllDyLibComponents(IsInDevelopmentTree, false);
|
GetAllDyLibComponents(IsInDevelopmentTree, false, DirSep);
|
||||||
|
|
||||||
for (auto &Component : DyLibComponents) {
|
for (auto &Component : DyLibComponents) {
|
||||||
FullDyLibComponents.insert(Component);
|
FullDyLibComponents.insert(Component);
|
||||||
|
@ -413,7 +413,7 @@ subdirectories = %s
|
|||||||
if library_name is None:
|
if library_name is None:
|
||||||
library_name_as_cstr = 'nullptr'
|
library_name_as_cstr = 'nullptr'
|
||||||
else:
|
else:
|
||||||
library_name_as_cstr = '"lib%s.a"' % library_name
|
library_name_as_cstr = '"%s"' % library_name
|
||||||
if is_installed:
|
if is_installed:
|
||||||
is_installed_as_cstr = 'true'
|
is_installed_as_cstr = 'true'
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user