Skip to content

Commit 082b8e6

Browse files
committed
---
yaml --- r: 209343 b: refs/heads/auto c: bc7c62d h: refs/heads/master i: 209341: 982fde7 209339: 5f8a852 209335: 3a5461c 209327: 94dbf74 209311: 4763afd 209279: 8e43be9 v: v3
1 parent 261b10b commit 082b8e6

File tree

170 files changed

+2760
-1359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+2760
-1359
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: efcc1d1bcb48122ae1c522b0f4a996188791f38a
13+
refs/heads/auto: bc7c62de6d2b9fbd6cc024a036494107e8c19f6f
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/mk/cfg/aarch64-linux-android.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# aarch64-linux-android configuration
22
# CROSS_PREFIX_aarch64-linux-android-
33
CC_aarch64-linux-android=$(CFG_ANDROID_CROSS_PATH)/bin/aarch64-linux-android-gcc
4-
LINK_aarch64-linux-android=$(CFG_ANDROID_CROSS_PATH)/bin/aarch64-linux-android-gcc
54
CXX_aarch64-linux-android=$(CFG_ANDROID_CROSS_PATH)/bin/aarch64-linux-android-g++
65
CPP_aarch64-linux-android=$(CFG_ANDROID_CROSS_PATH)/bin/aarch64-linux-android-gcc -E
76
AR_aarch64-linux-android=$(CFG_ANDROID_CROSS_PATH)/bin/aarch64-linux-android-ar

branches/auto/mk/cfg/aarch64-unknown-linux-gnu.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# aarch64-unknown-linux-gnu configuration
22
CROSS_PREFIX_aarch64-unknown-linux-gnu=aarch64-linux-gnu-
33
CC_aarch64-unknown-linux-gnu=gcc
4-
LINK_aarch64-unknown-linux-gnu=gcc
54
CXX_aarch64-unknown-linux-gnu=g++
65
CPP_aarch64-unknown-linux-gnu=gcc -E
76
AR_aarch64-unknown-linux-gnu=ar

branches/auto/mk/cfg/arm-linux-androideabi.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# arm-linux-androideabi configuration
2-
LINK_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-gcc
32
CC_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-gcc
43
CXX_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-g++
54
CPP_arm-linux-androideabi=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-gcc -E

branches/auto/mk/cfg/i686-apple-darwin.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# i686-apple-darwin configuration
22
CC_i686-apple-darwin=$(CC)
3-
LINK_i686-apple-darwin=cc
43
CXX_i686-apple-darwin=$(CXX)
54
CPP_i686-apple-darwin=$(CPP)
65
AR_i686-apple-darwin=$(AR)

branches/auto/mk/cfg/i686-unknown-linux-gnu.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# i686-unknown-linux-gnu configuration
22
CC_i686-unknown-linux-gnu=$(CC)
3-
LINK_i686-unknown-linux-gnu=cc
43
CXX_i686-unknown-linux-gnu=$(CXX)
54
CPP_i686-unknown-linux-gnu=$(CPP)
65
AR_i686-unknown-linux-gnu=$(AR)

branches/auto/mk/cfg/x86_64-apple-darwin.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# x86_64-apple-darwin configuration
22
CC_x86_64-apple-darwin=$(CC)
3-
LINK_x86_64-apple-darwin=cc
43
CXX_x86_64-apple-darwin=$(CXX)
54
CPP_x86_64-apple-darwin=$(CPP)
65
AR_x86_64-apple-darwin=$(AR)

branches/auto/mk/cfg/x86_64-pc-windows-gnu.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# x86_64-pc-windows-gnu configuration
22
CROSS_PREFIX_x86_64-pc-windows-gnu=x86_64-w64-mingw32-
33
CC_x86_64-pc-windows-gnu=gcc
4-
LINK_x86_64-pc-windows-gnu=gcc
54
CXX_x86_64-pc-windows-gnu=g++
65
CPP_x86_64-pc-windows-gnu=gcc -E
76
AR_x86_64-pc-windows-gnu=ar

branches/auto/mk/cfg/x86_64-unknown-linux-gnu.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# x86_64-unknown-linux-gnu configuration
22
CC_x86_64-unknown-linux-gnu=$(CC)
3-
LINK_x86_64-unknown-linux-gnu=cc
43
CXX_x86_64-unknown-linux-gnu=$(CXX)
54
CPP_x86_64-unknown-linux-gnu=$(CPP)
65
AR_x86_64-unknown-linux-gnu=$(AR)

branches/auto/mk/platform.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ endef
120120
$(foreach target,$(CFG_TARGET), \
121121
$(eval $(call ADD_INSTALLED_OBJECTS,$(target))))
122122

