Skip to content

Commit eee6ff4

Browse files
committed
---
yaml --- r: 207421 b: refs/heads/tmp c: f9846e9 h: refs/heads/master i: 207419: 757f0fd v: v3
1 parent ee2a65d commit eee6ff4

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
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: cd7d89af9169885642d43597302af69f842bbd78
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: a4ef308473f284a93d2d9f32763e09ba7424540b
35+
refs/heads/tmp: f9846e902dae169255c2d2b1766e7b9846488a89
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: 704c2ee730d2e948d11a2edd77e3f35de8329a6e
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/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/tmp/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/tmp/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)