forked from davidzchen/bazel-ycm-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_clang.sh
executable file
·57 lines (40 loc) · 1.58 KB
/
setup_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
#!/bin/bash -e
BAZELRC_FILE="${BAZELRC_FILE:-./clang.bazelrc}"
LLVM_PREFIX=$1
if [[ ! -e "${LLVM_PREFIX}/bin/llvm-config" ]]; then
echo "Error: cannot find local llvm-config in ${LLVM_PREFIX}."
exit 1
fi
PATH="$("${LLVM_PREFIX}"/bin/llvm-config --bindir):${PATH}"
export PATH
LLVM_VERSION="$(llvm-config --version)"
LLVM_LIBDIR="$(llvm-config --libdir)"
LLVM_TARGET="$(llvm-config --host-target)"
RT_LIBRARY_PATH="${LLVM_LIBDIR}/clang/${LLVM_VERSION}/lib/${LLVM_TARGET}"
echo "# Generated file, do not edit. If you want to disable clang, just delete this file.
# setup PATH
build:clang --action_env='PATH=${PATH}' --host_action_env='PATH=${PATH}'
# Use c++20 standard
build:clang --cxxopt='-std=c++20'
# Setup CC and CXX
build:clang --action_env=CC=clang --host_action_env=CC=clang
build:clang --action_env=CXX=clang++ --host_action_env=CXX=clang++
# Use libc++
build:clang --cxxopt='-stdlib=libc++'
# Optimization: operator new guarantees 8 byte alignment
# instead of 16
build:clang --cxxopt='-fnew-alignment=8'
# Disable rtti and exceptions(sorry)
build:clang --cxxopt='-fno-rtti'
build:clang --cxxopt='-fno-exceptions'
# Optimization: use sized deallocation for standard library containers
build:clang --cxxopt='-fsized-deallocation'
# Use llvm linker
build:clang --linkopt='-fuse-ld=lld'
# Link with libc++ instead of libstdc++
build:clang --linkopt='-stdlib=libc++'
# Use compiler-rt instead of gcc_s?
build:clang --linkopt='--rtlib=compiler-rt'
# To give -v to linker to see the exact flags used, uncomment these to debug linker issues
# build:clang --linkopt='-v'
" > "${BAZELRC_FILE}"