Skip to content

Commit

Permalink
Add ROCmDeviceLibs 5.2.3 (#5477)
Browse files Browse the repository at this point in the history
* Add ROCmDeviceLibs 5.2.3

* Up
  • Loading branch information
pxl-th authored Sep 12, 2022
1 parent fc4d563 commit 4ba5883
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 8 deletions.
7 changes: 7 additions & 0 deletions R/ROCmDeviceLibs/[email protected]/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Pkg
using BinaryBuilder

include("../common.jl")
build_tarballs(
ARGS, configure_build(v"5.2.3")...;
preferred_gcc_version=v"7", preferred_llvm_version=v"9", julia_compat="1.9")
25 changes: 17 additions & 8 deletions R/ROCmDeviceLibs/common.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const NAME = "ROCmDeviceLibs"

const ROCM_GIT = "https://github.com/RadeonOpenCompute/ROCm-Device-Libs/"
const ROCM_TAGS = Dict(
v"4.2.0" => "34a2ac39b9bb7cfa8175cbab05d30e7f3c06aaffce99eed5f79c616d0f910f5f",
v"4.5.2" => "50e9e87ecd6b561cad0d471295d29f7220e195528e567fcabe2ec73838979f61")
v"4.5.2" => "50e9e87ecd6b561cad0d471295d29f7220e195528e567fcabe2ec73838979f61",
v"5.2.3" => "16b7fc7db4759bd6fb54852e9855fa16ead76c97871d7e1e9392e846381d611a")
const ROCM_PLATFORMS = [
Platform("x86_64", "linux"; libc="glibc", cxxstring_abi="cxx11"),
Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11"),
Expand All @@ -11,28 +14,34 @@ const BUILDSCRIPT = raw"""
cd ${WORKSPACE}/srcdir/ROCm-Device-Libs*/
mkdir build && cd build
CC=${WORKSPACE}/srcdir/rocm-clang \
CXX=${WORKSPACE}/srcdir/rocm-clang++ \
cmake \
-DCMAKE_PREFIX_PATH=${prefix} \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-DLLVM_DIR=${prefix}/llvm/lib/cmake/llvm \
-DLLD_DIR=${prefix}/llvm/lib/cmake/lld \
-DClang_DIR=${prefix}/llvm/lib/cmake/clang \
..
make -j${nproc}
make install
install_license ${WORKSPACE}/srcdir/ROCm-Device-Libs*/LICENSE.TXT
"""

const PRODUCTS = [FileProduct("amdgcn/bitcode/", :bitcode_path)]

function configure_build(version)
sources = [
ArchiveSource(
ROCM_GIT * "/archive/rocm-$(version).tar.gz",
ROCM_TAGS[version]),
ROCM_GIT * "/archive/rocm-$(version).tar.gz", ROCM_TAGS[version]),
DirectorySource("../scripts"),
]
products = [FileProduct("amdgcn/bitcode/", :bitcode_path)]
dependencies = [
BuildDependency(PackageSpec(; name="ROCmLLVM_jll", version)),
BuildDependency(PackageSpec(; name="rocm_cmake_jll", version)),
Dependency("Zlib_jll"),
]
name = "ROCmDeviceLibs"
(
name, version, sources, BUILDSCRIPT,
ROCM_PLATFORMS, products, dependencies)
NAME, version, sources, BUILDSCRIPT, ROCM_PLATFORMS, PRODUCTS, dependencies
end
39 changes: 39 additions & 0 deletions R/ROCmDeviceLibs/scripts/rocm-clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

ARGS=( "$@" )
PRE_FLAGS=()
POST_FLAGS=()

PRE_FLAGS+=( -target ${target} )
PRE_FLAGS+=( --sysroot=/opt/${target}/${target}/sys-root )
PRE_FLAGS+=( --gcc-toolchain=/opt/${target} )

