]> granicus.if.org Git - llvm/commitdiff
[llvm-config] Print --system-libs only when static linking
authorMichal Gorny <mgorny@gentoo.org>
Fri, 6 Jan 2017 21:33:54 +0000 (21:33 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Fri, 6 Jan 2017 21:33:54 +0000 (21:33 +0000)
Modify the --system-libs option in llvm-config to print system libs only
when using static linking. The system libraries are irrelevant when
linking to a shared library since the library has appropriate library
dependencies embedded.

Modify the --system-libs test appropriately to force static linking, and
disable it if static libs are not available (i.e. BUILD_SHARED_LIBS is
enabled).

Differential Revision: https://reviews.llvm.org/D27805

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291285 91177308-0d34-0410-b5e6-96231b3b80d8

test/CMakeLists.txt
test/lit.cfg
test/lit.site.cfg.in
test/tools/llvm-config/system-libs.test
test/tools/llvm-config/system-libs.windows.test
tools/llvm-config/llvm-config.cpp

index 3bef0209620b9e281fd4b396bb458addd9f0aa0c..c1667049f80fc07358f8d9aaa90fba446b228db3 100644 (file)
@@ -7,7 +7,8 @@ llvm_canonicalize_cmake_booleans(
   HAVE_LIBZ
   HAVE_LIBXAR
   LLVM_ENABLE_DIA_SDK
-  LLVM_ENABLE_FFI)
+  LLVM_ENABLE_FFI
+  BUILD_SHARED_LIBS)
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
index f3b1d1c1ed288c88304b1885e01e02e62ac11848..e9916b2a60e8cb9b015a5391b30c7c4e1fcab36a 100644 (file)
@@ -377,6 +377,10 @@ else:
 if loadable_module:
     config.available_features.add('loadable_module')
 
+# Static libraries are not built if BUILD_SHARED_LIBS is ON.
+if not config.build_shared_libs:
+    config.available_features.add("static-libs")
+
 # Sanitizers.
 if 'Address' in config.llvm_use_sanitizer:
     config.available_features.add("asan")
index 4bf1211eeff9f464f6d484c5e37a2ed27381646d..b6a8b8b17bca2f6d1ede4aea76d79144adaf16cf 100644 (file)
@@ -38,6 +38,7 @@ config.have_zlib = @HAVE_LIBZ@
 config.have_libxar = @HAVE_LIBXAR@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.enable_ffi = @LLVM_ENABLE_FFI@
+config.build_shared_libs = @BUILD_SHARED_LIBS@
 
 # Support substitution of the tools_dir with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
index 6a1f3e39fa1ee18293b62c76e8ccac163e71b571..9105d242e049aa30d24605094d5743e88fb22eec 100644 (file)
@@ -1,4 +1,5 @@
-RUN: llvm-config --system-libs 2>&1 | FileCheck %s
+RUN: llvm-config --link-static --system-libs 2>&1 | FileCheck %s
+REQUIRES: static-libs
 UNSUPPORTED: system-windows
 CHECK: -l
 CHECK-NOT: error
index cc976ea34069757ecf64a326279075342b83744a..2c6e03afa2d95f8df4777aa2e76bbb1b62ebdd2f 100644 (file)
@@ -1,4 +1,5 @@
-RUN: llvm-config --system-libs 2>&1 | FileCheck %s
+RUN: llvm-config --link-static --system-libs 2>&1 | FileCheck %s
+REQUIRES: static-libs
 REQUIRES: system-windows
 CHECK-NOT: -l
 CHECK: psapi.lib shell32.lib ole32.lib uuid.lib
index 58571cc59b79717e7d626bd65f59ef64fb4194d3..e8afcbaaf4852eac8648719c5f0d1831a64cec14 100644 (file)
@@ -698,8 +698,12 @@ int main(int argc, char **argv) {
 
     // Print SYSTEM_LIBS after --libs.
     // FIXME: Each LLVM component may have its dependent system libs.
-    if (PrintSystemLibs)
-      OS << LLVM_SYSTEM_LIBS << '\n';
+    if (PrintSystemLibs) {
+      // Output system libraries only if linking against a static
+      // library (since the shared library links to all system libs
+      // already)
+      OS << (LinkMode == LinkModeStatic ? LLVM_SYSTEM_LIBS : "") << '\n';
+    }
   } else if (!Components.empty()) {
     errs() << "llvm-config: error: components given, but unused\n\n";
     usage();