diff options
| author | 2017-01-24 08:32:59 +0000 | |
|---|---|---|
| committer | 2017-01-24 08:32:59 +0000 | |
| commit | 53d771aafdbe5b919f264f53cba3788e2c4cffd2 (patch) | |
| tree | 7eca39498be0ff1e3a6daf583cd9ca5886bb2636 /gnu/llvm/tools/llvm-config/llvm-config.cpp | |
| parent | In preparation of compiling our kernels with -ffreestanding, explicitly map (diff) | |
| download | wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.tar.xz wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.zip | |
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/tools/llvm-config/llvm-config.cpp')
| -rw-r--r-- | gnu/llvm/tools/llvm-config/llvm-config.cpp | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/gnu/llvm/tools/llvm-config/llvm-config.cpp b/gnu/llvm/tools/llvm-config/llvm-config.cpp index 94d426be361..25344e4cd01 100644 --- a/gnu/llvm/tools/llvm-config/llvm-config.cpp +++ b/gnu/llvm/tools/llvm-config/llvm-config.cpp @@ -196,6 +196,7 @@ Options:\n\ --bindir Directory containing LLVM executables.\n\ --includedir Directory containing LLVM headers.\n\ --libdir Directory containing LLVM libraries.\n\ + --cmakedir Directory containing LLVM cmake modules.\n\ --cppflags C preprocessor flags for files that include LLVM headers.\n\ --cflags C compiler flags for files that include LLVM headers.\n\ --cxxflags C++ compiler flags for files that include LLVM headers.\n\ @@ -211,10 +212,11 @@ Options:\n\ --assertion-mode Print assertion mode of LLVM tree (ON or OFF).\n\ --build-system Print the build system used to build LLVM (always cmake).\n\ --has-rtti Print whether or not LLVM was built with rtti (YES or NO).\n\ - --has-global-isel Print whether or not LLVM was built with global-isel support (YES or NO).\n\ + --has-global-isel Print whether or not LLVM was built with global-isel support (ON or OFF).\n\ --shared-mode Print how the provided components can be collectively linked (`shared` or `static`).\n\ --link-shared Link the components as shared libraries.\n\ --link-static Link the component libraries statically.\n\ + --ignore-libllvm Ignore libLLVM and link component libraries instead.\n\ Typical components:\n\ all All LLVM libraries (default).\n\ engine Either a native JIT or a bitcode interpreter.\n"; @@ -240,7 +242,7 @@ std::vector<std::string> GetAllDyLibComponents(const bool IsInDevelopmentTree, size_t Offset = 0; while (true) { const size_t NextOffset = DyLibComponentsStr.find(';', Offset); - DyLibComponents.push_back(DyLibComponentsStr.substr(Offset, NextOffset)); + DyLibComponents.push_back(DyLibComponentsStr.substr(Offset, NextOffset-Offset)); if (NextOffset == std::string::npos) { break; } @@ -301,7 +303,8 @@ int main(int argc, char **argv) { // Compute various directory locations based on the derived location // information. - std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir; + std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir, + ActiveCMakeDir; std::string ActiveIncludeOption; if (IsInDevelopmentTree) { ActiveIncludeDir = std::string(LLVM_SRC_ROOT) + "/include"; @@ -313,12 +316,14 @@ int main(int argc, char **argv) { case CMakeStyle: ActiveBinDir = ActiveObjRoot + "/bin"; ActiveLibDir = ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX; + ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; break; case CMakeBuildModeStyle: ActivePrefix = ActiveObjRoot; ActiveBinDir = ActiveObjRoot + "/bin/" + build_mode; ActiveLibDir = ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX + "/" + build_mode; + ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; break; } @@ -330,6 +335,7 @@ int main(int argc, char **argv) { ActiveIncludeDir = ActivePrefix + "/include"; ActiveBinDir = ActivePrefix + "/bin"; ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; + ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; ActiveIncludeOption = "-I" + ActiveIncludeDir; } @@ -356,6 +362,7 @@ int main(int argc, char **argv) { std::replace(ActivePrefix.begin(), ActivePrefix.end(), '/', '\\'); std::replace(ActiveBinDir.begin(), ActiveBinDir.end(), '/', '\\'); std::replace(ActiveLibDir.begin(), ActiveLibDir.end(), '/', '\\'); + std::replace(ActiveCMakeDir.begin(), ActiveCMakeDir.end(), '/', '\\'); std::replace(ActiveIncludeOption.begin(), ActiveIncludeOption.end(), '/', '\\'); } @@ -376,10 +383,10 @@ int main(int argc, char **argv) { StaticPrefix = SharedPrefix = "lib"; } - const bool BuiltDyLib = (std::strcmp(LLVM_ENABLE_DYLIB, "ON") == 0); + const bool BuiltDyLib = !!LLVM_ENABLE_DYLIB; /// CMake style shared libs, ie each component is in a shared library. - const bool BuiltSharedLibs = std::strcmp(LLVM_ENABLE_SHARED, "ON") == 0; + const bool BuiltSharedLibs = !!LLVM_ENABLE_SHARED; bool DyLibExists = false; const std::string DyLibName = @@ -388,7 +395,7 @@ int main(int argc, char **argv) { // If LLVM_LINK_DYLIB is ON, the single shared library will be returned // for "--libs", etc, if they exist. This behaviour can be overridden with // --link-static or --link-shared. - bool LinkDyLib = (std::strcmp(LLVM_LINK_DYLIB, "ON") == 0); + bool LinkDyLib = !!LLVM_LINK_DYLIB; if (BuiltDyLib) { std::string path((SharedDir + DirSep + DyLibName).str()); @@ -432,7 +439,15 @@ int main(int argc, char **argv) { const bool Shared) { std::string LibFileName; if (Shared) { - LibFileName = (SharedPrefix + Lib + "." + SharedExt).str(); + if (Lib == DyLibName) { + // Treat the DyLibName specially. It is not a component library and + // already has the necessary prefix and suffix (e.g. `.so`) added so + // just return it unmodified. + assert(Lib.endswith(SharedExt) && "DyLib is missing suffix"); + LibFileName = Lib; + } else { + LibFileName = (SharedPrefix + Lib + "." + SharedExt).str(); + } } else { // default to static LibFileName = (StaticPrefix + Lib + "." + StaticExt).str(); @@ -466,6 +481,8 @@ int main(int argc, char **argv) { OS << ActiveIncludeDir << '\n'; } else if (Arg == "--libdir") { OS << ActiveLibDir << '\n'; + } else if (Arg == "--cmakedir") { + OS << ActiveCMakeDir << '\n'; } else if (Arg == "--cppflags") { OS << ActiveIncludeOption << ' ' << LLVM_CPPFLAGS << '\n'; } else if (Arg == "--cflags") { @@ -532,15 +549,18 @@ int main(int argc, char **argv) { } else if (Arg == "--build-system") { OS << LLVM_BUILD_SYSTEM << '\n'; } else if (Arg == "--has-rtti") { - OS << LLVM_HAS_RTTI << '\n'; + OS << (LLVM_HAS_RTTI ? "YES" : "NO") << '\n'; } else if (Arg == "--has-global-isel") { - OS << LLVM_HAS_GLOBAL_ISEL << '\n'; + OS << (LLVM_HAS_GLOBAL_ISEL ? "ON" : "OFF") << '\n'; } else if (Arg == "--shared-mode") { PrintSharedMode = true; } else if (Arg == "--obj-root") { OS << ActivePrefix << '\n'; } else if (Arg == "--src-root") { OS << LLVM_SRC_ROOT << '\n'; + } else if (Arg == "--ignore-libllvm") { + LinkDyLib = false; + LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto; } else if (Arg == "--link-shared") { LinkMode = LinkModeShared; } else if (Arg == "--link-static") { @@ -586,7 +606,7 @@ int main(int argc, char **argv) { if (!MissingLibs.empty()) { switch (LinkMode) { case LinkModeShared: - if (DyLibExists && !BuiltSharedLibs) + if (LinkDyLib && !BuiltSharedLibs) break; // Using component shared libraries. for (auto &Lib : MissingLibs) @@ -599,7 +619,7 @@ int main(int argc, char **argv) { } errs() << "llvm-config: error: component libraries and shared library\n\n"; - // fall through + LLVM_FALLTHROUGH; case LinkModeStatic: for (auto &Lib : MissingLibs) errs() << "llvm-config: error: missing: " << Lib << "\n"; @@ -662,7 +682,7 @@ int main(int argc, char **argv) { } }; - if (LinkMode == LinkModeShared && !BuiltSharedLibs) { + if (LinkMode == LinkModeShared && LinkDyLib) { PrintForLib(DyLibName); } else { for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) { @@ -678,8 +698,12 @@ int main(int argc, char **argv) { // Print SYSTEM_LIBS after --libs. // FIXME: Each LLVM component may have its dependent system libs. - if (PrintSystemLibs) - OS << LLVM_SYSTEM_LIBS << '\n'; + if (PrintSystemLibs) { + // Output system libraries only if linking against a static + // library (since the shared library links to all system libs + // already) + OS << (LinkMode == LinkModeStatic ? LLVM_SYSTEM_LIBS : "") << '\n'; + } } else if (!Components.empty()) { errs() << "llvm-config: error: components given, but unused\n\n"; usage(); |
