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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « tools/llvm-config/Makefile ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- llvm-config.cpp - LLVM project configuration utility --------------===// 1 //===-- llvm-config.cpp - LLVM project configuration utility --------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This tool encapsulates information about an LLVM project configuration for 10 // This tool encapsulates information about an LLVM project configuration for
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // If no components were specified, default to "all". 342 // If no components were specified, default to "all".
343 if (Components.empty()) 343 if (Components.empty())
344 Components.push_back("all"); 344 Components.push_back("all");
345 345
346 // Construct the list of all the required libraries. 346 // Construct the list of all the required libraries.
347 std::vector<StringRef> RequiredLibs; 347 std::vector<StringRef> RequiredLibs;
348 ComputeLibsForComponents(Components, RequiredLibs, 348 ComputeLibsForComponents(Components, RequiredLibs,
349 /*IncludeNonInstalled=*/IsInDevelopmentTree); 349 /*IncludeNonInstalled=*/IsInDevelopmentTree);
350 350
351 if (PrintLibs || PrintLibNames || PrintLibFiles) { 351 if (PrintLibs || PrintLibNames || PrintLibFiles) {
352 // If LLVM was built as a shared library, there will be only one thing
353 // that users should link against.
354 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
355 if (IsSharedLib) {
356 RequiredLibs.clear();
357 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
358 }
359
352 for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) { 360 for (unsigned i = 0, e = RequiredLibs.size(); i != e; ++i) {
353 StringRef Lib = RequiredLibs[i]; 361 StringRef Lib = RequiredLibs[i];
354 if (i) 362 if (i)
355 OS << ' '; 363 OS << ' ';
356 364
357 if (PrintLibNames) { 365 if (PrintLibNames) {
358 OS << Lib; 366 OS << Lib;
359 } else if (PrintLibFiles) { 367 } else if (PrintLibFiles) {
360 OS << ActiveLibDir << '/' << Lib; 368 OS << ActiveLibDir << '/' << Lib;
361 } else if (PrintLibs) { 369 } else if (PrintLibs) {
362 // If this is a typical library name, include it using -l. 370 // If this is a typical library name, include it using -l.
363 if (Lib.startswith("lib") && Lib.endswith(".a")) { 371 if (Lib.startswith("lib")) {
364 OS << "-l" << Lib.slice(3, Lib.size()-2); 372 if (Lib.endswith(".a")) {
365 continue; 373 OS << "-l" << Lib.slice(3, Lib.size() - 2);
374 continue;
375 } else if (Lib.endswith(".so")) {
JF 2015/06/24 21:09:01 Here too.
376 OS << "-l" << Lib.slice(3, Lib.size() - 3);
377 continue;
378 }
366 } 379 }
367 380
368 // Otherwise, print the full path. 381 // Otherwise, print the full path.
369 OS << ActiveLibDir << '/' << Lib; 382 OS << ActiveLibDir << '/' << Lib;
370 } 383 }
371 } 384 }
372 OS << '\n'; 385 OS << '\n';
373 } 386 }
374 387
375 // Print SYSTEM_LIBS after --libs. 388 // Print SYSTEM_LIBS after --libs.
376 // FIXME: Each LLVM component may have its dependent system libs. 389 // FIXME: Each LLVM component may have its dependent system libs.
377 if (PrintSystemLibs) 390 if (PrintSystemLibs)
378 OS << LLVM_SYSTEM_LIBS << '\n'; 391 OS << LLVM_SYSTEM_LIBS << '\n';
379 } else if (!Components.empty()) { 392 } else if (!Components.empty()) {
380 errs() << "llvm-config: error: components given, but unused\n\n"; 393 errs() << "llvm-config: error: components given, but unused\n\n";
381 usage(); 394 usage();
382 } 395 }
383 396
384 return 0; 397 return 0;
385 } 398 }
OLDNEW
« 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