123+
define DEFINE_LINKER
124+
ifndef LINK_$(1)
125+
LINK_$(1) := $$(CC_$(1))
126+
endif
127+
endef
128+
129+
$(foreach target,$(CFG_TARGET), \
130+
$(eval $(call DEFINE_LINKER,$(target))))
131+
123132
# The -Qunused-arguments sidesteps spurious warnings from clang
124133
define FILTER_FLAGS
125134
ifeq ($$(CFG_USING_CLANG),1)

branches/auto/mk/tests.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ ifeq ($(CFG_LLDB),)
581581
CTEST_DISABLE_debuginfo-lldb = "no lldb found"
582582
endif
583583

584+
ifeq ($(CFG_CLANG),)
585+
CTEST_DISABLE_codegen = "no clang found"
586+
endif
587+
584588
ifneq ($(CFG_OSTYPE),apple-darwin)
585589
CTEST_DISABLE_debuginfo-lldb = "lldb tests are only run on darwin"
586590
endif
@@ -641,6 +645,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
641645
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
642646
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
643647
--rustdoc-path $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
648+
--clang-path $(if $(CFG_CLANG),$(CFG_CLANG),clang) \
644649
--llvm-bin-path $(CFG_LLVM_INST_DIR_$(CFG_BUILD))/bin \
645650
--aux-base $$(S)src/test/auxiliary/ \
646651
--stage-id stage$(1)-$(2) \

branches/auto/src/compiletest/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ pub struct Config {
8080
// The python executable
8181
pub python: String,
8282

83+
// The clang executable
84+
pub clang_path: Option<PathBuf>,
85+
8386
// The llvm binaries path
8487
pub llvm_bin_path: Option<PathBuf>,
8588

branches/auto/src/compiletest/compiletest.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use std::fs;
3333
use std::path::{Path, PathBuf};
3434
use getopts::{optopt, optflag, reqopt};
3535
use common::Config;
36-
use common::{Pretty, DebugInfoGdb, DebugInfoLldb};
36+
use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Codegen};
3737
use util::logv;
3838

3939
pub mod procsrv;
@@ -63,6 +63,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
6363
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
6464
reqopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH"),
6565
reqopt("", "python", "path to python to use for doc tests", "PATH"),
66+
optopt("", "clang-path", "path to executable for codegen tests", "PATH"),
6667
optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM"),
6768
optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind"),
6869
optopt("", "llvm-bin-path", "path to directory holding llvm binaries", "DIR"),
@@ -132,6 +133,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
132133
rustc_path: opt_path(matches, "rustc-path"),
133134
rustdoc_path: opt_path(matches, "rustdoc-path"),
134135
python: matches.opt_str("python").unwrap(),
136+
clang_path: matches.opt_str("clang-path").map(|s| PathBuf::from(&s)),
135137
valgrind_path: matches.opt_str("valgrind-path"),
136138
force_valgrind: matches.opt_present("force-valgrind"),
137139
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| PathBuf::from(&s)),
@@ -282,7 +284,13 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
282284
let file = file.unwrap().path();
283285
debug!("inspecting file {:?}", file.display());
284286
if is_test(config, &file) {
285-
tests.push(make_test(config, &file))
287+
let t = make_test(config, &file, || {
288+
match config.mode {
289+
Codegen => make_metrics_test_closure(config, &file),
290+
_ => make_test_closure(config, &file)
291+
}
292+
});
293+
tests.push(t)
286294
}
287295
}
288296
tests
@@ -315,15 +323,16 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
315323
return valid;
316324
}
317325

318-
pub fn make_test(config: &Config, testfile: &Path) -> test::TestDescAndFn
326+
pub fn make_test<F>(config: &Config, testfile: &Path, f: F) -> test::TestDescAndFn where
327+
F: FnOnce() -> test::TestFn,
319328
{
320329
test::TestDescAndFn {
321330
desc: test::TestDesc {
322331
name: make_test_name(config, testfile),
323332
ignore: header::is_test_ignored(config, testfile),
324333
should_panic: test::ShouldPanic::No,
325334
},
326-
testfn: make_test_closure(config, &testfile),
335+
testfn: f(),
327336
}
328337
}
329338

@@ -348,6 +357,14 @@ pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
348357
}))
349358
}
350359

