-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathllvm-build-dev.sh
executable file
·171 lines (151 loc) · 8.38 KB
/
llvm-build-dev.sh
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
echo "cmake config ..."
#PYTHON_PATH=$(which python)//"/bin/python"
# -DPYTHON_EXECUTABLE:FILEPATH=$(which python) \
# -DPYTHON_INCLUDE_DIR:PATH=$PYTHON_PATH \
# -DPYTHON_LIBRARY:FILEPATH=$PYTHON_PATH/lib64 \
# -DPYTHON_LIBRARY_DEBUG:FILEPATH=PYTHON_LIBRARY_DEBUG-NOTFOUND \
CMAKE=$1
RELATIVE_SOURCE_PATH=$2
BUILD_PATH_PREFIX=$3
INSTALL_PATH_PREFIX=$4
COMPILER_SWITCH=$5
CLANG_MAIN_VERSION=$6
ATOMIC_PATH=$7
MAKE_PROGRAM=$8
PROJECT_TYPE=$9
#DOXYGEN_DOT_EXECUTABLE=$6 #/usr/bin/dot
#DOXYGEN_EXECUTABLE=$7 #/usr/bin/doxygen
if ! [ "$WORKING_PATH" = "" ] ; then
if ! [ "$CMAKE" = "" ] ; then
if ! [ "$RELATIVE_SOURCE_PATH" = "" ] ; then
if ! [ "$BUILD_PATH_PREFIX" = "" ] ; then
if ! [ "$INSTALL_PATH_PREFIX" = "" ] ; then
CC=""
CPP=""
if ! [ "$COMPILER_SWITCH" = "" ]; then
if [ "$COMPILER_SWITCH" = "gcc" ]; then
CC="gcc"
CPP="g++"
fi;
if [ "$COMPILER_SWITCH" = "clang" ]; then
CC="clang"
CPP="clang++"
fi;
if [[ ( "$CC" != "" ) && ( "$CPP" != "" ) ]]; then
if ! [ "$CLANG_MAIN_VERSION" = "" ]; then
if ! [ "$ATOMIC_PATH" = "" ]; then
if ! [ "$MAKE_PROGRAM" = "" ]; then
if ! [ "$PROJECT_TYPE" = "" ]; then
# if ! [ "$DOXYGEN_DOT_EXECUTABLE" = "" ] ; then
#
# if ! [ "$DOXYGEN_EXECUTABLE" = "" ] ; then
if ! [ -d "$WORKING_PATH/$BUILD_PATH_PREFIX-$RELATIVE_SOURCE_PATH" ]; then
mkdir "$WORKING_PATH/$BUILD_PATH_PREFIX-$RELATIVE_SOURCE_PATH"
fi;
if ! [ "$WORKING_PATH/$BUILD_PATH_PREFIX-$RELATIVE_SOURCE_PATH" = "$PWD" ]; then
cd "$WORKING_PATH/$BUILD_PATH_PREFIX-$RELATIVE_SOURCE_PATH"
fi;
if [ "$PWD" = "$WORKING_PATH/$BUILD_PATH_PREFIX-$RELATIVE_SOURCE_PATH" ]; then
$CMAKE -DCMAKE_INSTALL_PREFIX:PATH=$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH \
-DLLVM_PATH:PATH="$WORKING_PATH/$RELATIVE_SOURCE_PATH" \
-DCMAKE_OSX_ARCHITECTURES:STRING="x86_64" \
-DCMAKE_ASM_COMPILER_WORKS:INTERNAL=1 \
-DHAVE_CXX_ATOMICS_WITHOUT_LIB:INTERNAL=1 \
-DHAVE_CXX_ATOMICS64_WITHOUT_LIB:INTERNAL=1 \
-DLIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB:INTERNAL=1 \
`# -DCMAKE_ASM_COMPILER:FILEPATH="$INSTALL_ROOT/bin/$CC"` \
-DCMAKE_ASM_COMPILER:FILEPATH="$(which as)" \
-DCMAKE_MAKE_PROGRAM:FILEPATH="$MAKE_PROGRAM" \
-DCMAKE_CXX_STANDARD_REQUIRED:BOOL=TRUE \
-DCAN_TARGET_x86_64:INTERNAL=TRUE \
-DCMAKE_CXX_EXTENSIONS:BOOL=TRUE \
-DCMAKE_C_FLAGS_DEBUG:STRING=-g \
-DCMAKE_CXX_FLAGS_DEBUG:STRING=-g \
-DCUDALIB_INCLUDE_DIR:PATH=$ACCELERATOR_TOOLKIT \
-DCUDALIB_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu \
-DCMAKE_SKIP_INSTALL_RPATH:BOOL=TRUE \
`# -DCMAKE_CXX_LINK_FLAGS:STRING="-L${HOST_CC}/lib -L${ATOMIC_PATH} -Wl,-rpath,${HOST_CC}/lib -lc++ -lc++abi -latomic"` \
-DCMAKE_CXX_LINK_FLAGS:STRING="-L$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib -L${ATOMIC_PATH} -Wl,-rpath,$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib -lc++ -lc++abi -latomic" \
-DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE \
-DLLVM_ENABLE_WERROR:BOOL=TRUE \
-DLLVM_ENABLE_BACKTRACES:BOOL=TRUE \
-DLLVM_ENABLE_LIBCXX:BOOL=TRUE \
-DBUILD_SHARED_LIBS:BOOL=TRUE \
-DLLVM_ENABLE_LIBCXX:BOOL=TRUE ${IFS#//Use libc++ if available.}\
-DLIBCXX_CXX_ABI:STRING="libcxxabi" \
-DLIBCXXABI_LIBCXX_INCLUDES:PATH="$WORKING_PATH/$RELATIVE_SOURCE_PATH/projects/libcxx/include" \
`# -DLIBCXXABI_LIBCXX_INCLUDES:PATH="$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/include/c++/v1"` \
`# -DLIBCXX_CXX_ABI_INCLUDE_PATHS:PATHS="$WORKING_PATH/$RELATIVE_SOURCE_PATH/projects/libcxxabi/include;$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/include/c++/v1"` \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS:PATHS="$WORKING_PATH/$RELATIVE_SOURCE_PATH/projects/libcxxabi/include" \
-DLLVM_TOOL_LIBCXXABI_BUILD:BOOL=TRUE ${IFS#//Whether to build libcxxabi as part of LLVM}\
-DLLVM_TOOL_LIBCXX_BUILD:BOOL=TRUE ${IFS#//Whether to build libcxx as part of LLVM}\
-DLLVM_EXTERNAL_LIBCXXABI_SOURCE_DIR:PATH="$WORKING_PATH/$RELATIVE_SOURCE_PATH/projects/libcxxabi" ${IFS#//Path to libcxxabi source directory}\
-DLLVM_EXTERNAL_LIBCXX_SOURCE_DIR:PATH="$WORKING_PATH/$RELATIVE_SOURCE_PATH/projects/libcxx" ${IFS#//Path to libcxx source directory}\
-DPOLLY_ENABLE_GPGPU_CODEGEN:BOOL=TRUE \
`# -DCMAKE_CXX_FLAGS:STRING="-std=c++11 -stdlib=libc++ -I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib/clang/$CLANG_MAIN_VERSION.0.0/include -I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/include/c++/v1"` \
-DCMAKE_CXX_FLAGS:STRING="-stdlib=libc++ -I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib/clang/$CLANG_MAIN_VERSION.0.0/include -I$WORKING_PATH/$RELATIVE_SOURCE_PATH/projects/libcxx/include" \
`# -DCMAKE_C_FLAGS:STRING="-I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib/clang/$CLANG_MAIN_VERSION.0.0/include -I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/include/c++/v1"` \
-DCMAKE_C_FLAGS:STRING="-I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib/clang/$CLANG_MAIN_VERSION.0.0/include -I$WORKING_PATH/$RELATIVE_SOURCE_PATH/projects/libcxx/include" \
-DCMAKE_SHARED_LINKER_FLAGS:STRING="-stdlib=libc++" \
-DCMAKE_MODULE_LINKER_FLAGS:STRING="-stdlib=libc++" \
-DCMAKE_C_COMPILER:FILEPATH="$INSTALL_ROOT/bin/$CC" \
-DCMAKE_CXX_COMPILER:FILEPATH="$INSTALL_ROOT/bin/$CPP" \
`# -DCMAKE_SHARED_LIBRARY_LINK_C_FLAGS:STRING=""` \
`# -DCMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS:STRING=""` \
-DCMAKE_CXX_IMPLICIT_LINK_LIBRARIES:STRING="c++;m;c" \
`# -DCMAKE_CXX_IMPLICIT_LINK_DIRECTORIES:PATHS="$ATOMIC_PATH;$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib"` ${IFS#//"usr/lib/gcc/x86_64-linux-gnu/5;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib"} \
`# -DLIBOMP_CFLAGS:STRING="-I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib/clang/$CLANG_MAIN_VERSION.0.0/include -I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/include/c++/v1"` \
-DLIBOMP_CFLAGS:STRING="-I$WORKING_PATH/$INSTALL_PATH_PREFIX-$RELATIVE_SOURCE_PATH/lib/clang/$CLANG_MAIN_VERSION.0.0/include -I$WORKING_PATH/$RELATIVE_SOURCE_PATH/projects/libcxx/include" \
`# -DLIBOMP_USE_QUAD_PRECISION:BOOL=TRUE` \
`# -DLLVM_ENABLE_DOXYGEN:BOOL=TRUE` \
`# -DLLVM_BUILD_DOCS:BOOL=TRUE` \
`# -DLLDB_DISABLE_PYTHON:BOOL=TRUE` \
`# -DDOXYGEN_DOT_EXECUTABLE:FILEPATH=$DOXYGEN_DOT_EXECUTABLE` \
`# -DDOXYGEN_EXECUTABLE:FILEPATH=$WORKING_PATH/$DOXYGEN_EXECUTABLE` `#install-doxygen/bin/doxygen` \
`# -DLLDB_EXPORT_ALL_SYMBOLS:BOOL=TRUE` \
-DCMAKE_BUILD_TYPE:STRING="Debug" \
-G "$PROJECT_TYPE" \
$WORKING_PATH/$RELATIVE_SOURCE_PATH;
else
echo "Have not entered destination. Operation failed."
fi;
# else
# echo "Provide \$DOXYGEN_EXECUTABLE from argument 7, please."
# fi;
#
# else
# echo "Provide \$DOXYGEN_DOT_EXECUTABLE (just dot, not doxygen itself) from argument 6, please."
# fi;
else
echo "Provide \$PROJECT_TYPE from argument 9."
fi;
else
echo "Provide \$MAKE_PROGRAM from argument 8."
fi;
else
echo "Provide \$ATOMIC_PATH from argument 7."
fi;
else
echo "Provide \$CLANG_MAIN_VERSION from argument 6."
fi;
else
echo "Compiler type unkown, please check it again."
fi;
else
echo "Provide \$COMPILER_SWITCH (e.g.: \"gcc\" or \"clang\") from argument 5, please."
fi;
else
echo "Provide \$INSTALL_PATH_PREFIX from argument 4 (e.g.: \"install\"), please."
fi;
else
echo "Provide \$BUILD_PATH_PREFIX from argument 3 (e.g.: \"build\"), please."
fi;
else
echo "Provide \$RELATIVE_SOURCE_PATH from argument 2 (e.g.: \"llvm\"), please."
fi;
else
echo "Provide \$CMAKE from argument 1, please."
fi;
else
echo "Export \$WORKING_PATH first."
fi;