From 6e99de6d3c91037b207443e89b148c75e8340197 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Mon, 10 Aug 2020 11:23:48 -0700 Subject: [PATCH] Allow optimization level to be set in Makefile (#7202) Summary: `-O3` is already adopted widely, so we should make it easier to configure for development/open source. This PR adds an `OPTIMIZE_LEVEL` variable that users can set to override the `-O` flag chosen in the Makefile. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7202 Test Plan: built a few different ways and verified correct value is passed for `-O` flag Reviewed By: pdillinger Differential Revision: D22845291 Pulled By: ajkr fbshipit-source-id: 84471362e7d627dd606b25bf5f6a3d796817fa1c --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6177c136c..05f73a54d 100644 --- a/Makefile +++ b/Makefile @@ -131,11 +131,14 @@ endif # Figure out optimize level. ifneq ($(DEBUG_LEVEL), 2) ifeq ($(LITE), 0) - OPT += -O2 + OPTIMIZE_LEVEL ?= -O2 else - OPT += -Os + OPTIMIZE_LEVEL ?= -Os endif endif +# `OPTIMIZE_LEVEL` is empty when the user does not set it and `DEBUG_LEVEL=2`. +# In that case, the compiler default (`-O0` for gcc and clang) will be used. +OPT += $(OPTIMIZE_LEVEL) # compile with -O2 if debug level is not 2 ifneq ($(DEBUG_LEVEL), 2)