Skip to content

Commit f452973

Browse files
committed
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.
1 parent 5b37405 commit f452973

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

Makefile.in

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,24 @@ ifneq ($(wildcard $(NON_HOST_TRIPLES)),)
6868
CFG_INFO := $(info cfg: non host triples $(NON_HOST_TRIPLES))
6969
endif
7070

71+
CFG_RUSTC_FLAGS :=
72+
CFG_GCCISH_CFLAGS :=
73+
CFG_GCCISH_LINK_FLAGS :=
74+
7175
ifdef CFG_DISABLE_OPTIMIZE
7276
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
73-
CFG_RUSTC_FLAGS :=
77+
CFG_RUSTC_FLAGS +=
7478
else
75-
CFG_RUSTC_FLAGS := -O
79+
CFG_RUSTC_FLAGS += -O
80+
endif
81+
82+
ifdef CFG_ENABLE_DEBUG
83+
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
84+
CFG_RUSTC_FLAGS += -g --cfg=debug
85+
CFG_GCCISH_CFLAGS += -DRUST_DEBUG
86+
else
87+
CFG_RUSTC_FLAGS += --cfg=ndebug
88+
CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
7689
endif
7790

7891
ifdef SAVE_TEMPS
@@ -87,9 +100,6 @@ endif
87100
ifdef TIME_LLVM_PASSES
88101
CFG_RUSTC_FLAGS += --time-llvm-passes
89102
endif
90-
ifdef DEBUG
91-
CFG_RUSTC_FLAGS += -g
92-
endif
93103

94104
# platform-specific auto-configuration
95105
include $(CFG_SRC_DIR)mk/platform.mk

configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ opt docs 1 "build documentation"
280280
opt optimize 1 "build optimized rust code"
281281
opt optimize-cxx 1 "build optimized C++ code"
282282
opt optimize-llvm 1 "build optimized LLVM"
283+
opt debug 0 "build with extra debug fun"
283284
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
284285
opt manage-submodules 1 "let the build manage the git submodules"
285286
opt mingw-cross 0 "cross-compile for win32 using mingw"

mk/platform.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ endef
99
$(foreach t,$(CFG_TARGET_TRIPLES),$(eval $(call DEF_HOST_VAR,$(t))))
1010
$(foreach t,$(CFG_TARGET_TRIPLES),$(info cfg: host for $(t) is $(HOST_$(t))))
1111

12-
CFG_GCCISH_FLAGS := -fno-strict-aliasing
13-
CFG_GCCISH_LINK_FLAGS :=
12+
CFG_GCCISH_FLAGS += -fno-strict-aliasing
1413

1514
# On Darwin, we need to run dsymutil so the debugging information ends
1615
# up in the right place. On other platforms, it automatically gets

0 commit comments

Comments
 (0)