[PATCH] D27805: [llvm-config] Print --system-libs only when static linking
Michał Górny via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 15 06:38:08 PST 2016
mgorny created this revision.
mgorny added reviewers: chapuni, compnerd, ddunbar, beanz.
mgorny added a subscriber: llvm-commits.
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).
https://reviews.llvm.org/D27805
Files:
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: tools/llvm-config/llvm-config.cpp
===================================================================
--- tools/llvm-config/llvm-config.cpp
+++ tools/llvm-config/llvm-config.cpp
@@ -690,8 +690,15 @@
// 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 empty system libraries if linking against a shared library
+ // (since the library links to all system libs already)
+ if (LinkMode == LinkModeShared) {
+ OS << '\n';
+ } else {
+ OS << LLVM_SYSTEM_LIBS << '\n';
+ }
+ }
} else if (!Components.empty()) {
errs() << "llvm-config: error: components given, but unused\n\n";
usage();
Index: test/tools/llvm-config/system-libs.windows.test
===================================================================
--- test/tools/llvm-config/system-libs.windows.test
+++ test/tools/llvm-config/system-libs.windows.test
@@ -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: test/tools/llvm-config/system-libs.test
===================================================================
--- test/tools/llvm-config/system-libs.test
+++ test/tools/llvm-config/system-libs.test
@@ -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: test/lit.site.cfg.in
===================================================================
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -39,6 +39,7 @@
config.have_dia_sdk = @HAVE_DIA_SDK@
config.enable_ffi = "@LLVM_ENABLE_FFI@"
config.test_examples = "@ENABLE_EXAMPLES@"
+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: test/lit.cfg
===================================================================
--- test/lit.cfg
+++ test/lit.cfg
@@ -377,6 +377,10 @@
if loadable_module:
config.available_features.add('loadable_module')
+# Static libraries are not built if BUILD_SHARED_LIBS is ON.
+if config.build_shared_libs != '1':
+ config.available_features.add("static-libs")
+
# Sanitizers.
if 'Address' in config.llvm_use_sanitizer:
config.available_features.add("asan")
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -2,6 +2,11 @@
set(ENABLE_EXAMPLES 1)
endif()
+# Convert 1 for easy processing in Python.
+if(BUILD_SHARED_LIBS)
+ set(BUILD_SHARED_LIBS 1)
+endif()
+
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27805.81573.patch
Type: text/x-patch
Size: 3070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161215/5acc1d82/attachment.bin>
More information about the llvm-commits
mailing list