31 lines · plain
1# This makefile aims to make the binaries as small as possible, for us not to2# upload huge binary blobs in the repo.3# The binary should have debug symbols because stack unwinding doesn't work4# correctly using the information in the Minidump only. Also we want to evaluate5# local variables, etc.6# Breakpad compiles as a static library, so statically linking against it7# makes the binary huge.8# Dynamically linking to it does improve things, but we are still #include-ing9# breakpad headers (which is a lot of source code for which we generate debug10# symbols)11# So, install_breakpad.cpp does the #include-ing and defines a global function12# "InstallBreakpad" that does all the exception handler registration.13# We compile install_breakpad to object file and then link it, alongside the14# static libbreakpad, into a shared library.15# Then the binaries dynamically link to that lib.16# The other optimisation is not using the standard library (hence the _start17# instead of main). We only link dynamically to some standard libraries.18# This way we have a tiny binary (~8K) that has debug symbols and uses breakpad19# to generate a Minidump when the binary crashes/requests such.20#21CC=g++22CC_TYPE=gcc23FLAGS=-g --std=c++1124INCLUDE=-I$HOME/breakpad/src/src/25LINK=-L. -lbreakpad -lpthread -nostdlib -lc -lstdc++ -lgcc_s -fno-exceptions26all:27 $(CC) $(FLAGS) -fPIC -c install_breakpad.cpp $(INCLUDE) -o install_breakpad.o28 ld -shared install_breakpad.o libbreakpad_client.a -o libbreakpad.so29 $(CC) $(FLAGS) -o linux-x86_64 linux-x86_64.cpp $(LINK)30 $(CC) $(FLAGS) -o linux-x86_64_not_crashed linux-x86_64_not_crashed.cpp $(LINK)31