[PATCH] llvm-config: Print system libraries with --libs instead of --ldflags

NAKAMURA Takumi geek4civic at gmail.com
Sun Dec 15 05:19:56 PST 2013


Hi ddunbar,

Although I don't think it'd be *the right way* but more practical than ever.

In trunk, --ldflags prints out -L <dir> and system libs, for example -lpthread.
This behavior is useless and sometimes reported to bugs. (Seek llvm-config in bugs)

I suggest to print system libs after --libs. In fact, almost all system_libs are required from LLVMSupport.
Printing system libs at tail would satisfy most cases.

For example on mingw,

$ bin/llvm-config.exe --ldflags --libs object
-LX:/llvm_objroot/lib
-lLLVMObject -lLLVMSupport -limagehlp -lpsapi -lshell32

My patch affects neither --libnames and --libfiles.

http://llvm-reviews.chandlerc.com/D2412

Files:
  llvm/tools/llvm-config/llvm-config.cpp

Index: llvm/tools/llvm-config/llvm-config.cpp
===================================================================
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -278,8 +278,7 @@
       } else if (Arg == "--cxxflags") {
         OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
       } else if (Arg == "--ldflags") {
-        OS << "-L" << ActiveLibDir << ' ' << LLVM_LDFLAGS
-           << ' ' << LLVM_SYSTEM_LIBS << '\n';
+        OS << "-L" << ActiveLibDir << ' ' << LLVM_LDFLAGS << '\n';
       } else if (Arg == "--libs") {
         PrintLibs = true;
       } else if (Arg == "--libnames") {
@@ -358,6 +357,12 @@
         OS << ActiveLibDir << '/' << Lib;
       }
     }
+
+    // Assume LLVMSupport depends on system_libs.
+    // FIXME: LLVMBuild may take care of dependencies to system_libs.
+    if (PrintLibs)
+      OS << ' ' << LLVM_SYSTEM_LIBS << '\n';
+
     OS << '\n';
   } else if (!Components.empty()) {
     errs() << "llvm-config: error: components given, but unused\n\n";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2412.1.patch
Type: text/x-patch
Size: 1046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131215/0b206b92/attachment.bin>


More information about the llvm-commits mailing list