Skip to content

Commit cf1e4d1

Browse files
committed
---
yaml --- r: 153535 b: refs/heads/try2 c: 82fb85a h: refs/heads/master i: 153533: e13ec0b 153531: 01ec17f 153527: d0fee91 153519: 4a4ce49 153503: 174510d 153471: 5abe9dc v: v3
1 parent 3bd273d commit cf1e4d1

File tree

9 files changed

+42
-17
lines changed

9 files changed

+42
-17
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: 50868db351d5261346afe855f88235d044b80195
8+
refs/heads/try2: 82fb85a15223bf2e7345197bbbc96c399292d54f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,9 @@ pub fn find_crate_name(sess: Option<&Session>,
571571
};
572572

573573
// Look in attributes 100% of the time to make sure the attribute is marked
574-
// as used. After doing this, however, favor crate names from the command
575-
// line.
574+
// as used. After doing this, however, we still prioritize a crate name from
575+
// the command line over one found in the #[crate_name] attribute. If we
576+
// find both we ensure that they're the same later on as well.
576577
let attr_crate_name = attrs.iter().find(|at| at.check_name("crate_name"))
577578
.and_then(|at| at.value_str().map(|s| (at, s)));
578579

@@ -1558,7 +1559,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
15581559
add_dynamic_crate(cmd, sess, src.dylib.unwrap())
15591560
}
15601561
cstore::RequireStatic => {
1561-
add_static_crate(cmd, sess, tmpdir, cnum, src.rlib.unwrap())
1562+
add_static_crate(cmd, sess, tmpdir, src.rlib.unwrap())
15621563
}
15631564
}
15641565

@@ -1575,7 +1576,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
15751576

15761577
// Adds the static "rlib" versions of all crates to the command line.
15771578
fn add_static_crate(cmd: &mut Command, sess: &Session, tmpdir: &Path,
1578-
cnum: ast::CrateNum, cratepath: Path) {
1579+
cratepath: Path) {
15791580
// When performing LTO on an executable output, all of the
15801581
// bytecode from the upstream libraries has already been
15811582
// included in our object file output. We need to modify all of
@@ -1591,7 +1592,8 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
15911592
// If we're not doing LTO, then our job is simply to just link
15921593
// against the archive.
15931594
if sess.lto() {
1594-
let name = sess.cstore.get_crate_data(cnum).name.clone();
1595+
let name = cratepath.filename_str().unwrap();
1596+
let name = name.slice(3, name.len() - 5); // chop off lib/.rlib
15951597
time(sess.time_passes(),
15961598
format!("altering {}.rlib", name).as_slice(),
15971599
(), |()| {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,19 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
5454
};
5555

5656
let archive = ArchiveRO::open(&path).expect("wanted an rlib");
57-
debug!("reading {}", name);
57+
let file = path.filename_str().unwrap();
58+
let file = file.slice(3, file.len() - 5); // chop off lib/.rlib
59+
debug!("reading {}", file);
5860
let bc = time(sess.time_passes(),
5961
format!("read {}.bytecode.deflate", name).as_slice(),
6062
(),
6163
|_| {
6264
archive.read(format!("{}.bytecode.deflate",
63-
name).as_slice())
65+
file).as_slice())
6466
});
6567
let bc = bc.expect("missing compressed bytecode in archive!");
6668
let bc = time(sess.time_passes(),
67-
format!("inflate {}.bc", name).as_slice(),
69+
format!("inflate {}.bc", file).as_slice(),
6870
(),
6971
|_| {
7072
match flate::inflate_bytes(bc) {

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ pub struct OutputFilenames {
936936
pub out_directory: Path,
937937
pub out_filestem: String,
938938
pub single_output_file: Option<Path>,
939+
extra: String,
939940
}
940941

941942
impl OutputFilenames {
@@ -948,7 +949,7 @@ impl OutputFilenames {
948949
}
949950

950951
pub fn temp_path(&self, flavor: link::OutputType) -> Path {
951-
let base = self.out_directory.join(self.out_filestem.as_slice());
952+
let base = self.out_directory.join(self.filestem());
952953
match flavor {
953954
link::OutputTypeBitcode => base.with_extension("bc"),
954955
link::OutputTypeAssembly => base.with_extension("s"),
@@ -959,8 +960,11 @@ impl OutputFilenames {
959960
}
960961

961962
pub fn with_extension(&self, extension: &str) -> Path {
962-
let stem = self.out_filestem.as_slice();
963-
self.out_directory.join(stem).with_extension(extension)
963+
self.out_directory.join(self.filestem()).with_extension(extension)
964+
}
965+
966+
fn filestem(&self) -> String {
967+
format!("{}{}", self.out_filestem, self.extra)
964968
}
965969
}
966970

@@ -1000,6 +1004,7 @@ pub fn build_output_filenames(input: &Input,
10001004
out_directory: dirpath,
10011005
out_filestem: stem,
10021006
single_output_file: None,
1007+
extra: sess.opts.cg.extra_filename.clone(),
10031008
}
10041009
}
10051010

@@ -1018,6 +1023,7 @@ pub fn build_output_filenames(input: &Input,
10181023
out_directory: out_file.dir_path(),
10191024
out_filestem: out_file.filestem_str().unwrap().to_string(),
10201025
single_output_file: ofile,
1026+
extra: sess.opts.cg.extra_filename.clone(),
10211027
}
10221028
}
10231029
}

branches/try2/src/test/compile-fail/crate-name-mismatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-args: --crate-name foo
11+
// compile-flags: --crate-name foo
1212

1313
#![crate_name = "bar"]
1414
//~^ ERROR: --crate-name and #[crate_name] are required to match, but `foo` != `bar`

branches/try2/src/test/run-make/crate-name-priority/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@ all:
77
rm $(TMPDIR)/$(call BIN,bar)
88
$(RUSTC) foo1.rs
99
rm $(TMPDIR)/$(call BIN,foo)
10-
$(RUSTC) foo1.rs --crate-name bar
11-
rm $(TMPDIR)/$(call BIN,bar)
12-
$(RUSTC) foo1.rs --crate-name bar -o $(TMPDIR)/bar1
10+
$(RUSTC) foo1.rs -o $(TMPDIR)/bar1
1311
rm $(TMPDIR)/$(call BIN,bar1)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) -C extra-filename=bar foo.rs -C save-temps
5+
rm $(TMPDIR)/foobar.o
6+
rm $(TMPDIR)/$(call BIN,foobar)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {}

branches/try2/src/test/run-pass/crate-name-attr-used.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
// compile-flags:--crate-name crate-name-attr-used -F unused-attribute
1212

13-
#![crate_name = "test"]
13+
#![crate_name = "crate-name-attr-used"]
1414

1515
fn main() {}

0 commit comments

Comments
 (0)