-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.sh
executable file
·63 lines (53 loc) · 1.64 KB
/
make.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
#!/bin/sh
# tools:
# clang++: 16.0.6
# g++: 13.2.0
# nasm: 2.16.01
# ld: 2.41
set -e
# change to directory of the script
cd $(dirname "$0")
# set environment
CC="clang++ -std=c++20"
CF="-Wfatal-errors -Werror"
CW="-Weverything -Wno-c++98-compat -Wno-weak-vtables -Wno-padded \
-Wno-unqualified-std-cast-call -Wno-unsafe-buffer-usage"
MSAN=
PROF=
DBG=
OPT=-O3
if [ "$1" = "msan" ]; then
# sanitize (note: sanitize crashes unpredictably with core dump)
#MSAN="-fsanitize=memory,undefined -fsanitize-memory-track-origins=2 -fsanitize-ignorelist=etc/msan_suppressions.txt"
DBG=-g
elif [ "$1" = "prof" ]; then
# profiling, sanitize (note: sanitize crashes unpredictably with core dump)
# MSAN="-fsanitize=address,undefined -fno-omit-frame-pointer"
PROF="-fprofile-instr-generate -fcoverage-mapping"
DBG=-g
fi
SEP="--------------------------------------------------------------------------------"
CMD="$CC src/main.cpp -o baz $OPT $DBG $CF $CW $MSAN $PROF"
echo $SEP
echo $CMD
$CMD
echo $SEP
if [ "$1" = "prof" ]; then
exit 0
fi
./baz prog.baz > gen.s
grep -v -e'^\s*;.*$' -e'^\s*$' gen.s > gen-without-comments.s
nasm -f elf64 gen.s
ld -s -o gen gen.o
ls --color -la baz gen.s gen-without-comments.s gen
echo $SEP
echo ' lines words chars'
echo -n ' source: '; cat src/* | wc
echo -n ' gzipped: '; cat src/* | gzip | wc
echo -n 'baz source: '; cat prog.baz | grep -v -e'^\s*$' | wc
echo -n ' gzipped: '; cat prog.baz | grep -v -e'^\s*$' | gzip | wc
echo -n 'asm source: '; cat gen-without-comments.s | wc
echo -n ' gzipped: '; cat gen-without-comments.s | gzip | wc
echo $SEP
./gen
echo $SEP