Skip to content

Commit 2dffe78

Browse files
committed
Rollup merge of #24205 - brson:debug, r=alexcrichton
This makes the default configuration fully optimized, with no debugging options, no llvm asserts, renames --enable-debug to --enable-debug-assertions, and adds --enable-debug as a blanket option that toggles various things, per #17665. It does not add a `--enable-release` flag since that would be a no-op. cc @nrc Fixes #22390 Fixes #17081 Partially addresses #17665
2 parents 67fa4d3 + a725426 commit 2dffe78

File tree

4 files changed

+52
-28
lines changed

4 files changed

+52
-28
lines changed

configure

+37-16
Original file line numberDiff line numberDiff line change
@@ -523,30 +523,35 @@ fi
523523
BOOL_OPTIONS=""
524524
VAL_OPTIONS=""
525525

526+
opt debug 0 "debug mode"
526527
opt valgrind 0 "run tests with valgrind (memcheck by default)"
527528
opt helgrind 0 "run tests with helgrind instead of memcheck"
528529
opt valgrind-rpass 1 "run rpass-valgrind tests with valgrind"
529530
opt docs 1 "build standard library documentation"
530531
opt compiler-docs 0 "build compiler documentation"
531-
opt optimize 1 "build optimized rust code"
532-
opt optimize-cxx 1 "build optimized C++ code"
533-
opt optimize-llvm 1 "build optimized LLVM"
534532
opt optimize-tests 1 "build tests with optimizations"
535533
opt libcpp 1 "build with llvm with libc++ instead of libstdc++ when using clang"
536-
opt llvm-assertions 1 "build LLVM with assertions"
537-
opt debug 1 "build with extra debug fun"
534+
opt llvm-assertions 0 "build LLVM with assertions"
535+
opt debug-assertions 0 "build with debugging assertions"
538536
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
539537
opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
540538
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
541539
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM"
542540
opt rpath 0 "build rpaths into rustc itself"
543-
opt nightly 0 "build nightly packages"
544-
opt verify-install 1 "verify installed binaries work"
545541
# This is used by the automation to produce single-target nightlies
546542
opt dist-host-only 0 "only install bins for the host architecture"
547543
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
548544
opt llvm-version-check 1 "don't check if the LLVM version is supported, build anyway"
549545

546+
# Optimization and debugging options. These may be overridden by the release channel, etc.
547+
opt_nosave optimize 1 "build optimized rust code"
548+
opt_nosave optimize-cxx 1 "build optimized C++ code"
549+
opt_nosave optimize-llvm 1 "build optimized LLVM"
550+
opt_nosave llvm-assertions 0 "build LLVM with assertions"
551+
opt_nosave debug-assertions 0 "build with debugging assertions"
552+
opt_nosave debuginfo 0 "build with debugger metadata"
553+
opt_nosave debug-jemalloc 0 "build jemalloc with --enable-debug --enable-fill"
554+
550555
valopt localstatedir "/var/lib" "local state directory"
551556
valopt sysconfdir "/etc" "install system configuration files"
552557

@@ -556,6 +561,7 @@ valopt llvm-root "" "set LLVM root"
556561
valopt jemalloc-root "" "set directory where libjemalloc_pic.a is located"
557562
valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple"
558563
valopt android-cross-path "/opt/ndk_standalone" "Android NDK standalone path"
564+
valopt release-channel "dev" "the name of the release channel to build"
559565

560566
# Many of these are saved below during the "writing configuration" step
561567
# (others are conditionally saved).
@@ -568,7 +574,6 @@ valopt_nosave local-rust-root "/usr/local" "set prefix for local rust binary"
568574
valopt_nosave host "${CFG_BUILD}" "GNUs ./configure syntax LLVM host triples"
569575
valopt_nosave target "${CFG_HOST}" "GNUs ./configure syntax LLVM target triples"
570576
valopt_nosave mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
571-
valopt_nosave release-channel "dev" "the name of the release channel to build"
572577

573578
# Temporarily support old triples until buildbots get updated
574579
CFG_BUILD=$(to_llvm_triple $CFG_BUILD)
@@ -621,13 +626,24 @@ case "$CFG_RELEASE_CHANNEL" in
621626
;;
622627
esac
623628

