Skip to content

Commit 777f1e8

Browse files
committed
auto merge of #11355 : alexcrichton/rust/read-waits-forever, r=brson
All the fun is down below.
2 parents 07950e7 + 89f8bc2 commit 777f1e8

File tree

4 files changed

+47
-29
lines changed

4 files changed

+47
-29
lines changed

mk/target.mk

+20-24
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,22 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)): \
5454
@$$(call E, cp: $$@)
5555
$$(Q)cp $$< $$@
5656

57+
# SNAP a5fa1d9 remove this after the stage0 snapshot from rules below
58+
ifeq ($(1),0)
59+
LFLAGS_$(1)_$(2)_$(3) := -L $$(TLIB$(1)_T_$(2)_H_$(3))
60+
else
61+
LFLAGS_$(1)_$(2)_$(3) :=
62+
endif
63+
5764
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
5865
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
5966
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
6067
| $$(TLIB$(1)_T_$(2)_H_$(3))/
6168
@$$(call E, compile_and_link: $$@)
62-
ifeq ($(1),0)
63-
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
64-
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
65-
endif
6669
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
6770
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
68-
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
71+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $$(LFLAGS_$(1)_$(2)_$(3)) \
72+
--out-dir $$(@D) $$< && touch $$@
6973
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
7074
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
7175

@@ -75,13 +79,10 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
7579
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
7680
| $$(TLIB$(1)_T_$(2)_H_$(3))/
7781
@$$(call E, compile_and_link: $$@)
78-
ifeq ($(1),0)
79-
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
80-
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
81-
endif
8282
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
8383
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
84-
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
84+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $$(LFLAGS_$(1)_$(2)_$(3)) \
85+
--out-dir $$(@D) $$< && touch $$@
8586
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
8687
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
8788

@@ -98,6 +99,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2)): \
9899
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
99100
-L $$(UV_SUPPORT_DIR_$(2)) \
100101
-L $$(dir $$(LIBUV_LIB_$(2))) \
102+
$$(LFLAGS_$(1)_$(2)_$(3)) \
101103
--out-dir $$(@D) $$< && touch $$@
102104
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
103105
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(2)),$$(notdir $$@))
@@ -111,6 +113,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBGREEN_$(2)): \
111113
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBGREEN_GLOB_$(2)),$$(notdir $$@))
112114
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBGREEN_RGLOB_$(2)),$$(notdir $$@))
113115
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
116+
$$(LFLAGS_$(1)_$(2)_$(3)) \
114117
--out-dir $$(@D) $$< && touch $$@
115118
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBGREEN_GLOB_$(2)),$$(notdir $$@))
116119
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBGREEN_RGLOB_$(2)),$$(notdir $$@))
@@ -124,6 +127,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBNATIVE_$(2)): \
124127
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBNATIVE_GLOB_$(2)),$$(notdir $$@))
125128
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBNATIVE_RGLOB_$(2)),$$(notdir $$@))
126129
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
130+
$$(LFLAGS_$(1)_$(2)_$(3)) \
127131
--out-dir $$(@D) $$< && touch $$@
128132
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBNATIVE_GLOB_$(2)),$$(notdir $$@))
129133
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBNATIVE_RGLOB_$(2)),$$(notdir $$@))
@@ -135,13 +139,11 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
135139
$$(TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
136140
| $$(TLIB$(1)_T_$(2)_H_$(3))/
137141
@$$(call E, compile_and_link: $$@)
138-
ifeq ($(1),0)
139-
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
140-
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
141-
endif
142142
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
143143
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_RGLOB_$(2)),$$(notdir $$@))
144-
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $(BORROWCK) --out-dir $$(@D) $$< && touch $$@
144+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $(BORROWCK) \
145+
$$(LFLAGS_$(1)_$(2)_$(3)) \
146+
--out-dir $$(@D) $$< && touch $$@
145147
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
146148
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_RGLOB_$(2)),$$(notdir $$@))
147149

@@ -164,14 +166,11 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
164166
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
165167
| $$(TLIB$(1)_T_$(2)_H_$(3))/
166168
@$$(call E, compile_and_link: $$@)
167-
ifeq ($(1),0)
168-
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
169-
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
170-
endif
171169
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
172170
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_RGLOB_$(2)),$$(notdir $$@))
173171
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
174172
-L "$$(LLVM_LIBDIR_$(2))" \
173+
$$(LFLAGS_$(1)_$(2)_$(3)) \
175174
--out-dir $$(@D) $$< && touch $$@
176175
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
177176
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_RGLOB_$(2)),$$(notdir $$@))
@@ -182,11 +181,8 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \
182181
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)) \
183182
| $$(TBIN$(1)_T_$(2)_H_$(3))/
184183
@$$(call E, compile_and_link: $$@)
185-
ifeq ($(1),0)
186-
$$(Q)cp $(3)/stage0/$(CFG_LIBDIR)/rustlib/$(2)/$(CFG_LIBDIR)/* \
187-
$(3)/stage0/$(CFG_LIBDIR)/rustc/$(2)/$(CFG_LIBDIR)/
188-
endif
189-
$$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$<
184+
$$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$< \
185+
$$(LFLAGS_$(1)_$(2)_$(3))
190186
ifdef CFG_ENABLE_PAX_FLAGS
191187
@$$(call E, apply PaX flags: $$@)
192188
@"$(CFG_PAXCTL)" -cm "$$@"

src/libnative/io/file.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ impl FileDesc {
7979
pub fn inner_read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
8080
#[cfg(windows)] type rlen = libc::c_uint;
8181
#[cfg(not(windows))] type rlen = libc::size_t;
82-
let ret = keep_going(buf, |buf, len| {
83-
unsafe {
84-
libc::read(self.fd, buf as *mut libc::c_void, len as rlen) as i64
85-
}
82+
let ret = retry(|| unsafe {
83+
libc::read(self.fd,
84+
buf.as_ptr() as *mut libc::c_void,
85+
buf.len() as rlen) as libc::c_int
8686
});
8787
if ret == 0 {
8888
Err(io::standard_error(io::EndOfFile))

src/libnative/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub mod io;
3434
pub mod task;
3535

3636
// XXX: this should not exist here
37-
#[cfg(stage0)]
37+
#[cfg(stage0, nativestart)]
3838
#[lang = "start"]
3939
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
4040
use std::cast;

src/libstd/io/pipe.rs

+22
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,25 @@ impl Writer for PipeStream {
8080
}
8181
}
8282
}
83+
84+
#[cfg(test)]
85+
mod test {
86+
iotest!(fn partial_read() {
87+
use os;
88+
use io::pipe::PipeStream;
89+
90+
let os::Pipe { input, out } = os::pipe();
91+
let out = PipeStream::open(out);
92+
let mut input = PipeStream::open(input);
93+
let (p, c) = Chan::new();
94+
do spawn {
95+
let mut out = out;
96+
out.write([10]);
97+
p.recv(); // don't close the pipe until the other read has finished
98+
}
99+
100+
let mut buf = [0, ..10];
101+
input.read(buf);
102+
c.send(());
103+
})
104+
}

0 commit comments

Comments
 (0)