Created
February 16, 2019 16:57
-
-
Save awenocur/45bc56bb7b1edbb106929e3b68b8ca73 to your computer and use it in GitHub Desktop.
modified ebuild for ROCm OpenCL runtime to enable debug symbols and macros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright | |
# | |
EAPI=6 | |
inherit cmake-utils eapi7-ver | |
DESCRIPTION="ROCm OpenCL Runtime" | |
HOMEPAGE="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/" | |
SRC_URI="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/archive/roc-2.0.0.tar.gz -> rocm-opencl-runtime-${PV}.tar.gz | |
https://github.com/RadeonOpenCompute/ROCm-OpenCL-Driver/archive/roc-2.0.0.tar.gz -> rocm-opencl-driver-${PV}.tar.gz | |
https://github.com/RadeonOpenCompute/ROCm-Device-Libs/archive/roc-2.0.0.tar.gz -> rocm-device-libs-${PV}.tar.gz | |
https://github.com/justxi/OpenCL-ICD-Loader/archive/20180325.tar.gz -> OpenCL-ICD-Loader-20180325.tar.gz" | |
LICENSE="MIT" | |
SLOT="0/$(ver_cut 1-2)" | |
KEYWORDS="~amd64" | |
IUSE="" | |
DEPEND="dev-cpp/gtest" | |
RDEPEND="sys-devel/llvm-roc | |
dev-libs/rocr-runtime | |
!dev-libs/rocm-device-libs" | |
# should later depend on: | |
# dev-libs/rocm-device-libs | |
#PATCHES=( | |
# "${FILESDIR}/rocm-opencl-driver-2.0.0-add-link-libraries.patch" | |
#) | |
RESTRICT="strip" | |
S="${WORKDIR}/ROCm-OpenCL-Runtime-roc-${PV}" | |
BUILD_DIR="${WORKDIR}/build" | |
CMAKE_BUILD_TYPE="Debug" | |
src_unpack() { | |
unpack ${A} | |
mkdir "${S}/library" | |
ln -s "${WORKDIR}/ROCm-OpenCL-Driver-roc-${PV}" "${S}/compiler/driver" | |
ln -s "${WORKDIR}/ROCm-Device-Libs-roc-${PV}" "${S}/library/amdgcn" | |
ln -s "${WORKDIR}/OpenCL-ICD-Loader-20180325" "${S}/api/opencl/khronos/icd" | |
} | |
src_prepare() { | |
# fails to build without that ... | |
patch -d ../ROCm-OpenCL-Driver-roc-2.0.0/ -p1 < ${FILESDIR}/rocm-opencl-driver-2.0.0-add-link-libraries.patch || die | |
# add path to /usr/lib/llvm/roc-2.0.0/include ... | |
patch -p1 < ${FILESDIR}/rocm-opencl-runtime-2.0.0-add-paths.patch || die | |
# remove the compiler subdirectory, we want to detect it from the system ... | |
sed -e "s:add_subdirectory(compiler/llvm):#add_subdirectory(compiler/llvm):" -i CMakeLists.txt || die | |
# change include directories to llvm/clang ... | |
sed -e "s:\${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/include:/usr/lib/llvm/roc-${PV}/include/:" -i CMakeLists.txt || die | |
sed -e "s:\${CMAKE_SOURCE_DIR}/compiler/llvm/lib/Target/AMDGPU:/usr/lib/llvm/roc-${PV}/include/llvm/Target:" -i CMakeLists.txt || die | |
# change path to "opencl-c.h" | |
sed -e "s:< \${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h:< /usr/lib/llvm/roc-${PV}/lib/clang/8.0.0/include/opencl-c.h:" -i runtime/device/rocm/CMakeLists.txt || die | |
# remove dependency to cland directory inside build tree and change path to "opencl-c.h" | |
sed -e "s:DEPENDS clang \${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h:DEPENDS /usr/lib/llvm/roc-${PV}/lib/clang/8.0.0/include/opencl-c.h:" -i runtime/device/rocm/CMakeLists.txt || die | |
cmake-utils_src_prepare | |
} | |
src_configure() { | |
export LLVM_DIR=/usr/lib/llvm/roc-${PV} | |
local mycmakeargs=( | |
# -DLLVM_DIR=$LLVM_DIR | |
-DLLVM_DIR=/usr/lib/llvm/roc-2.0.0/lib/cmake/llvm/ | |
-DCMAKE_INSTALL_PREFIX=/usr/ | |
-DCMAKE_C_FLAGS='-O0 -ggdb' | |
-DCMAKE_CXX_FLAGS='-O0 -ggdb' | |
) | |
cmake-utils_src_configure | |
} | |
src_compile() { | |
cd "${BUILD_DIR}/runtime/device/rocm" | |
make -j1 || die | |
cd ${BUILD_DIR} | |
make -j1 || die | |
} | |
src_install() { | |
cd ${BUILD_DIR} | |
emake DESTDIR="${D}" install | |
rm ${D}/usr/lib/libOpenCL.so.1.2 | |
ROC_DIR=/usr/"$(get_libdir)"/OpenCL/vendors/roc/ | |
dodir "${ROC_DIR}" | |
dolib.so "${BUILD_DIR}/lib/libOpenCL.so.1.2" | |
chrpath --delete "${BUILD_DIR}/lib/libOpenCLDriverStub.so" | |
dolib.so "${BUILD_DIR}/lib/libOpenCLDriverStub.so" | |
mv ${D}/usr/"$(get_libdir)"/libOpenCL* ${D}"${ROC_DIR}" | |
dolib.so "${BUILD_DIR}/lib/libIcdLog.so" | |
mv ${D}/usr/"$(get_libdir)"/libIcdLog* ${D}"${ROC_DIR}" | |
into "${ROC_DIR}" | |
dosym "libOpenCL.so.1.2" "${ROC_DIR}/libOpenCL.so" | |
dosym "libOpenCL.so.1.2" "${ROC_DIR}/libOpenCL.so.1" | |
# move headers to vendor directory | |
mkdir "${D}${ROC_DIR}/include/" | |
mv "${D}/usr/include/opencl2.2/CL" "${D}${ROC_DIR}/include/" | |
rm -r "${D}/usr/include/opencl2.2" | |
mv ${D}/usr/lib/x86_64/libamdocl64.so ${D}/usr/lib/ | |
rm -r ${D}/usr/lib/x86_64 | |
chrpath --delete "${D}/usr/lib/libamdocl64.so" | |
insinto /etc/OpenCL/vendors | |
doins ${S}/api/opencl/config/amdocl64.icd | |
# Do not install the program "clinfo", due to the fact it is already installable thru "dev-util/clinfo" | |
rm ${D}/usr/bin/clinfo | |
} | |
pkg_postinst() { | |
elog "If more than one OpenCL library is installed, set environment variable OCL_ICD_VENDORS:" | |
elog "> export OCL_ICD_VENDORS=amdocl64.icd" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment