Skip to content

Commit afade18

Browse files
committed
---
yaml --- r: 80919 b: refs/heads/snap-stage3 c: 36cc414 h: refs/heads/master i: 80917: b5c24d4 80915: 07d0306 80911: 272024a v: v3
1 parent c96cbbb commit afade18

File tree

19 files changed

+429
-388
lines changed

19 files changed

+429
-388
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d3309eb4325cbe85b54554c5d35ca3d6865c3976
4+
refs/heads/snap-stage3: 36cc41481c788e8d781e24908dcf30120797ed8d
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,38 +2388,12 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
23882388
let et = ccx.sess.entry_type.unwrap();
23892389
match et {
23902390
session::EntryMain => {
2391-
let llfn = create_main(ccx, main_llfn);
2392-
create_entry_fn(ccx, llfn, true);
2391+
create_entry_fn(ccx, main_llfn, true);
23932392
}
23942393
session::EntryStart => create_entry_fn(ccx, main_llfn, false),
23952394
session::EntryNone => {} // Do nothing.
23962395
}
23972396

2398-
fn create_main(ccx: @mut CrateContext, main_llfn: ValueRef) -> ValueRef {
2399-
let nt = ty::mk_nil();
2400-
let llfty = type_of_rust_fn(ccx, [], nt);
2401-
let llfdecl = decl_fn(ccx.llmod, "_rust_main",
2402-
lib::llvm::CCallConv, llfty);
2403-
2404-
let fcx = new_fn_ctxt(ccx, ~[], llfdecl, nt, None);
2405-
2406-
// the args vector built in create_entry_fn will need
2407-
// be updated if this assertion starts to fail.
2408-
assert!(!fcx.caller_expects_out_pointer);
2409-
2410-
let bcx = fcx.entry_bcx.unwrap();
2411-
// Call main.
2412-
let llenvarg = unsafe {
2413-
let env_arg = fcx.env_arg_pos();
2414-
llvm::LLVMGetParam(llfdecl, env_arg as c_uint)
2415-
};
2416-
let args = ~[llenvarg];
2417-
Call(bcx, main_llfn, args, []);
2418-
2419-
finish_fn(fcx, bcx);
2420-
return llfdecl;
2421-
}
2422-
24232397
fn create_entry_fn(ccx: @mut CrateContext,
24242398
rust_main: ValueRef,
24252399
use_start_lang_item: bool) {
@@ -2442,6 +2416,11 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24422416
unsafe {
24432417
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
24442418

2419+
let crate_map = ccx.crate_map;
2420+
let opaque_crate_map = do "crate_map".with_c_str |buf| {
2421+
llvm::LLVMBuildPointerCast(bld, crate_map, Type::i8p().to_ref(), buf)
2422+
};
2423+
24452424
let (start_fn, args) = if use_start_lang_item {
24462425
let start_def_id = match ccx.tcx.lang_items.require(StartFnLangItem) {
24472426
Ok(id) => id,
@@ -2464,7 +2443,8 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24642443
C_null(Type::opaque_box(ccx).ptr_to()),
24652444
opaque_rust_main,
24662445
llvm::LLVMGetParam(llfn, 0),
2467-
llvm::LLVMGetParam(llfn, 1)
2446+
llvm::LLVMGetParam(llfn, 1),
2447+
opaque_crate_map
24682448
]
24692449
};
24702450
(start_fn, args)
@@ -2473,7 +2453,8 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
24732453
let args = ~[
24742454
C_null(Type::opaque_box(ccx).ptr_to()),
24752455
llvm::LLVMGetParam(llfn, 0 as c_uint),
2476-
llvm::LLVMGetParam(llfn, 1 as c_uint)
2456+
llvm::LLVMGetParam(llfn, 1 as c_uint),
2457+
opaque_crate_map
24772458
];
24782459

24792460
(rust_main, args)
@@ -2654,16 +2635,13 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
26542635
}
26552636
ast::foreign_item_static(*) => {
26562637
let ident = foreign::link_name(ccx, ni);
2657-
unsafe {
2658-
let g = do ident.with_c_str |buf| {
2638+
let g = do ident.with_c_str |buf| {
2639+
unsafe {
26592640
let ty = type_of(ccx, ty);
26602641
llvm::LLVMAddGlobal(ccx.llmod, ty.to_ref(), buf)
2661-
};
2662-
if attr::contains_name(ni.attrs, "weak_linkage") {
2663-
lib::llvm::SetLinkage(g, lib::llvm::ExternalWeakLinkage);
26642642
}
2665-
g
2666-
}
2643+
};
2644+
g
26672645
}
26682646
}
26692647
}

