-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure-clang.sh
executable file
·190 lines (174 loc) · 7.28 KB
/
configure-clang.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash
##
## Script: configure-clang.sh
##
## This second-level script configures Clang, and anything else that is
## needed to build it.
##
##- Make sure we're in the same directory as this script.
##
export TOP_DIR="$(cd "$(dirname "$0")" && pwd)"
cd $TOP_DIR
##- Get the CLANG-related variables and command-line options for this build.
##
source ./clang-build-vars.sh
##- Configure LLVM and CLANG prior for compilation.
##
if [ -n "$DO_CLANG" ]
then
echo -n "Checking for existing CLANG build directory $CLANG_BLD_DIR... "
if [ ! -e $CLANG_BLD_DIR ]
then
echo ""
echo "Making new clang build directory..."
mkdir -v $CLANG_BLD_DIR
else
echo " already exists"
fi
##- Run the CLANG configure script using our customizations.
##
cd $CLANG_BLD_DIR
echo -n "Checking for CLANG CMake cache in $CLANG_BLD_DIR... "
if [ ! -e CMakeCache.txt ]
then
echo ""
echo -n "Configuring CLANG build with CMake... "
##- Now run the configue script. There are several site-specific extra
## options that are set, and here is why:
##
## CXX=... CC=... CPP=...
## These variables are ensure that compilation occurs using the
## correct GCC executables
##
## CXXFLAGS=...
## This option is set to disable several annoying and meaningless
## warnings and notices that are issued during the build.
##
## --prefix=$CLANG_INSTALL_PREFIX
## This is the root directory for the installation.
##
## --with-gcc-toolchain=$GCC_INSTALL_PREFIX
## This option indicates the root directory for the GCC installation
## upon which this build of clang is based.
##
## --with-extra-ld-options=-Wl,-R,$GCC_INSTALL_PREFIX/lib64
## This option is set to ensure that, during the llmv and clang build,
## linking occurs against the correct GCC libraries.
##
if [ "$CLANG_PLATFORM" == "FreeBSD" ]
then
echo "for FreeBSD... "
CXX=/usr/bin/g++ \
CC=/usr/bin/gcc \
cmake $CLANG_SRC_DIR -G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$CLANG_INSTALL_PREFIX \
-DLLVM_ENABLE_WARNINGS=OFF
$CLANG_SRC_DIR/configure \
--prefix=$CLANG_INSTALL_PREFIX \
--disable-assertions \
--enable-optimized \
--enable-targets=host \
--enable-cxx11 \
CXX=/usr/bin/c++ \
CC=/usr/bin/cc \
CPP=/usr/bin/cpp \
CXXFLAGS=""
elif [ "$CLANG_PLATFORM" == "Linux" ]
then
echo "for Linux... "
GCC_CXXLIBDIR="$GCC_INSTALL_PREFIX/lib64"
GCC_CXXFLAGS="-Wno-unused-function -Wno-unused-local-typedefs \
-Wno-unused-but-set-variable \
-Wno-overloaded-virtual -Wno-sign-compare \
-Wno-strict-aliasing -Wno-pedantic"
GCC_CLAGS="-Wno-implicit-function-declaration"
CXX=$GCC_INSTALL_PREFIX/bin/g++ \
CC=$GCC_INSTALL_PREFIX/bin/gcc \
cmake $CLANG_SRC_DIR -G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$CLANG_INSTALL_PREFIX \
-DCMAKE_CXX_LINK_FLAGS="-Wl,-R,$GCC_CXXLIBDIR -L$GCC_CXXLIBDIR" \
-DGCC_INSTALL_PREFIX=$GCC_INSTALL_PREFIX \
-DCLANG_VENDOR="$CLANG_VENDOR" \
-DLLVM_ENABLE_WARNINGS=OFF
fi
else
echo "found"
echo "Configure has already been run for CLANG"
fi
echo ""
echo "CLANG configuration completed!"
echo ""
fi
##- Configure LIBC++ for compilation.
##
cd $TOP_DIR
if [ -n "$DO_CXXLIB" ]
then
if [ ! -e $CLANG_BLD_DIR/bin/clang ]
then
echo "missing built clang/clang++... you need to re-make clang..."
exit 1
fi
cd $LIBCXX_BLD_DIR
echo -n "Checking for LIBC++ CMake cache in $LIBCXX_BLD_DIR..."
if [ ! -e CMakeCache.txt ]
then
echo ""
echo "Configuring LIBC++ build with CMake... "
##- Now run the configure script. There are several site-specific
## extra options that are set, and here is why:
##
## CXX=... CC=...
## These environment variables are set to ensure that libc++
## compilation occurs using the correct Clang executables
##
## -DLIBCXX_CXX_ABI=libcxxrt|libstdc++|libsuppc++
## This option indicate the runtime ABI support library that we
## want libc++ to use.
##
## -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$.."
## This option indicates the location of the c++ ABI header files.
##
## -DCMAKE_INSTALL_PREFIX=$CLANG_INSTALL_PREFIX
## This option indicates the directory where libc++ is to be
## installed.
##
if [ "$CLANG_PLATFORM" == "FreeBSD" ]
then
echo "for FreeBSD... "
CC=$CLANG_BLD_DIR/bin/clang \
CXX=$CLANG_BLD_DIR/bin/clang++ \
cmake -G "Unix Makefiles" \
-DLIBCXX_CXX_ABI=libcxxrt \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/v1" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$CLANG_INSTALL_PREFIX \
-DLLVM_PATH="$CLANG_SRC_DIR" \
$LIBCXX_SRC_DIR
elif [ "$CLANG_PLATFORM" == "Linux" ]
then
echo "for Linux... "
echo "GCC include path for ABI is: $GCC_CXX_ABI_INC_PATH"
##- Build the makefile that makes libc++.
##
CC=$CLANG_BLD_DIR/bin/clang \
CXX=$CLANG_BLD_DIR/bin/clang++ \
cmake -G "Unix Makefiles" \
-DLIBCXX_CXX_ABI=$GCC_CXX_ABI \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="$GCC_CXX_ABI_INC_PATH" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$CLANG_INSTALL_PREFIX \
-DLIBCXX_INCLUDE_TESTS=ON \
-DLLVM_PATH="$CLANG_SRC_DIR" \
$LIBCXX_SRC_DIR
fi
else
echo " found"
echo "Configure has already been run for LIBC++"
fi
echo ""
echo "LIBC++ configuration completed!"
echo ""
fi