Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: tools/llvm-config/llvm-config.cpp

Issue 1196003003: Make `llvm-config` detect whether or not LLVM is a shared library. If it is, then only try to link … (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/llvm-config/Makefile ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/llvm-config/llvm-config.cpp
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 879b9ab0945ba64235584f2d1e2652bff8bc7c23..b04048a8bf1e05302390c1e40f9ef0b4da5ce386 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -349,6 +349,14 @@ int main(int argc, char **argv) {
/*IncludeNonInstalled=*/IsInDevelopmentTree);
if (PrintLibs || PrintLibNames || PrintLibFiles) {
+ // If LLVM was built as a shared library, there will be only one thing
+ // that users should link against.
+ const bool IsSharedLib = (std::strcmp(BUILD_SHARED_LIBS, "ON") == 0);
JF 2015/06/24 21:09:01 Could you change BUILD_SHARED_LIBS's name? There's
Richard Diamond 2015/06/24 21:44:30 `BUILD_SHARED_LIBS` is the CMake var name. Or did
JF 2015/06/24 21:52:42 If it's named the same as cmake's but doesn't have
Richard Diamond 2015/06/24 21:54:48 Setting `BUILD_SHARED_LIBS` to `ON` tells LLVM to
+ if (IsSharedLib) {
+ RequiredLibs.clear();
+ RequiredLibs.push_back("libLLVM-" PACKAGE_VERSION ".so");
JF 2015/06/24 21:09:01 Here and on line 375 you hard-code ".so". That see
+ }
+
for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
StringRef Lib = RequiredLibs[i];
if (i)
@@ -360,9 +368,14 @@ int main(int argc, char **argv) {
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 (Lib.startswith("lib")) {
+ if (Lib.endswith(".a")) {
+ OS << "-l" << Lib.slice(3, Lib.size() - 2);
+ continue;
+ } else if (Lib.endswith(".so")) {
JF 2015/06/24 21:09:01 Here too.
+ OS << "-l" << Lib.slice(3, Lib.size() - 3);
+ continue;
+ }
}
// Otherwise, print the full path.
« no previous file with comments | « tools/llvm-config/Makefile ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698