Skip to content

Commit 04f9d3c

Browse files
committed
---
yaml --- r: 225077 b: refs/heads/stable c: f9846e9 h: refs/heads/master i: 225075: 2b9a44a v: v3
1 parent 300d7d4 commit 04f9d3c

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: a4ef308473f284a93d2d9f32763e09ba7424540b
32+
refs/heads/stable: f9846e902dae169255c2d2b1766e7b9846488a89
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

branches/stable/src/librustc/metadata/loader.rs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ impl<'a> Context<'a> {
526526

527527
for (lib, kind) in m {
528528
info!("{} reading metadata from: {}", flavor, lib.display());
529-
let metadata = match get_metadata_section(self.target.options.is_like_osx,
530-
&lib) {
529+
let metadata = match get_metadata_section(self.target, &lib) {
531530
Ok(blob) => {
532531
if self.crate_matches(blob.as_slice(), &lib) {
533532
blob
@@ -715,17 +714,19 @@ impl ArchiveMetadata {
715714
}
716715

717716
// Just a small wrapper to time how long reading metadata takes.
718-
fn get_metadata_section(is_osx: bool, filename: &Path) -> Result<MetadataBlob, String> {
717+
fn get_metadata_section(target: &Target, filename: &Path)
718+
-> Result<MetadataBlob, String> {
719719
let mut ret = None;
720720
let dur = Duration::span(|| {
721-
ret = Some(get_metadata_section_imp(is_osx, filename));
721+
ret = Some(get_metadata_section_imp(target, filename));
722722
});
723723
info!("reading {:?} => {}ms", filename.file_name().unwrap(),
724724
dur.num_milliseconds());
725725
return ret.unwrap();;
726726
}
727727

728-
fn get_metadata_section_imp(is_osx: bool, filename: &Path) -> Result<MetadataBlob, String> {
728+
fn get_metadata_section_imp(target: &Target, filename: &Path)
729+
-> Result<MetadataBlob, String> {
729730
if !filename.exists() {
730731
return Err(format!("no such file: '{}'", filename.display()));
731732
}
@@ -769,7 +770,7 @@ fn get_metadata_section_imp(is_osx: bool, filename: &Path) -> Result<MetadataBlo
769770
name_len as usize).to_vec();
770771
let name = String::from_utf8(name).unwrap();
771772
debug!("get_metadata_section: name {}", name);
772-
if read_meta_section_name(is_osx) == name {
773+
if read_meta_section_name(target) == name {
773774
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
774775
let csz = llvm::LLVMGetSectionSize(si.llsi) as usize;
775776
let cvbuf: *const u8 = cbuf as *const u8;
@@ -799,26 +800,41 @@ fn get_metadata_section_imp(is_osx: bool, filename: &Path) -> Result<MetadataBlo
799800
}
800801
}
801802

802-
pub fn meta_section_name(is_osx: bool) -> &'static str {
803-
if is_osx {
803+
pub fn meta_section_name(target: &Target) -> &'static str {
804+
if target.options.is_like_osx {
804805
"__DATA,__note.rustc"
806+
} else if target.options.is_like_msvc {
807+
// When using link.exe it was seen that the section name `.note.rustc`
808+
// was getting shortened to `.note.ru`, and according to the PE and COFF
809+
// specification:
810+
//
811+
// > Executable images do not use a string table and do not support
812+
// > section names longer than 8 characters
813+
//
814+
// https://msdn.microsoft.com/en-us/library/windows/hardware/gg463119.aspx
815+
//
816+
// As a result, we choose a slightly shorter name! As to why
817+
// `.note.rustc` works on MinGW, that's another good question...
818+
".rustc"
805819
} else {
806820
".note.rustc"
807821
}
808822
}
809823

810-
pub fn read_meta_section_name(is_osx: bool) -> &'static str {
811-
if is_osx {
824+
pub fn read_meta_section_name(target: &Target) -> &'static str {
825+
if target.options.is_like_osx {
812826
"__note.rustc"
827+
} else if target.options.is_like_msvc {
828+
".rustc"
813829
} else {
814830
".note.rustc"
815831
}
816832
}
817833

818834
// A diagnostic function for dumping crate metadata to an output stream
819-
pub fn list_file_metadata(is_osx: bool, path: &Path,
835+
pub fn list_file_metadata(target: &Target, path: &Path,
820836
out: &mut io::Write) -> io::Result<()> {
821-
match get_metadata_section(is_osx, path) {
837+
match get_metadata_section(target, path) {
822838
Ok(bytes) => decoder::list_crate_metadata(bytes.as_slice(), out),
823839
Err(msg) => {
824840
write!(out, "{}\n", msg)

branches/stable/src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ impl RustcDefaultCalls {
402402
&Input::File(ref ifile) => {
403403
let path = &(*ifile);
404404
let mut v = Vec::new();
405-
metadata::loader::list_file_metadata(sess.target.target.options.is_like_osx,
405+
metadata::loader::list_file_metadata(&sess.target.target,
406406
path,
407407
&mut v).unwrap();
408408
println!("{}", String::from_utf8(v).unwrap());

branches/stable/src/librustc_trans/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,7 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate) -> Vec<u8> {
25272527
};
25282528
unsafe {
25292529
llvm::LLVMSetInitializer(llglobal, llconst);
2530-
let name = loader::meta_section_name(cx.sess().target.target.options.is_like_osx);
2530+
let name = loader::meta_section_name(&cx.sess().target.target);
25312531
let name = CString::new(name).unwrap();
25322532
llvm::LLVMSetSection(llglobal, name.as_ptr())
25332533
}

0 commit comments

Comments
 (0)