Skip to content

Commit f5d3883

Browse files
committed
Remove cg_llvm::metadata module
1 parent 267d55d commit f5d3883

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

compiler/rustc_codegen_llvm/src/base.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use crate::builder::Builder;
1818
use crate::common;
1919
use crate::context::CodegenCx;
2020
use crate::llvm;
21-
use crate::metadata;
2221
use crate::value::Value;
2322

2423
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
@@ -47,6 +46,21 @@ pub fn write_compressed_metadata<'tcx>(
4746
use snap::write::FrameEncoder;
4847
use std::io::Write;
4948

49+
// Historical note:
50+
//
51+
// When using link.exe it was seen that the section name `.note.rustc`
52+
// was getting shortened to `.note.ru`, and according to the PE and COFF
53+
// specification:
54+
//
55+
// > Executable images do not use a string table and do not support
56+
// > section names longer than 8 characters
57+
//
58+
// https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
59+
//
60+
// As a result, we choose a slightly shorter name! As to why
61+
// `.note.rustc` works on MinGW, that's another good question...
62+
let section_name = if tcx.sess.target.is_like_osx { "__DATA,.rustc" } else { ".rustc" };
63+
5064
let (metadata_llcx, metadata_llmod) = (&*llvm_module.llcx, llvm_module.llmod());
5165
let mut compressed = tcx.metadata_encoding_version();
5266
FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap();
@@ -59,7 +73,6 @@ pub fn write_compressed_metadata<'tcx>(
5973
unsafe { llvm::LLVMAddGlobal(metadata_llmod, common::val_ty(llconst), buf.as_ptr()) };
6074
unsafe {
6175
llvm::LLVMSetInitializer(llglobal, llconst);
62-
let section_name = metadata::metadata_section_name(&tcx.sess.target);
6376
let name = SmallCStr::new(section_name);
6477
llvm::LLVMSetSection(llglobal, name.as_ptr());
6578

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ pub mod llvm {
6969
}
7070

7171
mod llvm_util;
72-
mod metadata;
7372
mod mono_item;
7473
mod type_;
7574
mod type_of;

compiler/rustc_codegen_llvm/src/metadata.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)