add patch for not linking to clang rt bulitin lib, and apply patches to 3.9.0 too (#20937)

This commit is contained in:
Harmen Stoppels 2021-01-22 09:55:46 +01:00 committed by GitHub
parent f7064fa181
commit d42d9a619a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 141 additions and 13 deletions

View file

@ -0,0 +1,56 @@
From db2a538d9beaef9092dff19c36ed8a2e291bc69a Mon Sep 17 00:00:00 2001
From: Harmen Stoppels <harmenstoppels@gmail.com>
Date: Mon, 11 Jan 2021 16:38:14 +0100
Subject: [PATCH 1/2] Improve compilation without git repo
---
CMakeLists.txt | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f5bdad9..ca0e7ed4 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,9 +44,17 @@ string(REPLACE "." ";" VERSION_LIST ${HIP_BASE_VERSION})
list(GET VERSION_LIST 0 HIP_VERSION_MAJOR)
list(GET VERSION_LIST 1 HIP_VERSION_MINOR)
-find_package(Git)
+# only look for git when we have a git repo
+if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
+ find_package(Git)
+endif()
# FIXME: Two different version strings used.
+
+set(HIP_PACKAGING_VERSION_PATCH "0")
+set(HIP_VERSION_GITDATE "0")
+set(HIP_VERSION_PATCH "0")
+
if(GIT_FOUND)
# get date information based on UTC
# use the last two digits of year + week number + day in the week as HIP_VERSION_GITDATE
@@ -90,9 +98,6 @@ if(GIT_FOUND)
else()
set(HIP_PACKAGING_VERSION_PATCH ${HIP_VERSION_GITDATE}.${HIP_VERSION_GITCOUNT}-${HIP_VERSION_GITHASH})
endif()
-else()
- # FIXME: Some parts depend on this being set.
- set(HIP_PACKAGING_VERSION_PATCH "0")
endif()
add_to_config(_versionInfo HIP_VERSION_MAJOR)
@@ -447,10 +452,6 @@ endif()
# Generate .hipVersion
file(WRITE "${PROJECT_BINARY_DIR}/.hipVersion" ${_versionInfo})
-if(NOT DEFINED HIP_VERSION_GITDATE)
- set(HIP_VERSION_GITDATE 0)
-endif()
-
# Generate hip_version.h
set(_versionInfoHeader
"// Auto-generated by cmake\n
--
2.25.1

View file

@ -0,0 +1,32 @@
From 8b266132ee180ff8cc17b394ba64850f207a3dab Mon Sep 17 00:00:00 2001
From: Harmen Stoppels <harmenstoppels@gmail.com>
Date: Tue, 12 Jan 2021 12:26:44 +0100
Subject: [PATCH] Drop clang rt builtins linking on hip::host
Ref this comment
https://github.com/ROCm-Developer-Tools/HIP/pull/2217#discussion_r555402581:
> Yea, this should only be linked on hip::device as I believe its needed
> for __fp16 support on the GPU. If users need this on the host-side,
> then they should explicitly add it.
---
hip-config.cmake.in | 3 ---
1 file changed, 3 deletions(-)
diff --git a/hip-config.cmake.in b/hip-config.cmake.in
index 6dfbd527..0ac1b659 100644
--- a/hip-config.cmake.in
+++ b/hip-config.cmake.in
@@ -206,9 +206,6 @@ if(HIP_COMPILER STREQUAL "clang")
endif()
# Add support for __fp16 and _Float16, explicitly link with compiler-rt
- set_property(TARGET hip::host APPEND PROPERTY
- INTERFACE_LINK_LIBRARIES -L${HIP_CLANG_INCLUDE_PATH}/../lib/linux -lclang_rt.builtins-x86_64
- )
set_property(TARGET hip::device APPEND PROPERTY
INTERFACE_LINK_LIBRARIES -L${HIP_CLANG_INCLUDE_PATH}/../lib/linux -lclang_rt.builtins-x86_64
)
--
2.25.1

View file

@ -0,0 +1,35 @@
From 053bb794c57424fc47d53d8914bca1dc8d776a34 Mon Sep 17 00:00:00 2001
From: Harmen Stoppels <harmenstoppels@gmail.com>
Date: Tue, 12 Jan 2021 12:26:44 +0100
Subject: [PATCH 2/2] Drop clang rt builtins linking on hip::host
Ref this comment
https://github.com/ROCm-Developer-Tools/HIP/pull/2217#discussion_r555402581:
> Yea, this should only be linked on hip::device as I believe its needed
> for __fp16 support on the GPU. If users need this on the host-side,
> then they should explicitly add it.
---
hip-config.cmake.in | 6 ------
1 file changed, 6 deletions(-)
diff --git a/hip-config.cmake.in b/hip-config.cmake.in
index ba340134..4daff392 100644
--- a/hip-config.cmake.in
+++ b/hip-config.cmake.in
@@ -204,12 +204,6 @@ if(HIP_COMPILER STREQUAL "clang")
endif()
# Add support for __fp16 and _Float16, explicitly link with compiler-rt
- set_property(TARGET hip::host APPEND PROPERTY
- INTERFACE_COMPILE_OPTIONS -L${HIP_CLANG_INCLUDE_PATH}/../lib/linux -lclang_rt.builtins-x86_64
- )
- set_property(TARGET hip::host APPEND PROPERTY
- INTERFACE_LINK_LIBRARIES -L${HIP_CLANG_INCLUDE_PATH}/../lib/linux -lclang_rt.builtins-x86_64
- )
set_property(TARGET hip::device APPEND PROPERTY
INTERFACE_COMPILE_OPTIONS -L${HIP_CLANG_INCLUDE_PATH}/../lib/linux -lclang_rt.builtins-x86_64
)
--
2.25.1

View file

@ -52,7 +52,12 @@ class Hip(CMakePackage):
patch('0002-Fix-detection-of-HIP_CLANG_ROOT.patch', when='@:3.9.0')
# See https://github.com/ROCm-Developer-Tools/HIP/pull/2218
patch('0003-Improve-compilation-without-git-repo.patch', when='@4.0.0:')
patch('0003-Improve-compilation-without-git-repo.3.9.0.patch', when='@3.9.0')
patch('0003-Improve-compilation-without-git-repo.3.10.0.patch', when='@3.10.0:4.0.0')
# See https://github.com/ROCm-Developer-Tools/HIP/pull/2219
patch('0004-Drop-clang-rt-builtins-linking-on-hip-host.3.9.0.patch', when='@3.9.0')
patch('0004-Drop-clang-rt-builtins-linking-on-hip-host.3.10.0.patch', when='@3.10.0:4.0.0')
def get_rocm_prefix_info(self):
# External packages in Spack do not currently contain dependency
@ -109,6 +114,10 @@ def set_variables(self, env):
env.set('ROCMINFO_PATH', rocm_prefixes['rocminfo'])
env.set('DEVICE_LIB_PATH', rocm_prefixes['device_lib_path'])
env.set('HIP_PATH', rocm_prefixes['rocm-path'])
# this guy is used in comgr, see the following file:
# https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/blob/rocm-4.0.0/lib/comgr/src/comgr-env.cpp
# it's necessary on runtime when using hiprtcCreateProgram and such
env.set('LLVM_PATH', rocm_prefixes['llvm-amdgpu'])
env.set('HIPCC_COMPILE_FLAGS_APPEND',
'--rocm-path={0}'.format(rocm_prefixes['device_lib_path']))
@ -135,16 +144,6 @@ def patch(self):
'INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"',
'hip-config.cmake.in', string=True)
def flag_handler(self, name, flags):
if name == 'cxxflags' and '@3.7.0:' in self.spec:
incl = self.spec['hip-rocclr'].prefix.include
flags.append('-I {0}/compiler/lib/include'.format(incl))
flags.append('-I {0}/elf'.format(incl))
return (flags, None, None)
@run_before('install')
def filter_sbang(self):
perl = self.spec['perl'].command
kwargs = {'ignore_absent': False, 'backup': False, 'string': False}
@ -157,8 +156,6 @@ def filter_sbang(self):
]
filter_file(match, substitute, *files, **kwargs)
@run_before('install')
def filter_numactl(self):
if '@3.7.0:' in self.spec:
numactl = self.spec['numactl'].prefix.lib
kwargs = {'ignore_absent': False, 'backup': False, 'string': False}
@ -168,6 +165,14 @@ def filter_numactl(self):
substitute = " -L{numactl} -lnuma".format(numactl=numactl)
filter_file(match, substitute, 'hipcc', **kwargs)
def flag_handler(self, name, flags):
if name == 'cxxflags' and '@3.7.0:' in self.spec:
incl = self.spec['hip-rocclr'].prefix.include
flags.append('-I {0}/compiler/lib/include'.format(incl))
flags.append('-I {0}/elf'.format(incl))
return (flags, None, None)
def cmake_args(self):
args = [
'-DHIP_COMPILER=clang',