branches/snap-stage3/src/librustc/middle/typeck/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
402402
bound_lifetime_names: opt_vec::Empty,
403403
inputs: ~[
404404
ty::mk_int(),
405-
ty::mk_imm_ptr(tcx, ty::mk_imm_ptr(tcx, ty::mk_u8()))
405+
ty::mk_imm_ptr(tcx, ty::mk_imm_ptr(tcx, ty::mk_u8())),
406+
ty::mk_imm_ptr(tcx, ty::mk_u8())
406407
],
407408
output: ty::mk_int()
408409
}

branches/snap-stage3/src/librustpkg/api.rs

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use context::*;
1212
use crate::*;
1313
use package_id::*;
1414
use package_source::*;
15+
use target::*;
1516
use version::Version;
1617
use workcache_support::*;
1718

@@ -63,56 +64,40 @@ pub fn new_workcache_context(p: &Path) -> workcache::Context {
6364
pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
6465
lib: Path) {
6566
let cx = default_context(sysroot);
66-
let subroot = root.clone();
67-
let subversion = version.clone();
68-
let sublib = lib.clone();
69-
do cx.workcache_context.with_prep(name) |prep| {
70-
let pkg_src = PkgSrc {
71-
workspace: subroot.clone(),
72-
start_dir: subroot.push("src").push(name),
73-
id: PkgId{ version: subversion.clone(), ..PkgId::new(name)},
74-
libs: ~[mk_crate(sublib.clone())],
67+
let pkg_src = PkgSrc {
68+
workspace: root.clone(),
69+
start_dir: root.push("src").push(name),
70+
id: PkgId{ version: version, ..PkgId::new(name)},
71+
// n.b. This assumes the package only has one crate
72+
libs: ~[mk_crate(lib)],
7573
mains: ~[],
7674
tests: ~[],
7775
benchs: ~[]
7876
};
79-
pkg_src.declare_inputs(prep);
80-
let subcx = cx.clone();
81-
let subsrc = pkg_src.clone();
82-
do prep.exec |exec| {
83-
subsrc.build(exec, &subcx.clone(), ~[]);
84-
}
85-
};
77+
pkg_src.build(&cx, ~[]);
8678
}
8779

8880
pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
8981
main: Path) {
9082
let cx = default_context(sysroot);
91-
let subroot = root.clone();
92-
let submain = main.clone();
93-
do cx.workcache_context.with_prep(name) |prep| {
94-
let pkg_src = PkgSrc {
95-
workspace: subroot.clone(),
96-
start_dir: subroot.push("src").push(name),
97-
id: PkgId{ version: version.clone(), ..PkgId::new(name)},
98-
libs: ~[],
99-
mains: ~[mk_crate(submain.clone())],
100-
tests: ~[],
101-
benchs: ~[]
102-
};
103-
pkg_src.declare_inputs(prep);
104-
let subsrc = pkg_src.clone();
105-
let subcx = cx.clone();
106-
do prep.exec |exec| {
107-
subsrc.clone().build(exec, &subcx.clone(), ~[]);
108-
}
109-
}
83+
let pkg_src = PkgSrc {
84+
workspace: root.clone(),
85+
start_dir: root.push("src").push(name),
86+
id: PkgId{ version: version, ..PkgId::new(name)},
87+
libs: ~[],
88+
// n.b. This assumes the package only has one crate
89+
mains: ~[mk_crate(main)],
90+
tests: ~[],
91+
benchs: ~[]
92+
};
93+
94+
pkg_src.build(&cx, ~[]);
11095
}
11196

11297
pub fn install_pkg(sysroot: Path, workspace: Path, name: ~str, version: Version) {
11398
let cx = default_context(sysroot);
11499
let pkgid = PkgId{ version: version, ..PkgId::new(name)};
115-
cx.install(PkgSrc::new(workspace, false, pkgid));
100+
cx.install(PkgSrc::new(workspace, false, pkgid), &Everything);
116101
}
117102

118103
fn mk_crate(p: Path) -> Crate {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub static copy_failed_code: int = 65;

branches/snap-stage3/src/librustpkg/package_id.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ impl PkgId {
108108
}
109109
}
110110

111+
// This is the workcache function name for the *installed*
112+
// binaries for this package (as opposed to the built ones,
113+
// which are per-crate).
114+
pub fn install_tag(&self) -> ~str {
115+
fmt!("install(%s)", self.to_str())
116+
}
111117
}
112118

