Skip to content

Commit 536f90f

Browse files
committed
---
yaml --- r: 114576 b: refs/heads/master c: 3b56724 h: refs/heads/master v: v3
1 parent 6280c33 commit 536f90f

File tree

12 files changed

+102
-224
lines changed

12 files changed

+102
-224
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: cb3c4f9c8293cf792bff887ff170f8c774ac8457
2+
refs/heads/master: 3b56724c217612b4adc64a59dca9b1fd8cff081d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ opt optimize 1 "build optimized rust code"
406406
opt optimize-cxx 1 "build optimized C++ code"
407407
opt optimize-llvm 1 "build optimized LLVM"
408408
opt optimize-tests 1 "build tests with optimizations"
409-
opt libcpp 1 "build with clang's libcpp"
409+
opt libcpp 1 "build with llvm with libc++ instead of libstdc++ when using clang"
410410
opt llvm-assertions 1 "build LLVM with assertions"
411411
opt debug 1 "build with extra debug fun"
412412
opt ratchet-bench 0 "ratchet benchmarks"
@@ -1136,7 +1136,7 @@ do
11361136
CXXFLAGS=$LLVM_CXXFLAGS
11371137
LDFLAGS=$LLVM_LDFLAGS
11381138

1139-
if [ "$CFG_DISABLE_LIBCPP" != 1 ]; then
1139+
if [ "$CFG_DISABLE_LIBCPP" != 1 ] && [ "$CFG_USING_CLANG" == 1 ]; then
11401140
LLVM_OPTS="$LLVM_OPTS --enable-libcpp"
11411141
fi
11421142

trunk/mk/docs.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ $(foreach crate,$(COMPILER_DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),COMPIL
287287
ifdef CFG_DISABLE_DOCS
288288
$(info cfg: disabling doc build (CFG_DISABLE_DOCS))
289289
DOC_TARGETS :=
290-
COMPILER_DOC_TARGETS :=
291290
endif
292291

293292
docs: $(DOC_TARGETS)

trunk/src/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ trait Circle : Shape { fn radius() -> f64; }
14351435
~~~~
14361436

14371437
the syntax `Circle : Shape` means that types that implement `Circle` must also have an implementation for `Shape`.
1438-
Multiple supertraits are separated by `+`, `trait Circle : Shape + Eq { }`.
1438+
Multiple supertraits are separated by spaces, `trait Circle : Shape Eq { }`.
14391439
In an implementation of `Circle` for a given type `T`, methods can refer to `Shape` methods,
14401440
since the typechecker checks that any type with an implementation of `Circle` also has an implementation of `Shape`.
14411441

trunk/src/libcore/failure.rs

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,13 @@
2828
2929
#![allow(dead_code, missing_doc)]
3030

31-
use fmt;
32-
use intrinsics;
33-
#[cfg(not(test), stage0)]
31+
#[cfg(not(test))]
3432
use str::raw::c_str_to_static_slice;
33+
use fmt;
3534

3635
#[cold] #[inline(never)] // this is the slow path, always
3736
#[lang="fail_"]
38-
#[cfg(not(test), not(stage0))]
39-
fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
40-
format_args!(|args| -> () {
41-
begin_unwind(args, file, line);
42-
}, "{}", expr);
43-
44-
unsafe { intrinsics::abort() }
45-
}
46-
47-
#[cold] #[inline(never)] // this is the slow path, always
48-
#[lang="fail_"]
49-
#[cfg(not(test), stage0)]
37+
#[cfg(not(test))]
5038
fn fail_(expr: *u8, file: *u8, line: uint) -> ! {
5139
unsafe {
5240
let expr = c_str_to_static_slice(expr as *i8);
@@ -55,30 +43,19 @@ fn fail_(expr: *u8, file: *u8, line: uint) -> ! {
5543
begin_unwind(args, file, line);
5644
}, "{}", expr);
5745

58-
intrinsics::abort()
46+
loop {}
5947
}
6048
}
6149

6250
#[cold]
6351
#[lang="fail_bounds_check"]
64-
#[cfg(not(test), not(stage0))]
65-
fn fail_bounds_check(file: &'static str, line: uint,
66-
index: uint, len: uint) -> ! {
67-
format_args!(|args| -> () {
68-
begin_unwind(args, file, line);
69-
}, "index out of bounds: the len is {} but the index is {}", len, index);
70-
unsafe { intrinsics::abort() }
71-
}
72-
73-
#[cold]
74-
#[lang="fail_bounds_check"]
75-
#[cfg(not(test), stage0)]
52+
#[cfg(not(test))]
7653
fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! {
7754
let file = unsafe { c_str_to_static_slice(file as *i8) };
7855
format_args!(|args| -> () {
7956
begin_unwind(args, file, line);
8057
}, "index out of bounds: the len is {} but the index is {}", len, index);
81-
unsafe { intrinsics::abort() }
58+
loop {}
8259
}
8360