624-
# Continue supporting the old --enable-nightly flag to transition the bots
625-
# XXX Remove me
626-
if [ ! -z "$CFG_ENABLE_NIGHTLY" ]
627-
then
628-
CFG_RELEASE_CHANNEL=nightly
629+
# Adjust perf and debug options for debug mode
630+
if [ -n "$CFG_ENABLE_DEBUG" ]; then
631+
msg "debug mode enabled, setting performance options"
632+
CFG_DISABLE_OPTIMIZE=1
633+
CFG_DISABLE_OPTIMIZE_CXX=1
634+
CFG_ENABLE_LLVM_ASSERTIONS=1
635+
CFG_ENABLE_DEBUG_ASSERTIONS=1
636+
CFG_ENABLE_DEBUG_JEMALLOC=1
629637
fi
630-
putvar CFG_RELEASE_CHANNEL
638+
639+
# OK, now write the debugging options
640+
if [ -n "$CFG_DISABLE_OPTIMIZE" ]; then putvar CFG_DISABLE_OPTIMIZE; fi
641+
if [ -n "$CFG_DISABLE_OPTIMIZE_CXX" ]; then putvar CFG_DISABLE_OPTIMIZE_CXX; fi
642+
if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then putvar CFG_DISABLE_OPTIMIZE_LLVM; fi
643+
if [ -n "$CFG_ENABLE_LLVM_ASSERTIONS" ]; then putvar CFG_ENABLE_LLVM_ASSERTIONS; fi
644+
if [ -n "$CFG_ENABLE_DEBUG_ASSERTIONS" ]; then putvar CFG_ENABLE_DEBUG_ASSERTIONS; fi
645+
if [ -n "$CFG_ENABLE_DEBUGINFO" ]; then putvar CFG_ENABLE_DEBUGINFO; fi
646+
if [ -n "$CFG_ENABLE_DEBUG_JEMALLOC" ]; then putvar CFG_ENABLE_DEBUG_JEMALLOC; fi
631647

632648
# A magic value that allows the compiler to use unstable features
633649
# during the bootstrap even when doing so would normally be an error
@@ -1180,7 +1196,7 @@ do
11801196
LLVM_DBG_OPTS="--enable-optimized"
11811197
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release
11821198
fi
1183-
if [ ! -z "$CFG_DISABLE_LLVM_ASSERTIONS" ]
1199+
if [ -z "$CFG_ENABLE_LLVM_ASSERTIONS" ]
11841200
then
11851201
LLVM_ASSERTION_OPTS="--disable-assertions"
11861202
else
@@ -1434,6 +1450,11 @@ move_if_changed config.tmp config.mk
14341450
rm -f config.tmp
14351451
touch config.stamp
14361452

1437-
step_msg "complete"
1453+
if [ -z "$CFG_ENABLE_DEBUG" ]; then
1454+
step_msg "configured in release mode. for development consider --enable-debug"
1455+
else
1456+
step_msg "complete"
1457+
fi
1458+
14381459
msg "run \`make help\`"
14391460
msg

mk/install.mk

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
# option. This file may not be copied, modified, or distributed
99
# except according to those terms.
1010

11-
ifdef CFG_DISABLE_VERIFY_INSTALL
12-
MAYBE_DISABLE_VERIFY=--disable-verify
13-
else
14-
MAYBE_DISABLE_VERIFY=
15-
endif
16-
1711
install:
1812
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
1913
# Build the dist as the original user
@@ -22,9 +16,9 @@ else
2216
$(Q)$(MAKE) prepare_install
2317
endif
2418
ifeq ($(CFG_DISABLE_DOCS),)
25-
$(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(DOC_PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
19+
$(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(DOC_PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)"
2620
endif
27-
$(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
21+
$(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)"
2822
# Remove tmp files because it's a decent amount of disk space
2923
$(Q)rm -R tmp/dist
3024

mk/main.mk

+9-4
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,16 @@ endif
126126

127127
CFG_JEMALLOC_FLAGS += $(JEMALLOC_FLAGS)
128128

129-
ifdef CFG_DISABLE_DEBUG
130-
CFG_RUSTC_FLAGS += --cfg ndebug
131-
else
132-
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
129+
ifdef CFG_ENABLE_DEBUG_ASSERTIONS
130+
$(info cfg: enabling debug assertions (CFG_ENABLE_DEBUG_ASSERTIONS))
133131
CFG_RUSTC_FLAGS += --cfg debug -C debug-assertions=on
132+
else
133+
CFG_RUSTC_FLAGS += --cfg ndebug
134+
endif
135+
136+
ifdef CFG_ENABLE_DEBUGINFO
137+
$(info cfg: enabling debuginfo (CFG_ENABLE_DEBUGINFO))
138+
CFG_RUSTC_FLAGS += -g
134139
endif
135140

136141
ifdef SAVE_TEMPS

mk/rt.mk

+4
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ else ifeq ($(findstring android, $(OSTYPE_$(1))), android)
143143
JEMALLOC_ARGS_$(1) := --disable-tls
144144
endif
145145

146+
ifdef CFG_ENABLE_DEBUG_JEMALLOC
147+
JEMALLOC_ARGS_$(1) += --enable-debug --enable-fill
148+
endif
149+
146150
################################################################################
147151
# jemalloc
148152
################################################################################

0 commit comments

Comments
 (0)