[llvm] r291285 - [llvm-config] Print --system-libs only when static linking
Michal Gorny via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 6 13:33:55 PST 2017
Author: mgorny
Date: Fri Jan 6 15:33:54 2017
New Revision: 291285
URL: http://llvm.org/viewvc/llvm-project?rev=291285&view=rev
Log:
[llvm-config] Print --system-libs only when static linking
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
Modified:
llvm/trunk/test/CMakeLists.txt
llvm/trunk/test/lit.cfg
llvm/trunk/test/lit.site.cfg.in
llvm/trunk/test/tools/llvm-config/system-libs.test
llvm/trunk/test/tools/llvm-config/system-libs.windows.test
llvm/trunk/tools/llvm-config/llvm-config.cpp
Modified: llvm/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CMakeLists.txt?rev=291285&r1=291284&r2=291285&view=diff
==============================================================================
--- llvm/trunk/test/CMakeLists.txt (original)
+++ llvm/trunk/test/CMakeLists.txt Fri Jan 6 15:33:54 2017
@@ -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
Modified: llvm/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=291285&r1=291284&r2=291285&view=diff
==============================================================================
--- llvm/trunk/test/lit.cfg (original)
+++ llvm/trunk/test/lit.cfg Fri Jan 6 15:33:54 2017
@@ -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")
Modified: llvm/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.site.cfg.in?rev=291285&r1=291284&r2=291285&view=diff
==============================================================================
--- llvm/trunk/test/lit.site.cfg.in (original)
+++ llvm/trunk/test/lit.site.cfg.in Fri Jan 6 15:33:54 2017
@@ -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.
Modified: llvm/trunk/test/tools/llvm-config/system-libs.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-config/system-libs.test?rev=291285&r1=291284&r2=291285&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-config/system-libs.test (original)
+++ llvm/trunk/test/tools/llvm-config/system-libs.test Fri Jan 6 15:33:54 2017
@@ -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
Modified: llvm/trunk/test/tools/llvm-config/system-libs.windows.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-config/system-libs.windows.test?rev=291285&r1=291284&r2=291285&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-config/system-libs.windows.test (original)
+++ llvm/trunk/test/tools/llvm-config/system-libs.windows.test Fri Jan 6 15:33:54 2017
@@ -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
Modified: llvm/trunk/tools/llvm-config/llvm-config.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/llvm-config.cpp?rev=291285&r1=291284&r2=291285&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-config/llvm-config.cpp (original)
+++ llvm/trunk/tools/llvm-config/llvm-config.cpp Fri Jan 6 15:33:54 2017
@@ -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();
More information about the llvm-commits
mailing list