From bf2660ddc4a2efa0032305914016790e210e93c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= Date: Thu, 28 Nov 2024 05:45:11 +0100 Subject: [PATCH 1/2] chipstar: New recipe for chipStar 1.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zoltán Böszörményi --- ...LLVM-and-CLang-without-explicit-path.patch | 46 ++++++++ .../chipstar/0001-Fix-llvm-link-command.patch | 31 +++++ ...RGET_SYS-for-offload-compile-options.patch | 31 +++++ ...-compiler-for-generating-bitcode-fil.patch | 49 ++++++++ ...Remove-dump-usage-from-the-LLVM-pass.patch | 73 ++++++++++++ ...Use-native-build-of-prepare-builtins.patch | 31 +++++ ...-the-native-hipcc-in-samples-ccompat.patch | 44 +++++++ ...e-native-hipcc-in-add_custom_command.patch | 31 +++++ ...0006-Hide-source-and-build-directory.patch | 34 ++++++ ...007-Remove-rpath-from-linker-options.patch | 42 +++++++ recipes-support/chipstar/chipstar_1.2.1.bb | 111 ++++++++++++++++++ 11 files changed, 523 insertions(+) create mode 100644 recipes-support/chipstar/chipstar/0001-Allow-detecting-LLVM-and-CLang-without-explicit-path.patch create mode 100644 recipes-support/chipstar/chipstar/0001-Fix-llvm-link-command.patch create mode 100644 recipes-support/chipstar/chipstar/0002-Use-TARGET_SYS-for-offload-compile-options.patch create mode 100644 recipes-support/chipstar/chipstar/0002-Use-target-clang-compiler-for-generating-bitcode-fil.patch create mode 100644 recipes-support/chipstar/chipstar/0003-Remove-dump-usage-from-the-LLVM-pass.patch create mode 100644 recipes-support/chipstar/chipstar/0003-Use-native-build-of-prepare-builtins.patch create mode 100644 recipes-support/chipstar/chipstar/0004-Execute-the-native-hipcc-in-samples-ccompat.patch create mode 100644 recipes-support/chipstar/chipstar/0005-Use-native-hipcc-in-add_custom_command.patch create mode 100644 recipes-support/chipstar/chipstar/0006-Hide-source-and-build-directory.patch create mode 100644 recipes-support/chipstar/chipstar/0007-Remove-rpath-from-linker-options.patch create mode 100644 recipes-support/chipstar/chipstar_1.2.1.bb diff --git a/recipes-support/chipstar/chipstar/0001-Allow-detecting-LLVM-and-CLang-without-explicit-path.patch b/recipes-support/chipstar/chipstar/0001-Allow-detecting-LLVM-and-CLang-without-explicit-path.patch new file mode 100644 index 0000000..c4bf418 --- /dev/null +++ b/recipes-support/chipstar/chipstar/0001-Allow-detecting-LLVM-and-CLang-without-explicit-path.patch @@ -0,0 +1,46 @@ +From 4588e6b9f77e94211cdfedea095e2a7747c9b501 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Tue, 26 Nov 2024 13:36:31 +0100 +Subject: [PATCH 1/7] Allow detecting LLVM and CLang without explicit paths +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + cmake/FindLLVM.cmake | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake +index a12bd476..ac04bab4 100644 +--- a/cmake/FindLLVM.cmake ++++ b/cmake/FindLLVM.cmake +@@ -72,13 +72,13 @@ endif() + include_directories(${LLVM_INCLUDE_DIRS}) + + # Set the compilers +-find_program(CMAKE_CXX_COMPILER_PATH NAMES clang++ NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH_BIN}) ++find_program(CMAKE_CXX_COMPILER_PATH NAMES ${TARGET_SYS}-clang++ clang++) + if(NOT CMAKE_CXX_COMPILER_PATH) + message(FATAL_ERROR "Could not find clang++ in ${CLANG_ROOT_PATH_BIN}. Please provide CMake argument -DCMAKE_CXX_COMPILER_PATH=/path/to/clang++<-version>") + endif() + message(STATUS "Using CMAKE_CXX_COMPILER_PATH: ${CMAKE_CXX_COMPILER_PATH}") + +-find_program(CMAKE_C_COMPILER_PATH NAMES clang NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH_BIN}) ++find_program(CMAKE_C_COMPILER_PATH NAMES ${TARGET_SYS}-clang clang) + if(NOT CMAKE_C_COMPILER_PATH) + message(FATAL_ERROR "Could not find clang in ${CLANG_ROOT_PATH_BIN}. Please provide CMake argument -DCMAKE_C_COMPILER_PATH=/path/to/clang<-version>") + endif() +@@ -143,5 +143,5 @@ endif() + + enable_language(C CXX) + # required by ROCm-Device-Libs, must be after project() call +-find_package(LLVM REQUIRED CONFIG NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH}/lib/cmake/llvm) +-find_package(Clang REQUIRED CONFIG NO_DEFAULT_PATH PATHS ${CLANG_ROOT_PATH}/lib/cmake/clang) ++find_package(LLVM REQUIRED CONFIG) ++find_package(Clang REQUIRED CONFIG) +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0001-Fix-llvm-link-command.patch b/recipes-support/chipstar/chipstar/0001-Fix-llvm-link-command.patch new file mode 100644 index 0000000..acc9940 --- /dev/null +++ b/recipes-support/chipstar/chipstar/0001-Fix-llvm-link-command.patch @@ -0,0 +1,31 @@ +From bd3fd0a630762cda06e06208cf4ab0a300cb7424 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Tue, 26 Nov 2024 15:46:51 +0100 +Subject: [PATCH 1/3] Fix llvm-link command +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + irif/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/irif/CMakeLists.txt b/irif/CMakeLists.txt +index a874772..47f7616 100644 +--- a/irif/CMakeLists.txt ++++ b/irif/CMakeLists.txt +@@ -19,7 +19,7 @@ set(irif_lib_file ${CMAKE_CURRENT_BINARY_DIR}/irif.bc) + # set_target_properties(llvm-link PROPERTIES IMPORTED_LOCATION ${LLVM_LINK_EXECUTABLE}) + + add_custom_command(OUTPUT ${irif_lib_file} +- COMMAND $ ${sources} -o ${irif_lib_file} ++ COMMAND llvm-link ${sources} -o ${irif_lib_file} + DEPENDS ${sources}) + + add_custom_target(irif DEPENDS ${irif_lib_file} +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0002-Use-TARGET_SYS-for-offload-compile-options.patch b/recipes-support/chipstar/chipstar/0002-Use-TARGET_SYS-for-offload-compile-options.patch new file mode 100644 index 0000000..9e3dcbc --- /dev/null +++ b/recipes-support/chipstar/chipstar/0002-Use-TARGET_SYS-for-offload-compile-options.patch @@ -0,0 +1,31 @@ +From 21456b0816af8e80ee03f4ea5e73111195431948 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Wed, 27 Nov 2024 11:19:54 +0100 +Subject: [PATCH 2/7] Use TARGET_SYS for offload compile options +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c9cd19b2..59a7822b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -520,7 +520,7 @@ endif() + # For use by hipcc + execute_process(COMMAND ${LLVM_CONFIG_BIN} --host-target + OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE HOST_ARCH) +-set(HOST_ARCH "--target=${HOST_ARCH}") ++set(HOST_ARCH "--target=${TARGET_SYS}") + + set(HIP_OFFLOAD_COMPILE_OPTIONS_INSTALL_ + ${HIP_ENABLE_SPIRV} +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0002-Use-target-clang-compiler-for-generating-bitcode-fil.patch b/recipes-support/chipstar/chipstar/0002-Use-target-clang-compiler-for-generating-bitcode-fil.patch new file mode 100644 index 0000000..ca03bf9 --- /dev/null +++ b/recipes-support/chipstar/chipstar/0002-Use-target-clang-compiler-for-generating-bitcode-fil.patch @@ -0,0 +1,49 @@ +From bf8832d0b004b2c6a6ddaa074dd72a6c023ebeca Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Tue, 26 Nov 2024 16:00:00 +0100 +Subject: [PATCH 2/3] Use target clang compiler for generating bitcode files +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Also fix other COMMAND statements in the same macro + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + cmake/OCL.cmake | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/cmake/OCL.cmake b/cmake/OCL.cmake +index 2eaf44e..c6005d2 100644 +--- a/cmake/OCL.cmake ++++ b/cmake/OCL.cmake +@@ -99,7 +99,7 @@ macro(opencl_bc_lib) + if (fext STREQUAL ".cl") + set(output "${CMAKE_CURRENT_BINARY_DIR}/${fname_we}${BC_EXT}") + add_custom_command(OUTPUT "${output}" +- COMMAND ${CLANG_ROOT_PATH_BIN}/clang ${inc_options} ${CLANG_OCL_FLAGS} ++ COMMAND ${CMAKE_C_COMPILER_PATH} ${inc_options} ${CLANG_OCL_FLAGS} + -emit-llvm -Xclang -mlink-builtin-bitcode -Xclang "${irif_lib_output}" + -c "${file}" -o "${output}" + DEPENDS "${file}" "${irif_lib_output}" "${CLANG}" +@@ -130,12 +130,12 @@ macro(opencl_bc_lib) + + add_custom_command(OUTPUT ${OUTPUT_BC_LIB} + # Link regular library dependencies +- COMMAND ${CLANG_ROOT_PATH_BIN}/llvm-link ++ COMMAND llvm-link + -o "${OUT_NAME}.link0${LIB_SUFFIX}" "@${OUT_NAME}_response" + # Extra link step with internalize +- COMMAND ${CLANG_ROOT_PATH_BIN}/llvm-link -internalize -only-needed "${name}.link0${LIB_SUFFIX}" ++ COMMAND llvm-link -internalize -only-needed "${name}.link0${LIB_SUFFIX}" + -o "${OUT_NAME}${LIB_SUFFIX}" ${internal_link_libs} +- COMMAND ${CLANG_ROOT_PATH_BIN}/opt -passes=strip ++ COMMAND opt -passes=strip + -o "${OUT_NAME}${STRIP_SUFFIX}" "${OUT_NAME}${LIB_SUFFIX}" + COMMAND "${PREPARE_BUILTINS}" + -o ${OUTPUT_BC_LIB} "${OUT_NAME}${STRIP_SUFFIX}" +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0003-Remove-dump-usage-from-the-LLVM-pass.patch b/recipes-support/chipstar/chipstar/0003-Remove-dump-usage-from-the-LLVM-pass.patch new file mode 100644 index 0000000..b7eba58 --- /dev/null +++ b/recipes-support/chipstar/chipstar/0003-Remove-dump-usage-from-the-LLVM-pass.patch @@ -0,0 +1,73 @@ +From 2ae94496af84f2cfed2e2bf46312b601dedfbeee Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Wed, 27 Nov 2024 11:58:32 +0100 +Subject: [PATCH 3/7] Remove ->dump() usage from the LLVM pass +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Release builds of LLVM do not have the Elt->dump() method +which Yocto uses for LLVM and CLang. This fixes the error: + +chipstar/1.2.1/build/lib/libLLVMHipSpvPasses.so: undefined symbol: _ZNK4llvm5Value4dumpEv + +Upstream-Status: Inappropriate [oe specific] +Signed-off-by: Zoltán Böszörményi +--- + llvm_passes/HipPrintf.cpp | 3 --- + llvm_passes/HipTextureLowering.cpp | 17 +---------------- + 2 files changed, 1 insertion(+), 19 deletions(-) + +diff --git a/llvm_passes/HipPrintf.cpp b/llvm_passes/HipPrintf.cpp +index 18a8441c..5aa83984 100644 +--- a/llvm_passes/HipPrintf.cpp ++++ b/llvm_passes/HipPrintf.cpp +@@ -303,7 +303,6 @@ PreservedAnalyses HipPrintfToOpenCLPrintfPass::run(Module &Mod, + // 1 use if the "printf" is only used by "_cl_printf" + if (Printf == nullptr || Printf->getNumUses() == 1) + return PreservedAnalyses::all(); +- LLVM_DEBUG(dbgs() << "Found printf decl: "; Printf->dump()); + + Function *PrintfF = cast(Printf); + +@@ -351,8 +350,6 @@ PreservedAnalyses HipPrintfToOpenCLPrintfPass::run(Module &Mod, + if (!Callee->hasName() || Callee->getName() != ORIG_PRINTF_FUNC_NAME) + continue; + +- LLVM_DEBUG(dbgs() << "Original printf call: "; CI->dump()); +- + CallInst &OrigCall = cast(I); + unsigned TotalFmtSpecCount; + auto FmtSpecPieces = +diff --git a/llvm_passes/HipTextureLowering.cpp b/llvm_passes/HipTextureLowering.cpp +index c363010c..d2d799ac 100644 +--- a/llvm_passes/HipTextureLowering.cpp ++++ b/llvm_passes/HipTextureLowering.cpp +@@ -136,22 +136,7 @@ public: + } + }; + +-void TextureUseGroup::dump() const { +-#define DOIT(_container, _desc) \ +- do { \ +- dbgs() << _desc << ":" << (_container.empty() ? " none" : "") << "\n"; \ +- for (auto *Elt : _container) { \ +- dbgs() << "- "; \ +- Elt->dump(); \ +- } \ +- } while (0) +- +- DOIT(DirectTexSources_, "Direct tex sources"); +- DOIT(IndirectTexSources_, "Indirect tex sources"); +- DOIT(TexFunctionCalls_, "Tex function calls"); +- DOIT(UnknownTexUsers_, "Unknown tex users"); +-#undef DOIT +-} ++void TextureUseGroup::dump() const {} + + using TextureUseGroupList = std::vector; + using TextureUseGroupMap = std::map; +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0003-Use-native-build-of-prepare-builtins.patch b/recipes-support/chipstar/chipstar/0003-Use-native-build-of-prepare-builtins.patch new file mode 100644 index 0000000..6ba517d --- /dev/null +++ b/recipes-support/chipstar/chipstar/0003-Use-native-build-of-prepare-builtins.patch @@ -0,0 +1,31 @@ +From db7e15fbeb04d5b78b7573006aedfebedb66868c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Tue, 26 Nov 2024 16:44:40 +0100 +Subject: [PATCH 3/3] Use native build of prepare-builtins +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + cmake/OCL.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmake/OCL.cmake b/cmake/OCL.cmake +index c6005d2..fa99889 100644 +--- a/cmake/OCL.cmake ++++ b/cmake/OCL.cmake +@@ -137,7 +137,7 @@ macro(opencl_bc_lib) + -o "${OUT_NAME}${LIB_SUFFIX}" ${internal_link_libs} + COMMAND opt -passes=strip + -o "${OUT_NAME}${STRIP_SUFFIX}" "${OUT_NAME}${LIB_SUFFIX}" +- COMMAND "${PREPARE_BUILTINS}" ++ COMMAND prepare-builtins + -o ${OUTPUT_BC_LIB} "${OUT_NAME}${STRIP_SUFFIX}" + DEPENDS "${deps}" "${CMAKE_CURRENT_BINARY_DIR}/${OUT_NAME}_response" "${PREPARE_BUILTINS}" ${internal_link_libs}) + +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0004-Execute-the-native-hipcc-in-samples-ccompat.patch b/recipes-support/chipstar/chipstar/0004-Execute-the-native-hipcc-in-samples-ccompat.patch new file mode 100644 index 0000000..21e9893 --- /dev/null +++ b/recipes-support/chipstar/chipstar/0004-Execute-the-native-hipcc-in-samples-ccompat.patch @@ -0,0 +1,44 @@ +From 08e03e096bbd0672d2532d6965fb0c53caec0b9b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Wed, 27 Nov 2024 13:02:35 +0100 +Subject: [PATCH 4/7] Execute the native hipcc in samples/ccompat +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + samples/ccompat/CMakeLists.txt | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/samples/ccompat/CMakeLists.txt b/samples/ccompat/CMakeLists.txt +index 2c0e7648..7afe1216 100644 +--- a/samples/ccompat/CMakeLists.txt ++++ b/samples/ccompat/CMakeLists.txt +@@ -1,18 +1,18 @@ + add_custom_command( + OUTPUT saxpy.o DEPENDS ${CMAKE_SOURCE_DIR}/samples/ccompat/saxpy.hip +- COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc ++ COMMAND hipcc + ${CMAKE_SOURCE_DIR}/samples/ccompat/saxpy.hip -c -g -pthread + -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/HIP/include) + + add_custom_command( + OUTPUT ccompat.o DEPENDS ${CMAKE_SOURCE_DIR}/samples/ccompat/ccompat.c +- COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc ++ COMMAND hipcc + ${CMAKE_SOURCE_DIR}/samples/ccompat/ccompat.c -c -g -pthread + -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/HIP/include) + + add_custom_command( + OUTPUT ccompat DEPENDS ccompat.o saxpy.o +-COMMAND ${CMAKE_BINARY_DIR}/bin/hipcc ++COMMAND hipcc + ./ccompat.o ./saxpy.o -o ccompat -g -pthread) + + add_custom_target(ccompatBuild ALL +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0005-Use-native-hipcc-in-add_custom_command.patch b/recipes-support/chipstar/chipstar/0005-Use-native-hipcc-in-add_custom_command.patch new file mode 100644 index 0000000..c013e83 --- /dev/null +++ b/recipes-support/chipstar/chipstar/0005-Use-native-hipcc-in-add_custom_command.patch @@ -0,0 +1,31 @@ +From a2f46d748c9af2144374bf99626ffa25419ef2f5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Wed, 27 Nov 2024 13:15:41 +0100 +Subject: [PATCH 5/7] Use native hipcc in add_custom_command() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 59a7822b..aeb25580 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -428,7 +428,7 @@ endif() + # once hipcc.bin is built, execute hipcc ./samples/hipSample.cpp + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/hipInfo +- COMMAND ${HIPCC_BUILD_PATH}/hipcc ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp -o ${CMAKE_BINARY_DIR}/hipInfo ++ COMMAND hipcc ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp -o ${CMAKE_BINARY_DIR}/hipInfo + DEPENDS ${CMAKE_SOURCE_DIR}/samples/hipInfo/hipInfo.cpp hipcc.bin CHIP devicelib_bc + ) + +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0006-Hide-source-and-build-directory.patch b/recipes-support/chipstar/chipstar/0006-Hide-source-and-build-directory.patch new file mode 100644 index 0000000..6b9c642 --- /dev/null +++ b/recipes-support/chipstar/chipstar/0006-Hide-source-and-build-directory.patch @@ -0,0 +1,34 @@ +From 8e2f9062d1b5e4c78d6cd9574659d5f6d71ff289 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Wed, 27 Nov 2024 14:26:32 +0100 +Subject: [PATCH 6/7] Hide source and build directory +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + chipStarConfig.hh.in | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/chipStarConfig.hh.in b/chipStarConfig.hh.in +index a836cd8e..326d1b9b 100644 +--- a/chipStarConfig.hh.in ++++ b/chipStarConfig.hh.in +@@ -32,9 +32,9 @@ + // not implemented yet + #undef OCML_BASIC_ROUNDED_OPERATIONS + +-#cmakedefine CHIP_SOURCE_DIR "@CHIP_SOURCE_DIR@" ++#cmakedefine CHIP_SOURCE_DIR "@EXT_SOURCE_DIR@" + +-#cmakedefine CHIP_BUILD_DIR "@CHIP_BUILD_DIR@" ++#cmakedefine CHIP_BUILD_DIR "@EXT_BUILD_DIR@" + + #cmakedefine CHIP_INSTALL_DIR "@CHIP_INSTALL_DIR@" + +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar/0007-Remove-rpath-from-linker-options.patch b/recipes-support/chipstar/chipstar/0007-Remove-rpath-from-linker-options.patch new file mode 100644 index 0000000..5a29423 --- /dev/null +++ b/recipes-support/chipstar/chipstar/0007-Remove-rpath-from-linker-options.patch @@ -0,0 +1,42 @@ +From 42e48402815622a8388fa5ffce68218eabe8fd16 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Wed, 27 Nov 2024 14:48:20 +0100 +Subject: [PATCH 7/7] Remove rpath from linker options +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Inappropriate [cross compiler specific] +Signed-off-by: Zoltán Böszörményi +--- + CMakeLists.txt | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index aeb25580..6ef2ea8e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -550,19 +550,15 @@ list(APPEND HIP_OFFLOAD_LINK_OPTIONS_BUILD_ + "-L${CMAKE_BINARY_DIR}" "-lCHIP" "-no-hip-rt -locml_host_math_funcs") + + if(OpenCL_LIBRARY) +- target_link_options(CHIP PUBLIC -Wl,-rpath,${OpenCL_DIR}) + target_link_directories(CHIP PUBLIC ${OpenCL_DIR}) + endif() + + if(LevelZero_LIBRARY) + include_directories(CHIP PUBLIC ${LevelZeroInclude_DIR}) +- target_link_options(CHIP PUBLIC -Wl,-rpath,${LevelZeroLib_DIR}) + target_link_directories(CHIP PUBLIC ${LevelZeroLib_DIR}) + endif() + + if(CHIP_SET_RPATH) +- list(APPEND HIP_OFFLOAD_LINK_OPTIONS_INSTALL_ "-Wl,-rpath,${LIB_INSTALL_DIR}") +- list(APPEND HIP_OFFLOAD_LINK_OPTIONS_BUILD_ "-Wl,-rpath,${CMAKE_BINARY_DIR}") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + endif() + +-- +2.47.0 + diff --git a/recipes-support/chipstar/chipstar_1.2.1.bb b/recipes-support/chipstar/chipstar_1.2.1.bb new file mode 100644 index 0000000..0dda5e5 --- /dev/null +++ b/recipes-support/chipstar/chipstar_1.2.1.bb @@ -0,0 +1,111 @@ +DESCRIPTION = "chipStar enables compiling and running HIP and \ +CUDA applications on platforms which support SPIR-V as the device \ +intermediate representation. It supports OpenCL and Level Zero as \ +the low-level runtime alternatives." +HOMEPAGE = "https://github.com/CHIP-SPV/chipStar.git" +LICENSE = "MIT" + +DEPENDS = " \ + llvm-native vim-native spirv-llvm-translator-native chrpath-native \ + virtual/opencl-icd opencl-headers libffi libedit zlib libxml2 \ +" + +DEPENDS:append:class-target = " \ + llvm clang-cross-${TARGET_ARCH} spirv-llvm-translator \ + chipstar-native \ +" + +inherit cmake + +#PR = "r1" + +LIC_FILES_CHKSUM = "file://LICENSE;md5=18c85a1e3dc7c297bc0ab9ed498ceb21" + +SRC_URI = " \ + gitsm://github.com/CHIP-SPV/chipStar.git;protocol=https;branch=main \ + file://0001-Allow-detecting-LLVM-and-CLang-without-explicit-path.patch \ + file://0003-Remove-dump-usage-from-the-LLVM-pass.patch \ + file://0001-Fix-llvm-link-command.patch;patchdir=${S}/bitcode/ROCm-Device-Libs \ + file://0002-Use-target-clang-compiler-for-generating-bitcode-fil.patch;patchdir=${S}/bitcode/ROCm-Device-Libs \ +" + +SRC_URI:append:class-target = " \ + file://0002-Use-TARGET_SYS-for-offload-compile-options.patch \ + file://0004-Execute-the-native-hipcc-in-samples-ccompat.patch \ + file://0005-Use-native-hipcc-in-add_custom_command.patch \ + file://0006-Hide-source-and-build-directory.patch \ + file://0007-Remove-rpath-from-linker-options.patch \ + file://0003-Use-native-build-of-prepare-builtins.patch;patchdir=${S}/bitcode/ROCm-Device-Libs \ +" + +SRCREV = "d75c0180767d63bcd6c58948ba32123d48407138" + +S = "${UNPACKDIR}/git" + +PACKAGECONFIG:append:x86-64 = " levelzero" + +PACKAGECONFIG[levelzero] = ",,level-zero" + +# This causes a build problem in HIP tests +TUNE_CCARGS:remove:x86-64 = "-mfpmath=sse" + +OECMAKE_EXTRA_ROOT_PATH = "${S}/HIP/tests/catch/external" + +EXTRA_OECMAKE += " \ + -DTARGET_SYS=${TARGET_SYS} \ + -DCHIP_SET_RPATH=NO \ +" + +EXTRA_OECMAKE:append:class-target = " \ + -DCMAKE_BUILD_TYPE=Release \ + -DEXT_SOURCE_DIR='${prefix}/src/${BPN}-${PV}' \ + -DEXT_BUILD_DIR='${prefix}/src/${BPN}-${PV}' \ +" + +do_install:append () { + # chipStar installs the complete set of OpenCL headers + # which is provided by opencl-headers and opencl-clhpp + # but it's a different version, which would cause an + # LLVM build error complaining about OpenCL version mismatch. + rm -rf ${D}${includedir}/CL + + mv ${D}${prefix}/cmake/CHIP ${D}${libdir}/cmake + rmdir ${D}${prefix}/cmake + + ln -s cucc ${D}${bindir}/nvcc +} + +do_install:append:class-native () { + install -m755 ${B}/bitcode/ROCm-Device-Libs/utils/prepare-builtins/prepare-builtins ${D}${bindir} +} + +do_install:append:class-target () { + sed -i 's:^HIP_CLANG_PATH=.*$:HIP_CLANG_PATH=:' ${D}${datadir}/.hipInfo + + sed -i \ + -e 's:\(INTERFACE_LINK_DIRECTORIES.*\)${STAGING_LIBDIR};${STAGING_LIBDIR}\(.*\)$:\1${libdir}\2:' \ + -e 's:\(INTERFACE_LINK_LIBRARIES.*\)${STAGING_LIBDIR}/libze_loader.so;${STAGING_LIBDIR}/libOpenCL.so\(.*\)$:\1libze_loader.so;libOpenCL.so\2:' \ + ${D}${libdir}/cmake/hip/hip-targets.cmake \ + ${D}${libdir}/cmake/CHIP/CHIPTargets.cmake +} + +PACKAGES =+ "${PN}-lib ${PN}-samples" + +FILES:${PN} += " \ + ${bindir}/.hipVersion \ + ${datadir}/.hipInfo \ +" + +FILES:${PN}-lib = " \ + ${libdir}/libCHIP.so \ + ${libdir}/hip-device-lib/ \ + ${libdir}/llvm/ \ +" + +FILES:${PN}-samples = " \ + ${bindir}/chip_spv_samples/ \ +" + +TOOLCHAIN = "clang" + +BBCLASSEXTEND = "native" From 1e91a8cd5fbc4ff188bca564b78f40fa45ebc5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= Date: Tue, 3 Dec 2024 10:16:21 +0100 Subject: [PATCH 2/2] chipstar: Ship data files for samples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zoltán Böszörményi --- recipes-support/chipstar/chipstar_1.2.1.bb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes-support/chipstar/chipstar_1.2.1.bb b/recipes-support/chipstar/chipstar_1.2.1.bb index 0dda5e5..aa76f13 100644 --- a/recipes-support/chipstar/chipstar_1.2.1.bb +++ b/recipes-support/chipstar/chipstar_1.2.1.bb @@ -80,6 +80,10 @@ do_install:append:class-native () { } do_install:append:class-target () { + install -m644 ${S}/samples/hip-cuda/RecursiveGaussian/RecursiveGaussian_Input.bmp ${D}${bindir}/chip_spv_samples/ + install -m644 ${S}/samples/cuda_samples/2_Graphics/dwtHaar1D/data/signal.dat ${D}${bindir}/chip_spv_samples/cuda_samples + install -m644 ${S}/samples/cuda_samples/2_Graphics/dwtHaar1D/data/regression.gold.dat ${D}${bindir}/chip_spv_samples/cuda_samples + sed -i 's:^HIP_CLANG_PATH=.*$:HIP_CLANG_PATH=:' ${D}${datadir}/.hipInfo sed -i \