-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathxcode_cc.sh
More file actions
executable file
·87 lines (80 loc) · 1.84 KB
/
xcode_cc.sh
File metadata and controls
executable file
·87 lines (80 loc) · 1.84 KB
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
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
s=1
use_ll_in_xcode=1
use_ll_in_clang=0
new_args=()
CONF=Release
while [[ $# -gt 0 ]]; do
case "$1" in
-target)
TARGET="$2"
new_args+=("$1" "$2")
shift 2
;;
-isysroot)
SYSROOT="$2"
new_args+=("$1" "$2")
shift 2
;;
-c)
if [ $use_ll_in_xcode -eq 1 ]; then
new_args+=("-emit-llvm" "-S")
else
new_args+=("-c")
fi
shift 1
;;
-o)
OUTPUT="$2"
new_args+=("$1" "$2")
shift 2
;;
-O*)
OPTLEVEL="$1"
new_args+=("$1")
shift 1
;;
*)
new_args+=("$1")
shift 1
;;
esac
done
set -- "${new_args[@]}"
function log_run() {
local cmd="$*"
echo $cmd
eval $cmd
r=$?
if [ $r -ne 0 ]; then
exit -1
fi
return $r
}
XCODE_CLANG=$SYSROOT/../../../../../Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
echo XCODE_CLANG $XCODE_CLANG
OPT=~/data/ollvm/build_llvm19/bin/opt # TODO: set to desired value
SLLVM=~/Documents/Tool/sllvm_r1/build19/sllvm19.dylib # TODO: set to desired value
echo CONF $CONF
echo target $TARGET
echo sysroot $SYSROOT
echo clang $XCODE_CLANG
echo output $OUTPUT
if [ $use_ll_in_xcode -eq 1 ]; then
out_tmp_1=$OUTPUT.1.ll
else
out_tmp_1=$OUTPUT.1.bc
fi
if [ $use_ll_in_clang -eq 1 ]; then
out_tmp_2=$OUTPUT.2.ll
out_ext_2="-S"
else
out_tmp_2=$OUTPUT.2.bc
fi
log_run $XCODE_CLANG $@
log_run cp -f $OUTPUT $out_tmp_1
if [ ! x$OPTLEVEL = x-O0 ]; then
out_ext_2="$out_ext_2 -load-pass-plugin $SLLVM -passes all"
fi
log_run $OPT $out_ext_2 -o $out_tmp_2 $out_tmp_1
log_run $XCODE_CLANG -target $TARGET -c $OPTLEVEL -o $OUTPUT $out_tmp_2