7
7
8
8
# A bash script to build the Arm Toolchain for Embedded, with address sanitizer enabled.
9
9
10
+ # Script implements 2-stage pipeline: first clang is built using arm-toolchain sources.
11
+ # Then this clang is used to compile ATfE sanitizer build.
12
+ #
10
13
# The script creates a build of the toolchain in the 'build' directory, inside
11
14
# the repository tree.
12
15
@@ -23,11 +26,23 @@ clang --version
23
26
export CC=clang
24
27
export CXX=clang++
25
28
26
- # Get processor count, to execute job in parallel threads
27
- PROCESSOR_COUNT=$( getconf _NPROCESSORS_ONLN)
29
+ # Stage 1: Compile clang
30
+ mkdir -p " ${REPO_ROOT} " /build_llvm
31
+ cd " ${REPO_ROOT} " /build_llvm
28
32
29
- # Disable memory leaks detection of LeakSanitizer
30
- export ASAN_OPTIONS=detect_leaks=0
33
+ cmake ../llvm -G Ninja \
34
+ -DLLVM_ENABLE_PROJECTS=" clang;llvm;lld" \
35
+ -DLLVM_ENABLE_RUNTIMES=" libcxx;libcxxabi;libunwind;compiler-rt" \
36
+ -DCMAKE_BUILD_TYPE=Release \
37
+ -DCLANG_DEFAULT_LINKER=" lld"
38
+
39
+ ninja
40
+
41
+ echo " ==> Stage 1: Completed clang build"
42
+
43
+ # Stage 2: Compile ATfE with sanitizer
44
+ export CC=" ${REPO_ROOT} /build_llvm/bin/clang"
45
+ export CXX=" ${REPO_ROOT} /build_llvm/bin/clang++"
31
46
32
47
if [[ ! -z " ${FVP_INSTALL_DIR} " ]]; then
33
48
EXTRA_CMAKE_ARGS=" ${EXTRA_CMAKE_ARGS} -DENABLE_FVP_TESTING=ON -DFVP_INSTALL_DIR=${FVP_INSTALL_DIR} "
36
51
mkdir -p " ${REPO_ROOT} " /build
37
52
cd " ${REPO_ROOT} " /build
38
53
39
- cmake ../arm-software/embedded -GNinja -DFETCHCONTENT_QUIET=OFF -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_SANITIZER=" Address" -DLLVM_ENABLE_ASSERTIONS=ON ${EXTRA_CMAKE_ARGS}
54
+ # Enable below flag to disable memory leaks detection of LeakSanitizer.
55
+ # export ASAN_OPTIONS=detect_leaks=0
56
+
57
+ cmake ../arm-software/embedded -GNinja -DFETCHCONTENT_QUIET=OFF -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_SANITIZER=" Address;Undefined" -DLLVM_ENABLE_ASSERTIONS=ON ${EXTRA_CMAKE_ARGS}
58
+
59
+ ninja package-llvm-toolchain
40
60
41
- ninja -j $PROCESSOR_COUNT package-llvm-toolchain
61
+ echo " ==> Stage 2: Completed sanitizer build "
0 commit comments