Skip to content

Commit 3213683

Browse files
committed
---
yaml --- r: 146073 b: refs/heads/try2 c: ece5028 h: refs/heads/master i: 146071: c9592f9 v: v3
1 parent 664dde6 commit 3213683

File tree

10 files changed

+109
-38
lines changed

10 files changed

+109
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 1122d6ab4aec4c2b0bc805499cef43e7d8641d0f
8+
refs/heads/try2: ece5028a8be4183ccb203dac59e734f1ca753714
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,8 +2797,8 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
27972797

27982798
ifn!(intrinsics, "llvm.fabs.f32", [Type::f32()], Type::f32());
27992799
ifn!(intrinsics, "llvm.fabs.f64", [Type::f64()], Type::f64());
2800-
ifn!(intrinsics, "llvm.copysign.f32", [Type::f32()], Type::f32());
2801-
ifn!(intrinsics, "llvm.copysign.f64", [Type::f64()], Type::f64());
2800+
ifn!(intrinsics, "llvm.copysign.f32", [Type::f32(), Type::f32()], Type::f32());
2801+
ifn!(intrinsics, "llvm.copysign.f64", [Type::f64(), Type::f64()], Type::f64());
28022802

28032803
ifn!(intrinsics, "llvm.floor.f32",[Type::f32()], Type::f32());
28042804
ifn!(intrinsics, "llvm.floor.f64",[Type::f64()], Type::f64());
@@ -2807,12 +2807,12 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
28072807
ifn!(intrinsics, "llvm.trunc.f32",[Type::f32()], Type::f32());
28082808
ifn!(intrinsics, "llvm.trunc.f64",[Type::f64()], Type::f64());
28092809

2810-
ifn!(intrinsics, "llvm.rint.f32",[Type::f64()], Type::f64());
2811-
ifn!(intrinsics, "llvm.rint.f64",[Type::f64()], Type::f64());
2812-
ifn!(intrinsics, "llvm.nearbyint.f32",[Type::f64()], Type::f64());
2813-
ifn!(intrinsics, "llvm.nearbyint.f64",[Type::f64()], Type::f64());
2814-
ifn!(intrinsics, "llvm.round.f32",[Type::f64()], Type::f64());
2815-
ifn!(intrinsics, "llvm.round.f64",[Type::f64()], Type::f64());
2810+
ifn!(intrinsics, "llvm.rint.f32", [Type::f32()], Type::f32());
2811+
ifn!(intrinsics, "llvm.rint.f64", [Type::f64()], Type::f64());
2812+
ifn!(intrinsics, "llvm.nearbyint.f32", [Type::f32()], Type::f32());
2813+
ifn!(intrinsics, "llvm.nearbyint.f64", [Type::f64()], Type::f64());
2814+
ifn!(intrinsics, "llvm.round.f32", [Type::f32()], Type::f32());
2815+
ifn!(intrinsics, "llvm.round.f64", [Type::f64()], Type::f64());
28162816

28172817
ifn!(intrinsics, "llvm.ctpop.i8", [Type::i8()], Type::i8());
28182818
ifn!(intrinsics, "llvm.ctpop.i16",[Type::i16()], Type::i16());

