[llvm] [llvm-mt] Do not build llvm-mt if not functional (PR #134631)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 07:17:09 PDT 2025


https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/134631

>From 6e45dd0ebaae3864036e14b29ba1206ed6fcfac6 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Apr 2025 15:44:28 +0200
Subject: [PATCH 1/4] Do not build llvm-mt if not functional

---
 llvm/tools/llvm-mt/CMakeLists.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/tools/llvm-mt/CMakeLists.txt b/llvm/tools/llvm-mt/CMakeLists.txt
index dd427a2640cd6..baa9f986a85b3 100644
--- a/llvm/tools/llvm-mt/CMakeLists.txt
+++ b/llvm/tools/llvm-mt/CMakeLists.txt
@@ -1,3 +1,8 @@
+if (NOT LLVM_ENABLE_LIBXML2)
+  message(STATUS "Not building llvm-mt${CMAKE_EXECUTABLE_SUFFIX} because libxml2 is not available")
+  return()
+endif ()
+
 set(LLVM_LINK_COMPONENTS
   Option
   Support

>From 66637371a2c3ea745155c0e9b7fb1e5c2982d2c9 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Apr 2025 15:53:42 +0200
Subject: [PATCH 2/4] Require libxml2 for --help

---
 llvm/test/tools/llvm-mt/help.test | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/test/tools/llvm-mt/help.test b/llvm/test/tools/llvm-mt/help.test
index 291e13cd4a263..2331faa26c440 100644
--- a/llvm/test/tools/llvm-mt/help.test
+++ b/llvm/test/tools/llvm-mt/help.test
@@ -1,3 +1,4 @@
+REQUIRES: libxml2
 RUN: llvm-mt /h | FileCheck %s -check-prefix=HELP
 
 HELP:      OVERVIEW: Manifest Tool

>From fa99f5e077d45ee404528578a891f7d996d5a51d Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Apr 2025 16:12:25 +0200
Subject: [PATCH 3/4] Update docs

---
 llvm/docs/CMake.rst | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 91e34781ef307..8d01b4d8b3dc7 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -1191,16 +1191,6 @@ Windows
   Studio 2010 CMake generator. 0 means use all processors. Default is 0.
 
 **CMAKE_MT**:STRING
-  When compiling with clang-cl, recent CMake versions will default to selecting
-  `llvm-mt` as the Manifest Tool instead of Microsoft's `mt.exe`. This will
-  often cause errors like:
-
-  .. code-block:: console
-
-    -- Check for working C compiler: [...]clang-cl.exe - broken
-    [...]
-        MT: command [...] failed (exit code 0x1) with the following output:
-        llvm-mt: error: no libxml2
-        ninja: build stopped: subcommand failed.
-
-  To work around this error, set `CMAKE_MT=mt`.
+  When compiling with clang-cl, CMake may use `llvm-mt` as the Manifest Tool
+  when available. `llvm-mt` is only present when libxml2 is found at build-time.
+  To ensure using Microsoft's Manifest Tool set `CMAKE_MT=mt`.

>From b7e72ad0a27869feec2b12f6bb81a4000c324749 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 7 Apr 2025 16:15:56 +0200
Subject: [PATCH 4/4] Tests only conditionally depend on llvm-mt

---
 llvm/test/CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index a67e2b85d9b53..66849002eb470 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -111,7 +111,6 @@ set(LLVM_TEST_DEPENDS
           llvm-ml
           llvm-ml64
           llvm-modextract
-          llvm-mt
           llvm-nm
           llvm-objcopy
           llvm-objdump
@@ -173,6 +172,10 @@ if(TARGET LTO)
   set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
 endif()
 
+if (TARGET llvm-mt)
+  list(APPEND LLVM_TEST_DEPENDS llvm-mt)
+endif ()
+
 if(LLVM_BUILD_EXAMPLES)
   list(APPEND LLVM_TEST_DEPENDS
     Kaleidoscope-Ch3



More information about the llvm-commits mailing list