Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions llvm/docs/CMake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
5 changes: 4 additions & 1 deletion llvm/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ set(LLVM_TEST_DEPENDS
llvm-ml
llvm-ml64
llvm-modextract
llvm-mt
llvm-nm
llvm-objcopy
llvm-objdump
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions llvm/test/tools/llvm-mt/help.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
REQUIRES: libxml2
RUN: llvm-mt /h | FileCheck %s -check-prefix=HELP

HELP: OVERVIEW: Manifest Tool
Expand Down
5 changes: 5 additions & 0 deletions llvm/tools/llvm-mt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading