[CMake] Fix PR14200, llvm-config output misses -fno-rtti
[oota-llvm.git] / tools / llvm-config / llvm-config.cpp
index 53368ff067ea5ae3c56b779eef4bf14d377006a0..879b9ab0945ba64235584f2d1e2652bff8bc7c23 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Config/config.h"
 #include "llvm/Config/llvm-config.h"
@@ -90,9 +91,9 @@ static void VisitComponent(StringRef Name,
 /// are required to link the given components.
 /// \param IncludeNonInstalled - Whether non-installed components should be
 /// reported.
-void ComputeLibsForComponents(const std::vector<StringRef> &Components,
-                              std::vector<StringRef> &RequiredLibs,
-                              bool IncludeNonInstalled) {
+static void ComputeLibsForComponents(const std::vector<StringRef> &Components,
+                                     std::vector<StringRef> &RequiredLibs,
+                                     bool IncludeNonInstalled) {
   std::set<AvailableComponent*> VisitedComponents;
 
   // Build a map of component names to information.
@@ -125,7 +126,7 @@ void ComputeLibsForComponents(const std::vector<StringRef> &Components,
 
 /* *** */
 
-void usage() {
+static void usage() {
   errs() << "\
 usage: llvm-config <OPTION>... [<COMPONENT>...]\n\
 \n\
@@ -242,16 +243,18 @@ int main(int argc, char **argv) {
     case MakefileStyle:
       ActivePrefix = ActiveObjRoot;
       ActiveBinDir = ActiveObjRoot + "/" + build_mode + "/bin";
-      ActiveLibDir = ActiveObjRoot + "/" + build_mode + "/lib";
+      ActiveLibDir =
+          ActiveObjRoot + "/" + build_mode + "/lib" + LLVM_LIBDIR_SUFFIX;
       break;
     case CMakeStyle:
       ActiveBinDir = ActiveObjRoot + "/bin";
-      ActiveLibDir = ActiveObjRoot + "/lib";
+      ActiveLibDir = ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX;
       break;
     case CMakeBuildModeStyle:
       ActivePrefix = ActiveObjRoot;
       ActiveBinDir = ActiveObjRoot + "/bin/" + build_mode;
-      ActiveLibDir = ActiveObjRoot + "/lib/" + build_mode;
+      ActiveLibDir =
+          ActiveObjRoot + "/lib" + LLVM_LIBDIR_SUFFIX + "/" + build_mode;
       break;
     }
 
@@ -262,7 +265,7 @@ int main(int argc, char **argv) {
     ActivePrefix = CurrentExecPrefix;
     ActiveIncludeDir = ActivePrefix + "/include";
     ActiveBinDir = ActivePrefix + "/bin";
-    ActiveLibDir = ActivePrefix + "/lib";
+    ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
     ActiveIncludeOption = "-I" + ActiveIncludeDir;
   }
 
@@ -311,7 +314,7 @@ int main(int argc, char **argv) {
       } else if (Arg == "--targets-built") {
         OS << LLVM_TARGETS_BUILT << '\n';
       } else if (Arg == "--host-target") {
-        OS << LLVM_DEFAULT_TARGET_TRIPLE << '\n';
+        OS << Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE) << '\n';
       } else if (Arg == "--build-mode") {
         OS << build_mode << '\n';
       } else if (Arg == "--assertion-mode") {
@@ -345,27 +348,29 @@ int main(int argc, char **argv) {
     ComputeLibsForComponents(Components, RequiredLibs,
                              /*IncludeNonInstalled=*/IsInDevelopmentTree);
 
-    for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
-      StringRef Lib = RequiredLibs[i];
-      if (i)
-        OS << ' ';
-
-      if (PrintLibNames) {
-        OS << Lib;
-      } else if (PrintLibFiles) {
-        OS << ActiveLibDir << '/' << Lib;
-      } else if (PrintLibs) {
-        // If this is a typical library name, include it using -l.
-        if (Lib.startswith("lib") && Lib.endswith(".a")) {
-          OS << "-l" << Lib.slice(3, Lib.size()-2);
-          continue;
-        }
+    if (PrintLibs || PrintLibNames || PrintLibFiles) {
+      for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
+        StringRef Lib = RequiredLibs[i];
+        if (i)
+          OS << ' ';
 
-        // Otherwise, print the full path.
-        OS << ActiveLibDir << '/' << Lib;
+        if (PrintLibNames) {
+          OS << Lib;
+        } else if (PrintLibFiles) {
+          OS << ActiveLibDir << '/' << Lib;
+        } else if (PrintLibs) {
+          // If this is a typical library name, include it using -l.
+          if (Lib.startswith("lib") && Lib.endswith(".a")) {
+            OS << "-l" << Lib.slice(3, Lib.size()-2);
+            continue;
+          }
+
+          // Otherwise, print the full path.
+          OS << ActiveLibDir << '/' << Lib;
+        }
       }
+      OS << '\n';
     }
-    OS << '\n';
 
     // Print SYSTEM_LIBS after --libs.
     // FIXME: Each LLVM component may have its dependent system libs.