Skip to content

Commit 5d85d8d

Browse files
committed
rollup merge of rust-lang#24945: pnkfelix/fixes-for-dash-g-handling
Fixes for -g handling First: * decouples our handling of `-g` for the test suite from our handling of `-g` for the rest of the compiler/stdlib building. * Namely, if you do `--enable-debug` or `--enable-debuginfo`, that should only affect `rustc` and the standard library crates; the tests should all continue to compile without `-g` unless: * you pass `--enable-debuginfo-tests`, or * the test itself requests the `-g` option (e.g. via a `// compile-flags: -g` embedded comment). Second: * Makes `rustc` more flexible in that it now accepts multiple occurrences of `-g -g` * (as a drive-by, I gave `-O` the same treatment: multiple occurrences of `-O` are treated as synonymous as a single occurrence of `-O`. Fix rust-lang#24937
2 parents 373d620 + df82df8 commit 5d85d8d

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ opt valgrind-rpass 1 "run rpass-valgrind tests with valgrind"
551551
opt docs 1 "build standard library documentation"
552552
opt compiler-docs 0 "build compiler documentation"
553553
opt optimize-tests 1 "build tests with optimizations"
554+
opt debuginfo-tests 0 "build tests with debugger metadata"
554555
opt libcpp 1 "build with llvm with libc++ instead of libstdc++ when using clang"
555556
opt llvm-assertions 0 "build LLVM with assertions"
556557
opt debug-assertions 0 "build with debugging assertions"

mk/tests.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,13 @@ ifndef CFG_DISABLE_OPTIMIZE_TESTS
632632
CTEST_RUSTC_FLAGS += -O
633633
endif
634634

635+
# Analogously to the above, whether to pass `-g` when compiling tests
636+
# is a separate choice from whether to pass `-g` when building the
637+
# compiler and standard library themselves.
638+
CTEST_RUSTC_FLAGS := $$(subst -g,,$$(CTEST_RUSTC_FLAGS))
639+
ifdef CFG_ENABLE_DEBUGINFO_TESTS
640+
CTEST_RUSTC_FLAGS += -g
641+
endif
635642

636643
CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
637644
--compile-lib-path $$(HLIB$(1)_H_$(3)) \

src/librustc/session/config.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,14 @@ mod opt {
755755
pub fn multi(a: S, b: S, c: S, d: S) -> R { stable(getopts::optmulti(a, b, c, d)) }
756756
pub fn flag(a: S, b: S, c: S) -> R { stable(getopts::optflag(a, b, c)) }
757757
pub fn flagopt(a: S, b: S, c: S, d: S) -> R { stable(getopts::optflagopt(a, b, c, d)) }
758+
pub fn flagmulti(a: S, b: S, c: S) -> R { stable(getopts::optflagmulti(a, b, c)) }
759+
758760

759761
pub fn opt_u(a: S, b: S, c: S, d: S) -> R { unstable(getopts::optopt(a, b, c, d)) }
760762
pub fn multi_u(a: S, b: S, c: S, d: S) -> R { unstable(getopts::optmulti(a, b, c, d)) }
761763
pub fn flag_u(a: S, b: S, c: S) -> R { unstable(getopts::optflag(a, b, c)) }
762764
pub fn flagopt_u(a: S, b: S, c: S, d: S) -> R { unstable(getopts::optflagopt(a, b, c, d)) }
765+
pub fn flagmulti_u(a: S, b: S, c: S) -> R { unstable(getopts::optflagmulti(a, b, c)) }
763766
}
764767

765768
/// Returns the "short" subset of the rustc command line options,
@@ -786,8 +789,8 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
786789
opt::multi("", "print", "Comma separated list of compiler information to \
787790
print on stdout",
788791
"[crate-name|file-names|sysroot]"),
789-
opt::flag("g", "", "Equivalent to -C debuginfo=2"),
790-
opt::flag("O", "", "Equivalent to -C opt-level=2"),
792+
opt::flagmulti("g", "", "Equivalent to -C debuginfo=2"),
793+
opt::flagmulti("O", "", "Equivalent to -C opt-level=2"),
791794
opt::opt("o", "", "Write output to <filename>", "FILENAME"),
792795
opt::opt("", "out-dir", "Write output to compiler-chosen filename \
793796
in <dir>", "DIR"),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This test is just checking that we continue to accept `-g -g -O -O`
12+
// as options to the compiler.
13+
14+
// compile-flags:-g -g -O -O
15+
16+
fn main() {
17+
assert_eq!(1, 1);
18+
}

0 commit comments

Comments
 (0)