360+
pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
361+
let config = (*config).clone();
362+
let testfile = testfile.to_path_buf();
363+
test::DynMetricFn(box move |mm: &mut test::MetricMap| {
364+
runtest::run_metrics(config, &testfile, mm)
365+
})
366+
}
367+
351368
fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
352369
match full_version_line {
353370
Some(ref full_version_line)

branches/auto/src/compiletest/runtest.rs

Lines changed: 118 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ use std::iter::repeat;
2828
use std::net::TcpStream;
2929
use std::path::{Path, PathBuf};
3030
use std::process::{Command, Output, ExitStatus};
31+
use std::str;
32+
use test::MetricMap;
3133

3234
pub fn run(config: Config, testfile: &Path) {
3335
match &*config.target {
@@ -41,6 +43,11 @@ pub fn run(config: Config, testfile: &Path) {
4143
_=> { }
4244
}
4345

46+
let mut _mm = MetricMap::new();
47+
run_metrics(config, testfile, &mut _mm);
48+
}
49+
50+
pub fn run_metrics(config: Config, testfile: &Path, mm: &mut MetricMap) {
4451
if config.verbose {
4552
// We're going to be dumping a lot of info. Start on a new line.
4653
print!("\n\n");
@@ -57,7 +64,7 @@ pub fn run(config: Config, testfile: &Path) {
5764
Pretty => run_pretty_test(&config, &props, &testfile),
5865
DebugInfoGdb => run_debuginfo_gdb_test(&config, &props, &testfile),
5966
DebugInfoLldb => run_debuginfo_lldb_test(&config, &props, &testfile),
60-
Codegen => run_codegen_test(&config, &props, &testfile),
67+
Codegen => run_codegen_test(&config, &props, &testfile, mm),
6168
Rustdoc => run_rustdoc_test(&config, &props, &testfile),
6269
}
6370
}
@@ -1678,15 +1685,26 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
16781685
}
16791686
}
16801687

1681-
// codegen tests (using FileCheck)
1688+
// codegen tests (vs. clang)
1689+
1690+
fn append_suffix_to_stem(p: &Path, suffix: &str) -> PathBuf {
1691+
if suffix.is_empty() {
1692+
p.to_path_buf()
1693+
} else {
1694+
let mut stem = p.file_stem().unwrap().to_os_string();
1695+
stem.push("-");
1696+
stem.push(suffix);
1697+
p.with_file_name(&stem)
1698+
}
1699+
}
16821700

1683-
fn compile_test_and_save_ir(config: &Config, props: &TestProps,
1701+
fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
16841702
testfile: &Path) -> ProcRes {
16851703
let aux_dir = aux_output_dir_name(config, testfile);
16861704
// FIXME (#9639): This needs to handle non-utf8 paths
16871705
let mut link_args = vec!("-L".to_string(),
16881706
aux_dir.to_str().unwrap().to_string());
1689-
let llvm_args = vec!("--emit=llvm-ir".to_string(),
1707+
let llvm_args = vec!("--emit=llvm-bc,obj".to_string(),
16901708
"--crate-type=lib".to_string());
16911709
link_args.extend(llvm_args.into_iter());
16921710
let args = make_compile_args(config,
@@ -1699,34 +1717,121 @@ fn compile_test_and_save_ir(config: &Config, props: &TestProps,
16991717
compose_and_run_compiler(config, props, testfile, args, None)
17001718
}
17011719

1702-
fn check_ir_with_filecheck(config: &Config, testfile: &Path) -> ProcRes {
1703-
let irfile = output_base_name(config, testfile).with_extension("ll");
1704-
let prog = config.llvm_bin_path.as_ref().unwrap().join("FileCheck");
1720+
fn compile_cc_with_clang_and_save_bitcode(config: &Config, _props: &TestProps,
1721+
testfile: &Path) -> ProcRes {
1722+
let bitcodefile = output_base_name(config, testfile).with_extension("bc");
1723+
let bitcodefile = append_suffix_to_stem(&bitcodefile, "clang");
1724+
let testcc = testfile.with_extension("cc");
1725+
let proc_args = ProcArgs {
1726+
// FIXME (#9639): This needs to handle non-utf8 paths
1727+
prog: config.clang_path.as_ref().unwrap().to_str().unwrap().to_string(),
1728+
args: vec!("-c".to_string(),
1729+
"-emit-llvm".to_string(),
1730+
"-o".to_string(),
1731+
bitcodefile.to_str().unwrap().to_string(),
1732+
testcc.to_str().unwrap().to_string())
1733+
};
1734+
compose_and_run(config, testfile, proc_args, Vec::new(), "", None, None)
1735+
}
1736+
1737+
fn extract_function_from_bitcode(config: &Config, _props: &TestProps,
1738+
fname: &str, testfile: &Path,
1739+
suffix: &str) -> ProcRes {
1740+
let bitcodefile = output_base_name(config, testfile).with_extension("bc");
1741+
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
1742+
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
1743+
let prog = config.llvm_bin_path.as_ref().unwrap().join("llvm-extract");
17051744
let proc_args = ProcArgs {
17061745
// FIXME (#9639): This needs to handle non-utf8 paths
17071746
prog: prog.to_str().unwrap().to_string(),
1708-
args: vec!(format!("-input-file={}", irfile.to_str().unwrap()),
1709-
testfile.to_str().unwrap().to_string())
1747+
args: vec!(format!("-func={}", fname),
1748+
format!("-o={}", extracted_bc.to_str().unwrap()),
1749+
bitcodefile.to_str().unwrap().to_string())
17101750
};
17111751
compose_and_run(config, testfile, proc_args, Vec::new(), "", None, None)
17121752
}
17131753

1714-
fn run_codegen_test(config: &Config, props: &TestProps, testfile: &Path) {
1754+
fn disassemble_extract(config: &Config, _props: &TestProps,
1755+
testfile: &Path, suffix: &str) -> ProcRes {
1756+
let bitcodefile = output_base_name(config, testfile).with_extension("bc");
1757+
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
1758+
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
1759+
let extracted_ll = extracted_bc.with_extension("ll");
1760+
let prog = config.llvm_bin_path.as_ref().unwrap().join("llvm-dis");
1761+
let proc_args = ProcArgs {
1762+
// FIXME (#9639): This needs to handle non-utf8 paths
1763+
prog: prog.to_str().unwrap().to_string(),
1764+
args: vec!(format!("-o={}", extracted_ll.to_str().unwrap()),
1765+
extracted_bc.to_str().unwrap().to_string())
1766+
};
1767+
compose_and_run(config, testfile, proc_args, Vec::new(), "", None, None)
1768+
}
1769+
1770+
1771+
fn count_extracted_lines(p: &Path) -> usize {
1772+
let mut x = Vec::new();
1773+
File::open(&p.with_extension("ll")).unwrap().read_to_end(&mut x).unwrap();
1774+
let x = str::from_utf8(&x).unwrap();
1775+
x.lines().count()
1776+
}
1777+
1778+
1779+
fn run_codegen_test(config: &Config, props: &TestProps,
1780+
testfile: &Path, mm: &mut MetricMap) {
17151781

17161782
if config.llvm_bin_path.is_none() {
17171783
fatal("missing --llvm-bin-path");
17181784
}
17191785

1720-
let mut proc_res = compile_test_and_save_ir(config, props, testfile);
1786+
if config.clang_path.is_none() {
1787+
fatal("missing --clang-path");
1788+
}
1789+
1790+
let mut proc_res = compile_test_and_save_bitcode(config, props, testfile);
1791+
if !proc_res.status.success() {
1792+
fatal_proc_rec("compilation failed!", &proc_res);
1793+
}
1794+
1795+
proc_res = extract_function_from_bitcode(config, props, "test", testfile, "");
1796+
if !proc_res.status.success() {
1797+
fatal_proc_rec("extracting 'test' function failed",
1798+
&proc_res);
1799+
}
1800+
1801+
proc_res = disassemble_extract(config, props, testfile, "");
1802+
if !proc_res.status.success() {
1803+
fatal_proc_rec("disassembling extract failed", &proc_res);
1804+
}
1805+
1806+
1807+
let mut proc_res = compile_cc_with_clang_and_save_bitcode(config, props, testfile);
17211808
if !proc_res.status.success() {
17221809
fatal_proc_rec("compilation failed!", &proc_res);
17231810
}
17241811

1725-
proc_res = check_ir_with_filecheck(config, testfile);
1812+
proc_res = extract_function_from_bitcode(config, props, "test", testfile, "clang");
17261813
if !proc_res.status.success() {
1727-
fatal_proc_rec("verification with 'FileCheck' failed",
1814+
fatal_proc_rec("extracting 'test' function failed",
17281815
&proc_res);
17291816
}
1817+
1818+
proc_res = disassemble_extract(config, props, testfile, "clang");
1819+
if !proc_res.status.success() {
1820+
fatal_proc_rec("disassembling extract failed", &proc_res);
1821+
}
1822+
1823+
let base = output_base_name(config, testfile);
1824+
let base_extract = append_suffix_to_stem(&base, "extract");
1825+
1826+
let base_clang = append_suffix_to_stem(&base, "clang");
1827+
let base_clang_extract = append_suffix_to_stem(&base_clang, "extract");
1828+
1829+
let base_lines = count_extracted_lines(&base_extract);
1830+
let clang_lines = count_extracted_lines(&base_clang_extract);
1831+
1832+
mm.insert_metric("clang-codegen-ratio",
1833+
(base_lines as f64) / (clang_lines as f64),
1834+
0.001);
17301835
}
17311836

17321837
fn charset() -> &'static str {

branches/auto/src/doc/trpl/macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ There are additional rules regarding the next token after a metavariable:
478478

479479
* `expr` variables may only be followed by one of: `=> , ;`
480480
* `ty` and `path` variables may only be followed by one of: `=> , : = > as`
481-
* `pat` variables may only be followed by one of: `=> , = if in`
481+
* `pat` variables may only be followed by one of: `=> , =`
482482
* Other variables may be followed by any token.
483483

484484
These rules provide some flexibility for Rust’s syntax to evolve without

0 commit comments

Comments
 (0)