build: Add --enable-debug configure option

When CFG_ENABLE_DEBUG is defined it will call rustc with -g --cfg=debug
and cc with -DRUST_DEBUG. Otherwise it calls rustc with --cfg=ndebug and cc
with -DRUST_NDEBUG.

I plan to use this for a few things in the runtime.
This commit is contained in:
Brian Anderson 2012-03-29 19:10:38 -07:00
parent 5b3740508a
commit f452973a7f
3 changed files with 17 additions and 7 deletions

View File

@ -68,11 +68,24 @@ ifneq ($(wildcard $(NON_HOST_TRIPLES)),)
CFG_INFO := $(info cfg: non host triples $(NON_HOST_TRIPLES))
endif
CFG_RUSTC_FLAGS :=
CFG_GCCISH_CFLAGS :=
CFG_GCCISH_LINK_FLAGS :=
ifdef CFG_DISABLE_OPTIMIZE
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
CFG_RUSTC_FLAGS :=
CFG_RUSTC_FLAGS +=
else
CFG_RUSTC_FLAGS := -O
CFG_RUSTC_FLAGS += -O
endif
ifdef CFG_ENABLE_DEBUG
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
CFG_RUSTC_FLAGS += -g --cfg=debug
CFG_GCCISH_CFLAGS += -DRUST_DEBUG
else
CFG_RUSTC_FLAGS += --cfg=ndebug
CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
endif
ifdef SAVE_TEMPS
@ -87,9 +100,6 @@ endif
ifdef TIME_LLVM_PASSES
CFG_RUSTC_FLAGS += --time-llvm-passes
endif
ifdef DEBUG
CFG_RUSTC_FLAGS += -g
endif
# platform-specific auto-configuration
include $(CFG_SRC_DIR)mk/platform.mk

1
configure vendored
View File

@ -280,6 +280,7 @@ opt docs 1 "build documentation"
opt optimize 1 "build optimized rust code"
opt optimize-cxx 1 "build optimized C++ code"
opt optimize-llvm 1 "build optimized LLVM"
opt debug 0 "build with extra debug fun"
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
opt manage-submodules 1 "let the build manage the git submodules"
opt mingw-cross 0 "cross-compile for win32 using mingw"

View File

@ -9,8 +9,7 @@ endef
$(foreach t,$(CFG_TARGET_TRIPLES),$(eval $(call DEF_HOST_VAR,$(t))))
$(foreach t,$(CFG_TARGET_TRIPLES),$(info cfg: host for $(t) is $(HOST_$(t))))
CFG_GCCISH_FLAGS := -fno-strict-aliasing
CFG_GCCISH_LINK_FLAGS :=
CFG_GCCISH_FLAGS += -fno-strict-aliasing
# On Darwin, we need to run dsymutil so the debugging information ends
# up in the right place. On other platforms, it automatically gets