@@ -11,6 +11,7 @@ function display_help()
11
11
echo " [-h|--help] prints this help message"
12
12
echo " [-i|--install] install after build"
13
13
echo " [-p|--package] build package"
14
+ echo " [-r]--relocatable] create a package to support relocatable ROCm"
14
15
# Not implemented yet
15
16
# echo " [-d|--dependencies] install build dependencies"
16
17
echo " [-c|--clients] build library clients too (combines with -i & -d)"
@@ -28,15 +29,17 @@ build_clients=false
28
29
build_release=true
29
30
run_tests=false
30
31
build_hip_clang=false
31
- rocm_path=/opt/rocm/bin
32
+ rocm_path=/opt/rocm
33
+ build_relocatable=false
34
+
32
35
# #################################################
33
36
# Parameter parsing
34
37
# #################################################
35
38
36
39
# check if we have a modern version of getopt that can handle whitespace and long parameters
37
40
getopt -T
38
41
if [[ $? -eq 4 ]]; then
39
- GETOPT_PARSE=$( getopt --name " ${0} " --longoptions help,install,clients,debug,hip-clang,test,package --options hicdtp -- " $@ " )
42
+ GETOPT_PARSE=$( getopt --name " ${0} " --longoptions help,install,clients,debug,hip-clang,test,package,relocatable --options hicdtpr -- " $@ " )
40
43
else
41
44
echo " Need a new version of getopt"
42
45
exit 1
@@ -62,6 +65,9 @@ while true; do
62
65
-p|--package)
63
66
build_package=true
64
67
shift ;;
68
+ -r|--relocatable)
69
+ build_relocatable=true
70
+ shift ;;
65
71
-c|--clients)
66
72
build_clients=true
67
73
shift ;;
@@ -81,6 +87,16 @@ while true; do
81
87
esac
82
88
done
83
89
90
+ if [[ " ${build_relocatable} " == true ]]; then
91
+ if ! [ -z ${ROCM_PATH+x} ]; then
92
+ rocm_path=${ROCM_PATH}
93
+ fi
94
+
95
+ rocm_rpath=" -Wl,--enable-new-dtags -Wl,--rpath,/opt/rocm/lib:/opt/rocm/lib64"
96
+ if ! [ -z ${ROCM_RPATH+x} ]; then
97
+ rocm_rpath=" -Wl,--enable-new-dtags -Wl,--rpath,${ROCM_RPATH} "
98
+ fi
99
+ fi
84
100
85
101
# Instal the pre-commit hook
86
102
# bash .githooks/install
@@ -111,19 +127,22 @@ if ($build_hip_clang); then
111
127
fi
112
128
113
129
if [ -e /etc/redhat-release ] ; then
114
- distro= ' centos '
130
+ cmake_executable= " cmake3 "
115
131
else
116
- distro= ' ubuntu '
132
+ cmake_executable= " cmake "
117
133
fi
118
134
119
- case " $distro " in
120
- centos)
121
- CXX=$rocm_path /$compiler cmake3 -DBUILD_BENCHMARK=ON ../../. # or cmake-gui ../.
122
- ;;
123
- ubuntu)
124
- CXX=$rocm_path /$compiler cmake -DBUILD_BENCHMARK=ON ../../. # or cmake-gui ../.
125
- ;;
126
- esac
135
+ if [[ " ${build_relocatable} " == true ]]; then
136
+ CXX=${rocm_path} /bin/$compiler ${cmake_executable} -DCMAKE_INSTALL_PREFIX=${rocm_path} \
137
+ -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON -DBUILD_CRUSH_TEST=ON -DDEPENDENCIES_FORCE_DOWNLOAD=ON \
138
+ -DCMAKE_PREFIX_PATH=" ${rocm_path} ${rocm_path} /hcc ${rocm_path} /hip" \
139
+ -DCMAKE_SHARED_LINKER_FLAGS=${rocm_rpath} \
140
+ -DROCM_DISABLE_LDCONFIG=ON \
141
+ -DCMAKE_MODULE_PATH=" ${rocm_path} /hip/cmake" \
142
+ ../../. # or cmake-gui ../.
143
+ else
144
+ CXX=${rocm_path} /bin/$compiler ${cmake_executable} -DBUILD_BENCHMARK=ON ../../. # or cmake-gui ../.
145
+ fi
127
146
128
147
# Build
129
148
make -j$( nproc)
0 commit comments