From b60ea12b477b4cbb4ff24eb7ef19905acacd8f6c Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 23 Sep 2014 22:03:23 -0400 Subject: [PATCH] make release builds the default This cuts the compilation time for a trivial Rust program by 15-20% on Windows due to a massive improvement in `rustc` start-up time. The debug logging has a very high cost because it makes extensive use of mutable global variables and those result in expensive relocations. It also makes jemalloc debug assertions / logging tied to the same flag as ones in the standard library or compiler. Enabling debug assertions by default discourages their use, because normal builds will be paying a cost for each one. The few debug assertions not removed before landing a pull request are a significant performance problem for types like `RefCell`. The defaults should cater to users or packagers building Rust rather than compiler developers. A compiler developer can be expected to override a default flag, but the same cannot be said of someone who lacks the same in-depth knowledge of the project. Even someone working on the standard libraries is not going to want to pay the high cost for debug logging. Many people who contribute to the compiler don't use the feature either, because a debugger tends to work a lot better than inconsistent / bit-rotted logging code. --- configure | 2 +- mk/main.mk | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index ad2dd1b87895a..ca5851176ca0d 100755 --- a/configure +++ b/configure @@ -418,7 +418,7 @@ opt optimize-llvm 1 "build optimized LLVM" opt optimize-tests 1 "build tests with optimizations" opt libcpp 1 "build with llvm with libc++ instead of libstdc++ when using clang" opt llvm-assertions 1 "build LLVM with assertions" -opt debug 1 "build with extra debug fun" +opt debug 0 "build with extra debug fun" opt ratchet-bench 0 "ratchet benchmarks" opt fast-make 0 "use .gitmodules as timestamp for submodule deps" opt manage-submodules 1 "let the build manage the git submodules" diff --git a/mk/main.mk b/mk/main.mk index a12198b771b82..3bde0bd2ed0a4 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -105,7 +105,6 @@ CFG_JEMALLOC_FLAGS := ifdef CFG_DISABLE_OPTIMIZE $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)) CFG_RUSTC_FLAGS += - CFG_JEMALLOC_FLAGS += --enable-debug else # The rtopt cfg turns off runtime sanity checks CFG_RUSTC_FLAGS += -O --cfg rtopt @@ -113,13 +112,14 @@ endif CFG_JEMALLOC_FLAGS += $(JEMALLOC_FLAGS) -ifdef CFG_DISABLE_DEBUG +ifndef CFG_ENABLE_DEBUG CFG_RUSTC_FLAGS += --cfg ndebug CFG_GCCISH_CFLAGS += -DRUST_NDEBUG else $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG)) CFG_RUSTC_FLAGS += --cfg debug CFG_GCCISH_CFLAGS += -DRUST_DEBUG + CFG_JEMALLOC_FLAGS += --enable-debug endif ifdef SAVE_TEMPS