Skip to content

Commit 604e634

Browse files
committed
---
yaml --- r: 139105 b: refs/heads/try2 c: db4dc1f h: refs/heads/master i: 139103: 2f00f36 v: v3
1 parent fe18c7a commit 604e634

36 files changed

+538
-217
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: 3fac7cce8fb3fb50328e2c2051532361d7d25aaf
8+
refs/heads/try2: db4dc1ffe29045361c34abab8d810d2c717b82e0
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/compiletest/runtest.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,19 @@ actual:\n\
208208
testfile: &Path, src: ~str) -> ProcRes {
209209
compose_and_run_compiler(
210210
config, props, testfile,
211-
make_typecheck_args(config, testfile),
211+
make_typecheck_args(config, props, testfile),
212212
Some(src))
213213
}
214214

215-
fn make_typecheck_args(config: config, testfile: &Path) -> ProcArgs {
215+
fn make_typecheck_args(config: config, props: TestProps, testfile: &Path) -> ProcArgs {
216216
let prog = config.rustc_path;
217217
let mut args = ~[~"-",
218218
~"--no-trans", ~"--lib",
219219
~"-L", config.build_base.to_str(),
220220
~"-L",
221221
aux_output_dir_name(config, testfile).to_str()];
222222
args += split_maybe_args(config.rustcflags);
223+
args += split_maybe_args(props.compile_flags);
223224
return ProcArgs {prog: prog.to_str(), args: args};
224225
}
225226
}

