-
Notifications
You must be signed in to change notification settings - Fork 0
/
060-build-compiler-rt-llvm8.sh
executable file
·83 lines (73 loc) · 2.46 KB
/
060-build-compiler-rt-llvm8.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
#!/usr/bin/env bash
# Build runtime
# parameters:
# - SCRIPT_ROOT
# - SRC_ROOT
# - BUILD_ROOT
# - INSTALL_PREFIX
# requirements:
# - build-base
# - ninja
# - cmake
# - git
# - patch
# - vim
# - python2
# - curl
# - file
set -e
set -o errexit
source ./config.sh
LLVM_PROJECT_SRC_ROOT="${LLVM_PROJECT_SRC_ROOT:-${SRC_ROOT}}"
CXX_FLAGS="--target=${XTARGET} -mcpu=${XCPU} ${XFPU} ${XABI} ${XOPTFLAGS}"
CXX_DEFINES=""
CXX_INCLUDE_PATH=""
COMPILER_FLAGS="${CXX_FLAGS} ${CXX_DEFINES} ${CXX_INCLUDE_PATH}"
mkdir -p ${BUILD_ROOT}/compiler-rt
cd ${BUILD_ROOT}/compiler-rt
cmake -GNinja -Wno-dev \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
-DCMAKE_SYSTEM_PROCESSOR=arm \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_CROSSCOMPILING=ON \
-DUNIX=1 \
-DCMAKE_CXX_COMPILER_FORCED=TRUE \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_TARGET=${XTARGET} \
-DCMAKE_ASM_COMPILER_TARGET=${XTARGET} \
-DCMAKE_C_COMPILER=${INSTALL_PREFIX}/bin/clang \
-DCMAKE_CXX_COMPILER=${INSTALL_PREFIX}/bin/clang++ \
-DCMAKE_LINKER=${INSTALL_PREFIX}/bin/clang \
-DCMAKE_AR=${INSTALL_PREFIX}/bin/llvm-ar \
-DCMAKE_RANLIB=${INSTALL_PREFIX}/bin/llvm-ranlib \
-DLLVM_CONFIG_PATH=${BUILD_ROOT}/llvm/bin/llvm-config \
-DLLVM_ENABLE_SPHINX=False \
-DLLVM_INCLUDE_TESTS=False \
-DLLVM_ABI_BREAKING_CHECKS=WITH_ASSERTS \
-DLLVM_TARGETS_TO_BUILD="ARM" \
-DLLVM_DEFAULT_TARGET_TRIPLE="armv7em-none-eabi" \
-DLLVM_ENABLE_LLD=ON \
-DLLVM_ENABLE_LIBCXX=ON \
-DCMAKE_SYSROOT=${SYSROOT} \
-DCMAKE_SYSROOT_LINK=${SYSROOT} \
-DCMAKE_C_FLAGS="${COMPILER_FLAGS}" \
-DCMAKE_ASM_FLAGS="${COMPILER_FLAGS}" \
-DCMAKE_CXX_FLAGS="${COMPILER_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS=-L${SYSROOT}/lib \
-DCOMPILER_RT_OS_DIR="baremetal" \
-DCOMPILER_RT_BUILD_BUILTINS=ON \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_PROFILE=OFF \
-DCOMPILER_RT_BAREMETAL_BUILD=ON \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
-DCOMPILER_RT_INCLUDE_TESTS=OFF \
-DCOMPILER_RT_USE_LIBCXX=ON \
${LLVM_PROJECT_SRC_ROOT}/compiler-rt
cmake --build .
cmake --build . --target install
# due to a bug in clang (https://bugs.llvm.org/show_bug.cgi?id=34578),
# the builtins are found with the wrong name - just create a link here to fix it
ln -fs libclang_rt.builtins-armv7em.a ${INSTALL_PREFIX}/lib/baremetal/libclang_rt.builtins-armv7em.a.a