branches/try2/src/librustc/middle/trans/intrinsic.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,20 +460,20 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
460460
"fmaf64" => simple_llvm_intrinsic(bcx, "llvm.fma.f64", 3),
461461
"fabsf32" => simple_llvm_intrinsic(bcx, "llvm.fabs.f32", 1),
462462
"fabsf64" => simple_llvm_intrinsic(bcx, "llvm.fabs.f64", 1),
463-
"copysignf32" => simple_llvm_intrinsic(bcx, "llvm.copysign.f32", 1),
464-
"copysignf64" => simple_llvm_intrinsic(bcx, "llvm.copysign.f64", 1),
463+
"copysignf32" => simple_llvm_intrinsic(bcx, "llvm.copysign.f32", 2),
464+
"copysignf64" => simple_llvm_intrinsic(bcx, "llvm.copysign.f64", 2),
465465
"floorf32" => simple_llvm_intrinsic(bcx, "llvm.floor.f32", 1),
466466
"floorf64" => simple_llvm_intrinsic(bcx, "llvm.floor.f64", 1),
467467
"ceilf32" => simple_llvm_intrinsic(bcx, "llvm.ceil.f32", 1),
468468
"ceilf64" => simple_llvm_intrinsic(bcx, "llvm.ceil.f64", 1),
469469
"truncf32" => simple_llvm_intrinsic(bcx, "llvm.trunc.f32", 1),
470470
"truncf64" => simple_llvm_intrinsic(bcx, "llvm.trunc.f64", 1),
471-
"rintf64" => simple_llvm_intrinsic(bcx, "llvm.rint.f64", 1),
472471
"rintf32" => simple_llvm_intrinsic(bcx, "llvm.rint.f32", 1),
473-
"nearbyintf32" => simple_llvm_intrinsic(bcx, "llvm.nearbyint.f64", 1),
474-
"nearbyintf64" => simple_llvm_intrinsic(bcx, "llvm.nearbyint.f32", 1),
475-
"roundf32" => simple_llvm_intrinsic(bcx, "llvm.round.f64", 1),
476-
"roundf64" => simple_llvm_intrinsic(bcx, "llvm.round.f32", 1),
472+
"rintf64" => simple_llvm_intrinsic(bcx, "llvm.rint.f64", 1),
473+
"nearbyintf32" => simple_llvm_intrinsic(bcx, "llvm.nearbyint.f32", 1),
474+
"nearbyintf64" => simple_llvm_intrinsic(bcx, "llvm.nearbyint.f64", 1),
475+
"roundf32" => simple_llvm_intrinsic(bcx, "llvm.round.f32", 1),
476+
"roundf64" => simple_llvm_intrinsic(bcx, "llvm.round.f64", 1),
477477
"ctpop8" => simple_llvm_intrinsic(bcx, "llvm.ctpop.i8", 1),
478478
"ctpop16" => simple_llvm_intrinsic(bcx, "llvm.ctpop.i16", 1),
479479
"ctpop32" => simple_llvm_intrinsic(bcx, "llvm.ctpop.i32", 1),

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,8 +3809,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
38093809
}
38103810
"fabsf32" => (0, ~[ ty::mk_f32() ], ty::mk_f32()),
38113811
"fabsf64" => (0, ~[ ty::mk_f64() ], ty::mk_f64()),
3812-
"copysignf32" => (0, ~[ ty::mk_f32() ], ty::mk_f32()),
3813-
"copysignf64" => (0, ~[ ty::mk_f64() ], ty::mk_f64()),
3812+
"copysignf32" => (0, ~[ ty::mk_f32(), ty::mk_f32() ], ty::mk_f32()),
3813+
"copysignf64" => (0, ~[ ty::mk_f64(), ty::mk_f64() ], ty::mk_f64()),
38143814
"floorf32" => (0, ~[ ty::mk_f32() ], ty::mk_f32()),
38153815
"floorf64" => (0, ~[ ty::mk_f64() ], ty::mk_f64()),
38163816
"ceilf32" => (0, ~[ ty::mk_f32() ], ty::mk_f32()),

branches/try2/src/librustpkg/conditions.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ condition! {
4747
pub no_rust_path: (~str) -> Path;
4848
}
4949

50-
condition! {
51-
pub not_a_workspace: (~str) -> Path;
52-
}
53-
5450
condition! {
5551
pub failed_to_create_temp_dir: (~str) -> Path;
5652
}

