@@ -19,16 +19,23 @@ $(basename "$0")
19
19
[ -r | --release ] Release build, requires rebuild of LLVM in Release mode, activates 'dev' option
20
20
[ -c | --clean ] Delete the build artifacts from the previous build
21
21
[ -i | --imex ] Compile with IMEX (used for GPU pipeline)
22
+ [ -s | --suffix ] Build dir suffix
23
+ [ -v | --llvm ] Build llvm only
22
24
[ -h | --help ] Print this message
23
25
EOF
24
26
}
25
27
26
28
DYN_LINK=OFF
27
29
ENABLE_IMEX=false
28
30
for arg in " $@ " ; do
31
+ if [ ! -z " $ASSIGN_NEXT " ]; then
32
+ eval " $ASSIGN_NEXT =$arg "
33
+ unset ASSIGN_NEXT
34
+ continue
35
+ fi
29
36
case $arg in
30
- -d | --dev)
31
- DEV_BUILD=true
37
+ -d | --dev)
38
+ DEV_BUILD=true
32
39
;;
33
40
-i | --imex)
34
41
ENABLE_IMEX=true
@@ -44,12 +51,18 @@ for arg in "$@"; do
44
51
-c | --clean)
45
52
CLEANUP=true
46
53
;;
54
+ -s | --suffix)
55
+ ASSIGN_NEXT=BUILD_DIR_SFX
56
+ ;;
57
+ -v | --llvm)
58
+ LLVM_ONLY=true
59
+ ;;
47
60
-h | --help)
48
61
print_usage
49
62
exit 0
50
63
;;
51
64
# -- means the end of the arguments; drop this, and break out of the while loop
52
- * )
65
+ * )
53
66
echo Unsupported option: $arg
54
67
print_usage
55
68
exit 1
@@ -99,6 +112,10 @@ load_llvm() {
99
112
100
113
build_llvm () {
101
114
local llvm_dir=" $EXTERNALS_DIR /llvm-project"
115
+ LLVM_BUILD_DIR=" $llvm_dir /build$BUILD_DIR_SFX "
116
+ MLIR_DIR=" $LLVM_BUILD_DIR /lib/cmake/mlir"
117
+ mkdir -p " $LLVM_BUILD_DIR "
118
+
102
119
if ! [ -d " $llvm_dir " ]; then
103
120
git clone https://github.com/llvm/llvm-project.git
104
121
cd " $llvm_dir "
@@ -111,16 +128,17 @@ build_llvm() {
111
128
fi
112
129
113
130
git checkout ${LLVM_HASH}
114
- [ -z " $CLEANUP " ] || rm -rf build
131
+ [ -z " $CLEANUP " ] || rm -rf " $LLVM_BUILD_DIR "
115
132
116
133
[ " $DYN_LINK " = " OFF" ] && CXX_FLAGS=" -fvisibility=hidden"
117
134
118
135
if [ " $ENABLE_IMEX " = " true" ]; then
119
136
# clone IMEX and apply patches
120
- local mlir_ext_dir=" $EXTERNALS_DIR /mlir-extensions "
137
+ local mlir_ext_dir=" $EXTERNALS_DIR /imex-src "
121
138
if ! [ -d " $mlir_ext_dir " ]; then
122
139
cd " $EXTERNALS_DIR "
123
- git clone https://github.com/intel/mlir-extensions.git
140
+ local imex_url=" $( grep -F ' set(IMEX_URL ' " $PROJECT_DIR /cmake/imex.cmake" | awk ' {print $2}' | tr -d ' )' ) "
141
+ git clone " $imex_url " " $mlir_ext_dir "
124
142
cd " $mlir_ext_dir "
125
143
else
126
144
cd " $mlir_ext_dir "
@@ -134,7 +152,7 @@ build_llvm() {
134
152
find " $mlir_ext_dir /build_tools/patches" -name ' *.patch' | sort -V | xargs git apply
135
153
fi
136
154
137
- cmake -G Ninja llvm -B build \
155
+ cmake -G Ninja llvm -B " $LLVM_BUILD_DIR " \
138
156
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
139
157
-DCMAKE_CXX_FLAGS=" $CXX_FLAGS " \
140
158
-DCMAKE_CXX_FLAGS_DEBUG=" -g -O0" \
@@ -153,9 +171,7 @@ build_llvm() {
153
171
-DLLVM_INSTALL_UTILS=ON \
154
172
-DLLVM_INSTALL_GTEST=ON \
155
173
-DMLIR_ENABLE_BINDINGS_PYTHON=ON
156
- cmake --build build --parallel $MAX_JOBS
157
-
158
- MLIR_DIR=" $PWD /build/lib/cmake/mlir"
174
+ cmake --build " $LLVM_BUILD_DIR " --parallel $MAX_JOBS
159
175
}
160
176
161
177
# MLIR_DIR is set on all passes
@@ -174,13 +190,14 @@ get_llvm() {
174
190
cd " $llvm_dir "
175
191
load_llvm
176
192
cd " $PROJECT_DIR "
177
- else
193
+ else
178
194
MLIR_DIR=" $llvm_dir /lib/cmake/mlir"
179
195
fi
180
196
return 0
181
197
}
182
198
183
199
get_llvm
200
+ [ -z " $LLVM_ONLY " ] || exit 0
184
201
185
202
# written in this form to set LIT_PATH in any case
186
203
if ! LIT_PATH=$( which lit) && [ -z " $DEV_BUILD " ]; then
@@ -193,16 +210,17 @@ if [ -z "$DEV_BUILD" ]; then
193
210
FETCH_DIR=$PROJECT_DIR /build/_deps
194
211
else
195
212
FETCH_DIR=$PROJECT_DIR /externals
196
- LIT_PATH=$PROJECT_DIR /externals/llvm-project/build/ bin/llvm-lit
213
+ LIT_PATH=" $LLVM_BUILD_DIR / bin/llvm-lit"
197
214
fi
198
215
199
- [ -z " $CLEANUP " ] || rm -rf build
200
- cmake -S . -G Ninja -B build \
216
+ BUILD_DIR=" $PROJECT_DIR /build$BUILD_DIR_SFX "
217
+ [ -z " $CLEANUP " ] || rm -rf " $BUILD_DIR "
218
+ cmake -S . -G Ninja -B " $BUILD_DIR " \
201
219
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
202
220
-DMLIR_DIR=$MLIR_DIR \
203
221
-DLLVM_EXTERNAL_LIT=$LIT_PATH \
204
222
-DFETCHCONTENT_BASE_DIR=$FETCH_DIR \
205
223
-DGC_DEV_LINK_LLVM_DYLIB=$DYN_LINK \
206
224
-DGC_ENABLE_IMEX=$ENABLE_IMEX
207
225
208
- cmake --build build --parallel $MAX_JOBS
226
+ cmake --build " $BUILD_DIR " --parallel $MAX_JOBS
0 commit comments