113119
struct Prefixes {

branches/snap-stage3/src/librustpkg/package_source.rs

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use path_util::{find_dir_using_rust_path_hack, default_workspace, make_dir_rwx_r
2222
use util::compile_crate;
2323
use workspace::is_workspace;
2424
use workcache_support;
25+
use workcache_support::crate_tag;
2526
use extra::workcache;
2627

2728
// An enumeration of the unpacked source of a package workspace.
@@ -231,7 +232,7 @@ impl PkgSrc {
231232
p.filestem().map_default(false, |p| { p == &self.id.short_name.as_slice() })
232233
}
233234

234-
fn push_crate(cs: &mut ~[Crate], prefix: uint, p: &Path) {
235+
pub fn push_crate(cs: &mut ~[Crate], prefix: uint, p: &Path) {
235236
assert!(p.components.len() > prefix);
236237
let mut sub = Path("");
237238
for c in p.components.slice(prefix, p.components.len()).iter() {
@@ -286,7 +287,6 @@ impl PkgSrc {
286287

287288
fn build_crates(&self,
288289
ctx: &BuildContext,
289-
exec: &mut workcache::Exec,
290290
destination_dir: &Path,
291291
crates: &[Crate],
292292
cfgs: &[~str],
@@ -297,25 +297,40 @@ impl PkgSrc {
297297
let path_str = path.to_str();
298298
let cfgs = crate.cfgs + cfgs;
299299

300-
let result =
301-
// compile_crate should return the path of the output artifact
302-
compile_crate(ctx,
303-
exec,
304-
&self.id,
305-
&path,
306-
destination_dir,
307-
crate.flags,
308-
cfgs,
309-
false,
310-
what).to_str();
311-
debug!("Result of compiling %s was %s", path_str, result);
300+
do ctx.workcache_context.with_prep(crate_tag(&path)) |prep| {
301+
debug!("Building crate %s, declaring it as an input", path.to_str());
302+
prep.declare_input("file", path.to_str(),
303+
workcache_support::digest_file_with_date(&path));
304+
let subpath = path.clone();
305+
let subcfgs = cfgs.clone();
306+
let subpath_str = path_str.clone();
307+
let subcx = ctx.clone();
308+
let id = self.id.clone();
309+
let sub_dir = destination_dir.clone();
310+
let sub_flags = crate.flags.clone();
311+
do prep.exec |exec| {
312+
let result = compile_crate(&subcx,
313+
exec,
314+
&id,
315+
&subpath,
316+
&sub_dir,
317+
sub_flags,
318+
subcfgs,
319+
false,
320+
what).to_str();
321+
debug!("Result of compiling %s was %s", subpath_str, result);
322+
result
323+
}
324+
};
312325
}
313326
}
314327

315328
/// Declare all the crate files in the package source as inputs
329+
/// (to the package)
316330
pub fn declare_inputs(&self, prep: &mut workcache::Prep) {
317331
let to_do = ~[self.libs.clone(), self.mains.clone(),
318332
self.tests.clone(), self.benchs.clone()];
333+
debug!("In declare inputs, self = %s", self.to_str());
319334
for cs in to_do.iter() {
320335
for c in cs.iter() {
321336
let path = self.start_dir.push_rel(&c.file).normalize();
@@ -330,7 +345,6 @@ impl PkgSrc {
330345
// It would be better if build returned a Path, but then Path would have to derive
331346
// Encodable.
332347
pub fn build(&self,
333-
exec: &mut workcache::Exec,
334348
build_context: &BuildContext,
335349
cfgs: ~[~str]) -> ~str {
336350
use conditions::not_a_workspace::cond;
@@ -360,13 +374,23 @@ impl PkgSrc {
360374
let benchs = self.benchs.clone();
361375
debug!("Building libs in %s, destination = %s",
362376
destination_workspace.to_str(), destination_workspace.to_str());
363-
self.build_crates(build_context, exec, &destination_workspace, libs, cfgs, Lib);
377+
self.build_crates(build_context, &destination_workspace, libs, cfgs, Lib);
364378
debug!("Building mains");
365-
self.build_crates(build_context, exec, &destination_workspace, mains, cfgs, Main);
379+
self.build_crates(build_context, &destination_workspace, mains, cfgs, Main);
366380
debug!("Building tests");
367-
self.build_crates(build_context, exec, &destination_workspace, tests, cfgs, Test);
381+
self.build_crates(build_context, &destination_workspace, tests, cfgs, Test);
368382
debug!("Building benches");
369-
self.build_crates(build_context, exec, &destination_workspace, benchs, cfgs, Bench);
383+
self.build_crates(build_context, &destination_workspace, benchs, cfgs, Bench);
370384
destination_workspace.to_str()
371385
}
386+
387+
/// Debugging
388+
pub fn dump_crates(&self) {
389+
let crate_sets = [&self.libs, &self.mains, &self.tests, &self.benchs];
390+
for crate_set in crate_sets.iter() {
391+
for c in crate_set.iter() {
392+
debug!("Built crate: %s", c.file.to_str())
393+
}
394+
}
395+
}
372396
}

0 commit comments

Comments
 (0)