branches/try2/src/librustpkg/package_source.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use crate::Crate;
1919
use messages::*;
2020
use source_control::{safe_git_clone, git_clone_url, DirToUse, CheckedOutSources};
2121
use source_control::make_read_only;
22-
use path_util::{find_dir_using_rust_path_hack, make_dir_rwx_recursive};
23-
use path_util::{target_build_dir, versionize};
22+
use path_util::{find_dir_using_rust_path_hack, make_dir_rwx_recursive, default_workspace};
23+
use path_util::{target_build_dir, versionize, dir_has_crate_file};
2424
use util::{compile_crate, DepMap};
2525
use workcache_support;
2626
use workcache_support::crate_tag;
@@ -197,7 +197,23 @@ impl PkgSrc {
197197
match ok_d {
198198
Some(d) => d,
199199
None => {
200-
if use_rust_path_hack {
200+
// See if the sources are in $CWD
201+
let cwd = os::getcwd();
202+
if dir_has_crate_file(&cwd) {
203+
return PkgSrc {
204+
// In this case, source_workspace isn't really a workspace.
205+
// This data structure needs yet more refactoring.
206+
source_workspace: cwd.clone(),
207+
destination_workspace: default_workspace(),
208+
build_in_destination: true,
209+
start_dir: cwd,
210+
id: id,
211+
libs: ~[],
212+
mains: ~[],
213+
benchs: ~[],
214+
tests: ~[]
215+
}
216+
} else if use_rust_path_hack {
201217
match find_dir_using_rust_path_hack(&id) {
202218
Some(d) => d,
203219
None => {

branches/try2/src/librustpkg/path_util.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ pub fn uninstall_package_from(workspace: &Path, pkgid: &PkgId) {
414414

415415
}
416416

417+
pub fn dir_has_crate_file(dir: &Path) -> bool {
418+
dir_has_file(dir, "lib.rs") || dir_has_file(dir, "main.rs")
419+
|| dir_has_file(dir, "test.rs") || dir_has_file(dir, "bench.rs")
420+
}
421+
417422
fn dir_has_file(dir: &Path, file: &str) -> bool {
418423
assert!(dir.is_absolute());
419424
os::path_exists(&dir.join(file))
@@ -427,8 +432,7 @@ pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> {
427432
// has a name that's a single component
428433
if dir.ends_with_path(&p.path) || dir.ends_with_path(&versionize(&p.path, &p.version)) {
429434
debug2!("In find_dir_using_rust_path_hack: checking dir {}", dir.display());
430-
if dir_has_file(dir, "lib.rs") || dir_has_file(dir, "main.rs")
431-
|| dir_has_file(dir, "test.rs") || dir_has_file(dir, "bench.rs") {
435+
if dir_has_crate_file(dir) {
432436
debug2!("Did find id {} in dir {}", p.to_str(), dir.display());
433437
return Some(dir.clone());
434438
}

branches/try2/src/librustpkg/rustpkg.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use messages::{error, warn, note};
3838
use path_util::{build_pkg_id_in_workspace, built_test_in_workspace};
3939
use path_util::{U_RWX, in_rust_path};
4040
use path_util::{built_executable_in_workspace, built_library_in_workspace, default_workspace};
41-
use path_util::{target_executable_in_workspace, target_library_in_workspace};
41+
use path_util::{target_executable_in_workspace, target_library_in_workspace, dir_has_crate_file};
4242
use source_control::{CheckedOutSources, is_git_dir, make_read_only};
4343
use workspace::{each_pkg_parent_workspace, pkg_parent_workspaces, cwd_to_workspace};
4444
use workspace::determine_destination;
@@ -48,7 +48,6 @@ use context::{Context, BuildContext,
4848
use package_id::PkgId;
4949
use package_source::PkgSrc;
5050
use target::{WhatToBuild, Everything, is_lib, is_main, is_test, is_bench, Tests};
51-
// use workcache_support::{discover_outputs, digest_only_date};
5251
use workcache_support::digest_only_date;
5352
use exit_codes::{COPY_FAILED_CODE, BAD_FLAG_CODE};
5453

@@ -210,10 +209,11 @@ pub trait CtxMethods {
210209

211210
impl CtxMethods for BuildContext {
212211
fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)> {
212+
let cwd = os::getcwd();
213+
213214
if args.len() < 1 {
214215
match cwd_to_workspace() {
215-
None if self.context.use_rust_path_hack => {
216-
let cwd = os::getcwd();
216+
None if dir_has_crate_file(&cwd) => {
217217
// FIXME (#9639): This needs to handle non-utf8 paths
218218
let pkgid = PkgId::new(cwd.filename_str().unwrap());
219219
let mut pkg_src = PkgSrc::new(cwd, default_workspace(), true, pkgid);
@@ -260,6 +260,7 @@ impl CtxMethods for BuildContext {
260260
}
261261
}
262262
fn run(&self, cmd: &str, args: ~[~str]) {
263+
let cwd = os::getcwd();
263264
match cmd {
264265
"build" => {
265266
self.build_args(args, &Everything);
@@ -278,7 +279,6 @@ impl CtxMethods for BuildContext {
278279
// The package id is presumed to be the first command-line
279280
// argument
280281
let pkgid = PkgId::new(args[0].clone());
281-
let cwd = os::getcwd();
282282
self.clean(&cwd, &pkgid); // tjc: should use workspace, not cwd
283283
}
284284
}
@@ -295,9 +295,9 @@ impl CtxMethods for BuildContext {
295295
"install" => {
296296
if args.len() < 1 {
297297
match cwd_to_workspace() {
298-
None if self.context.use_rust_path_hack => {
299-
let cwd = os::getcwd();
298+
None if dir_has_crate_file(&cwd) => {
300299
// FIXME (#9639): This needs to handle non-utf8 paths
300+
301301
let inferred_pkgid =
302302
PkgId::new(cwd.filename_str().unwrap());
303303
self.install(PkgSrc::new(cwd, default_workspace(),

branches/try2/src/librustpkg/tests.rs

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@ fn test_make_dir_rwx() {
580580
assert!(os::remove_dir_recursive(&dir));
581581
}
582582

583+
// n.b. I ignored the next two tests for now because something funny happens on linux
584+
// and I don't want to debug the issue right now (calling into the rustpkg lib directly
585+
// is a little sketchy anyway)
583586
#[test]
587+
#[ignore]
584588
fn test_install_valid() {
585589
use path_util::installed_library_in_workspace;
586590

@@ -621,6 +625,7 @@ fn test_install_valid() {
621625
}
622626

623627
#[test]
628+
#[ignore]
624629
fn test_install_invalid() {
625630
let sysroot = test_sysroot();
626631
let pkgid = fake_pkg();
@@ -641,7 +646,44 @@ fn test_install_invalid() {
641646
assert!(result == Err(()));
642647
}
643648

644-
// Tests above should (maybe) be converted to shell out to rustpkg, too
649+
#[test]
650+
fn test_install_valid_external() {
651+
let temp_pkg_id = PkgId::new("foo");
652+
let (tempdir, _) = mk_temp_workspace(&temp_pkg_id.path,
653+
&temp_pkg_id.version);
654+
let temp_workspace = tempdir.path();
655+
command_line_test([~"install", ~"foo"], temp_workspace);
656+
657+
// Check that all files exist
658+
let exec = target_executable_in_workspace(&temp_pkg_id, temp_workspace);
659+
debug2!("exec = {}", exec.display());
660+
assert!(os::path_exists(&exec));
661+
assert!(is_rwx(&exec));
662+
663+
let lib = installed_library_in_workspace(&temp_pkg_id.path, temp_workspace);
664+
debug2!("lib = {:?}", lib);
665+
assert!(lib.as_ref().map_default(false, |l| os::path_exists(l)));
666+
assert!(lib.as_ref().map_default(false, |l| is_rwx(l)));
667+
668+
// And that the test and bench executables aren't installed
669+
assert!(!os::path_exists(&target_test_in_workspace(&temp_pkg_id, temp_workspace)));
670+
let bench = target_bench_in_workspace(&temp_pkg_id, temp_workspace);
671+
debug2!("bench = {}", bench.display());
672+
assert!(!os::path_exists(&bench));
673+
674+
}
675+
676+
#[test]
677+
#[ignore(reason = "9994")]
678+
fn test_install_invalid_external() {
679+
let cwd = os::getcwd();
680+
command_line_test_expect_fail([~"install", ~"foo"],
681+
&cwd,
682+
None,
683+
// FIXME #3408: Should be NONEXISTENT_PACKAGE_CODE
684+
COPY_FAILED_CODE);
685+
}
686+
645687
#[test]
646688
fn test_install_git() {
647689
let temp_pkg_id = git_repo_pkg();
@@ -1367,6 +1409,8 @@ fn rust_path_hack_test(hack_flag: bool) {
13671409
assert!(!built_executable_exists(workspace, "foo"));
13681410
}
13691411

1412+
// Notice that this is the only test case where the --rust-path-hack
1413+
// flag is actually needed
13701414
#[test]
13711415
fn test_rust_path_can_contain_package_dirs_with_flag() {
13721416
/*
@@ -2029,7 +2073,6 @@ fn test_rustpkg_test_output() {
20292073
}
20302074

20312075
#[test]
2032-
#[ignore(reason = "Issue 9441")]
20332076
fn test_rebuild_when_needed() {
20342077
let foo_id = PkgId::new("foo");
20352078
let foo_workspace = create_local_package(&foo_id);
@@ -2196,6 +2239,18 @@ fn test_compile_error() {
21962239
}
21972240
}
21982241

2242+
#[test]
2243+
fn find_sources_in_cwd() {
2244+
let temp_dir = TempDir::new("sources").expect("find_sources_in_cwd failed");
2245+
let temp_dir = temp_dir.path();
2246+
let source_dir = temp_dir.join("foo");
2247+
os::mkdir_recursive(&source_dir, U_RWX);
2248+
writeFile(&source_dir.join("main.rs"),
2249+
"fn main() { let _x = (); }");
2250+
command_line_test([~"install", ~"foo"], &source_dir);
2251+
assert_executable_exists(&source_dir.join(".rust"), "foo");
2252+
}
2253+
21992254
/// Returns true if p exists and is executable
22002255
fn is_executable(p: &Path) -> bool {
22012256
use std::libc::consts::os::posix88::{S_IXUSR};

branches/try2/src/libstd/unstable/intrinsics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,9 @@ extern "rust-intrinsic" {
411411
pub fn fabsf64(x: f64) -> f64;
412412

413413
#[cfg(not(stage0))]
414-
pub fn copysignf32(x: f32) -> f32;
414+
pub fn copysignf32(x: f32, y: f32) -> f32;
415415
#[cfg(not(stage0))]
416-
pub fn copysignf64(x: f64) -> f64;
416+
pub fn copysignf64(x: f64, y: f64) -> f64;
417417

418418
pub fn floorf32(x: f32) -> f32;
419419
pub fn floorf64(x: f64) -> f64;

0 commit comments

Comments
 (0)