Skip to content

Commit

Permalink
rustc: Remove deprecated flags
Browse files Browse the repository at this point in the history
This commit removes a number of deprecated flags from the compiler:

* opt-level => -C opt-level
* debuginfo => -C debuginfo
* print-crate-name => --print crate-name
* print-file-name => --print file-names
* no-trans => -Z no-trans
* no-analysis => -Z no-analysis
* parse-only => -Z parse-only
* dep-info => --emit dep-info

This commit also moves the --pretty flag behind `-Z unstable-options` as the
pretty printer will likely not be stable for 1.0

cc rust-lang#19051
  • Loading branch information
alexcrichton committed Jan 20, 2015
1 parent ffd8cb7 commit 953f294
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 193 deletions.
3 changes: 2 additions & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
let aux_dir = aux_output_dir_name(config, testfile);
// FIXME (#9639): This needs to handle non-utf8 paths
let mut args = vec!("-".to_string(),
"-Zunstable-options".to_string(),
"--pretty".to_string(),
pretty_type,
format!("--target={}", config.target),
Expand Down Expand Up @@ -340,7 +341,7 @@ actual:\n\
};
// FIXME (#9639): This needs to handle non-utf8 paths
let mut args = vec!("-".to_string(),
"--no-trans".to_string(),
"-Zno-trans".to_string(),
"--crate-type=lib".to_string(),
format!("--target={}", target),
"-L".to_string(),
Expand Down
102 changes: 6 additions & 96 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,30 +786,14 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
opt::multi("", "extern", "Specify where an external rust library is \
located",
"NAME=PATH"),
opt::opt("", "opt-level", "Optimize with possible levels 0-3", "LEVEL"),
opt::opt("", "sysroot", "Override the system root", "PATH"),
opt::multi("Z", "", "Set internal debugging options", "FLAG"),
opt::opt("", "color", "Configure coloring of output:
auto = colorize, if output goes to a tty (default);
always = always colorize output;
never = never colorize output", "auto|always|never"),

// DEPRECATED
opt::flag("", "print-crate-name", "Output the crate name and exit"),
opt::flag("", "print-file-name", "Output the file(s) that would be \
written if compilation \
continued and exit"),
opt::opt("", "debuginfo", "Emit DWARF debug info to the objects created:
0 = no debug info,
1 = line-tables only (for stacktraces and breakpoints),
2 = full debug info with variable and type information \
(same as -g)", "LEVEL"),
opt::flag("", "no-trans", "Run all passes except translation; no output"),
opt::flag("", "no-analysis", "Parse and expand the source, but run no \
analysis and produce no output"),
opt::flag("", "parse-only", "Parse only; do not compile, assemble, \
or link"),
opt::flagopt("", "pretty",
opt::flagopt_u("", "pretty",
"Pretty-print the input instead of compiling;
valid types are: `normal` (un-annotated source),
`expanded` (crates expanded),
Expand All @@ -823,9 +807,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
`everybody_loops` (all function bodies replaced with `loop {}`).",
"TYPE"),
opt::opt_u("", "show-span", "Show spans for compiler debugging", "expr|pat|ty"),
opt::flagopt("", "dep-info",
"Output dependency info to <filename> after compiling, \
in a format suitable for use by Makefiles", "FILENAME"),
]);
opts
}
Expand Down Expand Up @@ -861,27 +842,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {

let debugging_opts = build_debugging_options(matches);

let parse_only = if matches.opt_present("parse-only") {
// FIXME(acrichto) remove this eventually
early_warn("--parse-only is deprecated in favor of -Z parse-only");
true
} else {
debugging_opts.parse_only
};
let no_trans = if matches.opt_present("no-trans") {
// FIXME(acrichto) remove this eventually
early_warn("--no-trans is deprecated in favor of -Z no-trans");
true
} else {
debugging_opts.no_trans
};
let no_analysis = if matches.opt_present("no-analysis") {
// FIXME(acrichto) remove this eventually
early_warn("--no-analysis is deprecated in favor of -Z no-analysis");
true
} else {
debugging_opts.no_analysis
};
let parse_only = debugging_opts.parse_only;
let no_trans = debugging_opts.no_trans;
let no_analysis = debugging_opts.no_analysis;

if debugging_opts.debug_llvm {
unsafe { llvm::LLVMSetDebug(1); }
Expand Down Expand Up @@ -921,28 +884,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
host_triple().to_string());
let opt_level = {
if matches.opt_present("O") {
if matches.opt_present("opt-level") {
early_error("-O and --opt-level both provided");
}
if cg.opt_level.is_some() {
early_error("-O and -C opt-level both provided");
}
Default
} else if matches.opt_present("opt-level") {
// FIXME(acrichto) remove this eventually
early_warn("--opt-level=N is deprecated in favor of -C opt-level=N");
match matches.opt_str("opt-level").as_ref().map(|s| s.as_slice()) {
None |
Some("0") => No,
Some("1") => Less,
Some("2") => Default,
Some("3") => Aggressive,
Some(arg) => {
early_error(&format!("optimization level needs to be \
between 0-3 (instead was `{}`)",
arg)[]);
}
}
} else {
match cg.opt_level {
None => No,
Expand All @@ -960,27 +905,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
};
let gc = debugging_opts.gc;
let debuginfo = if matches.opt_present("g") {
if matches.opt_present("debuginfo") {
early_error("-g and --debuginfo both provided");
}
if cg.debuginfo.is_some() {
early_error("-g and -C debuginfo both provided");
}
FullDebugInfo
} else if matches.opt_present("debuginfo") {
// FIXME(acrichto) remove this eventually
early_warn("--debuginfo=N is deprecated in favor of -C debuginfo=N");
match matches.opt_str("debuginfo").as_ref().map(|s| s.as_slice()) {
Some("0") => NoDebugInfo,
Some("1") => LimitedDebugInfo,
None |
Some("2") => FullDebugInfo,
Some(arg) => {
early_error(&format!("debug info level needs to be between \
0-2 (instead was `{}`)",
arg)[]);
}
}
} else {
match cg.debuginfo {
None | Some(0) => NoDebugInfo,
Expand Down Expand Up @@ -1036,15 +964,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {

let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
let test = matches.opt_present("test");
let write_dependency_info = if matches.opt_present("dep-info") {
// FIXME(acrichto) remove this eventually
early_warn("--dep-info has been deprecated in favor of --emit");
(true, matches.opt_str("dep-info").map(|p| Path::new(p)))
} else {
(output_types.contains(&OutputTypeDepInfo), None)
};
let write_dependency_info = (output_types.contains(&OutputTypeDepInfo), None);

let mut prints = matches.opt_strs("print").into_iter().map(|s| {
let prints = matches.opt_strs("print").into_iter().map(|s| {
match s.as_slice() {
"crate-name" => PrintRequest::CrateName,
"file-names" => PrintRequest::FileNames,
Expand All @@ -1054,18 +976,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}
}
}).collect::<Vec<_>>();
if matches.opt_present("print-crate-name") {
// FIXME(acrichto) remove this eventually
early_warn("--print-crate-name has been deprecated in favor of \
--print crate-name");
prints.push(PrintRequest::CrateName);
}
if matches.opt_present("print-file-name") {
// FIXME(acrichto) remove this eventually
early_warn("--print-file-name has been deprecated in favor of \
--print file-names");
prints.push(PrintRequest::FileNames);
}

if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
early_warn("-C remark will not show source locations without \
Expand Down
12 changes: 8 additions & 4 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ fn run_compiler(args: &[String]) {
return
}

let pretty = matches.opt_default("pretty", "normal").map(|a| {
// stable pretty-print variants only
pretty::parse_pretty(&sess, a.as_slice(), false)
});
let pretty = if sess.opts.debugging_opts.unstable_options {
matches.opt_default("pretty", "normal").map(|a| {
// stable pretty-print variants only
pretty::parse_pretty(&sess, a.as_slice(), false)
})
} else {
None
};
let pretty = if pretty.is_none() &&
sess.unstable_options() {
matches.opt_str("xpretty").map(|a| {
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/issue7712.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags:--debuginfo=1
// compile-flags:-C debuginfo=1
// min-lldb-version: 310

pub trait TraitWithDefaultMethod : Sized {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ignore-android: FIXME(#10381)
// min-lldb-version: 310

// compile-flags:--debuginfo=1
// compile-flags:-C debuginfo=1

// gdb-command:run
// lldb-command:run
Expand Down
2 changes: 1 addition & 1 deletion src/test/debuginfo/limited-debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// ignore-lldb

// compile-flags:--debuginfo=1
// compile-flags:-C debuginfo=1

// Make sure functions have proper names
// gdb-command:info functions
Expand Down
12 changes: 6 additions & 6 deletions src/test/run-make/crate-data-smoke/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-include ../tools.mk

all:
[ `$(RUSTC) --print-crate-name crate.rs` = "foo" ]
[ `$(RUSTC) --print-file-name crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print-file-name --crate-type=lib \
[ `$(RUSTC) --print crate-name crate.rs` = "foo" ]
[ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print file-names --crate-type=lib \
--test crate.rs` = "$(call BIN,foo)" ]
[ `$(RUSTC) --print-file-name --test lib.rs` = "$(call BIN,mylib)" ]
$(RUSTC) --print-file-name lib.rs
$(RUSTC) --print-file-name rlib.rs
[ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ]
$(RUSTC) --print file-names lib.rs
$(RUSTC) --print file-names rlib.rs
25 changes: 0 additions & 25 deletions src/test/run-make/dep-info-custom/Makefile

This file was deleted.

7 changes: 0 additions & 7 deletions src/test/run-make/dep-info-custom/Makefile.foo

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/run-make/dep-info-custom/bar.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/run-make/dep-info-custom/foo.rs

This file was deleted.

14 changes: 0 additions & 14 deletions src/test/run-make/dep-info-custom/lib.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/run-make/dep-info-spaces/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ifneq ($(shell uname),FreeBSD)
ifndef IS_WINDOWS
all:
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
$(RUSTC) --emit link,dep-info --crate-type=lib lib.rs
sleep 1
touch 'foo foo.rs'
-rm -f $(TMPDIR)/done
Expand Down
6 changes: 3 additions & 3 deletions src/test/run-make/dep-info-spaces/Makefile.foo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LIB := $(shell $(RUSTC) --print-file-name --crate-type=lib lib.rs)
LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs)

$(TMPDIR)/$(LIB):
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
$(RUSTC) --emit link,dep-info --crate-type=lib lib.rs
touch $(TMPDIR)/done

-include $(TMPDIR)/custom-deps-file.d
-include $(TMPDIR)/lib.d
2 changes: 1 addition & 1 deletion src/test/run-make/dep-info/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ifneq ($(shell uname),FreeBSD)
ifndef IS_WINDOWS
all:
$(RUSTC) --dep-info --crate-type=lib lib.rs
$(RUSTC) --emit dep-info,link --crate-type=lib lib.rs
sleep 2
touch foo.rs
-rm -f $(TMPDIR)/done
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-make/error-writing-dependencies/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

all:
# Let's get a nice error message
$(RUSTC) foo.rs --dep-info foo/bar/baz 2>&1 | \
$(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \
grep "error writing dependencies"
# Make sure the filename shows up
$(RUSTC) foo.rs --dep-info foo/bar/baz 2>&1 | grep "baz"
$(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | grep "baz"
2 changes: 1 addition & 1 deletion src/test/run-make/graphviz-flowgraph/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ all: $(patsubst %.rs,$(TMPDIR)/%.check,$(FILES))
RUSTC_LIB=$(RUSTC) --crate-type=lib

define FIND_LAST_BLOCK
LASTBLOCKNUM_$(1) := $(shell $(RUSTC_LIB) --pretty=expanded,identified $(1) \
LASTBLOCKNUM_$(1) := $(shell $(RUSTC_LIB) -Z unstable-options --pretty=expanded,identified $(1) \
| grep block
| tail -1
| sed -e 's@.*/\* block \([0-9]*\) \*/.*@\1@')
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-make/pretty-expanded-hygiene/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
REPLACEMENT := s/[0-9][0-9]*\#[0-9][0-9]*/$(shell date)/g

all:
$(RUSTC) -o $(TMPDIR)/input.out --pretty expanded,hygiene input.rs
$(RUSTC) -o $(TMPDIR)/input.out -Z unstable-options \
--pretty expanded,hygiene input.rs

# the name/ctxt numbers are very internals-dependent and thus
# change relatively frequently, and testing for their exact values
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-make/pretty-expanded/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-include ../tools.mk

all:
$(RUSTC) -o $(TMPDIR)/input.expanded.rs --pretty=expanded input.rs
$(RUSTC) -o $(TMPDIR)/input.expanded.rs -Z unstable-options \
--pretty=expanded input.rs
6 changes: 3 additions & 3 deletions src/test/run-make/pretty-print-path-suffix/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-include ../tools.mk

all:
$(RUSTC) -o $(TMPDIR)/foo.out --pretty normal=foo input.rs
$(RUSTC) -o $(TMPDIR)/nest_foo.out --pretty normal=nest::foo input.rs
$(RUSTC) -o $(TMPDIR)/foo_method.out --pretty normal=foo_method input.rs
$(RUSTC) -o $(TMPDIR)/foo.out -Z unstable-options --pretty normal=foo input.rs
$(RUSTC) -o $(TMPDIR)/nest_foo.out -Z unstable-options --pretty normal=nest::foo input.rs
$(RUSTC) -o $(TMPDIR)/foo_method.out -Z unstable-options --pretty normal=foo_method input.rs
diff -u $(TMPDIR)/foo.out foo.pp
diff -u $(TMPDIR)/nest_foo.out nest_foo.pp
diff -u $(TMPDIR)/foo_method.out foo_method.pp
Loading

0 comments on commit 953f294

Please sign in to comment.