-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.zsh
executable file
·38 lines (30 loc) · 1.15 KB
/
compile.zsh
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
#!/bin/zsh
WARNINGS=()
# https://clang.llvm.org/docs/DiagnosticsReference.html#wall
WARNINGS+=(-Wall)
# https://clang.llvm.org/docs/DiagnosticsReference.html#wpedantic
WARNINGS+=(-Wpedantic)
# https://clang.llvm.org/docs/DiagnosticsReference.html#wextra
WARNINGS+=(-Wextra)
# https://clang.llvm.org/docs/DiagnosticsReference.html#wconversion
WARNINGS+=(-Wconversion)
# https://clang.llvm.org/docs/DiagnosticsReference.html#wassign-enum
WARNINGS+=(-Wassign-enum)
# https://clang.llvm.org/docs/DiagnosticsReference.html#wshadow-all
WARNINGS+=(-Wshadow-all)
DISABLED_WARNINGS=()
# DISABLED_WARNINGS+=(-Wno-unused-variable -Wno-unused-parameter -Wno-unused-function)
OPTIMIZATION_LEVEL=-O1
CLANG_SANITIZE=()
# https://clang.llvm.org/docs/AddressSanitizer.html#usage
CLANG_SANITIZE+=(-fsanitize=address -fno-omit-frame-pointer)
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#usage
CLANG_SANITIZE+=(-fsanitize=undefined,integer,nullability -fno-sanitize-recover)
set -euo pipefail
mkdir -p ./bin
set -x
clang $CLANG_SANITIZE \
$WARNINGS $DISABLED_WARNINGS -Werror -ferror-limit=256 \
$OPTIMIZATION_LEVEL -std=c17 \
--debug \
-o ./bin/"${1%.*}" "$1"