-
Notifications
You must be signed in to change notification settings - Fork 386
rustup to rustc 1.15.0-dev (ace092f56 2016-12-13) #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
69fa3eb
rustup to rustc 1.15.0-dev (ace092f56 2016-12-13) (always_encode_mir)
oli-obk 8b8c743
re-use `mir-opt` compiletest instead of rolling our own
oli-obk 9ec97ba
enable auxiliary builds
oli-obk 2420360
remove unused import
oli-obk fd0c21e
check that the null terminator is defined and not part of a pointer
oli-obk 0a79304
improve variable name
oli-obk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,15 @@ fn run_pass() { | |
compiletest::run_tests(&config); | ||
} | ||
|
||
fn miri_pass(path: &str, target: &str) { | ||
let mut config = compiletest::default_config(); | ||
config.mode = "mir-opt".parse().expect("Invalid mode"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mir-opt is not ideal
The clean solution would be to add a "compile-pass" test to compiletest But it saves us this giant mess below, which would just get bigger if we started to play with auxiliary builds. |
||
config.src_base = PathBuf::from(path); | ||
config.target = target.to_owned(); | ||
config.rustc_path = PathBuf::from("target/debug/miri"); | ||
compiletest::run_tests(&config); | ||
} | ||
|
||
fn for_all_targets<F: FnMut(String)>(sysroot: &str, mut f: F) { | ||
for target in std::fs::read_dir(format!("{}/lib/rustlib/", sysroot)).unwrap() { | ||
let target = target.unwrap(); | ||
|
@@ -57,65 +66,10 @@ fn compile_test() { | |
}; | ||
run_pass(); | ||
for_all_targets(&sysroot, |target| { | ||
let files = std::fs::read_dir("tests/run-pass").unwrap(); | ||
let files: Box<Iterator<Item=_>> = if let Ok(path) = std::env::var("MIRI_RUSTC_TEST") { | ||
Box::new(files.chain(std::fs::read_dir(path).unwrap())) | ||
} else { | ||
Box::new(files) | ||
}; | ||
let mut mir_not_found = 0; | ||
let mut crate_not_found = 0; | ||
let mut success = 0; | ||
let mut failed = 0; | ||
for file in files { | ||
let file = file.unwrap(); | ||
let path = file.path(); | ||
|
||
if !file.metadata().unwrap().is_file() || !path.to_str().unwrap().ends_with(".rs") { | ||
continue; | ||
} | ||
|
||
let stderr = std::io::stderr(); | ||
write!(stderr.lock(), "test [miri-pass] {} ... ", path.display()).unwrap(); | ||
let mut cmd = std::process::Command::new("target/debug/miri"); | ||
cmd.arg(path); | ||
cmd.arg(format!("--target={}", target)); | ||
let libs = Path::new(&sysroot).join("lib"); | ||
let sysroot = libs.join("rustlib").join(&target).join("lib"); | ||
let paths = std::env::join_paths(&[libs, sysroot]).unwrap(); | ||
cmd.env(compiletest::procsrv::dylib_env_var(), paths); | ||
|
||
match cmd.output() { | ||
Ok(ref output) if output.status.success() => { | ||
success += 1; | ||
writeln!(stderr.lock(), "ok").unwrap() | ||
}, | ||
Ok(output) => { | ||
let output_err = std::str::from_utf8(&output.stderr).unwrap(); | ||
if let Some(text) = output_err.splitn(2, "no mir for `").nth(1) { | ||
mir_not_found += 1; | ||
let end = text.find('`').unwrap(); | ||
writeln!(stderr.lock(), "NO MIR FOR `{}`", &text[..end]).unwrap(); | ||
} else if let Some(text) = output_err.splitn(2, "can't find crate for `").nth(1) { | ||
crate_not_found += 1; | ||
let end = text.find('`').unwrap(); | ||
writeln!(stderr.lock(), "CAN'T FIND CRATE FOR `{}`", &text[..end]).unwrap(); | ||
} else { | ||
failed += 1; | ||
writeln!(stderr.lock(), "FAILED with exit code {:?}", output.status.code()).unwrap(); | ||
writeln!(stderr.lock(), "stdout: \n {}", std::str::from_utf8(&output.stdout).unwrap()).unwrap(); | ||
writeln!(stderr.lock(), "stderr: \n {}", output_err).unwrap(); | ||
} | ||
} | ||
Err(e) => { | ||
writeln!(stderr.lock(), "FAILED: {}", e).unwrap(); | ||
panic!("failed to execute miri"); | ||
}, | ||
} | ||
miri_pass("tests/run-pass", &target); | ||
if let Ok(path) = std::env::var("MIRI_RUSTC_TEST") { | ||
miri_pass(&path, &target); | ||
} | ||
let stderr = std::io::stderr(); | ||
writeln!(stderr.lock(), "{} success, {} mir not found, {} crate not found, {} failed", success, mir_not_found, crate_not_found, failed).unwrap(); | ||
assert_eq!(failed, 0, "some tests failed"); | ||
}); | ||
compile_fail(&sysroot); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// aux-build:dep.rs | ||
|
||
extern crate dep; | ||
|
||
fn main() { | ||
dep::foo(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub fn foo() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for our current experimentation, but I guess we'll need a plan for stuff like this eventually. For the real CTFE that gets put into rustc, it would probably make more sense to have
cfg(const)
sections that avoid needing the libc calls.@eddyb Have you thought about this? Panicking, printing when panicking, and even
Vec
allocation all currently require us to hook libc calls, which might be considered too dirty...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
real ctfe can only evaluate
const fn
.Also we can't do any
cfg(const)
if we don't want to end up compilinglibstd
twice (once for the target and once for const eval).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to make panic allowed in real CTFE in some form, though, don't we? Otherwise we can't call anything that has any code path leading to panic.
It doesn't need to be literally
cfg()
, but something to tell CTFE what to do instead of going into low-level code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allowing panicking in
const fn
implies that whatever functionspanic!()
calls (transitively) all need to beconst fn
unless we cut it off somewhere with aconst fn
-specific feature to tell CTFE to do something differently from what the native code does.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, hooking libc calls is effectively just one version of "tell CTFE to do something differently", but we could perhaps do it in a more first-class, maintainable way if it was explicit in the code implementing panic.
But I'm still pretty unsure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest thing would be to create an unstable attribute that libstd can use to annotate functions that CTFE should not go into this function, but instead do some magic.