branches/try2/src/libcore/libc.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,9 +1221,8 @@ pub mod funcs {
12211221
#[nolink]
12221222
#[abi = "cdecl"]
12231223
pub mod fcntl {
1224+
use libc::types::os::arch::c95::{c_int, c_char};
12241225
pub extern {
1225-
use libc::types::os::arch::c95::{c_int, c_char};
1226-
12271226
#[link_name = "_open"]
12281227
unsafe fn open(path: *c_char, oflag: c_int, mode: c_int)
12291228
-> c_int;
@@ -1562,11 +1561,11 @@ pub mod funcs {
15621561
#[cfg(target_os = "macos")]
15631562
#[cfg(target_os = "freebsd")]
15641563
pub mod bsd44 {
1564+
use libc::types::common::c95::{c_void};
1565+
use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1566+
15651567
#[abi = "cdecl"]
15661568
pub extern {
1567-
use libc::types::common::c95::{c_void};
1568-
use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1569-
15701569
unsafe fn sysctl(name: *c_int, namelen: c_uint,
15711570
oldp: *mut c_void, oldlenp: *mut size_t,
15721571
newp: *c_void, newlen: size_t) -> c_int;

branches/try2/src/libcore/rt/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ pub fn get() -> &Environment {
4444

4545
extern {
4646
fn rust_get_rt_env() -> &Environment;
47-
}
47+
}

branches/try2/src/libcore/rt/sched.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ enum CleanupJob {
7070

7171
pub impl Scheduler {
7272

73-
static fn new(event_loop: ~EventLoopObject) -> Scheduler {
73+
static pub fn new(event_loop: ~EventLoopObject) -> Scheduler {
7474
Scheduler {
7575
event_loop: event_loop,
7676
task_queue: WorkQueue::new(),
@@ -296,7 +296,7 @@ pub struct Task {
296296
}
297297

298298
impl Task {
299-
static fn new(stack_pool: &mut StackPool, start: ~fn()) -> Task {
299+
static pub fn new(stack_pool: &mut StackPool, start: ~fn()) -> Task {
300300
// XXX: Putting main into a ~ so it's a thin pointer and can
301301
// be passed to the spawn function. Another unfortunate
302302
// allocation

branches/try2/src/libcore/rt/stack.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ pub impl StackSegment {
3737
pub struct StackPool(());
3838

3939
impl StackPool {
40-
41-
static fn new() -> StackPool { StackPool(()) }
40+
static pub fn new() -> StackPool { StackPool(()) }
4241

4342
fn take_segment(&self, min_size: uint) -> StackSegment {
4443
StackSegment::new(min_size)

branches/try2/src/libcore/rt/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Thread {
2020
}
2121

2222
impl Thread {
23-
static fn start(main: ~fn()) -> Thread {
23+
static pub fn start(main: ~fn()) -> Thread {
2424
fn substart(main: &fn()) -> *raw_thread {
2525
unsafe { rust_raw_thread_start(&main) }
2626
}

branches/try2/src/libcore/task/rt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub type rust_task = libc::c_void;
3030
#[allow(non_camel_case_types)] // runtime type
3131
pub type rust_closure = libc::c_void;
3232

33-
extern {
33+
pub extern {
3434
#[rust_stack]
3535
fn rust_task_yield(task: *rust_task) -> bool;
3636

branches/try2/src/librustc/back/link.rs

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,18 @@ pub mod write {
167167
use back::link::{output_type_assembly, output_type_bitcode};
168168
use back::link::{output_type_exe, output_type_llvm_assembly};
169169
use back::link::{output_type_object};
170+
use back::link::output_type;
170171
use driver::session::Session;
171172
use driver::session;
172173
use lib::llvm::llvm;
173174
use lib::llvm::{False, True, ModuleRef, mk_pass_manager, mk_target_data};
174175
use lib;
175176

177+
use core::prelude::*;
176178
use core::libc::{c_char, c_int, c_uint};
177179
use core::path::Path;
178180
use core::str;
181+
use core::run;
179182

180183
pub fn is_object_or_assembly_or_exe(ot: output_type) -> bool {
181184
if ot == output_type_assembly || ot == output_type_object ||
@@ -185,7 +188,8 @@ pub mod write {
185188
return false;
186189
}
187190

188-
pub fn run_passes(sess: Session, llmod: ModuleRef, output: &Path) {
191+
pub fn run_passes(sess: Session, llmod: ModuleRef,
192+
output_type: output_type, output: &Path) {
189193
unsafe {
190194
let opts = sess.opts;
191195
if sess.time_llvm_passes() { llvm::LLVMRustEnableTimePasses(); }
@@ -200,7 +204,7 @@ pub mod write {
200204

201205

202206
if opts.save_temps {
203-
match opts.output_type {
207+
match output_type {
204208
output_type_bitcode => {
205209
if opts.optimize != session::No {
206210
let filename = output.with_filetype("no-opt.bc");
@@ -261,7 +265,7 @@ pub mod write {
261265
llvm::LLVMPassManagerBuilderDispose(MPMB);
262266
}
263267
if !sess.no_verify() { llvm::LLVMAddVerifierPass(pm.llpm); }
264-
if is_object_or_assembly_or_exe(opts.output_type) || opts.jit {
268+
if is_object_or_assembly_or_exe(output_type) || opts.jit {
265269
let LLVMOptNone = 0 as c_int; // -O0
266270
let LLVMOptLess = 1 as c_int; // -O1
267271
let LLVMOptDefault = 2 as c_int; // -O2, -Os
@@ -289,8 +293,8 @@ pub mod write {
289293
}
290294

291295
let mut FileType;
292-
if opts.output_type == output_type_object ||
293-
opts.output_type == output_type_exe {
296+
if output_type == output_type_object ||
297+
output_type == output_type_exe {
294298
FileType = lib::llvm::ObjectFile;
295299
} else { FileType = lib::llvm::AssemblyFile; }
296300
// Write optimized bitcode if --save-temps was on.
@@ -306,7 +310,7 @@ pub mod write {
306310
pm = mk_pass_manager();
307311
// Save the assembly file if -S is used
308312

309-
if opts.output_type == output_type_assembly {
313+
if output_type == output_type_assembly {
310314
let _: () = str::as_c_str(
311315
sess.targ_cfg.target_strs.target_triple,
312316
|buf_t| {
@@ -327,8 +331,8 @@ pub mod write {
327331

328332
// Save the object file for -c or --save-temps alone
329333
// This .o is needed when an exe is built
330-
if opts.output_type == output_type_object ||
331-
opts.output_type == output_type_exe {
334+
if output_type == output_type_object ||
335+
output_type == output_type_exe {
332336
let _: () = str::as_c_str(
333337
sess.targ_cfg.target_strs.target_triple,
334338
|buf_t| {
@@ -374,7 +378,7 @@ pub mod write {
374378
return;
375379
}
376380

377-
if opts.output_type == output_type_llvm_assembly {
381+
if output_type == output_type_llvm_assembly {
378382
// Given options "-S --emit-llvm": output LLVM assembly
379383
str::as_c_str(output.to_str(), |buf_o| {
380384
llvm::LLVMRustAddPrintModulePass(pm.llpm, llmod, buf_o)});
@@ -390,6 +394,34 @@ pub mod write {
390394
if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
391395
}
392396
}
397+
398+
pub fn run_ndk(sess: Session, assembly: &Path, object: &Path) {
399+
let cc_prog: ~str = match &sess.opts.android_cross_path {
400+
&Some(copy path) => {
401+
fmt!("%s/bin/arm-linux-androideabi-gcc", path)
402+
}
403+
&None => {
404+
sess.fatal(~"need Android NDK path for building \
405+
(--android-cross-path)")
406+
}
407+
};
408+
let mut cc_args = ~[];
409+
cc_args.push(~"-c");
410+
cc_args.push(~"-o");
411+
cc_args.push(object.to_str());
412+
cc_args.push(assembly.to_str());
413+
414+
let prog = run::program_output(cc_prog, cc_args);
415+
416+
if prog.status != 0 {
417+
sess.err(fmt!("building with `%s` failed with code %d",
418+
cc_prog, prog.status));
419+
sess.note(fmt!("%s arguments: %s",
420+
cc_prog, str::connect(cc_args, ~" ")));
421+
sess.note(prog.err + prog.out);
422+
sess.abort_if_errors();
423+
}
424+
}
393425
}
394426
395427

branches/try2/src/librustc/driver/driver.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,23 @@ pub fn compile_rest(sess: Session, cfg: ast::crate_cfg,
320320

321321
};
322322

323-
time(time_passes, ~"LLVM passes", ||
324-
link::write::run_passes(sess, llmod,
323+
// NOTE: Android hack
324+
if sess.targ_cfg.arch == session::arch_arm &&
325+
(sess.opts.output_type == link::output_type_object ||
326+
sess.opts.output_type == link::output_type_exe) {
327+
let output_type = link::output_type_assembly;
328+
let obj_filename = outputs.obj_filename.with_filetype("s");
329+
330+
time(time_passes, ~"LLVM passes", ||
331+
link::write::run_passes(sess, llmod, output_type,
332+
&obj_filename));
333+
334+
link::write::run_ndk(sess, &obj_filename, &outputs.obj_filename);
335+
} else {
336+
time(time_passes, ~"LLVM passes", ||
337+
link::write::run_passes(sess, llmod, sess.opts.output_type,
325338
&outputs.obj_filename));
339+
}
326340

327341
let stop_after_codegen =
328342
sess.opts.output_type != link::output_type_exe ||

branches/try2/src/librustc/front/config.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,19 @@ pub fn metas_in_cfg(cfg: ast::crate_cfg,
185185
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
186186
// so we can match against them. This is the list of configurations for
187187
// which the item is valid
188-
let cfg_metas =
189-
vec::concat(
190-
vec::filter_map(cfg_metas, |i| attr::get_meta_item_list(i)));
191-
192-
let has_cfg_metas = vec::len(cfg_metas) > 0u;
193-
if !has_cfg_metas { return true; }
194-
195-
for cfg_metas.each |cfg_mi| {
196-
if attr::contains(cfg, *cfg_mi) { return true; }
197-
}
198-
199-
return false;
188+
let cfg_metas = vec::filter_map(cfg_metas, |i| attr::get_meta_item_list(i));
189+
190+
if cfg_metas.all(|c| c.is_empty()) { return true; }
191+
192+
cfg_metas.any(|cfg_meta| {
193+
cfg_meta.all(|cfg_mi| {
194+
match cfg_mi.node {
195+
ast::meta_list(s, ref it) if *s == ~"not"
196+
=> it.all(|mi| !attr::contains(cfg, *mi)),
197+
_ => attr::contains(cfg, *cfg_mi)
198+
}
199+
})
200+
})
200201
}
201202

202203

branches/try2/src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fn item_family(item: ebml::Doc) -> Family {
146146

147147
fn item_visibility(item: ebml::Doc) -> ast::visibility {
148148
let visibility = reader::get_doc(item, tag_items_data_item_visibility);
149+
debug!("item visibility for %?", item_family(item));
149150
match reader::doc_as_u8(visibility) as char {
150151
'y' => ast::public,
151152
'n' => ast::private,

branches/try2/src/librustc/metadata/encoder.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
896896
encode_family(ebml_w, purity_fn_family(mty.fty.purity));
897897
encode_self_type(ebml_w, mty.self_ty);
898898
encode_method_sort(ebml_w, 'r');
899+
encode_visibility(ebml_w, ast::public);
899900
ebml_w.end_tag();
900901
}
901902
provided(m) => {
@@ -911,6 +912,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
911912
encode_family(ebml_w, purity_fn_family(mty.fty.purity));
912913
encode_self_type(ebml_w, mty.self_ty);
913914
encode_method_sort(ebml_w, 'p');
915+
encode_visibility(ebml_w, m.vis);
914916
ebml_w.end_tag();
915917
}
916918
}
@@ -945,6 +947,11 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
945947
let mut m_path = vec::append(~[], path); // :-(
946948
m_path += [ast_map::path_name(item.ident)];
947949
encode_path(ecx, ebml_w, m_path, ast_map::path_name(ty_m.ident));
950+
951+
// For now, use the item visibility until trait methods can have
952+
// real visibility in the AST.
953+
encode_visibility(ebml_w, item.vis);
954+
948955
ebml_w.end_tag();
949956
}
950957
@@ -1033,7 +1040,7 @@ fn encode_info_for_items(ecx: @EncodeContext, ebml_w: writer::Encoder,
10331040
|ni, cx, v| {
10341041
visit::visit_foreign_item(ni, cx, v);
10351042
match ecx.tcx.items.get(&ni.id) {
1036-
ast_map::node_foreign_item(_, abi, pt) => {
1043+
ast_map::node_foreign_item(_, abi, _, pt) => {
10371044
encode_info_for_foreign_item(ecx, ebml_w, ni,
10381045
index, /*bad*/copy *pt,
10391046
abi);

0 commit comments

Comments
 (0)