Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -7,7 +7,8 @@ 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: 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 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: test/lit.site.cfg.in =================================================================== --- test/lit.site.cfg.in +++ test/lit.site.cfg.in @@ -38,6 +38,7 @@ 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: 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/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: tools/llvm-config/llvm-config.cpp =================================================================== --- tools/llvm-config/llvm-config.cpp +++ tools/llvm-config/llvm-config.cpp @@ -698,8 +698,12 @@ // 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();