From 0569c7713c42d835251d688c4110cb4131fd223b Mon Sep 17 00:00:00 2001 From: "Andryeyev, German" Date: Tue, 22 Apr 2025 11:35:04 -0400 Subject: [PATCH] SWDEV-523300 - Add the new option to build HIP (#179) Add the new cmake option AMD_COMPUTE_WIN to build HIP on Windows from the public github. AMD_COMPUTE_WIN should point to a special repo with the PAL static libs [ROCm/clr commit: a3effa16f15b0981eea2865b6d179babd9121111] --- projects/clr/CMakeLists.txt | 8 ++++ .../clr/rocclr/cmake/FindAMD_PAL_LIB.cmake | 42 +++++++++++++++++++ projects/clr/rocclr/cmake/ROCclrPAL.cmake | 6 ++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 projects/clr/rocclr/cmake/FindAMD_PAL_LIB.cmake diff --git a/projects/clr/CMakeLists.txt b/projects/clr/CMakeLists.txt index ea99630abc..b15fce65f1 100644 --- a/projects/clr/CMakeLists.txt +++ b/projects/clr/CMakeLists.txt @@ -33,6 +33,14 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") add_compile_options(-D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH) endif() endif() + +if (AMD_COMPUTE_WIN) + add_compile_options("/MT") + set(AMD_LIBELF_PATH "${AMD_COMPUTE_WIN}/hsail-compiler/lib/loaders/elf/utils/libelf") + set(AMD_SC_PATH "${AMD_COMPUTE_WIN}/sc") + message("Public Compute Windows build path: ${AMD_COMPUTE_WIN}, SC: ${AMD_SC_PATH}, LibElf: ${AMD_LIBELF_PATH}") +endif() + option(CLR_BUILD_HIP "Build HIP" OFF) option(CLR_BUILD_OCL "Build OCL" OFF) diff --git a/projects/clr/rocclr/cmake/FindAMD_PAL_LIB.cmake b/projects/clr/rocclr/cmake/FindAMD_PAL_LIB.cmake new file mode 100644 index 0000000000..2ae7662960 --- /dev/null +++ b/projects/clr/rocclr/cmake/FindAMD_PAL_LIB.cmake @@ -0,0 +1,42 @@ +# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +if(AMD_PAL_LIB_FOUND) + return() +endif() + +find_path(AMD_PAL_LIB_INCLUDE_DIR pal.h + HINTS + ${AMD_COMPUTE_WIN}/pal + PATHS + ${CMAKE_SOURCE_DIR}/pal + ${CMAKE_SOURCE_DIR}/../pal + ${CMAKE_SOURCE_DIR}/../../pal + ${CMAKE_SOURCE_DIR}/../../../pal + PATH_SUFFIXES + inc/core) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(AMD_PAL_LIB + "\nPAL not found" + AMD_PAL_LIB_INCLUDE_DIR) +mark_as_advanced(AMD_PAL_LIB_INCLUDE_DIR) + +add_subdirectory("${AMD_PAL_LIB_INCLUDE_DIR}/../.." ${CMAKE_CURRENT_BINARY_DIR}/pal) diff --git a/projects/clr/rocclr/cmake/ROCclrPAL.cmake b/projects/clr/rocclr/cmake/ROCclrPAL.cmake index 91122433cd..4f7da71ac4 100644 --- a/projects/clr/rocclr/cmake/ROCclrPAL.cmake +++ b/projects/clr/rocclr/cmake/ROCclrPAL.cmake @@ -51,8 +51,12 @@ set(PAL_BUILD_PHOENIX1 ON) # Please do not set above flags in staging and mainline in new ASICs set(PAL_BRANCHDEFS ON) +if (AMD_COMPUTE_WIN) + find_package(AMD_PAL_LIB) +else() + find_package(AMD_PAL) +endif() -find_package(AMD_PAL) find_package(AMD_HSA_LOADER) target_sources(rocclr PRIVATE