mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
CUDA, HIP: Restore support for LINKER_LAUNCHER
Reapply the implementation in commits commits77312cc6(CUDA: Add support for [CMAKE_]CUDA_LINKER_LAUNCHER, 2025-05-30, v4.1.0-rc1~80^2~1) andcdf2a36f(HIP: Add support for [CMAKE_]HIP_LINKER_LAUNCHER, 2025-05-30, v4.1.0-rc1~80^2). Add a special case to expand the correct rule placeholder for these languages, which is spelled `CMAKE_<LANG>_HOST_LINK_LAUNCHER`. Enable the tests for these languages correctly. Re-document support under CMake 4.5. Fixes: #26967
This commit is contained in:
@@ -6,13 +6,25 @@
|
||||
This property is implemented only when ``<LANG>`` is one of:
|
||||
|
||||
* ``C``
|
||||
|
||||
* ``CXX``
|
||||
|
||||
* ``CUDA``
|
||||
|
||||
.. versionadded:: 4.5
|
||||
|
||||
* ``OBJC``
|
||||
|
||||
* ``OBJCXX``
|
||||
|
||||
* ``Fortran``
|
||||
|
||||
.. versionadded:: 4.1
|
||||
|
||||
* ``HIP``
|
||||
|
||||
.. versionadded:: 4.5
|
||||
|
||||
Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a
|
||||
command line for a linker launching tool. The :ref:`Makefile Generators` and the
|
||||
:generator:`Ninja` generator will run this tool and pass the linker and its
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
cuda-hip-linker-launcher
|
||||
------------------------
|
||||
|
||||
* :ref:`Makefile Generators` and :ref:`Ninja Generators` gained support
|
||||
for adding a linker launcher with ``CUDA`` and ``HIP``.
|
||||
See the :variable:`CMAKE_<LANG>_LINKER_LAUNCHER` variable
|
||||
and :prop_tgt:`<LANG>_LINKER_LAUNCHER` target property for details.
|
||||
@@ -11,6 +11,10 @@ This is done only when ``<LANG>`` is one of:
|
||||
|
||||
* ``CXX``
|
||||
|
||||
* ``CUDA``
|
||||
|
||||
.. versionadded:: 4.5
|
||||
|
||||
* ``OBJC``
|
||||
|
||||
* ``OBJCXX``
|
||||
@@ -19,5 +23,9 @@ This is done only when ``<LANG>`` is one of:
|
||||
|
||||
.. versionadded:: 4.1
|
||||
|
||||
* ``HIP``
|
||||
|
||||
.. versionadded:: 4.5
|
||||
|
||||
This variable is initialized to the :envvar:`CMAKE_<LANG>_LINKER_LAUNCHER`
|
||||
environment variable if it is set.
|
||||
|
||||
@@ -75,6 +75,11 @@ if(NOT CMAKE_CUDA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_CUDA_COMPILER_LAUNCHER
|
||||
CACHE STRING "Compiler launcher for CUDA.")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CUDA_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_CUDA_LINKER_LAUNCHER})
|
||||
set(CMAKE_CUDA_LINKER_LAUNCHER "$ENV{CMAKE_CUDA_LINKER_LAUNCHER}"
|
||||
CACHE STRING "Linker launcher for CUDA.")
|
||||
endif()
|
||||
|
||||
include(CMakeCommonLanguageInclude)
|
||||
_cmake_common_language_platform_flags(CUDA)
|
||||
|
||||
|
||||
@@ -55,6 +55,11 @@ if(NOT CMAKE_HIP_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_HIP_COMPILER_LAUNCHER})
|
||||
CACHE STRING "Compiler launcher for HIP.")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_HIP_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_HIP_LINKER_LAUNCHER})
|
||||
set(CMAKE_HIP_LINKER_LAUNCHER "$ENV{CMAKE_HIP_LINKER_LAUNCHER}"
|
||||
CACHE STRING "Linker launcher for HIP.")
|
||||
endif()
|
||||
|
||||
include(CMakeCommonLanguageInclude)
|
||||
_cmake_common_language_platform_flags(HIP)
|
||||
|
||||
|
||||
@@ -54,6 +54,19 @@ std::string cmRulePlaceholderExpander::ExpandVariable(
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (this->ReplaceValues->Language && this->ReplaceValues->Launcher &&
|
||||
variable ==
|
||||
cmStrCat("CMAKE_", this->ReplaceValues->Language,
|
||||
"_HOST_LINK_LAUNCHER")) {
|
||||
auto mapIt = this->VariableMappings.find(variable);
|
||||
std::string result = mapIt != this->VariableMappings.end()
|
||||
? this->ConvertToOutputForExisting(mapIt->second)
|
||||
: variable;
|
||||
// Add launcher as part of expansion so that it always appears
|
||||
// immediately before the command itself, regardless of whether the
|
||||
// overall rule template contains other content at the front.
|
||||
return cmStrCat(this->ReplaceValues->Launcher, ' ', result);
|
||||
}
|
||||
if (this->ReplaceValues->Manifests) {
|
||||
if (variable == "MANIFESTS") {
|
||||
return this->ReplaceValues->Manifests;
|
||||
|
||||
@@ -464,9 +464,11 @@ TargetProperty const StaticTargetProperties[] = {
|
||||
// ---- C++
|
||||
{ "CXX_LINKER_LAUNCHER"_s, IC::CanCompileSources },
|
||||
// ---- CUDA
|
||||
{ "CUDA_LINKER_LAUNCHER"_s, IC::CanCompileSources },
|
||||
{ "CUDA_RESOLVE_DEVICE_SYMBOLS"_s, IC::CanCompileSources },
|
||||
{ "CUDA_RUNTIME_LIBRARY"_s, IC::CanCompileSources },
|
||||
// ---- HIP
|
||||
{ "HIP_LINKER_LAUNCHER"_s, IC::CanCompileSources },
|
||||
{ "HIP_RUNTIME_LIBRARY"_s, IC::CanCompileSources },
|
||||
// ---- Objective C
|
||||
{ "OBJC_LINKER_LAUNCHER"_s, IC::CanCompileSources },
|
||||
|
||||
@@ -1340,6 +1340,12 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja|FASTBuild")
|
||||
add_RunCMake_test(CompilerArgs)
|
||||
|
||||
# Enable supported languages for {Compiler,Linker}Launcher.
|
||||
if(DEFINED CMake_TEST_CUDA)
|
||||
list(APPEND LauncherCommon_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
|
||||
endif()
|
||||
if(DEFINED CMake_TEST_HIP)
|
||||
list(APPEND LauncherCommon_ARGS -DCMake_TEST_HIP=${CMake_TEST_HIP})
|
||||
endif()
|
||||
if(DEFINED CMake_TEST_OBJC)
|
||||
list(APPEND LauncherCommon_ARGS -DCMake_TEST_OBJC=${CMake_TEST_OBJC})
|
||||
endif()
|
||||
@@ -1351,18 +1357,12 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja|FASTBuild")
|
||||
if(DEFINED CMake_TEST_ISPC)
|
||||
list(APPEND CompilerLauncher_ARGS -DCMake_TEST_ISPC=${CMake_TEST_ISPC})
|
||||
endif()
|
||||
if(DEFINED CMake_TEST_CUDA)
|
||||
list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
|
||||
endif()
|
||||
if(DEFINED CMake_TEST_HIP)
|
||||
list(APPEND CompilerLauncher_ARGS -DCMake_TEST_HIP=${CMake_TEST_HIP})
|
||||
endif()
|
||||
add_RunCMake_test(CompilerLauncher)
|
||||
set_property(TEST RunCMake.CompilerLauncher APPEND
|
||||
PROPERTY LABELS "CUDA" "HIP" "ISPC" "Fortran")
|
||||
add_RunCMake_test(LinkerLauncher)
|
||||
set_property(TEST RunCMake.LinkerLauncher APPEND
|
||||
PROPERTY LABELS "Fortran")
|
||||
PROPERTY LABEL "CUDA" "HIP" "Fortran")
|
||||
endif()
|
||||
|
||||
set(cpack_tests
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.*-E env USED_LAUNCHER=1.*
|
||||
@@ -0,0 +1,4 @@
|
||||
cmake_policy(SET CMP0104 NEW)
|
||||
enable_language(CUDA)
|
||||
set(CMAKE_VERBOSE_MAKEFILE TRUE)
|
||||
add_executable(main main.cu)
|
||||
@@ -0,0 +1 @@
|
||||
.*-E env USED_LAUNCHER=1 TARGET_NAME=main LANGUAGE=CUDA.*
|
||||
@@ -0,0 +1 @@
|
||||
include(CUDA-common.cmake)
|
||||
@@ -0,0 +1 @@
|
||||
.*-E env USED_LAUNCHER=1.*
|
||||
@@ -0,0 +1 @@
|
||||
.*-E env USED_LAUNCHER=1 TARGET_NAME=main LANGUAGE=CUDA.*
|
||||
@@ -0,0 +1,3 @@
|
||||
set(CTEST_USE_LAUNCHERS 1)
|
||||
include(CTestUseLaunchers)
|
||||
include(CUDA-env.cmake)
|
||||
@@ -0,0 +1,3 @@
|
||||
set(CTEST_USE_LAUNCHERS 1)
|
||||
include(CTestUseLaunchers)
|
||||
include(CUDA.cmake)
|
||||
@@ -0,0 +1,2 @@
|
||||
set(CMAKE_CUDA_LINKER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
|
||||
include(CUDA-common.cmake)
|
||||
@@ -0,0 +1,5 @@
|
||||
enable_language(HIP)
|
||||
enable_language(CXX)
|
||||
set(CMAKE_VERBOSE_MAKEFILE TRUE)
|
||||
|
||||
add_executable(main main.hip)
|
||||
@@ -0,0 +1 @@
|
||||
.*-E env USED_LAUNCHER=1 TARGET_NAME=main LANGUAGE=HIP.*
|
||||
@@ -0,0 +1 @@
|
||||
include(HIP-common.cmake)
|
||||
@@ -0,0 +1 @@
|
||||
.*-E env USED_LAUNCHER=1.*
|
||||
@@ -0,0 +1 @@
|
||||
.*-E env USED_LAUNCHER=1 TARGET_NAME=main LANGUAGE=HIP.*
|
||||
@@ -0,0 +1,3 @@
|
||||
set(CTEST_USE_LAUNCHERS 1)
|
||||
include(CTestUseLaunchers)
|
||||
include(HIP-env.cmake)
|
||||
@@ -0,0 +1,3 @@
|
||||
set(CTEST_USE_LAUNCHERS 1)
|
||||
include(CTestUseLaunchers)
|
||||
include(HIP.cmake)
|
||||
@@ -0,0 +1,2 @@
|
||||
set(CMAKE_HIP_LINKER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
|
||||
include(HIP-common.cmake)
|
||||
@@ -27,9 +27,15 @@ function(run_linker_launcher_env lang)
|
||||
endfunction()
|
||||
|
||||
set(langs C CXX)
|
||||
if(CMake_TEST_CUDA)
|
||||
list(APPEND langs CUDA)
|
||||
endif()
|
||||
if(CMake_TEST_Fortran)
|
||||
list(APPEND langs Fortran)
|
||||
endif()
|
||||
if(CMake_TEST_HIP)
|
||||
list(APPEND langs HIP)
|
||||
endif()
|
||||
if(CMake_TEST_OBJC)
|
||||
list(APPEND langs OBJC OBJCXX)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user