Skip to content

Commit

Permalink
Build with optimizations by default (#543)
Browse files Browse the repository at this point in the history
GCC builds without optimizations by default while Clang uses -O2.
Use -O2 for GCC by default too, but switch to -O0 when DEBUG is
defined. Also make sure to always output debug information, not
only in debug builds. Additional sections with it do not impact
performance but are very useful in production. And they can be
easily stripped out of the binaries if necessary, like we do when
building packages.

We disable frame pointer omission optimization to get better stack
frames and enable debugging on x86. While it has some impact, I'd
rather have working backtraces.
  • Loading branch information
ilammy committed Oct 1, 2019
1 parent da6066a commit 170bec7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,15 @@ ifdef IS_LINUX
LDFLAGS += -Wl,--no-undefined
endif

CFLAGS += -O2 -fno-omit-frame-pointer -g

ifdef COVERAGE
CFLAGS += -g -O0 --coverage
CFLAGS += -O0 --coverage
LDFLAGS += --coverage
endif

ifdef DEBUG
CFLAGS += -DDEBUG -g
CFLAGS += -O0 -DDEBUG
endif

ifneq ($(GEM_INSTALL_OPTIONS),)
Expand Down

0 comments on commit 170bec7

Please sign in to comment.