From 30ce1cfdcb8d5c11f457b609855bd8c4759ddc5b Mon Sep 17 00:00:00 2001 From: Eduard Voronkin <42834212+Noxybot@users.noreply.github.com> Date: Sat, 14 Mar 2026 22:01:18 -0700 Subject: [PATCH] FASTBuild: fix clang-cl build with manifests Fixes: #27691 --- Modules/Platform/Windows-MSVC.cmake | 13 ++++++++++-- Source/cmFastbuildNormalTargetGenerator.cxx | 23 +++++---------------- Source/cmLocalFastbuildGenerator.cxx | 6 ++++++ Source/cmLocalFastbuildGenerator.h | 1 + 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 389c2c410a..f7cc13f31c 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -392,12 +392,21 @@ else() endif() unset(__WINDOWS_MSVC_CMP0184) +# Use manifest directly on the linker's command line. +set(_CMAKE_FASTBUILD_MANIFESTS "") +if(CMAKE_GENERATOR MATCHES "FASTBuild") + string(APPEND _CMAKE_FASTBUILD_MANIFESTS " ") +endif() + macro(__windows_compiler_msvc lang) if(NOT MSVC_VERSION LESS 1400 AND NOT CMAKE_GENERATOR MATCHES "FASTBuild") # for 2005 make sure the manifest is put in the dll with mt set(_CMAKE_VS_LINK_DLL " -E vs_link_dll --msvc-ver=${MSVC_VERSION} --intdir= --rc= --mt= --manifests -- ") set(_CMAKE_VS_LINK_EXE " -E vs_link_exe --msvc-ver=${MSVC_VERSION} --intdir= --rc= --mt= --manifests -- ") endif() + if (CMAKE_GENERATOR MATCHES "FASTBuild") + set(CMAKE_${lang}_LINKER_MANIFEST_FLAG " /MANIFEST:EMBED /MANIFESTINPUT:") + endif() set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "") if(CMAKE_SYSTEM_NAME STREQUAL "WindowsKernelModeDriver") set(CMAKE_${lang}_SHARED_LIBRARY_COMPILE_DEFINITIONS "") @@ -407,7 +416,7 @@ macro(__windows_compiler_msvc lang) set(_DLL_DRIVER "/dll") endif() set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "${_CMAKE_VS_LINK_DLL} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: ${_DLL_DRIVER} /version:.${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") + "${_CMAKE_VS_LINK_DLL} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: ${_DLL_DRIVER} /version:.${_PLATFORM_LINK_FLAGS} ${_CMAKE_FASTBUILD_MANIFESTS} ${CMAKE_END_TEMP_FILE}") unset(_DLL_DRIVER) set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) @@ -423,7 +432,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_LINK_DEF_FILE_FLAG "/DEF:") set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1) set(CMAKE_${lang}_LINK_EXECUTABLE - "${_CMAKE_VS_LINK_EXE} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: /version:.${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") + "${_CMAKE_VS_LINK_EXE} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: /version:.${_PLATFORM_LINK_FLAGS} ${_CMAKE_FASTBUILD_MANIFESTS} ${CMAKE_END_TEMP_FILE}") if(CMAKE_SYSTEM_NAME STREQUAL "WindowsCE") set(CMAKE_${lang}_CREATE_WIN32_EXE "/entry:WinMainCRTStartup") diff --git a/Source/cmFastbuildNormalTargetGenerator.cxx b/Source/cmFastbuildNormalTargetGenerator.cxx index f9acd33b14..7e970bd35a 100644 --- a/Source/cmFastbuildNormalTargetGenerator.cxx +++ b/Source/cmFastbuildNormalTargetGenerator.cxx @@ -277,8 +277,7 @@ bool cmFastbuildNormalTargetGenerator::DetectBaseLinkerCommand( vars.CMTargetType = cmState::GetTargetTypeName(targetType).c_str(); vars.Config = Config.c_str(); vars.Language = linkLanguage.c_str(); - std::string const manifests = - cmJoin(this->GetManifestsAsFastbuildPath(), " "); + std::string const manifests = this->GetManifests(Config); vars.Manifests = manifests.c_str(); std::string const stdLibString = this->Makefile->GetSafeDefinition( @@ -1006,27 +1005,15 @@ void cmFastbuildNormalTargetGenerator::ProcessManifests( if (this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) { return; } - auto manifests = this->GetManifestsAsFastbuildPath(); - if (manifests.empty()) { - return; - } + std::vector const manifests = + this->GetManifestsAsFastbuildPath(); // Manifests should always be in .Libraries2, so we re-link when needed. // Tested in RunCMake.BuildDepends + linkerNode.Libraries2.reserve(linkerNode.Libraries2.size() + + manifests.size()); for (auto const& manifest : manifests) { linkerNode.Libraries2.emplace_back(manifest); } - - if (this->Makefile->GetSafeDefinition("CMAKE_C_COMPILER_ID") != "MSVC") { - return; - } - - for (auto const& manifest : manifests) { - linkerNode.LinkerOptions = - cmStrCat("/MANIFESTINPUT:", manifest, ' ', linkerNode.LinkerOptions); - } - // /MANIFESTINPUT only works with /MANIFEST:EMBED - linkerNode.LinkerOptions = - cmStrCat("/MANIFEST:EMBED ", linkerNode.LinkerOptions); } void cmFastbuildNormalTargetGenerator::AddStampExeIfApplicable( diff --git a/Source/cmLocalFastbuildGenerator.cxx b/Source/cmLocalFastbuildGenerator.cxx index b2e4a69c95..599fa95e11 100644 --- a/Source/cmLocalFastbuildGenerator.cxx +++ b/Source/cmLocalFastbuildGenerator.cxx @@ -127,3 +127,9 @@ std::string cmLocalFastbuildGenerator::ConvertToIncludeReference( } return converted; } + +std::string cmLocalFastbuildGenerator::MaybeRelativeToWorkDir( + std::string const& path) const +{ + return this->MaybeRelativeToTopBinDir(path); +} diff --git a/Source/cmLocalFastbuildGenerator.h b/Source/cmLocalFastbuildGenerator.h index 282178662f..4bdb59aff0 100644 --- a/Source/cmLocalFastbuildGenerator.h +++ b/Source/cmLocalFastbuildGenerator.h @@ -33,4 +33,5 @@ public: private: std::string ConvertToIncludeReference( std::string const& path, cmOutputConverter::OutputFormat format) override; + std::string MaybeRelativeToWorkDir(std::string const& path) const override; };