if [[ " ${ARGS[@]} " != *' -x assembler '* ]]; then
PRE_FLAGS+=( -march=x86-64 )
PRE_FLAGS+=( -mtune=generic )
fi

COMPILE_BASE_DIR=/opt/${target}/${target}
COMPILE_CPP_DIR=${COMPILE_BASE_DIR}/include/c++/*
PRE_FLAGS+=(-isystem ${COMPILE_CPP_DIR} -isystem ${COMPILE_CPP_DIR}/${target})

if [[ " ${ARGS[@]} " != *' -c '* ]] && [[ " ${ARGS[@]} " != *' -E '* ]] && [[ " ${ARGS[@]} " != *' -M '* ]] && [[ " ${ARGS[@]} " != *' -fsyntax-only '* ]]; then
POST_FLAGS+=( -rtlib=libgcc )
POST_FLAGS+=( -stdlib=libstdc++ )
POST_FLAGS+=( -fuse-ld=lld )
fi

COMPILE_BASE_DIR=/opt/${target}/${target}
LINK_GCC_DIR=/opt/${target}/lib/gcc/${target}/*
POST_FLAGS+=(-B ${LINK_GCC_DIR} -L ${LINK_GCC_DIR} -L ${COMPILE_BASE_DIR}/lib64)

if [[ " ${ARGS[@]} " == *"-march="* ]]; then
echo "BinaryBuilder: Cannot force an architecture via -march" >&2
exit 1
fi

if [ ${USE_CCACHE} == "true" ]; then
CCACHE="ccache"
fi

${CCACHE} ${prefix}/llvm/bin/clang "${PRE_FLAGS[@]}" "${ARGS[@]}" "${POST_FLAGS[@]}"
39 changes: 39 additions & 0 deletions R/ROCmDeviceLibs/scripts/rocm-clang++
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

ARGS=( "$@" )
PRE_FLAGS=()
POST_FLAGS=()

PRE_FLAGS+=( -target ${target} )
PRE_FLAGS+=( --sysroot=/opt/${target}/${target}/sys-root )
PRE_FLAGS+=( --gcc-toolchain=/opt/${target} )

if [[ " ${ARGS[@]} " != *' -x assembler '* ]]; then
PRE_FLAGS+=( -march=x86-64 )
PRE_FLAGS+=( -mtune=generic )
fi

COMPILE_BASE_DIR=/opt/${target}/${target}
COMPILE_CPP_DIR=${COMPILE_BASE_DIR}/include/c++/*
PRE_FLAGS+=(-isystem ${COMPILE_CPP_DIR} -isystem ${COMPILE_CPP_DIR}/${target})

if [[ " ${ARGS[@]} " != *' -c '* ]] && [[ " ${ARGS[@]} " != *' -E '* ]] && [[ " ${ARGS[@]} " != *' -M '* ]] && [[ " ${ARGS[@]} " != *' -fsyntax-only '* ]]; then
POST_FLAGS+=( -rtlib=libgcc )
POST_FLAGS+=( -stdlib=libstdc++ )
POST_FLAGS+=( -fuse-ld=lld )
fi

COMPILE_BASE_DIR=/opt/${target}/${target}
LINK_GCC_DIR=/opt/${target}/lib/gcc/${target}/*
POST_FLAGS+=(-B ${LINK_GCC_DIR} -L ${LINK_GCC_DIR} -L ${COMPILE_BASE_DIR}/lib64)

if [[ " ${ARGS[@]} " == *"-march="* ]]; then
echo "BinaryBuilder: Cannot force an architecture via -march" >&2
exit 1
fi

if [ ${USE_CCACHE} == "true" ]; then
CCACHE="ccache"
fi

${CCACHE} ${prefix}/llvm/bin/clang++ "${PRE_FLAGS[@]}" "${ARGS[@]}" "${POST_FLAGS[@]}"

0 comments on commit 4ba5883

Please sign in to comment.