-
Notifications
You must be signed in to change notification settings - Fork 36
/
cflags
executable file
·45 lines (37 loc) · 998 Bytes
/
cflags
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
#!/bin/sh
cflags="-std=c89 -pedantic"
cflags="$cflags -Os"
cflags="$cflags -fno-strict-aliasing"
cflags="$cflags -Wall"
cflags="$cflags -ffunction-sections -fdata-sections"
if [ -z $DBGINFO ]; then
cflags="$cflags -g0 -fno-unwind-tables -s"
cflags="$cflags -fno-asynchronous-unwind-tables"
cflags="$cflags -fno-stack-protector"
else
cflags="$cflags -g -fsanitize=address -fsanitize=leak "
cflags="$cflags -fsanitize=signed-integer-overflow -fsanitize=undefined -static-libasan"
fi
if [ $(uname) = "Darwin" ]; then
cflags="$cflags -Wl,-dead_strip"
else
cflags="$cflags -Wl,--gc-sections,--build-id=none"
fi
ldflags="-lm"
cflags="$cflags $CFLAGS"
ldflags="$ldflags $LDFLAGS"
cc="$CC"
if [ $(uname) = "Darwin" ]; then
cc=${cc:-clang}
else
cc=${cc:-gcc}
fi
uname -a > flags.log
echo $cc >> flags.log
echo $cflags >> flags.log
echo $ldflags >> flags.log
$cc --version >> flags.log
$cc -dumpmachine >> flags.log
export cflags="$cflags"
export ldflags="$ldflags"
export cc="$cc"