Skip to content

Commit

Permalink
llvm-config: fix --libs on Linux
Browse files Browse the repository at this point in the history
Summary:
llvm-config --libs does not produce correct output since commit r260263
(llvm-config: Add preliminary Windows support) changed naming format of
the libraries. This patch updates llvm-config to recognize new naming
format and output correct linker flags.

Ref: https://llvm.org/bugs/show_bug.cgi?id=26581

Patch by Vedran Miletić

Reviewers: ehsan, rnk, pxli168

Subscribers: pxli168

Differential Revision: http://reviews.llvm.org/D17300

llvm-svn: 263497
  • Loading branch information
rnk committed Mar 14, 2016
1 parent 64bd8df commit ecb4090
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions llvm/tools/llvm-config/llvm-config.cpp
Original file line number Diff line number Diff line change
@@ -645,17 +645,19 @@ int main(int argc, char **argv) {
} else if (PrintLibFiles) {
OS << GetComponentLibraryPath(Lib, Shared);
} else if (PrintLibs) {
// If this is a typical library name, include it using -l.
StringRef LibName;
if (Lib.startswith("lib")) {
// On Windows, output full path to library without parameters.
// Elsewhere, if this is a typical library name, include it using -l.
if (HostTriple.isWindowsMSVCEnvironment()) {
OS << GetComponentLibraryPath(Lib, Shared);
} else {
StringRef LibName;
if (GetComponentLibraryNameSlice(Lib, LibName)) {
// Extract library name (remove prefix and suffix).
OS << "-l" << LibName;
} else {
OS << "-l:" << GetComponentLibraryFileName(Lib, Shared);
// Lib is already a library name without prefix and suffix.
OS << "-l" << Lib;
}
} else {
// Otherwise, print the full path.
OS << GetComponentLibraryPath(Lib, Shared);
}
}
};

0 comments on commit ecb4090

Please sign in to comment.