8461
#[cold]

trunk/src/liblibc/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ pub use funcs::bsd43::{shutdown};
235235
#[cfg(windows)] pub use types::os::arch::extra::{LARGE_INTEGER, LPVOID, LONG};
236236
#[cfg(windows)] pub use types::os::arch::extra::{time64_t, OVERLAPPED, LPCWSTR};
237237
#[cfg(windows)] pub use types::os::arch::extra::{LPOVERLAPPED, SIZE_T, LPDWORD};
238-
#[cfg(windows)] pub use types::os::arch::extra::{SECURITY_ATTRIBUTES};
239238
#[cfg(windows)] pub use funcs::c95::string::{wcslen};
240239
#[cfg(windows)] pub use funcs::posix88::stat_::{wstat, wutime, wchmod, wrmdir};
241240
#[cfg(windows)] pub use funcs::bsd43::{closesocket};
@@ -1141,12 +1140,8 @@ pub mod types {
11411140
pub type LPWCH = *mut WCHAR;
11421141
pub type LPCH = *mut CHAR;
11431142

1144-
pub struct SECURITY_ATTRIBUTES {
1145-
pub nLength: DWORD,
1146-
pub lpSecurityDescriptor: LPVOID,
1147-
pub bInheritHandle: BOOL,
1148-
}
1149-
pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
1143+
// Not really, but opaque to us.
1144+
pub type LPSECURITY_ATTRIBUTES = LPVOID;
11501145

11511146
pub type LPVOID = *mut c_void;
11521147
pub type LPCVOID = *c_void;

trunk/src/libnative/io/process.rs

Lines changed: 52 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ struct SpawnProcessResult {
244244
}
245245

246246
#[cfg(windows)]
247-
fn spawn_process_os(cfg: ProcessConfig,
248-
in_fd: c_int, out_fd: c_int, err_fd: c_int)
247+
fn spawn_process_os(cfg: ProcessConfig, in_fd: c_int, out_fd: c_int, err_fd: c_int)
249248
-> IoResult<SpawnProcessResult> {
250249
use libc::types::os::arch::extra::{DWORD, HANDLE, STARTUPINFO};
251250
use libc::consts::os::extra::{
@@ -279,51 +278,38 @@ fn spawn_process_os(cfg: ProcessConfig,
279278

280279
let cur_proc = GetCurrentProcess();
281280

282-
// Similarly to unix, we don't actually leave holes for the stdio file
283-
// descriptors, but rather open up /dev/null equivalents. These
284-
// equivalents are drawn from libuv's windows process spawning.
285-
let set_fd = |fd: c_int, slot: &mut HANDLE, is_stdin: bool| {
286-
if fd == -1 {
287-
let access = if is_stdin {
288-
libc::FILE_GENERIC_READ
289-
} else {
290-
libc::FILE_GENERIC_WRITE | libc::FILE_READ_ATTRIBUTES
291-
};
292-
let size = mem::size_of::<libc::SECURITY_ATTRIBUTES>();
293-
let mut sa = libc::SECURITY_ATTRIBUTES {
294-
nLength: size as libc::DWORD,
295-
lpSecurityDescriptor: ptr::mut_null(),
296-
bInheritHandle: 1,
297-
};
298-
*slot = os::win32::as_utf16_p("NUL", |filename| {
299-
libc::CreateFileW(filename,
300-
access,
301-
libc::FILE_SHARE_READ |
302-
libc::FILE_SHARE_WRITE,
303-
&mut sa,
304-
libc::OPEN_EXISTING,
305-
0,
306-
ptr::mut_null())
307-
});
308-
if *slot == INVALID_HANDLE_VALUE as libc::HANDLE {
309-
return Err(super::last_error())
310-
}
311-
} else {
312-
let orig = get_osfhandle(fd) as HANDLE;
313-
if orig == INVALID_HANDLE_VALUE as HANDLE {
314-
return Err(super::last_error())
315-
}
316-
if DuplicateHandle(cur_proc, orig, cur_proc, slot,
317-
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
318-
return Err(super::last_error())
319-
}
281+
if in_fd != -1 {
282+
let orig_std_in = get_osfhandle(in_fd) as HANDLE;
283+
if orig_std_in == INVALID_HANDLE_VALUE as HANDLE {
284+
fail!("failure in get_osfhandle: {}", os::last_os_error());
285+
}
286+
if DuplicateHandle(cur_proc, orig_std_in, cur_proc, &mut si.hStdInput,
287+
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
288+
fail!("failure in DuplicateHandle: {}", os::last_os_error());
289+
}
290+
}
291+
292+
if out_fd != -1 {
293+
let orig_std_out = get_osfhandle(out_fd) as HANDLE;
294+
if orig_std_out == INVALID_HANDLE_VALUE as HANDLE {
295+
fail!("failure in get_osfhandle: {}", os::last_os_error());
296+
}
297+
if DuplicateHandle(cur_proc, orig_std_out, cur_proc, &mut si.hStdOutput,
298+
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
299+
fail!("failure in DuplicateHandle: {}", os::last_os_error());
320300
}
321-
Ok(())
322-
};
301+
}
323302

324-
try!(set_fd(in_fd, &mut si.hStdInput, true));
325-
try!(set_fd(out_fd, &mut si.hStdOutput, false));
326-
try!(set_fd(err_fd, &mut si.hStdError, false));
303+
if err_fd != -1 {
304+
let orig_std_err = get_osfhandle(err_fd) as HANDLE;
305+
if orig_std_err == INVALID_HANDLE_VALUE as HANDLE {
306+
fail!("failure in get_osfhandle: {}", os::last_os_error());
307+
}
308+
if DuplicateHandle(cur_proc, orig_std_err, cur_proc, &mut si.hStdError,
309+
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
310+
fail!("failure in DuplicateHandle: {}", os::last_os_error());
311+
}
312+
}
327313

328314
let cmd_str = make_command_line(cfg.program, cfg.args);
329315
let mut pi = zeroed_process_information();
@@ -352,9 +338,9 @@ fn spawn_process_os(cfg: ProcessConfig,
352338
})
353339
});
354340

355-
assert!(CloseHandle(si.hStdInput) != 0);
356-
assert!(CloseHandle(si.hStdOutput) != 0);
357-
assert!(CloseHandle(si.hStdError) != 0);
341+
if in_fd != -1 { assert!(CloseHandle(si.hStdInput) != 0); }
342+
if out_fd != -1 { assert!(CloseHandle(si.hStdOutput) != 0); }
343+
if err_fd != -1 { assert!(CloseHandle(si.hStdError) != 0); }
358344

359345
match create_err {
360346
Some(err) => return Err(err),
@@ -393,9 +379,9 @@ fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO {
393379
wShowWindow: 0,
394380
cbReserved2: 0,
395381
lpReserved2: ptr::mut_null(),
396-
hStdInput: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
397-
hStdOutput: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
398-
hStdError: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
382+
hStdInput: ptr::mut_null(),
383+
hStdOutput: ptr::mut_null(),
384+
hStdError: ptr::mut_null()
399385
}
400386
}
401387

@@ -503,10 +489,6 @@ fn spawn_process_os(cfg: ProcessConfig, in_fd: c_int, out_fd: c_int, err_fd: c_i
503489
let mut input = file::FileDesc::new(pipe.input, true);
504490
let mut output = file::FileDesc::new(pipe.out, true);
505491

506-
// We may use this in the child, so perform allocations before the
507-
// fork
508-
let devnull = "/dev/null".to_c_str();
509-
510492
set_cloexec(output.fd());
511493

512494
let pid = fork();
@@ -581,29 +563,21 @@ fn spawn_process_os(cfg: ProcessConfig, in_fd: c_int, out_fd: c_int, err_fd: c_i
581563

582564
rustrt::rust_unset_sigprocmask();
583565

584-
// If a stdio file descriptor is set to be ignored (via a -1 file
585-
// descriptor), then we don't actually close it, but rather open
586-
// up /dev/null into that file descriptor. Otherwise, the first file
587-
// descriptor opened up in the child would be numbered as one of the
588-
// stdio file descriptors, which is likely to wreak havoc.
589-
let setup = |src: c_int, dst: c_int| {
590-
let src = if src == -1 {
591-
let flags = if dst == libc::STDIN_FILENO {
592-
libc::O_RDONLY
593-
} else {
594-
libc::O_RDWR
595-
};
596-
devnull.with_ref(|p| libc::open(p, flags, 0))
597-
} else {
598-
src
599-
};
600-
src != -1 && retry(|| dup2(src, dst)) != -1
601-
};
602-
603-
if !setup(in_fd, libc::STDIN_FILENO) { fail(&mut output) }
604-
if !setup(out_fd, libc::STDOUT_FILENO) { fail(&mut output) }
605-
if !setup(err_fd, libc::STDERR_FILENO) { fail(&mut output) }
606-
566+
if in_fd == -1 {
567+
let _ = libc::close(libc::STDIN_FILENO);
568+
} else if retry(|| dup2(in_fd, 0)) == -1 {
569+
fail(&mut output);
570+
}
571+
if out_fd == -1 {
572+
let _ = libc::close(libc::STDOUT_FILENO);
573+
} else if retry(|| dup2(out_fd, 1)) == -1 {
574+
fail(&mut output);
575+
}
576+
if err_fd == -1 {
577+
let _ = libc::close(libc::STDERR_FILENO);
578+
} else if retry(|| dup2(err_fd, 2)) == -1 {
579+
fail(&mut output);
580+
}
607581
// close all other fds
608582
for fd in range(3, getdtablesize()).rev() {
609583
if fd != output.fd() {

trunk/src/librustc/back/link.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,6 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
10191019
a.add_native_library("compiler-rt").unwrap();
10201020

10211021
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
1022-
let mut all_native_libs = vec![];
1023-
10241022
for &(cnum, ref path) in crates.iter() {
10251023
let name = sess.cstore.get_crate_data(cnum).name.clone();
10261024
let p = match *path {
@@ -1031,25 +1029,17 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
10311029
}
10321030
};
10331031
a.add_rlib(&p, name.as_slice(), sess.lto()).unwrap();
1034-
10351032
let native_libs = csearch::get_native_libraries(&sess.cstore, cnum);
1036-
all_native_libs.extend(native_libs.move_iter());
1037-
}
1038-
1039-
if !all_native_libs.is_empty() {
1040-
sess.warn("link against the following native artifacts when linking against \
1041-
this static library");
1042-
sess.note("the order and any duplication can be significant on some platforms, \
1043-
and so may need to be preserved");
1044-
}
1045-
1046-
for &(kind, ref lib) in all_native_libs.iter() {
1047-
let name = match kind {
1048-
cstore::NativeStatic => "static library",
1049-
cstore::NativeUnknown => "library",
1050-
cstore::NativeFramework => "framework",
1051-
};
1052-
sess.note(format!("{}: {}", name, *lib).as_slice());
1033+
for &(kind, ref lib) in native_libs.iter() {
1034+
let name = match kind {
1035+
cstore::NativeStatic => "static library",
1036+
cstore::NativeUnknown => "library",
1037+
cstore::NativeFramework => "framework",
1038+
};
1039+
sess.warn(format!("unlinked native {}: {}",
1040+
name,
1041+
*lib).as_slice());
1042+
}
10531043
}
10541044
}
10551045

trunk/src/librustc/middle/trans/common.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
596596
pub fn C_str_slice(cx: &CrateContext, s: InternedString) -> ValueRef {
597597
unsafe {
598598
let len = s.get().len();
599-
let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s, false),
600-
Type::i8p(cx).to_ref());
599+
let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s, false), Type::i8p(cx).to_ref());
601600
C_struct(cx, [cs, C_uint(cx, len)], false)
602601
}
603602
}
@@ -844,6 +843,19 @@ pub fn find_vtable(tcx: &ty::ctxt,
844843
param_bounds.get(n_bound).clone()
845844
}
846845

846+
pub fn filename_and_line_num_from_span(bcx: &Block, span: Span)
847+
-> (ValueRef, ValueRef) {
848+
let loc = bcx.sess().codemap().lookup_char_pos(span.lo);
849+
let filename_cstr = C_cstr(bcx.ccx(),
850+
token::intern_and_get_ident(loc.file
851+
.name
852+
.as_slice()),
853+
true);
854+
let filename = build::PointerCast(bcx, filename_cstr, Type::i8p(bcx.ccx()));
855+
let line = C_int(bcx.ccx(), loc.line as int);
856+
(filename, line)
857+
}
858+
847859
// Casts a Rust bool value to an i1.
848860
pub fn bool_to_i1(bcx: &Block, llval: ValueRef) -> ValueRef {
849861
build::ICmp(bcx, lib::llvm::IntNE, llval, C_bool(bcx.ccx(), false))

0 commit comments

Comments
 (0)