-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (31 loc) · 922 Bytes
/
Makefile
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
CXX := xcrun clang++
LD := $(CXX)
SYSROOT := $(shell xcodebuild -version -sdk macosx Path |head -1)
ifeq ($(SYSROOT),,)
$(error "Can't find macosx sysroot")
endif
COMMONFLAGS := \
-arch x86_64 \
-isysroot $(SYSROOT)
# Passing -fsanitize=undefined or -fsanitize=address finds no errors, but
# _avoids_ the bug!
COMMONFLAGS += $(if $(SANITIZE),-fsanitize=$(SANITIZE))
CXXFLAGS := \
$(COMMONFLAGS) \
-std=c++11 -stdlib=libc++ \
-Wall -Werror
# Removing -g avoids the crash.
CXXFLAGS += $(if $(NO_DEBUG),,-g)
# Using this makes it not crash.
#CXXFLAGS += -gline-tables-only
# Optimization levels that crash (with -g): -Os -Oz -O3 -O2 -Ofast
# Optimization levels that work (with -g) : -O1 -O0
CXXFLAGS += -Os
LDFLAGS := $(COMMONFLAGS)
all:
$(CXX) --version
$(CXX) -c $(CXXFLAGS) Thing.cc -o Thing.o
$(CXX) -c $(CXXFLAGS) main.cc -o main.o
$(LD) $(LDFLAGS) -o prog Thing.o main.o
clean:
rm *.o prog