From 9b58b0c06e6906583a1225e5c8c51dda9cbc7cfd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <mati865@gmail.com>
Date: Thu, 8 Oct 2020 09:34:18 +0300
Subject: [PATCH] [LLD] Ignore ELF tests when ld.lld defaults to MinGW

Follow-up to D87418.

Differential Revision: https://reviews.llvm.org/D88991
---
 test/CMakeLists.txt     | 1 +
 test/lit.cfg.py         | 4 ++++
 test/lit.site.cfg.py.in | 1 +
 3 files changed, 6 insertions(+)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index ff957e89121..6875a54df99 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s"
 llvm_canonicalize_cmake_booleans(
   HAVE_LIBZ
   LLVM_LIBXML2_ENABLED
+  LLD_DEFAULT_LD_LLD_IS_MINGW
   )
 
 configure_lit_site_cfg(
diff --git a/test/lit.cfg.py b/test/lit.cfg.py
index 090a7c21fa7..c031505e5c3 100644
--- a/test/lit.cfg.py
+++ b/test/lit.cfg.py
@@ -110,3 +110,7 @@ if tar_executable:
     sout, _ = tar_version.communicate()
     if 'GNU tar' in sout.decode():
         config.available_features.add('gnutar')
+
+# ELF tests expect the default target for ld.lld to be ELF.
+if config.ld_lld_default_mingw:
+    config.excludes.append('ELF')
diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in
index bbc2c892eb7..a4e00b9dac9 100644
--- a/test/lit.site.cfg.py.in
+++ b/test/lit.site.cfg.py.in
@@ -16,6 +16,7 @@ config.python_executable = "@Python3_EXECUTABLE@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.have_libxml2 = @LLVM_ENABLE_LIBXML2@
 config.sizeof_void_p = @CMAKE_SIZEOF_VOID_P@
+config.ld_lld_default_mingw = @LLD_DEFAULT_LD_LLD_IS_MINGW@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
-- 
2.29.0.rc1.windows.1

