Turn on using LLVM threadsafely
This commit is contained in:
parent
1c48aac9aa
commit
5183a6cc6c
@ -2883,6 +2883,10 @@ pub fn trans_crate(sess: session::Session,
|
||||
reachable_map: @mut HashSet<ast::node_id>,
|
||||
maps: astencode::Maps)
|
||||
-> (ContextRef, ModuleRef, LinkMeta) {
|
||||
// Before we touch LLVM, make sure that multithreading is enabled.
|
||||
if unsafe { !llvm::LLVMRustStartMultithreading() } {
|
||||
sess.bug("couldn't enable multi-threaded LLVM");
|
||||
}
|
||||
|
||||
let mut symbol_hasher = hash::default_state();
|
||||
let link_meta = link::build_link_meta(sess, crate, output, &mut symbol_hasher);
|
||||
@ -2897,12 +2901,6 @@ pub fn trans_crate(sess: session::Session,
|
||||
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
|
||||
let llmod_id = link_meta.name.to_owned() + ".rc";
|
||||
|
||||
// FIXME(#6511): get LLVM building with --enable-threads so this
|
||||
// function can be called
|
||||
// if !llvm::LLVMRustStartMultithreading() {
|
||||
// sess.bug("couldn't enable multi-threaded LLVM");
|
||||
// }
|
||||
|
||||
let ccx = @mut CrateContext::new(sess,
|
||||
llmod_id,
|
||||
tcx,
|
||||
|
@ -528,6 +528,9 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: #7220 rusti on 32bit mac doesn't work.
|
||||
#[cfg(not(target_word_size="32"))]
|
||||
#[cfg(not(target_os="macos"))]
|
||||
fn run_program(prog: &str) {
|
||||
let mut r = repl();
|
||||
for prog.split_iter('\n').advance |cmd| {
|
||||
@ -536,54 +539,55 @@ mod tests {
|
||||
r = result.expect(fmt!("the command '%s' failed", cmd));
|
||||
}
|
||||
}
|
||||
#[cfg(target_word_size="32", target_os="macos")]
|
||||
fn run_program(_: &str) {}
|
||||
|
||||
#[test]
|
||||
// FIXME: #7220 rusti on 32bit mac doesn't work.
|
||||
#[cfg(not(target_word_size="32",
|
||||
target_os="macos"))]
|
||||
fn run_all() {
|
||||
// FIXME(#7071):
|
||||
// By default, unit tests are run in parallel. Rusti, on the other hand,
|
||||
// does not enjoy doing this. I suspect that it is because the LLVM
|
||||
// bindings are not thread-safe (when running parallel tests, some tests
|
||||
// were triggering assertions in LLVM (or segfaults). Hence, this
|
||||
// function exists to run everything serially (sadface).
|
||||
//
|
||||
// To get some interesting output, run with RUST_LOG=rusti::tests
|
||||
|
||||
debug!("hopefully this runs");
|
||||
fn super_basic() {
|
||||
run_program("");
|
||||
}
|
||||
|
||||
debug!("regression test for #5937");
|
||||
#[test]
|
||||
fn regression_5937() {
|
||||
run_program("use std::hashmap;");
|
||||
}
|
||||
|
||||
debug!("regression test for #5784");
|
||||
#[test]
|
||||
fn regression_5784() {
|
||||
run_program("let a = 3;");
|
||||
}
|
||||
|
||||
#[test] #[ignore]
|
||||
fn new_tasks() {
|
||||
// XXX: can't spawn new tasks because the JIT code is cleaned up
|
||||
// after the main function is done.
|
||||
// debug!("regression test for #5803");
|
||||
// run_program("
|
||||
// spawn( || println(\"Please don't segfault\") );
|
||||
// do spawn { println(\"Please?\"); }
|
||||
// ");
|
||||
run_program("
|
||||
spawn( || println(\"Please don't segfault\") );
|
||||
do spawn { println(\"Please?\"); }
|
||||
");
|
||||
}
|
||||
|
||||
debug!("inferred integers are usable");
|
||||
#[test]
|
||||
fn inferred_integers_usable() {
|
||||
run_program("let a = 2;\n()\n");
|
||||
run_program("
|
||||
let a = 3;
|
||||
let b = 4u;
|
||||
assert!((a as uint) + b == 7)
|
||||
");
|
||||
}
|
||||
|
||||
debug!("local variables can be shadowed");
|
||||
#[test]
|
||||
fn local_variables_allow_shadowing() {
|
||||
run_program("
|
||||
let a = 3;
|
||||
let a = 5;
|
||||
assert!(a == 5)
|
||||
");
|
||||
}
|
||||
|
||||
debug!("strings are usable");
|
||||
#[test]
|
||||
fn string_usable() {
|
||||
run_program("
|
||||
let a = ~\"\";
|
||||
let b = \"\";
|
||||
@ -591,8 +595,10 @@ mod tests {
|
||||
let d = a + b + c;
|
||||
assert!(d.len() == 0);
|
||||
");
|
||||
}
|
||||
|
||||
debug!("vectors are usable");
|
||||
#[test]
|
||||
fn vectors_usable() {
|
||||
run_program("
|
||||
let a = ~[1, 2, 3];
|
||||
let b = &[1, 2, 3];
|
||||
@ -601,15 +607,19 @@ mod tests {
|
||||
assert!(d.len() == 9);
|
||||
let e: &[int] = [];
|
||||
");
|
||||
}
|
||||
|
||||
debug!("structs are usable");
|
||||
#[test]
|
||||
fn structs_usable() {
|
||||
run_program("
|
||||
struct A{ a: int }
|
||||
let b = A{ a: 3 };
|
||||
assert!(b.a == 3)
|
||||
");
|
||||
}
|
||||
|
||||
debug!("mutable variables");
|
||||
#[test]
|
||||
fn mutable_variables_work() {
|
||||
run_program("
|
||||
let mut a = 3;
|
||||
a = 5;
|
||||
@ -618,29 +628,37 @@ mod tests {
|
||||
assert!(b.contains(&5))
|
||||
assert!(b.len() == 1)
|
||||
");
|
||||
}
|
||||
|
||||
debug!("functions are cached");
|
||||
#[test]
|
||||
fn functions_saved() {
|
||||
run_program("
|
||||
fn fib(x: int) -> int { if x < 2 {x} else { fib(x - 1) + fib(x - 2) } }
|
||||
let a = fib(3);
|
||||
let a = a + fib(4);
|
||||
assert!(a == 5)
|
||||
");
|
||||
}
|
||||
|
||||
debug!("modules are cached");
|
||||
#[test]
|
||||
fn modules_saved() {
|
||||
run_program("
|
||||
mod b { pub fn foo() -> uint { 3 } }
|
||||
assert!(b::foo() == 3)
|
||||
");
|
||||
}
|
||||
|
||||
debug!("multiple function definitions are allowed");
|
||||
#[test]
|
||||
fn multiple_functions() {
|
||||
run_program("
|
||||
fn f() {}
|
||||
fn f() {}
|
||||
f()
|
||||
");
|
||||
}
|
||||
|
||||
debug!("multiple item definitions are allowed");
|
||||
#[test]
|
||||
fn multiple_items_same_name() {
|
||||
run_program("
|
||||
fn f() {}
|
||||
mod f {}
|
||||
@ -657,9 +675,6 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
// FIXME: #7220 rusti on 32bit mac doesn't work.
|
||||
#[cfg(not(target_word_size="32",
|
||||
target_os="macos"))]
|
||||
fn exit_quits() {
|
||||
let mut r = repl();
|
||||
assert!(r.running);
|
||||
|
@ -307,18 +307,10 @@ fn frob_source_file(workspace: &Path, pkgid: &PkgId) {
|
||||
}
|
||||
}
|
||||
|
||||
#[test] #[ignore] //FIXME(#7249)
|
||||
fn test_all() {
|
||||
// FIXME(#7071): these tests use rustc, so they can't be run in parallel
|
||||
// until this issue is resolved
|
||||
test_make_dir_rwx();
|
||||
test_install_valid();
|
||||
test_install_invalid();
|
||||
test_install_url();
|
||||
test_package_ids_must_be_relative_path_like();
|
||||
test_package_version();
|
||||
}
|
||||
// FIXME(#7249): these tests fail on multi-platform builds, so for now they're
|
||||
// only run one x86
|
||||
|
||||
#[test] #[ignore(cfg(target_arch = "x86"))]
|
||||
fn test_make_dir_rwx() {
|
||||
let temp = &os::tmpdir();
|
||||
let dir = temp.push("quux");
|
||||
@ -331,6 +323,7 @@ fn test_make_dir_rwx() {
|
||||
assert!(os::remove_dir_recursive(&dir));
|
||||
}
|
||||
|
||||
#[test] #[ignore(cfg(target_arch = "x86"))]
|
||||
fn test_install_valid() {
|
||||
use path_util::installed_library_in_workspace;
|
||||
|
||||
@ -360,6 +353,7 @@ fn test_install_valid() {
|
||||
assert!(!os::path_exists(&bench));
|
||||
}
|
||||
|
||||
#[test] #[ignore(cfg(target_arch = "x86"))]
|
||||
fn test_install_invalid() {
|
||||
use conditions::nonexistent_package::cond;
|
||||
use cond1 = conditions::missing_pkg_files::cond;
|
||||
@ -382,6 +376,7 @@ fn test_install_invalid() {
|
||||
assert!(error_occurred && error1_occurred);
|
||||
}
|
||||
|
||||
#[test] #[ignore(cfg(target_arch = "x86"))]
|
||||
fn test_install_url() {
|
||||
let workspace = mkdtemp(&os::tmpdir(), "test").expect("couldn't create temp dir");
|
||||
let sysroot = test_sysroot();
|
||||
@ -417,6 +412,7 @@ fn test_install_url() {
|
||||
assert!(!os::path_exists(&bench));
|
||||
}
|
||||
|
||||
#[test] #[ignore(cfg(target_arch = "x86"))]
|
||||
fn test_package_ids_must_be_relative_path_like() {
|
||||
use conditions::bad_pkg_id::cond;
|
||||
|
||||
@ -457,6 +453,7 @@ fn test_package_ids_must_be_relative_path_like() {
|
||||
|
||||
}
|
||||
|
||||
#[test] #[ignore(cfg(target_arch = "x86"))]
|
||||
fn test_package_version() {
|
||||
let temp_pkg_id = PkgId::new("github.com/catamorphism/test_pkg_version");
|
||||
match temp_pkg_id.version {
|
||||
@ -479,9 +476,8 @@ fn test_package_version() {
|
||||
push("test_pkg_version")));
|
||||
}
|
||||
|
||||
// FIXME #7006: Fails on linux for some reason
|
||||
#[test]
|
||||
#[ignore]
|
||||
// FIXME #7006: Fails on linux/mac for some reason
|
||||
#[test] #[ignore]
|
||||
fn test_package_request_version() {
|
||||
let temp_pkg_id = PkgId::new("github.com/catamorphism/test_pkg_version#0.3");
|
||||
let temp = mk_empty_workspace(&LocalPath(Path("test_pkg_version")), &ExactRevision(~"0.3"));
|
||||
|
@ -0,0 +1,4 @@
|
||||
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
|
||||
# The actual contents of this file do not matter, but to trigger a change on the
|
||||
# build bots then the contents should be changed so git updates the mtime.
|
||||
6-29-2013
|
Loading…
x
Reference in New Issue
Block a user