Skip to content

Commit 25d6aca

Browse files
committed
---
yaml --- r: 50798 b: refs/heads/try c: 01e1798 h: refs/heads/master v: v3
1 parent ca5d9b1 commit 25d6aca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1010
-686
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
5-
refs/heads/try: 3fac7cce8fb3fb50328e2c2051532361d7d25aaf
5+
refs/heads/try: 01e179840fe57c9d2a574613b0cafce756520894
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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/try/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/try/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/try/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/try/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/try/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/try/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/try/src/librustc/back/link.rs

Lines changed: 45 additions & 13 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,12 +188,14 @@ 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(); }
192196
let mut pm = mk_pass_manager();
193-
let td = mk_target_data(sess.targ_cfg.target_strs.data_layout);
197+
let td = mk_target_data(
198+
/*bad*/copy sess.targ_cfg.target_strs.data_layout);
194199
llvm::LLVMAddTargetData(td.lltd, pm.llpm);
195200
// FIXME (#2812): run the linter here also, once there are llvm-c
196201
// bindings for it.
@@ -200,7 +205,7 @@ pub mod write {
200205

201206

202207
if opts.save_temps {
203-
match opts.output_type {
208+
match output_type {
204209
output_type_bitcode => {
205210
if opts.optimize != session::No {
206211
let filename = output.with_filetype("no-opt.bc");
@@ -261,7 +266,7 @@ pub mod write {
261266
llvm::LLVMPassManagerBuilderDispose(MPMB);
262267
}
263268
if !sess.no_verify() { llvm::LLVMAddVerifierPass(pm.llpm); }
264-
if is_object_or_assembly_or_exe(opts.output_type) || opts.jit {
269+
if is_object_or_assembly_or_exe(output_type) || opts.jit {
265270
let LLVMOptNone = 0 as c_int; // -O0
266271
let LLVMOptLess = 1 as c_int; // -O1
267272
let LLVMOptDefault = 2 as c_int; // -O2, -Os
@@ -289,8 +294,8 @@ pub mod write {
289294
}
290295

291296
let mut FileType;
292-
if opts.output_type == output_type_object ||
293-
opts.output_type == output_type_exe {
297+
if output_type == output_type_object ||
298+
output_type == output_type_exe {
294299
FileType = lib::llvm::ObjectFile;
295300
} else { FileType = lib::llvm::AssemblyFile; }
296301
// Write optimized bitcode if --save-temps was on.
@@ -306,7 +311,7 @@ pub mod write {
306311
pm = mk_pass_manager();
307312
// Save the assembly file if -S is used
308313

309-
if opts.output_type == output_type_assembly {
314+
if output_type == output_type_assembly {
310315
let _: () = str::as_c_str(
311316
sess.targ_cfg.target_strs.target_triple,
312317
|buf_t| {
@@ -327,8 +332,8 @@ pub mod write {
327332

328333
// Save the object file for -c or --save-temps alone
329334
// This .o is needed when an exe is built
330-
if opts.output_type == output_type_object ||
331-
opts.output_type == output_type_exe {
335+
if output_type == output_type_object ||
336+
output_type == output_type_exe {
332337
let _: () = str::as_c_str(
333338
sess.targ_cfg.target_strs.target_triple,
334339
|buf_t| {
@@ -374,7 +379,7 @@ pub mod write {
374379
return;
375380
}
376381

377-
if opts.output_type == output_type_llvm_assembly {
382+
if output_type == output_type_llvm_assembly {
378383
// Given options "-S --emit-llvm": output LLVM assembly
379384
str::as_c_str(output.to_str(), |buf_o| {
380385
llvm::LLVMRustAddPrintModulePass(pm.llpm, llmod, buf_o)});
@@ -390,6 +395,34 @@ pub mod write {
390395
if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
391396
}
392397
}
398+
399+
pub fn run_ndk(sess: Session, assembly: &Path, object: &Path) {
400+
let cc_prog: ~str = match &sess.opts.android_cross_path {
401+
&Some(copy path) => {
402+
fmt!("%s/bin/arm-linux-androideabi-gcc", path)
403+
}
404+
&None => {
405+
sess.fatal(~"need Android NDK path for building \
406+
(--android-cross-path)")
407+
}
408+
};
409+
let mut cc_args = ~[];
410+
cc_args.push(~"-c");
411+
cc_args.push(~"-o");
412+
cc_args.push(object.to_str());
413+
cc_args.push(assembly.to_str());
414+
415+
let prog = run::program_output(cc_prog, cc_args);
416+
417+
if prog.status != 0 {
418+
sess.err(fmt!("building with `%s` failed with code %d",
419+
cc_prog, prog.status));
420+
sess.note(fmt!("%s arguments: %s",
421+
cc_prog, str::connect(cc_args, ~" ")));
422+
sess.note(prog.err + prog.out);
423+
sess.abort_if_errors();
424+
}
425+
}
393426
}
394427
395428
@@ -833,9 +866,8 @@ pub fn link_binary(sess: Session,
833866
// to be found at compile time so it is still entirely up to outside
834867
// forces to make sure that library can be found at runtime.
835868
836-
for sess.opts.addl_lib_search_paths.each |path| {
837-
cc_args.push(~"-L" + path.to_str());
838-
}
869+
let addl_paths = /*bad*/copy sess.opts.addl_lib_search_paths;
870+
for addl_paths.each |path| { cc_args.push(~"-L" + path.to_str()); }
839871
840872
// The names of the extern libraries
841873
let used_libs = cstore::get_used_libraries(cstore);

branches/try/src/librustc/back/rpath.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path)
4545
// where rustrt is and we know every rust program needs it
4646
let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess));
4747

48-
let rpaths = get_rpaths(os, &sysroot, output, libs,
49-
sess.opts.target_triple);
48+
let target_triple = /*bad*/copy sess.opts.target_triple;
49+
let rpaths = get_rpaths(os, &sysroot, output, libs, target_triple);
5050
rpaths_to_flags(rpaths)
5151
}
5252

@@ -140,8 +140,8 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
140140
let abs2 = abs2.normalize();
141141
debug!("finding relative path from %s to %s",
142142
abs1.to_str(), abs2.to_str());
143-
let split1: &[~str] = abs1.components;
144-
let split2: &[~str] = abs2.components;
143+
let split1 = /*bad*/copy abs1.components;
144+
let split2 = /*bad*/copy abs2.components;
145145
let len1 = vec::len(split1);
146146
let len2 = vec::len(split2);
147147
fail_unless!(len1 > 0);

branches/try/src/librustc/driver/driver.rs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ pub fn build_configuration(sess: Session, +argv0: ~str, input: input) ->
132132
}
133133

134134
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
135-
fn parse_cfgspecs(+cfgspecs: ~[~str],
135+
fn parse_cfgspecs(cfgspecs: ~[~str],
136136
demitter: diagnostic::Emitter) -> ast::crate_cfg {
137-
do vec::map_consume(cfgspecs) |s| {
137+
let mut meta = ~[];
138+
for cfgspecs.each |s| {
138139
let sess = parse::new_parse_sess(Some(demitter));
139-
parse::parse_meta_from_source_str(~"cfgspec", @s, ~[], sess)
140+
let m = parse::parse_meta_from_source_str(~"cfgspec", @/*bad*/ copy *s, ~[], sess);
141+
meta.push(m)
140142
}
143+
return meta;
141144
}
142145

143146
pub enum input {
@@ -320,9 +323,23 @@ pub fn compile_rest(sess: Session, cfg: ast::crate_cfg,
320323

321324
};
322325

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

327344
let stop_after_codegen =
328345
sess.opts.output_type != link::output_type_exe ||
@@ -563,9 +580,9 @@ pub fn build_session_options(+binary: ~str,
563580
let debug_map = session::debugging_opts_map();
564581
for debug_flags.each |debug_flag| {
565582
let mut this_bit = 0u;
566-
for debug_map.each |tuple| {
567-
let (name, bit) = match *tuple { (ref a, _, b) => (a, b) };
568-
if name == debug_flag { this_bit = bit; break; }
583+
for debug_map.each |pair| {
584+
let (name, _, bit) = /*bad*/copy *pair;
585+
if name == *debug_flag { this_bit = bit; break; }
569586
}
570587
if this_bit == 0u {
571588
early_error(demitter, fmt!("unknown debug flag: %s", *debug_flag))
@@ -630,7 +647,7 @@ pub fn build_session_options(+binary: ~str,
630647
let target =
631648
match target_opt {
632649
None => host_triple(),
633-
Some(s) => s
650+
Some(ref s) => (/*bad*/copy *s)
634651
};
635652
636653
let addl_lib_search_paths =

branches/try/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/try/src/librustc/lib/llvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ pub struct TargetData {
16471647
dtor: @target_data_res
16481648
}
16491649

1650-
pub fn mk_target_data(string_rep: &str) -> TargetData {
1650+
pub fn mk_target_data(string_rep: ~str) -> TargetData {
16511651
let lltd =
16521652
str::as_c_str(string_rep, |buf| unsafe {
16531653
llvm::LLVMCreateTargetData(buf)

0 commit comments

Comments
 (0)