From 197d2f0df32a342d90013b7d1434cbae230e68dd Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 12 Dec 2016 23:07:22 +0000 Subject: [PATCH] [llvm-config] Fix bug where `--libfiles` and `--names` would produce incorrect output when LLVM is built with `LLVM_BUILD_LLVM_DYLIB`. `llvm-config` previously produced output like this ``` $ llvm-config --libfiles /usr/lib/liblibLLVM-4.0svn.so.so $ llvm-config --libnames liblibLLVM-4.0svn.so.so ``` The library prefix and shared library extension were added to the library name twice which was wrong. I wanted to write a test cases for this but it looks like **all** `llvm-config` tests were disabled by r260386 so I'll leave this for now. Subscribers: llvm-commits, tstellarAMD Reviewers: beanz, DiamondLovesYou, axw Differential Revision: https://reviews.llvm.org/D27393 llvm-svn: 289488 --- llvm/tools/llvm-config/llvm-config.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp index c63733f..4b4a3ea 100644 --- a/llvm/tools/llvm-config/llvm-config.cpp +++ b/llvm/tools/llvm-config/llvm-config.cpp @@ -432,7 +432,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(); -- 2.7.4