build.sh 2.45 KB
Newer Older
dugupeiwen's avatar
init  
dugupeiwen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash

set -x

###############################################################################
# Extract bitcodes from ROCM rpm source
###############################################################################

RPM_PATH=`readlink -f opencl_tmp/*.rpm`
ROCM_PATH="opt/rocm/opencl/lib/x86_64/bitcode"

declare -a bitcodes=(                       \
"opencl.amdgcn.bc"                          \
"ocml.amdgcn.bc"                            \
"ockl.amdgcn.bc"                            \
"oclc_correctly_rounded_sqrt_off.amdgcn.bc" \
"oclc_daz_opt_off.amdgcn.bc"                \
"oclc_finite_only_off.amdgcn.bc"            \
"oclc_isa_version_803.amdgcn.bc"            \
"oclc_unsafe_math_off.amdgcn.bc"            \
"irif.amdgcn.bc"                            \
)

for bitcode in "${bitcodes[@]}"; do
    bsdtar -x -f "$RPM_PATH" --strip-components 6 "$ROCM_PATH/$bitcode"
done

# move the bitcode to the pkg dir
RESOURCE_PATH="$PREFIX/share/rocmtools"
mv bitcode $RESOURCE_PATH

###############################################################################
# Now do C++ library build
###############################################################################
CMAKE_BUILD_DIR="cmake_build" # this needs to match meta.yaml test::source_files
mkdir ${CMAKE_BUILD_DIR}
pushd ${CMAKE_BUILD_DIR}

printenv

# Force CMake to look in the conda env "CMAKE_CONDA_ROOT" `/lib` etc 
# for libraries via `-L`
cmake .. -DCMAKE_BUILD_TYPE=RELEASE \
         -DCMAKE_CONDA_ROOT:PATH="$BUILD_PREFIX" \
         -DCMAKE_BITCODE_ROOT:PATH="$RESOURCE_PATH"

# build
make VERBOSE=1

# move DSO to lib
cp "rocmlite/librocmlite.so" "$PREFIX/lib"

# test now, splitting this out to work at test time is hard to do
# the test_XXX binaries are dynamically linked to librocmlite but no rpath
# fix is made unless the binaries are also shipped (undesirable).
ctest -V

popd

###############################################################################
# Copy llvmdev binary tools to /bin
# NOTE: should these names start to cause collision issues with llvm installs
# they can be prefixed e.g. amd_opt. However `ld.lld` will need to have a 
# `-flavour gnu` permanently supplied so it knows that it is emulating the GNU
# linker variant.
###############################################################################
declare -a tools=( \
"opt"              \
"llc"              \
"llvm-link"        \
"ld.lld"           \
)

for tool in "${tools[@]}"; do
    cp "$BUILD_PREFIX/bin/$tool" "$PREFIX/bin/$tool"
done