diff options
Diffstat (limited to 'dev-libs/rocm-comgr/files')
5 files changed, 180 insertions, 0 deletions
diff --git a/dev-libs/rocm-comgr/files/0001-COMGR-changes-needed-for-upstream-llvm.patch b/dev-libs/rocm-comgr/files/0001-COMGR-changes-needed-for-upstream-llvm.patch new file mode 100644 index 000000000000..8200d4414f8b --- /dev/null +++ b/dev-libs/rocm-comgr/files/0001-COMGR-changes-needed-for-upstream-llvm.patch @@ -0,0 +1,66 @@ +From be2bcaaea228cdcb5981b261046175275c402fb9 Mon Sep 17 00:00:00 2001 +From: Konstantin Zhuravlyov <kzhuravl_dev@outlook.com> +Date: Wed, 26 Jan 2022 12:02:52 -0500 +Subject: [PATCH] COMGR changes needed for + https://github.com/llvm/llvm-project/commit/83d59e05b201760e3f364ff6316301d347cbad95 + +Change-Id: Iac01d024463865734879faf5f814e0862c26f7a1 +--- + lib/comgr/src/comgr-compiler.cpp | 3 ++- + lib/comgr/src/comgr-env.h | 1 + + lib/comgr/src/comgr-objdump.cpp | 4 +++- + 3 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/lib/comgr/src/comgr-compiler.cpp b/lib/comgr/src/comgr-compiler.cpp +index 6c2cba2..db4c8d5 100644 +--- a/src/comgr-compiler.cpp ++++ b/src/comgr-compiler.cpp +@@ -605,7 +605,8 @@ static amd_comgr_status_t linkWithLLD(llvm::ArrayRef<const char *> Args, + ArrayRef<const char *> ArgRefs = llvm::makeArrayRef(LLDArgs); + static std::mutex MScreen; + MScreen.lock(); +- bool LLDRet = lld::elf::link(ArgRefs, false, LogS, LogE); ++ bool LLDRet = lld::elf::link(ArgRefs, LogS, LogE, false, false); ++ lld::CommonLinkerContext::destroy(); + MScreen.unlock(); + if (!LLDRet) { + return AMD_COMGR_STATUS_ERROR; +diff --git a/lib/comgr/src/comgr-env.h b/lib/comgr/src/comgr-env.h +index eb13e61..aef57b3 100644 +--- a/src/comgr-env.h ++++ b/src/comgr-env.h +@@ -36,6 +36,7 @@ + #ifndef COMGR_ENV_H + #define COMGR_ENV_H + ++#include "llvm/ADT/Optional.h" + #include "llvm/ADT/StringRef.h" + + namespace COMGR { +diff --git a/lib/comgr/src/comgr-objdump.cpp b/lib/comgr/src/comgr-objdump.cpp +index 094bbac..b41e6c1 100644 +--- a/src/comgr-objdump.cpp ++++ b/src/comgr-objdump.cpp +@@ -43,6 +43,7 @@ + #include "llvm/ADT/STLExtras.h" + #include "llvm/ADT/StringExtras.h" + #include "llvm/ADT/Triple.h" ++#include "llvm/CodeGen/CommandFlags.h" + #include "llvm/DebugInfo/DWARF/DWARFContext.h" + #include "llvm/DebugInfo/Symbolize/Symbolize.h" + #include "llvm/MC/MCAsmInfo.h" +@@ -2395,9 +2396,10 @@ llvm::DisassemHelper::disassembleAction(StringRef Input, + size_t ArgC = ArgV.size(); + ArgV.push_back(nullptr); + COMGR::clearLLVMOptions(); ++ llvm::codegen::RegisterCodeGenFlags CGF; + cl::ParseCommandLineOptions(ArgC, ArgV.data(), "llvm object file dumper\n", + &ErrS); +- MCPU = lld::getCPUStr(); ++ MCPU = llvm::codegen::getCPUStr(); + + ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr = + MemoryBuffer::getMemBuffer(Input); +-- +2.35.1 + diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch new file mode 100644 index 000000000000..362f5fcf16ca --- /dev/null +++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch @@ -0,0 +1,71 @@ +From 4c01c63a49af5748a8ee698553aa107803b60362 Mon Sep 17 00:00:00 2001 +From: Yiyang Wu <xgreenlandforwyy@gmail.com> +Date: Tue, 14 Jun 2022 20:21:22 +0800 +Subject: [PATCH] Find CLANG_RESOURCE_DIR using clang -print-resource-dir + +Suggested-By: https://reviews.llvm.org/D49486 +Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com> +--- + lib/comgr/cmake/opencl_pch.cmake | 24 +++--------------------- + 1 file changed, 3 insertions(+), 21 deletions(-) + +Index: comgr/cmake/opencl_pch.cmake +=================================================================== +--- comgr.orig/cmake/opencl_pch.cmake ++++ comgr/cmake/opencl_pch.cmake +@@ -1,26 +1,8 @@ + if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + find_package(Clang REQUIRED CONFIG) +- +- # FIXME: CLANG_CMAKE_DIR seems like the most stable way to find this, but +- # really there is no way to reliably discover this header. +- # +- # We effectively back up to the Clang output directory (for the case of a build +- # tree) or install prefix (for the case of an installed copy), and then search +- # for a file named opencl-c.h anywhere below that. We take the first result in +- # the case where there are multiple (e.g. if there is an installed copy nested +- # in a build directory). This is a bit imprecise, but it covers cases like MSVC +- # adding some additional configuration-specific subdirectories to the build +- # tree but not to an installed copy. +- file(GLOB_RECURSE OPENCL_C_H_LIST "${CLANG_CMAKE_DIR}/../../../*/opencl-c.h") +- +- list(GET OPENCL_C_H_LIST 0 OPENCL_C_H) +- +- if (NOT EXISTS "${OPENCL_C_H}" OR IS_DIRECTORY "${OPENCL_C_H}") +- message(FATAL_ERROR "Unable to locate opencl-c.h from the supplied Clang. The path '${CLANG_CMAKE_DIR}/../../../*' was searched.") +- endif() +-else() +- get_target_property(clang_build_header_dir clang-resource-headers RUNTIME_OUTPUT_DIRECTORY) +- set(OPENCL_C_H "${clang_build_header_dir}/opencl-c.h") ++ execute_process(COMMAND "${CLANG_INSTALL_PREFIX}/bin/clang" -print-resource-dir OUTPUT_VARIABLE CLANG_RESOURCE_DIR) ++ string(STRIP ${CLANG_RESOURCE_DIR} CLANG_RESOURCE_DIR) ++ set(OPENCL_C_H "${CLANG_RESOURCE_DIR}/include/opencl-c.h") + endif() + + # Macro to create and install a custom target for generating PCH for given +Index: comgr/src/comgr-compiler.cpp +=================================================================== +--- comgr.orig/src/comgr-compiler.cpp ++++ comgr/src/comgr-compiler.cpp +@@ -42,6 +42,7 @@ + #include "lld/Common/Driver.h" + #include "clang/Basic/Version.h" + #include "clang/CodeGen/CodeGenAction.h" ++#include "clang/Config/config.h" + #include "clang/Driver/Compilation.h" + #include "clang/Driver/DriverDiagnostic.h" + #include "clang/Driver/Job.h" +@@ -988,11 +989,8 @@ amd_comgr_status_t AMDGPUCompiler::addCo + HIPIncludePath = (Twine(env::getHIPPath()) + "/include").str(); + // HIP headers depend on hsa.h which is in ROCM_DIR/include. + ROCMIncludePath = (Twine(env::getROCMPath()) + "/include").str(); +- ClangIncludePath = +- (Twine(env::getLLVMPath()) + "/lib/clang/" + CLANG_VERSION_STRING).str(); +- ClangIncludePath2 = (Twine(env::getLLVMPath()) + "/lib/clang/" + +- CLANG_VERSION_STRING + "/include") +- .str(); ++ ClangIncludePath = (Twine(env::getLLVMPath()) + "/bin/" + CLANG_RESOURCE_DIR).str(); ++ ClangIncludePath2 = (Twine(env::getLLVMPath()) + "/bin/" + CLANG_RESOURCE_DIR + "/include").str(); + + Args.push_back("-x"); + diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-fix-include.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-fix-include.patch new file mode 100644 index 000000000000..6bf47c610dfc --- /dev/null +++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-fix-include.patch @@ -0,0 +1,12 @@ +Index: comgr/src/comgr-env.h +=================================================================== +--- comgr.orig/src/comgr-env.h ++++ comgr/src/comgr-env.h +@@ -37,6 +37,7 @@ + #define COMGR_ENV_H + + #include "llvm/ADT/StringRef.h" ++#include "llvm/ADT/Optional.h" + + namespace COMGR { + namespace env { diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-link.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-link.patch new file mode 100644 index 000000000000..0e2a9a668216 --- /dev/null +++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-link.patch @@ -0,0 +1,17 @@ +Index: comgr/CMakeLists.txt +=================================================================== +--- comgr.orig/CMakeLists.txt ++++ comgr/CMakeLists.txt +@@ -283,11 +283,7 @@ install(FILES + DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}") + + set(CLANG_LIBS +- clangFrontendTool +- clangFrontend +- clangBasic +- clangDriver +- clangSerialization) ++ clang-cpp) + + set(LLD_LIBS + lldELF diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-rocm-path.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-rocm-path.patch new file mode 100644 index 000000000000..c6d39715e864 --- /dev/null +++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-rocm-path.patch @@ -0,0 +1,14 @@ +Add --rocm-path=/usr argument in runtime because our rocm path is not in default seach list. +--- comgr/src/comgr-compiler.cpp ++++ comgr.orig/src/comgr-compiler.cpp +@@ -1096,6 +1096,10 @@ + } + } + } ++ else { ++ llvm::SmallString<128> RealRocmDir = env::getLLVMPath(); ++ Args.push_back(Saver.save(Twine("--rocm-path=") + RealRocmDir).data()); ++ } + + return processFiles(AMD_COMGR_DATA_KIND_BC, ".bc"); + } |