about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-29 15:45:54 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-29 15:45:54 -0700
commit5d85d8d80081211ca26cdf5a19671e7462ef4fe2 (patch)
tree7c5126fbe1197fe615c0d33775541f604d5bdce1
parent373d6202cffedd379cbb22128fb754f42fdbfb97 (diff)
parentdf82df8cf846246577507d32edcec14c6d3d0851 (diff)
downloadrust-5d85d8d80081211ca26cdf5a19671e7462ef4fe2.tar.gz
rust-5d85d8d80081211ca26cdf5a19671e7462ef4fe2.zip
rollup merge of #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 #24937
-rwxr-xr-xconfigure1
-rw-r--r--mk/tests.mk7
-rw-r--r--src/librustc/session/config.rs7
-rw-r--r--src/test/run-pass/issue-24945-repeat-dash-opts.rs18
4 files changed, 31 insertions, 2 deletions
diff --git a/configure b/configure
index f4e1d41276a..dbca73415fe 100755
--- a/configure
+++ b/configure
@@ -551,6 +551,7 @@ opt valgrind-rpass 1 "run rpass-valgrind tests with valgrind"
 opt docs     1 "build standard library documentation"
 opt compiler-docs     0 "build compiler documentation"
 opt optimize-tests 1 "build tests with optimizations"
+opt debuginfo-tests 0 "build tests with debugger metadata"
 opt libcpp 1 "build with llvm with libc++ instead of libstdc++ when using clang"
 opt llvm-assertions 0 "build LLVM with assertions"
 opt debug-assertions 0 "build with debugging assertions"
diff --git a/mk/tests.mk b/mk/tests.mk
index 3c4818f65da..f391d8555fc 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -632,6 +632,13 @@ ifndef CFG_DISABLE_OPTIMIZE_TESTS
 CTEST_RUSTC_FLAGS += -O
 endif
 
+# Analogously to the above, whether to pass `-g` when compiling tests
+# is a separate choice from whether to pass `-g` when building the
+# compiler and standard library themselves.
+CTEST_RUSTC_FLAGS := $$(subst -g,,$$(CTEST_RUSTC_FLAGS))
+ifdef CFG_ENABLE_DEBUGINFO_TESTS
+CTEST_RUSTC_FLAGS += -g
+endif
 
 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
 		--compile-lib-path $$(HLIB$(1)_H_$(3)) \
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index 072761f2754..b999929c4af 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -755,11 +755,14 @@ mod opt {
     pub fn   multi(a: S, b: S, c: S, d: S) -> R { stable(getopts::optmulti(a, b, c, d)) }
     pub fn    flag(a: S, b: S, c: S)       -> R { stable(getopts::optflag(a, b, c)) }
     pub fn flagopt(a: S, b: S, c: S, d: S) -> R { stable(getopts::optflagopt(a, b, c, d)) }
+    pub fn flagmulti(a: S, b: S, c: S)     -> R { stable(getopts::optflagmulti(a, b, c)) }
+
 
     pub fn     opt_u(a: S, b: S, c: S, d: S) -> R { unstable(getopts::optopt(a, b, c, d)) }
     pub fn   multi_u(a: S, b: S, c: S, d: S) -> R { unstable(getopts::optmulti(a, b, c, d)) }
     pub fn    flag_u(a: S, b: S, c: S)       -> R { unstable(getopts::optflag(a, b, c)) }
     pub fn flagopt_u(a: S, b: S, c: S, d: S) -> R { unstable(getopts::optflagopt(a, b, c, d)) }
+    pub fn flagmulti_u(a: S, b: S, c: S)     -> R { unstable(getopts::optflagmulti(a, b, c)) }
 }
 
 /// Returns the "short" subset of the rustc command line options,
@@ -786,8 +789,8 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
         opt::multi("", "print", "Comma separated list of compiler information to \
                                print on stdout",
                  "[crate-name|file-names|sysroot]"),
-        opt::flag("g",  "",  "Equivalent to -C debuginfo=2"),
-        opt::flag("O", "", "Equivalent to -C opt-level=2"),
+        opt::flagmulti("g",  "",  "Equivalent to -C debuginfo=2"),
+        opt::flagmulti("O", "", "Equivalent to -C opt-level=2"),
         opt::opt("o", "", "Write output to <filename>", "FILENAME"),
         opt::opt("",  "out-dir", "Write output to compiler-chosen filename \
                                 in <dir>", "DIR"),
diff --git a/src/test/run-pass/issue-24945-repeat-dash-opts.rs b/src/test/run-pass/issue-24945-repeat-dash-opts.rs
new file mode 100644
index 00000000000..33ac519a584
--- /dev/null
+++ b/src/test/run-pass/issue-24945-repeat-dash-opts.rs
@@ -0,0 +1,18 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This test is just checking that we continue to accept `-g -g -O -O`
+// as options to the compiler.
+
+// compile-flags:-g -g -O -O
+
+fn main() {
+    assert_eq!(1, 1);
+}