rustc: Start "stabilizing" some flags
This commit shuffles around some CLI flags of the compiler to some more stable locations with some renamings. The changes made were: * The `-v` flag has been repurposes as the "verbose" flag. The version flag has been renamed to `-V`. * The `-h` screen has been split into two parts. Most top-level options (not all) show with `-h`, and the remaining options (generally obscure) can be shown with `--help -v` which is a "verbose help screen" * The `-V` flag (version flag now) has lost its argument as it is now requested with `rustc -vV` "verbose version". * The `--emit` option has had its `ir` and `bc` variants renamed to `llvm-ir` and `llvm-bc` to emphasize that they are LLVM's IR/bytecode. * The `--emit` option has grown a new variant, `dep-info`, which subsumes the `--dep-info` CLI argument. The `--dep-info` flag is now deprecated. * The `--parse-only`, `--no-trans`, and `--no-analysis` flags have moved behind the `-Z` family of flags. * The `--debuginfo` and `--opt-level` flags were moved behind the top-level `-C` flag. * The `--print-file-name` and `--print-crate-name` flags were moved behind one global `--print` flag which now accepts one of `crate-name`, `file-names`, or `sysroot`. This global `--print` flag is intended to serve as a mechanism for learning various metadata about the compiler itself. No warnings are currently enabled to allow tools like Cargo to have time to migrate to the new flags before spraying warnings to all users.
This commit is contained in:
parent
f9a48492a8
commit
117984b884
16 changed files with 274 additions and 152 deletions
|
@ -1666,7 +1666,7 @@ fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let mut link_args = vec!("-L".to_string(),
|
let mut link_args = vec!("-L".to_string(),
|
||||||
aux_dir.as_str().unwrap().to_string());
|
aux_dir.as_str().unwrap().to_string());
|
||||||
let llvm_args = vec!("--emit=bc,obj".to_string(),
|
let llvm_args = vec!("--emit=llvm-bc,obj".to_string(),
|
||||||
"--crate-type=lib".to_string());
|
"--crate-type=lib".to_string());
|
||||||
link_args.extend(llvm_args.into_iter());
|
link_args.extend(llvm_args.into_iter());
|
||||||
let args = make_compile_args(config,
|
let args = make_compile_args(config,
|
||||||
|
|
|
@ -19,7 +19,7 @@ TMPFILE=`mktemp /tmp/rust-lldb-commands.XXXXXX`
|
||||||
trap "rm -f $TMPFILE; exit" INT TERM EXIT
|
trap "rm -f $TMPFILE; exit" INT TERM EXIT
|
||||||
|
|
||||||
# Find out where to look for the pretty printer Python module
|
# Find out where to look for the pretty printer Python module
|
||||||
RUSTC_SYSROOT=`rustc -Zprint-sysroot`
|
RUSTC_SYSROOT=`rustc --print sysroot`
|
||||||
|
|
||||||
# Write the LLDB script to the tempfile
|
# Write the LLDB script to the tempfile
|
||||||
echo "command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\"" >> $TMPFILE
|
echo "command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\"" >> $TMPFILE
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub use self::OptLevel::*;
|
||||||
pub use self::OutputType::*;
|
pub use self::OutputType::*;
|
||||||
pub use self::DebugInfoLevel::*;
|
pub use self::DebugInfoLevel::*;
|
||||||
|
|
||||||
use session::{early_error, early_warn, Session};
|
use session::{early_error, Session};
|
||||||
|
|
||||||
use rustc_back::target::Target;
|
use rustc_back::target::Target;
|
||||||
use lint;
|
use lint;
|
||||||
|
@ -73,6 +73,7 @@ pub enum OutputType {
|
||||||
OutputTypeLlvmAssembly,
|
OutputTypeLlvmAssembly,
|
||||||
OutputTypeObject,
|
OutputTypeObject,
|
||||||
OutputTypeExe,
|
OutputTypeExe,
|
||||||
|
OutputTypeDepInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for OutputType {}
|
impl Copy for OutputType {}
|
||||||
|
@ -108,8 +109,7 @@ pub struct Options {
|
||||||
pub debugging_opts: u64,
|
pub debugging_opts: u64,
|
||||||
/// Whether to write dependency files. It's (enabled, optional filename).
|
/// Whether to write dependency files. It's (enabled, optional filename).
|
||||||
pub write_dependency_info: (bool, Option<Path>),
|
pub write_dependency_info: (bool, Option<Path>),
|
||||||
/// Crate id-related things to maybe print. It's (crate_name, crate_file_name).
|
pub prints: Vec<PrintRequest>,
|
||||||
pub print_metas: (bool, bool),
|
|
||||||
pub cg: CodegenOptions,
|
pub cg: CodegenOptions,
|
||||||
pub color: ColorConfig,
|
pub color: ColorConfig,
|
||||||
pub externs: HashMap<String, Vec<String>>,
|
pub externs: HashMap<String, Vec<String>>,
|
||||||
|
@ -120,6 +120,14 @@ pub struct Options {
|
||||||
pub alt_std_name: Option<String>
|
pub alt_std_name: Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving(Clone, PartialEq, Eq)]
|
||||||
|
#[allow(missing_copy_implementations)]
|
||||||
|
pub enum PrintRequest {
|
||||||
|
FileNames,
|
||||||
|
Sysroot,
|
||||||
|
CrateName,
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Input {
|
pub enum Input {
|
||||||
/// Load source from file
|
/// Load source from file
|
||||||
File(Path),
|
File(Path),
|
||||||
|
@ -160,6 +168,7 @@ impl OutputFilenames {
|
||||||
OutputTypeAssembly => base.with_extension("s"),
|
OutputTypeAssembly => base.with_extension("s"),
|
||||||
OutputTypeLlvmAssembly => base.with_extension("ll"),
|
OutputTypeLlvmAssembly => base.with_extension("ll"),
|
||||||
OutputTypeObject => base.with_extension("o"),
|
OutputTypeObject => base.with_extension("o"),
|
||||||
|
OutputTypeDepInfo => base.with_extension("d"),
|
||||||
OutputTypeExe => base,
|
OutputTypeExe => base,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +215,7 @@ pub fn basic_options() -> Options {
|
||||||
no_analysis: false,
|
no_analysis: false,
|
||||||
debugging_opts: 0,
|
debugging_opts: 0,
|
||||||
write_dependency_info: (false, None),
|
write_dependency_info: (false, None),
|
||||||
print_metas: (false, false),
|
prints: Vec::new(),
|
||||||
cg: basic_codegen_options(),
|
cg: basic_codegen_options(),
|
||||||
color: Auto,
|
color: Auto,
|
||||||
externs: HashMap::new(),
|
externs: HashMap::new(),
|
||||||
|
@ -276,8 +285,10 @@ debugging_opts! {
|
||||||
FLOWGRAPH_PRINT_MOVES,
|
FLOWGRAPH_PRINT_MOVES,
|
||||||
FLOWGRAPH_PRINT_ASSIGNS,
|
FLOWGRAPH_PRINT_ASSIGNS,
|
||||||
FLOWGRAPH_PRINT_ALL,
|
FLOWGRAPH_PRINT_ALL,
|
||||||
PRINT_SYSROOT,
|
PRINT_REGION_GRAPH,
|
||||||
PRINT_REGION_GRAPH
|
PARSE_ONLY,
|
||||||
|
NO_TRANS,
|
||||||
|
NO_ANALYSIS
|
||||||
]
|
]
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -322,11 +333,14 @@ pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
|
||||||
--pretty flowgraph output", FLOWGRAPH_PRINT_ASSIGNS),
|
--pretty flowgraph output", FLOWGRAPH_PRINT_ASSIGNS),
|
||||||
("flowgraph-print-all", "Include all dataflow analysis data in \
|
("flowgraph-print-all", "Include all dataflow analysis data in \
|
||||||
--pretty flowgraph output", FLOWGRAPH_PRINT_ALL),
|
--pretty flowgraph output", FLOWGRAPH_PRINT_ALL),
|
||||||
("print-sysroot", "Print the sysroot as used by this rustc invocation",
|
|
||||||
PRINT_SYSROOT),
|
|
||||||
("print-region-graph", "Prints region inference graph. \
|
("print-region-graph", "Prints region inference graph. \
|
||||||
Use with RUST_REGION_GRAPH=help for more info",
|
Use with RUST_REGION_GRAPH=help for more info",
|
||||||
PRINT_REGION_GRAPH)]
|
PRINT_REGION_GRAPH),
|
||||||
|
("parse-only", "Parse only; do not compile, assemble, or link", PARSE_ONLY),
|
||||||
|
("no-trans", "Run all passes except translation; no output", NO_TRANS),
|
||||||
|
("no-analysis", "Parse and expand the source, but run no analysis and",
|
||||||
|
NO_TRANS),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
|
@ -380,6 +394,8 @@ macro_rules! cgoptions {
|
||||||
pub const parse_uint: Option<&'static str> = Some("a number");
|
pub const parse_uint: Option<&'static str> = Some("a number");
|
||||||
pub const parse_passes: Option<&'static str> =
|
pub const parse_passes: Option<&'static str> =
|
||||||
Some("a space-separated list of passes, or `all`");
|
Some("a space-separated list of passes, or `all`");
|
||||||
|
pub const parse_opt_uint: Option<&'static str> =
|
||||||
|
Some("a number");
|
||||||
}
|
}
|
||||||
|
|
||||||
mod cgsetters {
|
mod cgsetters {
|
||||||
|
@ -451,6 +467,13 @@ macro_rules! cgoptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_opt_uint(slot: &mut Option<uint>, v: Option<&str>) -> bool {
|
||||||
|
match v {
|
||||||
|
Some(s) => { *slot = from_str(s); slot.is_some() }
|
||||||
|
None => { *slot = None; true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
|
fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
|
||||||
match v {
|
match v {
|
||||||
Some("all") => {
|
Some("all") => {
|
||||||
|
@ -520,6 +543,11 @@ cgoptions! {
|
||||||
"print remarks for these optimization passes (space separated, or \"all\")"),
|
"print remarks for these optimization passes (space separated, or \"all\")"),
|
||||||
no_stack_check: bool = (false, parse_bool,
|
no_stack_check: bool = (false, parse_bool,
|
||||||
"disable checks for stack exhaustion (a memory-safety hazard!)"),
|
"disable checks for stack exhaustion (a memory-safety hazard!)"),
|
||||||
|
debuginfo: Option<uint> = (None, parse_opt_uint,
|
||||||
|
"debug info emission level, 0 = no debug info, 1 = line tables only, \
|
||||||
|
2 = full debug info with variable and type information"),
|
||||||
|
opt_level: Option<uint> = (None, parse_opt_uint,
|
||||||
|
"Optimize with possible levels 0-3"),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
|
pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
|
||||||
|
@ -635,9 +663,8 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rustc command line options
|
pub fn short_optgroups() -> Vec<getopts::OptGroup> {
|
||||||
pub fn optgroups() -> Vec<getopts::OptGroup> {
|
vec![
|
||||||
vec!(
|
|
||||||
optflag("h", "help", "Display this message"),
|
optflag("h", "help", "Display this message"),
|
||||||
optmulti("", "cfg", "Configure the compilation environment", "SPEC"),
|
optmulti("", "cfg", "Configure the compilation environment", "SPEC"),
|
||||||
optmulti("L", "", "Add a directory to the library search path", "PATH"),
|
optmulti("L", "", "Add a directory to the library search path", "PATH"),
|
||||||
|
@ -647,29 +674,68 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
|
||||||
assumed.", "NAME[:KIND]"),
|
assumed.", "NAME[:KIND]"),
|
||||||
optmulti("", "crate-type", "Comma separated list of types of crates
|
optmulti("", "crate-type", "Comma separated list of types of crates
|
||||||
for the compiler to emit",
|
for the compiler to emit",
|
||||||
"[bin|lib|rlib|dylib|staticlib]"),
|
"[bin|lib|rlib|dylib|staticlib|dep-info]"),
|
||||||
optmulti("", "emit", "Comma separated list of types of output for the compiler to emit",
|
|
||||||
"[asm|bc|ir|obj|link]"),
|
|
||||||
optopt("", "crate-name", "Specify the name of the crate being built",
|
optopt("", "crate-name", "Specify the name of the crate being built",
|
||||||
"NAME"),
|
"NAME"),
|
||||||
optflag("", "print-crate-name", "Output the crate name and exit"),
|
optmulti("", "emit", "Comma separated list of types of output for \
|
||||||
optflag("", "print-file-name", "Output the file(s) that would be written if compilation \
|
the compiler to emit",
|
||||||
continued and exit"),
|
"[asm|llvm-bc|llvm-ir|obj|link]"),
|
||||||
optflag("", "crate-file-name", "deprecated in favor of --print-file-name"),
|
optmulti("", "print", "Comma separated list of compiler information to \
|
||||||
|
print on stdout",
|
||||||
|
"[crate-name|output-file-names|sysroot]"),
|
||||||
optflag("g", "", "Equivalent to --debuginfo=2"),
|
optflag("g", "", "Equivalent to --debuginfo=2"),
|
||||||
|
optflag("O", "", "Equivalent to --opt-level=2"),
|
||||||
|
optopt("o", "", "Write output to <filename>", "FILENAME"),
|
||||||
|
optopt("", "out-dir", "Write output to compiler-chosen filename \
|
||||||
|
in <dir>", "DIR"),
|
||||||
|
optopt("", "explain", "Provide a detailed explanation of an error \
|
||||||
|
message", "OPT"),
|
||||||
|
optflag("", "test", "Build a test harness"),
|
||||||
|
optopt("", "target", "Target triple cpu-manufacturer-kernel[-os] \
|
||||||
|
to compile for (see chapter 3.4 of \
|
||||||
|
http://www.sourceware.org/autobook/
|
||||||
|
for details)",
|
||||||
|
"TRIPLE"),
|
||||||
|
optmulti("W", "warn", "Set lint warnings", "OPT"),
|
||||||
|
optmulti("A", "allow", "Set lint allowed", "OPT"),
|
||||||
|
optmulti("D", "deny", "Set lint denied", "OPT"),
|
||||||
|
optmulti("F", "forbid", "Set lint forbidden", "OPT"),
|
||||||
|
optmulti("C", "codegen", "Set a codegen option", "OPT[=VALUE]"),
|
||||||
|
optflag("V", "version", "Print version info and exit"),
|
||||||
|
optflag("v", "verbose", "Use verbose output"),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// rustc command line options
|
||||||
|
pub fn optgroups() -> Vec<getopts::OptGroup> {
|
||||||
|
let mut opts = short_optgroups();
|
||||||
|
opts.push_all(&[
|
||||||
|
optmulti("", "extern", "Specify where an external rust library is \
|
||||||
|
located",
|
||||||
|
"NAME=PATH"),
|
||||||
|
optopt("", "opt-level", "Optimize with possible levels 0-3", "LEVEL"),
|
||||||
|
optopt("", "sysroot", "Override the system root", "PATH"),
|
||||||
|
optmulti("Z", "", "Set internal debugging options", "FLAG"),
|
||||||
|
optopt("", "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
|
||||||
|
optflag("", "print-crate-name", "Output the crate name and exit"),
|
||||||
|
optflag("", "print-file-name", "Output the file(s) that would be \
|
||||||
|
written if compilation \
|
||||||
|
continued and exit"),
|
||||||
optopt("", "debuginfo", "Emit DWARF debug info to the objects created:
|
optopt("", "debuginfo", "Emit DWARF debug info to the objects created:
|
||||||
0 = no debug info,
|
0 = no debug info,
|
||||||
1 = line-tables only (for stacktraces and breakpoints),
|
1 = line-tables only (for stacktraces and breakpoints),
|
||||||
2 = full debug info with variable and type information (same as -g)", "LEVEL"),
|
2 = full debug info with variable and type information \
|
||||||
|
(same as -g)", "LEVEL"),
|
||||||
optflag("", "no-trans", "Run all passes except translation; no output"),
|
optflag("", "no-trans", "Run all passes except translation; no output"),
|
||||||
optflag("", "no-analysis",
|
optflag("", "no-analysis", "Parse and expand the source, but run no \
|
||||||
"Parse and expand the source, but run no analysis and produce no output"),
|
analysis and produce no output"),
|
||||||
optflag("O", "", "Equivalent to --opt-level=2"),
|
optflag("", "parse-only", "Parse only; do not compile, assemble, \
|
||||||
optopt("o", "", "Write output to <filename>", "FILENAME"),
|
or link"),
|
||||||
optopt("", "opt-level", "Optimize with possible levels 0-3", "LEVEL"),
|
|
||||||
optopt( "", "out-dir", "Write output to compiler-chosen filename in <dir>", "DIR"),
|
|
||||||
optflag("", "parse-only", "Parse only; do not compile, assemble, or link"),
|
|
||||||
optopt("", "explain", "Provide a detailed explanation of an error message", "OPT"),
|
|
||||||
optflagopt("", "pretty",
|
optflagopt("", "pretty",
|
||||||
"Pretty-print the input instead of compiling;
|
"Pretty-print the input instead of compiling;
|
||||||
valid types are: `normal` (un-annotated source),
|
valid types are: `normal` (un-annotated source),
|
||||||
|
@ -681,25 +747,8 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
|
||||||
optflagopt("", "dep-info",
|
optflagopt("", "dep-info",
|
||||||
"Output dependency info to <filename> after compiling, \
|
"Output dependency info to <filename> after compiling, \
|
||||||
in a format suitable for use by Makefiles", "FILENAME"),
|
in a format suitable for use by Makefiles", "FILENAME"),
|
||||||
optopt("", "sysroot", "Override the system root", "PATH"),
|
]);
|
||||||
optflag("", "test", "Build a test harness"),
|
opts
|
||||||
optopt("", "target", "Target triple cpu-manufacturer-kernel[-os]
|
|
||||||
to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
|
|
||||||
for details)", "TRIPLE"),
|
|
||||||
optmulti("W", "warn", "Set lint warnings", "OPT"),
|
|
||||||
optmulti("A", "allow", "Set lint allowed", "OPT"),
|
|
||||||
optmulti("D", "deny", "Set lint denied", "OPT"),
|
|
||||||
optmulti("F", "forbid", "Set lint forbidden", "OPT"),
|
|
||||||
optmulti("C", "codegen", "Set a codegen option", "OPT[=VALUE]"),
|
|
||||||
optmulti("Z", "", "Set internal debugging options", "FLAG"),
|
|
||||||
optflagopt("v", "version", "Print version info and exit", "verbose"),
|
|
||||||
optopt("", "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"),
|
|
||||||
optmulti("", "extern", "Specify where an external rust library is located",
|
|
||||||
"NAME=PATH"),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -719,10 +768,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
|
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
|
||||||
.unwrap_or_else(|e| early_error(e.as_slice()));
|
.unwrap_or_else(|e| early_error(e.as_slice()));
|
||||||
|
|
||||||
let parse_only = matches.opt_present("parse-only");
|
|
||||||
let no_trans = matches.opt_present("no-trans");
|
|
||||||
let no_analysis = matches.opt_present("no-analysis");
|
|
||||||
|
|
||||||
let mut lint_opts = vec!();
|
let mut lint_opts = vec!();
|
||||||
let mut describe_lints = false;
|
let mut describe_lints = false;
|
||||||
|
|
||||||
|
@ -754,6 +799,28 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
debugging_opts |= this_bit;
|
debugging_opts |= this_bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let parse_only = if matches.opt_present("parse-only") {
|
||||||
|
// FIXME(acrichto) uncomment deprecation warning
|
||||||
|
// early_warn("--parse-only is deprecated in favor of -Z parse-only");
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
debugging_opts & PARSE_ONLY != 0
|
||||||
|
};
|
||||||
|
let no_trans = if matches.opt_present("no-trans") {
|
||||||
|
// FIXME(acrichto) uncomment deprecation warning
|
||||||
|
// early_warn("--no-trans is deprecated in favor of -Z no-trans");
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
debugging_opts & NO_TRANS != 0
|
||||||
|
};
|
||||||
|
let no_analysis = if matches.opt_present("no-analysis") {
|
||||||
|
// FIXME(acrichto) uncomment deprecation warning
|
||||||
|
// early_warn("--no-analysis is deprecated in favor of -Z no-analysis");
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
debugging_opts & NO_ANALYSIS != 0
|
||||||
|
};
|
||||||
|
|
||||||
if debugging_opts & DEBUG_LLVM != 0 {
|
if debugging_opts & DEBUG_LLVM != 0 {
|
||||||
unsafe { llvm::LLVMSetDebug(1); }
|
unsafe { llvm::LLVMSetDebug(1); }
|
||||||
}
|
}
|
||||||
|
@ -764,11 +831,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
for unparsed_output_type in unparsed_output_types.iter() {
|
for unparsed_output_type in unparsed_output_types.iter() {
|
||||||
for part in unparsed_output_type.split(',') {
|
for part in unparsed_output_type.split(',') {
|
||||||
let output_type = match part.as_slice() {
|
let output_type = match part.as_slice() {
|
||||||
"asm" => OutputTypeAssembly,
|
"asm" => OutputTypeAssembly,
|
||||||
"ir" => OutputTypeLlvmAssembly,
|
"llvm-ir" => OutputTypeLlvmAssembly,
|
||||||
"bc" => OutputTypeBitcode,
|
"llvm-bc" => OutputTypeBitcode,
|
||||||
"obj" => OutputTypeObject,
|
"obj" => OutputTypeObject,
|
||||||
"link" => OutputTypeExe,
|
"link" => OutputTypeExe,
|
||||||
|
"dep-info" => OutputTypeDepInfo,
|
||||||
_ => {
|
_ => {
|
||||||
early_error(format!("unknown emission type: `{}`",
|
early_error(format!("unknown emission type: `{}`",
|
||||||
part).as_slice())
|
part).as_slice())
|
||||||
|
@ -784,6 +852,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
output_types.push(OutputTypeExe);
|
output_types.push(OutputTypeExe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cg = build_codegen_options(matches);
|
||||||
|
|
||||||
let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m));
|
let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m));
|
||||||
let target = matches.opt_str("target").unwrap_or(
|
let target = matches.opt_str("target").unwrap_or(
|
||||||
host_triple().to_string());
|
host_triple().to_string());
|
||||||
|
@ -792,8 +862,13 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
if matches.opt_present("opt-level") {
|
if matches.opt_present("opt-level") {
|
||||||
early_error("-O and --opt-level both provided");
|
early_error("-O and --opt-level both provided");
|
||||||
}
|
}
|
||||||
|
if cg.opt_level.is_some() {
|
||||||
|
early_error("-O and -C opt-level both provided");
|
||||||
|
}
|
||||||
Default
|
Default
|
||||||
} else if matches.opt_present("opt-level") {
|
} else if matches.opt_present("opt-level") {
|
||||||
|
// FIXME(acrichto) uncomment deprecation warning
|
||||||
|
// 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()) {
|
match matches.opt_str("opt-level").as_ref().map(|s| s.as_slice()) {
|
||||||
None |
|
None |
|
||||||
Some("0") => No,
|
Some("0") => No,
|
||||||
|
@ -807,7 +882,18 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
No
|
match cg.opt_level {
|
||||||
|
None => No,
|
||||||
|
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).as_slice());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let gc = debugging_opts & GC != 0;
|
let gc = debugging_opts & GC != 0;
|
||||||
|
@ -815,8 +901,13 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
if matches.opt_present("debuginfo") {
|
if matches.opt_present("debuginfo") {
|
||||||
early_error("-g and --debuginfo both provided");
|
early_error("-g and --debuginfo both provided");
|
||||||
}
|
}
|
||||||
|
if cg.debuginfo.is_some() {
|
||||||
|
early_error("-g and -C debuginfo both provided");
|
||||||
|
}
|
||||||
FullDebugInfo
|
FullDebugInfo
|
||||||
} else if matches.opt_present("debuginfo") {
|
} else if matches.opt_present("debuginfo") {
|
||||||
|
// FIXME(acrichto) uncomment deprecation warning
|
||||||
|
// early_warn("--debuginfo=N is deprecated in favor of -C debuginfo=N");
|
||||||
match matches.opt_str("debuginfo").as_ref().map(|s| s.as_slice()) {
|
match matches.opt_str("debuginfo").as_ref().map(|s| s.as_slice()) {
|
||||||
Some("0") => NoDebugInfo,
|
Some("0") => NoDebugInfo,
|
||||||
Some("1") => LimitedDebugInfo,
|
Some("1") => LimitedDebugInfo,
|
||||||
|
@ -829,7 +920,16 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NoDebugInfo
|
match cg.debuginfo {
|
||||||
|
None | Some(0) => NoDebugInfo,
|
||||||
|
Some(1) => LimitedDebugInfo,
|
||||||
|
Some(2) => FullDebugInfo,
|
||||||
|
Some(arg) => {
|
||||||
|
early_error(format!("debug info level needs to be between \
|
||||||
|
0-2 (instead was `{}`)",
|
||||||
|
arg).as_slice());
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let addl_lib_search_paths = matches.opt_strs("L").iter().map(|s| {
|
let addl_lib_search_paths = matches.opt_strs("L").iter().map(|s| {
|
||||||
|
@ -855,21 +955,41 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
|
|
||||||
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
|
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
|
||||||
let test = matches.opt_present("test");
|
let test = matches.opt_present("test");
|
||||||
let write_dependency_info = (matches.opt_present("dep-info"),
|
let write_dependency_info = if matches.opt_present("dep-info") {
|
||||||
matches.opt_str("dep-info")
|
// FIXME(acrichto) uncomment deprecation warning
|
||||||
.map(|p| Path::new(p)));
|
// 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 print_metas = (matches.opt_present("print-crate-name"),
|
let mut prints = matches.opt_strs("print").into_iter().map(|s| {
|
||||||
matches.opt_present("print-file-name") ||
|
match s.as_slice() {
|
||||||
matches.opt_present("crate-file-name"));
|
"crate-name" => PrintRequest::CrateName,
|
||||||
if matches.opt_present("crate-file-name") {
|
"file-names" => PrintRequest::FileNames,
|
||||||
early_warn("the --crate-file-name argument has been renamed to \
|
"sysroot" => PrintRequest::Sysroot,
|
||||||
--print-file-name");
|
req => {
|
||||||
|
early_error(format!("unknown print request `{}`", req).as_slice())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).collect::<Vec<_>>();
|
||||||
|
if matches.opt_present("print-crate-name") {
|
||||||
|
// FIXME(acrichto) uncomment deprecation warning
|
||||||
|
// 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) uncomment deprecation warning
|
||||||
|
// early_warn("--print-file-name has been deprecated in favor of \
|
||||||
|
// --print file-names");
|
||||||
|
prints.push(PrintRequest::FileNames);
|
||||||
}
|
}
|
||||||
let cg = build_codegen_options(matches);
|
|
||||||
|
|
||||||
if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
|
if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
|
||||||
early_warn("-C remark will not show source locations without --debuginfo");
|
// FIXME(acrichto) uncomment deprecation warning
|
||||||
|
// early_warn("-C remark will not show source locations without \
|
||||||
|
// --debuginfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
let color = match matches.opt_str("color").as_ref().map(|s| s.as_slice()) {
|
let color = match matches.opt_str("color").as_ref().map(|s| s.as_slice()) {
|
||||||
|
@ -924,7 +1044,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
no_analysis: no_analysis,
|
no_analysis: no_analysis,
|
||||||
debugging_opts: debugging_opts,
|
debugging_opts: debugging_opts,
|
||||||
write_dependency_info: write_dependency_info,
|
write_dependency_info: write_dependency_info,
|
||||||
print_metas: print_metas,
|
prints: prints,
|
||||||
cg: cg,
|
cg: cg,
|
||||||
color: color,
|
color: color,
|
||||||
externs: externs,
|
externs: externs,
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub use syntax::diagnostic;
|
||||||
|
|
||||||
use rustc_trans::back::link;
|
use rustc_trans::back::link;
|
||||||
use rustc::session::{config, Session, build_session};
|
use rustc::session::{config, Session, build_session};
|
||||||
use rustc::session::config::Input;
|
use rustc::session::config::{Input, PrintRequest};
|
||||||
use rustc::lint::Lint;
|
use rustc::lint::Lint;
|
||||||
use rustc::lint;
|
use rustc::lint;
|
||||||
use rustc::metadata;
|
use rustc::metadata;
|
||||||
|
@ -101,6 +101,8 @@ fn run_compiler(args: &[String]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let sopts = config::build_session_options(&matches);
|
let sopts = config::build_session_options(&matches);
|
||||||
|
let odir = matches.opt_str("out-dir").map(|o| Path::new(o));
|
||||||
|
let ofile = matches.opt_str("o").map(|o| Path::new(o));
|
||||||
let (input, input_file_path) = match matches.free.len() {
|
let (input, input_file_path) = match matches.free.len() {
|
||||||
0u => {
|
0u => {
|
||||||
if sopts.describe_lints {
|
if sopts.describe_lints {
|
||||||
|
@ -109,13 +111,10 @@ fn run_compiler(args: &[String]) {
|
||||||
describe_lints(&ls, false);
|
describe_lints(&ls, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let sess = build_session(sopts, None, descriptions);
|
let sess = build_session(sopts, None, descriptions);
|
||||||
if sess.debugging_opt(config::PRINT_SYSROOT) {
|
if print_crate_info(&sess, None, &odir, &ofile) {
|
||||||
println!("{}", sess.sysroot().display());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
early_error("no input filename given");
|
early_error("no input filename given");
|
||||||
}
|
}
|
||||||
1u => {
|
1u => {
|
||||||
|
@ -133,13 +132,14 @@ fn run_compiler(args: &[String]) {
|
||||||
|
|
||||||
let sess = build_session(sopts, input_file_path, descriptions);
|
let sess = build_session(sopts, input_file_path, descriptions);
|
||||||
let cfg = config::build_configuration(&sess);
|
let cfg = config::build_configuration(&sess);
|
||||||
let odir = matches.opt_str("out-dir").map(|o| Path::new(o));
|
if print_crate_info(&sess, Some(&input), &odir, &ofile) {
|
||||||
let ofile = matches.opt_str("o").map(|o| Path::new(o));
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let pretty = matches.opt_default("pretty", "normal").map(|a| {
|
let pretty = matches.opt_default("pretty", "normal").map(|a| {
|
||||||
pretty::parse_pretty(&sess, a.as_slice())
|
pretty::parse_pretty(&sess, a.as_slice())
|
||||||
});
|
});
|
||||||
match pretty {
|
match pretty.into_iter().next() {
|
||||||
Some((ppm, opt_uii)) => {
|
Some((ppm, opt_uii)) => {
|
||||||
pretty::pretty_print_input(sess, cfg, &input, ppm, opt_uii, ofile);
|
pretty::pretty_print_input(sess, cfg, &input, ppm, opt_uii, ofile);
|
||||||
return;
|
return;
|
||||||
|
@ -161,10 +161,6 @@ fn run_compiler(args: &[String]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if print_crate_info(&sess, &input, &odir, &ofile) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
driver::compile_input(sess, cfg, &input, &odir, &ofile, None);
|
driver::compile_input(sess, cfg, &input, &odir, &ofile, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,12 +181,8 @@ pub fn commit_date_str() -> Option<&'static str> {
|
||||||
|
|
||||||
/// Prints version information and returns None on success or an error
|
/// Prints version information and returns None on success or an error
|
||||||
/// message on panic.
|
/// message on panic.
|
||||||
pub fn version(binary: &str, matches: &getopts::Matches) -> Option<String> {
|
pub fn version(binary: &str, matches: &getopts::Matches) {
|
||||||
let verbose = match matches.opt_str("version").as_ref().map(|s| s.as_slice()) {
|
let verbose = matches.opt_present("verbose");
|
||||||
None => false,
|
|
||||||
Some("verbose") => true,
|
|
||||||
Some(s) => return Some(format!("Unrecognized argument: {}", s))
|
|
||||||
};
|
|
||||||
|
|
||||||
println!("{} {}", binary, option_env!("CFG_VERSION").unwrap_or("unknown version"));
|
println!("{} {}", binary, option_env!("CFG_VERSION").unwrap_or("unknown version"));
|
||||||
if verbose {
|
if verbose {
|
||||||
|
@ -201,18 +193,27 @@ pub fn version(binary: &str, matches: &getopts::Matches) -> Option<String> {
|
||||||
println!("host: {}", config::host_triple());
|
println!("host: {}", config::host_triple());
|
||||||
println!("release: {}", unw(release_str()));
|
println!("release: {}", unw(release_str()));
|
||||||
}
|
}
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage() {
|
fn usage(verbose: bool) {
|
||||||
|
let groups = if verbose {
|
||||||
|
config::optgroups()
|
||||||
|
} else {
|
||||||
|
config::short_optgroups()
|
||||||
|
};
|
||||||
let message = format!("Usage: rustc [OPTIONS] INPUT");
|
let message = format!("Usage: rustc [OPTIONS] INPUT");
|
||||||
|
let extra_help = if verbose {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
"\n --help -v Print the full set of options rustc accepts"
|
||||||
|
};
|
||||||
println!("{}\n\
|
println!("{}\n\
|
||||||
Additional help:
|
Additional help:
|
||||||
-C help Print codegen options
|
-C help Print codegen options
|
||||||
-W help Print 'lint' options and default settings
|
-W help Print 'lint' options and default settings
|
||||||
-Z help Print internal options for debugging rustc\n",
|
-Z help Print internal options for debugging rustc{}\n",
|
||||||
getopts::usage(message.as_slice(),
|
getopts::usage(message.as_slice(), groups.as_slice()),
|
||||||
config::optgroups().as_slice()));
|
extra_help);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn describe_lints(lint_store: &lint::LintStore, loaded_plugins: bool) {
|
fn describe_lints(lint_store: &lint::LintStore, loaded_plugins: bool) {
|
||||||
|
@ -360,7 +361,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
|
||||||
let _binary = args.remove(0).unwrap();
|
let _binary = args.remove(0).unwrap();
|
||||||
|
|
||||||
if args.is_empty() {
|
if args.is_empty() {
|
||||||
usage();
|
usage(false);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +374,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.opt_present("h") || matches.opt_present("help") {
|
if matches.opt_present("h") || matches.opt_present("help") {
|
||||||
usage();
|
usage(matches.opt_present("verbose"));
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,49 +398,55 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.opt_present("version") {
|
if matches.opt_present("version") {
|
||||||
match version("rustc", &matches) {
|
version("rustc", &matches);
|
||||||
Some(err) => early_error(err.as_slice()),
|
return None;
|
||||||
None => return None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(matches)
|
Some(matches)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_crate_info(sess: &Session,
|
fn print_crate_info(sess: &Session,
|
||||||
input: &Input,
|
input: Option<&Input>,
|
||||||
odir: &Option<Path>,
|
odir: &Option<Path>,
|
||||||
ofile: &Option<Path>)
|
ofile: &Option<Path>)
|
||||||
-> bool {
|
-> bool {
|
||||||
let (crate_name, crate_file_name) = sess.opts.print_metas;
|
if sess.opts.prints.len() == 0 { return false }
|
||||||
// these nasty nested conditions are to avoid doing extra work
|
|
||||||
if crate_name || crate_file_name {
|
|
||||||
let attrs = parse_crate_attrs(sess, input);
|
|
||||||
let t_outputs = driver::build_output_filenames(input,
|
|
||||||
odir,
|
|
||||||
ofile,
|
|
||||||
attrs.as_slice(),
|
|
||||||
sess);
|
|
||||||
let id = link::find_crate_name(Some(sess), attrs.as_slice(), input);
|
|
||||||
|
|
||||||
if crate_name {
|
let attrs = input.map(|input| parse_crate_attrs(sess, input));
|
||||||
println!("{}", id);
|
for req in sess.opts.prints.iter() {
|
||||||
}
|
match *req {
|
||||||
if crate_file_name {
|
PrintRequest::Sysroot => println!("{}", sess.sysroot().display()),
|
||||||
let crate_types = driver::collect_crate_types(sess, attrs.as_slice());
|
PrintRequest::FileNames |
|
||||||
let metadata = driver::collect_crate_metadata(sess, attrs.as_slice());
|
PrintRequest::CrateName => {
|
||||||
*sess.crate_metadata.borrow_mut() = metadata;
|
let input = match input {
|
||||||
for &style in crate_types.iter() {
|
Some(input) => input,
|
||||||
let fname = link::filename_for_input(sess, style, id.as_slice(),
|
None => early_error("no input file provided"),
|
||||||
&t_outputs.with_extension(""));
|
};
|
||||||
println!("{}", fname.filename_display());
|
let attrs = attrs.as_ref().unwrap().as_slice();
|
||||||
|
let t_outputs = driver::build_output_filenames(input,
|
||||||
|
odir,
|
||||||
|
ofile,
|
||||||
|
attrs,
|
||||||
|
sess);
|
||||||
|
let id = link::find_crate_name(Some(sess), attrs.as_slice(),
|
||||||
|
input);
|
||||||
|
if *req == PrintRequest::CrateName {
|
||||||
|
println!("{}", id);
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
let crate_types = driver::collect_crate_types(sess, attrs);
|
||||||
|
let metadata = driver::collect_crate_metadata(sess, attrs);
|
||||||
|
*sess.crate_metadata.borrow_mut() = metadata;
|
||||||
|
for &style in crate_types.iter() {
|
||||||
|
let fname = link::filename_for_input(sess, style,
|
||||||
|
id.as_slice(),
|
||||||
|
&t_outputs.with_extension(""));
|
||||||
|
println!("{}", fname.filename_display());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_crate_attrs(sess: &Session, input: &Input) ->
|
fn parse_crate_attrs(sess: &Session, input: &Input) ->
|
||||||
|
|
|
@ -607,6 +607,7 @@ pub fn run_passes(sess: &Session,
|
||||||
modules_config.emit_obj = true;
|
modules_config.emit_obj = true;
|
||||||
metadata_config.emit_obj = true;
|
metadata_config.emit_obj = true;
|
||||||
},
|
},
|
||||||
|
config::OutputTypeDepInfo => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,6 +780,7 @@ pub fn run_passes(sess: &Session,
|
||||||
link_obj(&crate_output.temp_path(config::OutputTypeObject));
|
link_obj(&crate_output.temp_path(config::OutputTypeObject));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
config::OutputTypeDepInfo => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let user_wants_bitcode = user_wants_bitcode;
|
let user_wants_bitcode = user_wants_bitcode;
|
||||||
|
|
|
@ -169,13 +169,8 @@ pub fn main_args(args: &[String]) -> int {
|
||||||
usage(args[0].as_slice());
|
usage(args[0].as_slice());
|
||||||
return 0;
|
return 0;
|
||||||
} else if matches.opt_present("version") {
|
} else if matches.opt_present("version") {
|
||||||
match rustc_driver::version("rustdoc", &matches) {
|
rustc_driver::version("rustdoc", &matches);
|
||||||
Some(err) => {
|
return 0;
|
||||||
println!("{}", err);
|
|
||||||
return 1
|
|
||||||
},
|
|
||||||
None => return 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.opt_strs("passes") == ["list"] {
|
if matches.opt_strs("passes") == ["list"] {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
LIB := $(shell $(RUSTC) --crate-file-name --crate-type=lib lib.rs)
|
LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs)
|
||||||
|
|
||||||
$(TMPDIR)/$(LIB):
|
$(TMPDIR)/$(LIB):
|
||||||
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
|
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
LIB := $(shell $(RUSTC) --crate-file-name --crate-type=lib lib.rs)
|
LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs)
|
||||||
|
|
||||||
$(TMPDIR)/$(LIB):
|
$(TMPDIR)/$(LIB):
|
||||||
$(RUSTC) --dep-info --crate-type=lib lib.rs
|
$(RUSTC) --emit dep-info,link --crate-type=lib lib.rs
|
||||||
touch $(TMPDIR)/done
|
touch $(TMPDIR)/done
|
||||||
|
|
||||||
-include $(TMPDIR)/foo.d
|
-include $(TMPDIR)/foo.d
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
# used in the inner functions should each appear only once in the generated IR.
|
# used in the inner functions should each appear only once in the generated IR.
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs --emit=ir
|
$(RUSTC) foo.rs --emit=llvm-ir
|
||||||
[ "$$(grep -c 8675309 "$(TMPDIR)/foo.ll")" -eq "1" ]
|
[ "$$(grep -c 8675309 "$(TMPDIR)/foo.ll")" -eq "1" ]
|
||||||
[ "$$(grep -c 11235813 "$(TMPDIR)/foo.ll")" -eq "1" ]
|
[ "$$(grep -c 11235813 "$(TMPDIR)/foo.ll")" -eq "1" ]
|
||||||
|
|
|
@ -4,7 +4,7 @@ ifdef IS_WINDOWS
|
||||||
all:
|
all:
|
||||||
else
|
else
|
||||||
|
|
||||||
NAME := $(shell $(RUSTC) --crate-file-name foo.rs)
|
NAME := $(shell $(RUSTC) --print file-names foo.rs)
|
||||||
|
|
||||||
all:
|
all:
|
||||||
mkdir -p $(TMPDIR)/outdir
|
mkdir -p $(TMPDIR)/outdir
|
||||||
|
|
|
@ -12,7 +12,7 @@ all:
|
||||||
rm $(TMPDIR)/$(call BIN,bar)
|
rm $(TMPDIR)/$(call BIN,bar)
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
$(RUSTC) foo.rs --emit=asm,ir,bc,obj,link
|
$(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link
|
||||||
rm $(TMPDIR)/bar.ll
|
rm $(TMPDIR)/bar.ll
|
||||||
rm $(TMPDIR)/bar.bc
|
rm $(TMPDIR)/bar.bc
|
||||||
rm $(TMPDIR)/bar.s
|
rm $(TMPDIR)/bar.s
|
||||||
|
@ -24,11 +24,11 @@ all:
|
||||||
rm $(TMPDIR)/foo
|
rm $(TMPDIR)/foo
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
$(RUSTC) foo.rs --emit=bc -o $(TMPDIR)/foo
|
$(RUSTC) foo.rs --emit=llvm-bc -o $(TMPDIR)/foo
|
||||||
rm $(TMPDIR)/foo
|
rm $(TMPDIR)/foo
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
$(RUSTC) foo.rs --emit=ir -o $(TMPDIR)/foo
|
$(RUSTC) foo.rs --emit=llvm-ir -o $(TMPDIR)/foo
|
||||||
rm $(TMPDIR)/foo
|
rm $(TMPDIR)/foo
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ all:
|
||||||
rm $(TMPDIR)/$(call BIN,foo)
|
rm $(TMPDIR)/$(call BIN,foo)
|
||||||
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
[ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
|
||||||
|
|
||||||
$(RUSTC) foo.rs --emit=asm,ir,bc,obj,link --crate-type=staticlib
|
$(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link --crate-type=staticlib
|
||||||
rm $(TMPDIR)/bar.ll
|
rm $(TMPDIR)/bar.ll
|
||||||
rm $(TMPDIR)/bar.s
|
rm $(TMPDIR)/bar.s
|
||||||
rm $(TMPDIR)/bar.o
|
rm $(TMPDIR)/bar.o
|
||||||
|
@ -65,7 +65,7 @@ all:
|
||||||
# Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later
|
# Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later
|
||||||
# comparison.
|
# comparison.
|
||||||
|
|
||||||
$(RUSTC) foo.rs --emit=bc,link --crate-type=rlib
|
$(RUSTC) foo.rs --emit=llvm-bc,link --crate-type=rlib
|
||||||
cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
|
cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
|
||||||
rm $(TMPDIR)/bar.bc
|
rm $(TMPDIR)/bar.bc
|
||||||
rm $(TMPDIR)/foo.bc
|
rm $(TMPDIR)/foo.bc
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) cci_lib.rs
|
$(RUSTC) cci_lib.rs
|
||||||
$(RUSTC) foo.rs --emit=ir -C codegen-units=3
|
$(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ .*cci_fn)" -eq "2" ]
|
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ .*cci_fn)" -eq "2" ]
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# function should be defined in only one compilation unit.
|
# function should be defined in only one compilation unit.
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs --emit=ir -C codegen-units=3
|
$(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ i32\ .*inlined)" -eq "1" ]
|
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ i32\ .*inlined)" -eq "1" ]
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ available_externally\ i32\ .*inlined)" -eq "2" ]
|
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ available_externally\ i32\ .*inlined)" -eq "2" ]
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ i32\ .*normal)" -eq "1" ]
|
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ i32\ .*normal)" -eq "1" ]
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
# wind up in three different compilation units.
|
# wind up in three different compilation units.
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) foo.rs --emit=ir -C codegen-units=3
|
$(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3
|
||||||
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ .*magic_fn)" -eq "3" ]
|
[ "$$(cat "$(TMPDIR)"/foo.?.ll | grep -c define\ .*magic_fn)" -eq "3" ]
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
-include ../tools.mk
|
-include ../tools.mk
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(RUSTC) -v
|
$(RUSTC) -V
|
||||||
$(RUSTC) -v verbose
|
$(RUSTC) -vV
|
||||||
$(RUSTC) -v bad_arg && exit 1 || exit 0
|
$(RUSTC) --version --verbose
|
||||||
$(RUSTC) --version verbose
|
|
||||||
$(RUSTC) --version bad_arg && exit 1 || exit 0
|
|
||||||
|
|
|
@ -5,6 +5,6 @@ all:
|
||||||
$(RUSTC) main.rs
|
$(RUSTC) main.rs
|
||||||
$(call RUN,main)
|
$(call RUN,main)
|
||||||
# ... and the loads/stores must not be optimized out.
|
# ... and the loads/stores must not be optimized out.
|
||||||
$(RUSTC) main.rs --emit=ir
|
$(RUSTC) main.rs --emit=llvm-ir
|
||||||
grep "load volatile" $(TMPDIR)/main.ll
|
grep "load volatile" $(TMPDIR)/main.ll
|
||||||
grep "store volatile" $(TMPDIR)/main.ll
|
grep "store volatile" $(TMPDIR)/main.ll
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue