Skip to content

Commit e769a81

Browse files
committed
---
yaml --- r: 272203 b: refs/heads/auto c: 18172d1 h: refs/heads/master i: 272201: 5d295c7 272199: e4e0959
1 parent cae6441 commit e769a81

File tree

17 files changed

+191
-60
lines changed

17 files changed

+191
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 45c4769920caf7e8099dcf0c9533b071e8dbbda8
11+
refs/heads/auto: 18172d1375274050fbe37acd9b3c884f2caaacb9
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/bootstrap/build/compile.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,38 @@ fn build_startup_objects(build: &Build, target: &str, into: &Path) {
123123
}
124124
}
125125

126+
/// Build libtest.
127+
///
128+
/// This will build libtest and supporting libraries for a particular stage of
129+
/// the build using the `compiler` targeting the `target` architecture. The
130+
/// artifacts created will also be linked into the sysroot directory.
131+
pub fn test<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
132+
println!("Building stage{} test artifacts ({} -> {})", compiler.stage,
133+
compiler.host, target);
134+
let out_dir = build.cargo_out(compiler, Mode::Libtest, target);
135+
build.clear_if_dirty(&out_dir, &libstd_shim(build, compiler, target));
136+
let mut cargo = build.cargo(compiler, Mode::Libtest, target, "build");
137+
cargo.arg("--manifest-path")
138+
.arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
139+
build.run(&mut cargo);
140+
test_link(build, target, compiler, compiler.host);
141+
}
142+
143+
/// Link all libtest rlibs/dylibs into the sysroot location.
144+
///
145+
/// Links those artifacts generated in the given `stage` for `target` produced
146+
/// by `compiler` into `host`'s sysroot.
147+
pub fn test_link(build: &Build,
148+
target: &str,
149+
compiler: &Compiler,
150+
host: &str) {
151+
let target_compiler = Compiler::new(compiler.stage, host);
152+
let libdir = build.sysroot_libdir(&target_compiler, target);
153+
let out_dir = build.cargo_out(compiler, Mode::Libtest, target);
154+
add_to_sysroot(&out_dir, &libdir);
155+
}
156+
157+
126158
/// Build the compiler.
127159
///
128160
/// This will build the compiler for a particular stage of the build using
@@ -133,7 +165,7 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
133165
compiler.stage, compiler.host, target);
134166

135167
let out_dir = build.cargo_out(compiler, Mode::Librustc, target);
136-
build.clear_if_dirty(&out_dir, &libstd_shim(build, compiler, target));
168+
build.clear_if_dirty(&out_dir, &libtest_shim(build, compiler, target));
137169

138170
let mut cargo = build.cargo(compiler, Mode::Librustc, target, "build");
139171
cargo.arg("--features").arg(build.rustc_features())
@@ -202,6 +234,12 @@ fn libstd_shim(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
202234
build.cargo_out(compiler, Mode::Libstd, target).join("libstd_shim.rlib")
203235
}
204236

237+
/// Cargo's output path for libtest in a given stage, compiled by a particular
238+
/// compiler for the specified target.
239+
fn libtest_shim(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
240+
build.cargo_out(compiler, Mode::Libtest, target).join("libtest_shim.rlib")
241+
}
242+
205243
fn compiler_file(compiler: &Path, file: &str) -> String {
206244
output(Command::new(compiler)
207245
.arg(format!("-print-file-name={}", file))).trim().to_string()

branches/auto/src/bootstrap/build/doc.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,22 @@ pub fn std(build: &Build, stage: u32, host: &str, out: &Path) {
122122
cp_r(&out_dir, out)
123123
}
124124

125+
pub fn test(build: &Build, stage: u32, host: &str, out: &Path) {
126+
println!("Documenting stage{} test ({})", stage, host);
127+
let compiler = Compiler::new(stage, host);
128+
let out_dir = build.stage_out(&compiler, Mode::Libtest)
129+
.join(host).join("doc");
130+
let rustdoc = build.rustdoc(&compiler);
131+
132+
build.clear_if_dirty(&out_dir, &rustdoc);
133+
134+
let mut cargo = build.cargo(&compiler, Mode::Libtest, host, "doc");
135+
cargo.arg("--manifest-path")
136+
.arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
137+
build.run(&mut cargo);
138+
cp_r(&out_dir, out)
139+
}
140+
125141
pub fn rustc(build: &Build, stage: u32, host: &str, out: &Path) {
126142
println!("Documenting stage{} compiler ({})", stage, host);
127143
let compiler = Compiler::new(stage, host);

branches/auto/src/bootstrap/build/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub struct Build {
8888

8989
pub enum Mode {
9090
Libstd,
91+
Libtest,
9192
Librustc,
9293
Tool,
9394
}
@@ -141,9 +142,13 @@ impl Build {
141142
return clean::clean(self);
142143
}
143144

145+
self.verbose("finding compilers");
144146
cc::find(self);
147+
self.verbose("running sanity check");
145148
sanity::check(self);
149+
self.verbose("collecting channel variables");
146150
channel::collect(self);
151+
self.verbose("updating submodules");
147152
self.update_submodules();
148153

149154
for target in step::all(self) {
@@ -158,12 +163,18 @@ impl Build {
158163
Libstd { compiler } => {
159164
compile::std(self, target.target, &compiler);
160165
}
166+
Libtest { compiler } => {
167+
compile::test(self, target.target, &compiler);
168+
}
161169
Librustc { compiler } => {
162170
compile::rustc(self, target.target, &compiler);
163171
}
164172
LibstdLink { compiler, host } => {
165173
compile::std_link(self, target.target, &compiler, host);
166174
}
175+
LibtestLink { compiler, host } => {
176+
compile::test_link(self, target.target, &compiler, host);
177+
}
167178
LibrustcLink { compiler, host } => {
168179
compile::rustc_link(self, target.target, &compiler, host);
169180
}
@@ -203,6 +214,9 @@ impl Build {
203214
DocStd { stage } => {
204215
doc::std(self, stage, target.target, &doc_out);
205216
}
217+
DocTest { stage } => {
218+
doc::test(self, stage, target.target, &doc_out);
219+
}
206220
DocRustc { stage } => {
207221
doc::rustc(self, stage, target.target, &doc_out);
208222
}
@@ -360,6 +374,7 @@ impl Build {
360374
let host = compiler.host;
361375
let paths = vec![
362376
self.cargo_out(compiler, Mode::Libstd, host).join("deps"),
377+
self.cargo_out(compiler, Mode::Libtest, host).join("deps"),
363378
self.cargo_out(compiler, Mode::Librustc, host).join("deps"),
364379
];
365380
add_lib_path(paths, &mut cmd);
@@ -414,7 +429,8 @@ impl Build {
414429
fn stage_out(&self, compiler: &Compiler, mode: Mode) -> PathBuf {
415430
let suffix = match mode {
416431
Mode::Libstd => "-std",
417-
_ => "-rustc",
432+
Mode::Libtest => "-test",
433+
Mode::Tool | Mode::Librustc => "-rustc",
418434
};
419435
self.out.join(compiler.host)
420436
.join(format!("stage{}{}", compiler.stage, suffix))

branches/auto/src/bootstrap/build/step.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,22 @@ macro_rules! targets {
2525
// compiler executable itself, not any of the support libraries
2626
(rustc, Rustc { stage: u32 }),
2727

28-
// Steps for the two main cargo builds, one for the standard library
29-
// and one for the compiler itself. These are parameterized over the
30-
// stage output they're going to be placed in along with the
31-
// compiler which is producing the copy of libstd or librustc
28+
// Steps for the two main cargo builds. These are parameterized over
29+
// the compiler which is producing the artifact.
3230
(libstd, Libstd { compiler: Compiler<'a> }),
31+
(libtest, Libtest { compiler: Compiler<'a> }),
3332
(librustc, Librustc { compiler: Compiler<'a> }),
3433

35-
// Links the standard library/librustc produced by the compiler
36-
// provided into the host's directory also provided.
34+
// Links the target produced by the compiler provided into the
35+
// host's directory also provided.
3736
(libstd_link, LibstdLink {
3837
compiler: Compiler<'a>,
3938
host: &'a str
4039
}),
40+
(libtest_link, LibtestLink {
41+
compiler: Compiler<'a>,
42+
host: &'a str
43+
}),
4144
(librustc_link, LibrustcLink {
4245
compiler: Compiler<'a>,
4346
host: &'a str
@@ -67,6 +70,7 @@ macro_rules! targets {
6770
(doc_style, DocStyle { stage: u32 }),
6871
(doc_standalone, DocStandalone { stage: u32 }),
6972
(doc_std, DocStd { stage: u32 }),
73+
(doc_test, DocTest { stage: u32 }),
7074
(doc_rustc, DocRustc { stage: u32 }),
7175
(doc_error_index, DocErrorIndex { stage: u32 }),
7276

@@ -162,10 +166,10 @@ fn top_level(build: &Build) -> Vec<Step> {
162166

163167
if host.target == build.config.build {
164168
targets.push(host.target(target)
165-
.libstd(host.compiler(stage)));
169+
.libtest(host.compiler(stage)));
166170
} else {
167171
targets.push(host.target(target)
168-
.libstd_link(t.compiler(stage), host.target));
172+
.libtest_link(t.compiler(stage), host.target));
169173
}
170174
}
171175
}
@@ -246,15 +250,21 @@ impl<'a> Step<'a> {
246250
vec![self.librustc(compiler)]
247251
}
248252
Source::Librustc { compiler } => {
249-
vec![self.libstd(compiler), self.llvm(())]
253+
vec![self.libtest(compiler), self.llvm(())]
254+
}
255+
Source::Libtest { compiler } => {
256+
vec![self.libstd(compiler)]
250257
}
251258
Source::Libstd { compiler } => {
252259
vec![self.compiler_rt(()),
253260
self.rustc(compiler.stage).target(compiler.host)]
254261
}
255262
Source::LibrustcLink { compiler, host } => {
256263
vec![self.librustc(compiler),
257-
self.libstd_link(compiler, host)]
264+
self.libtest_link(compiler, host)]
265+
}
266+
Source::LibtestLink { compiler, host } => {
267+
vec![self.libtest(compiler), self.libstd_link(compiler, host)]
258268
}
259269
Source::LibstdLink { compiler, host } => {
260270
vec![self.libstd(compiler),
@@ -267,6 +277,9 @@ impl<'a> Step<'a> {
267277
Source::DocStd { stage } => {
268278
vec![self.libstd(self.compiler(stage))]
269279
}
280+
Source::DocTest { stage } => {
281+
vec![self.libtest(self.compiler(stage))]
282+
}
270283
Source::DocBook { stage } |
271284
Source::DocNomicon { stage } |
272285
Source::DocStyle { stage } => {
@@ -279,7 +292,7 @@ impl<'a> Step<'a> {
279292
vec![self.rustc(stage)]
280293
}
281294
Source::DocRustc { stage } => {
282-
vec![self.doc_std(stage)]
295+
vec![self.doc_test(stage)]
283296
}
284297
Source::Doc { stage } => {
285298
vec![self.doc_book(stage), self.doc_nomicon(stage),
@@ -315,7 +328,7 @@ impl<'a> Step<'a> {
315328
vec![self.rustc(stage)]
316329
}
317330
Source::DistStd { compiler } => {
318-
vec![self.libstd(compiler)]
331+
vec![self.libtest(compiler)]
319332
}
320333

321334
Source::Dist { stage } => {

branches/auto/src/etc/tidy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'src/libcore',
3232
'src/libstd',
3333
'src/rustc/std_shim',
34+
'src/rustc/test_shim',
3435
'src/test'
3536
}
3637

branches/auto/src/liballoc/arc.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<T> Arc<T> {
223223
#[stable(feature = "arc_unique", since = "1.4.0")]
224224
pub fn try_unwrap(this: Self) -> Result<T, Self> {
225225
// See `drop` for why all these atomics are like this
226-
if this.inner().strong.compare_and_swap(1, 0, Release) != 1 {
226+
if this.inner().strong.compare_exchange(1, 0, Release, Relaxed).is_err() {
227227
return Err(this);
228228
}
229229

@@ -256,11 +256,11 @@ impl<T: ?Sized> Arc<T> {
256256
/// ```
257257
#[stable(feature = "arc_weak", since = "1.4.0")]
258258
pub fn downgrade(this: &Self) -> Weak<T> {
259-
loop {
260-
// This Relaxed is OK because we're checking the value in the CAS
261-
// below.
262-
let cur = this.inner().weak.load(Relaxed);
259+
// This Relaxed is OK because we're checking the value in the CAS
260+
// below.
261+
let mut cur = this.inner().weak.load(Relaxed);
263262

263+
loop {
264264
// check if the weak counter is currently "locked"; if so, spin.
265265
if cur == usize::MAX {
266266
continue;
@@ -273,8 +273,9 @@ impl<T: ?Sized> Arc<T> {
273273
// Unlike with Clone(), we need this to be an Acquire read to
274274
// synchronize with the write coming from `is_unique`, so that the
275275
// events prior to that write happen before this read.
276-
if this.inner().weak.compare_and_swap(cur, cur + 1, Acquire) == cur {
277-
return Weak { _ptr: this._ptr };
276+
match this.inner().weak.compare_exchange_weak(cur, cur + 1, Acquire, Relaxed) {
277+
Ok(_) => return Weak { _ptr: this._ptr },
278+
Err(old) => cur = old,
278279
}
279280
}
280281
}
@@ -416,7 +417,7 @@ impl<T: Clone> Arc<T> {
416417
// before release writes (i.e., decrements) to `strong`. Since we hold a
417418
// weak count, there's no chance the ArcInner itself could be
418419
// deallocated.
419-
if this.inner().strong.compare_and_swap(1, 0, Acquire) != 1 {
420+
if this.inner().strong.compare_exchange(1, 0, Acquire, Relaxed).is_err() {
420421
// Another strong pointer exists; clone
421422
*this = Arc::new((**this).clone());
422423
} else if this.inner().weak.load(Relaxed) != 1 {
@@ -506,7 +507,7 @@ impl<T: ?Sized> Arc<T> {
506507
// The acquire label here ensures a happens-before relationship with any
507508
// writes to `strong` prior to decrements of the `weak` count (via drop,
508509
// which uses Release).
509-
if self.inner().weak.compare_and_swap(1, usize::MAX, Acquire) == 1 {
510+
if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() {
510511
// Due to the previous acquire read, this will observe any writes to
511512
// `strong` that were due to upgrading weak pointers; only strong
512513
// clones remain, which require that the strong count is > 1 anyway.
@@ -618,12 +619,14 @@ impl<T: ?Sized> Weak<T> {
618619
// We use a CAS loop to increment the strong count instead of a
619620
// fetch_add because once the count hits 0 it must never be above 0.
620621
let inner = self.inner();
622+
623+
// Relaxed load because any write of 0 that we can observe
624+
// leaves the field in a permanently zero state (so a
625+
// "stale" read of 0 is fine), and any other value is
626+
// confirmed via the CAS below.
627+
let mut n = inner.strong.load(Relaxed);
628+
621629
loop {
622-
// Relaxed load because any write of 0 that we can observe
623-
// leaves the field in a permanently zero state (so a
624-
// "stale" read of 0 is fine), and any other value is
625-
// confirmed via the CAS below.
626-
let n = inner.strong.load(Relaxed);
627630
if n == 0 {
628631
return None;
629632
}
@@ -634,9 +637,9 @@ impl<T: ?Sized> Weak<T> {
634637
}
635638

636639
// Relaxed is valid for the same reason it is on Arc's Clone impl
637-
let old = inner.strong.compare_and_swap(n, n + 1, Relaxed);
638-
if old == n {
639-
return Some(Arc { _ptr: self._ptr });
640+
match inner.strong.compare_exchange_weak(n, n + 1, Relaxed, Relaxed) {
641+
Ok(_) => return Some(Arc { _ptr: self._ptr }),
642+
Err(old) => n = old,
640643
}
641644
}
642645
}

branches/auto/src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#![feature(unique)]
9191
#![feature(unsafe_no_drop_flag, filling_drop)]
9292
#![feature(unsize)]
93+
#![feature(extended_compare_and_swap)]
9394

9495
#![cfg_attr(not(test), feature(raw, fn_traits, placement_new_protocol))]
9596
#![cfg_attr(test, feature(test, box_heap))]

branches/auto/src/librustc/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ crate-type = ["dylib"]
1212
arena = { path = "../libarena" }
1313
flate = { path = "../libflate" }
1414
fmt_macros = { path = "../libfmt_macros" }
15-
getopts = { path = "../libgetopts" }
1615
graphviz = { path = "../libgraphviz" }
1716
log = { path = "../liblog" }
1817
rbml = { path = "../librbml" }

branches/auto/src/librustc_driver/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ crate-type = ["dylib"]
1111
[dependencies]
1212
arena = { path = "../libarena" }
1313
flate = { path = "../libflate" }
14-
getopts = { path = "../libgetopts" }
1514
graphviz = { path = "../libgraphviz" }
1615
log = { path = "../liblog" }
1716
rustc = { path = "../librustc" }

branches/auto/src/librustc_trans/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ crate-type = ["dylib"]
1111
[dependencies]
1212
arena = { path = "../libarena" }
1313
flate = { path = "../libflate" }
14-
getopts = { path = "../libgetopts" }
1514
graphviz = { path = "../libgraphviz" }
1615
log = { path = "../liblog" }
1716
rustc = { path = "../librustc" }

0 commit comments

Comments
 (0)