@@ -18,7 +18,6 @@ use crate::builder::Builder;
18
18
use crate :: common;
19
19
use crate :: context:: CodegenCx ;
20
20
use crate :: llvm;
21
- use crate :: metadata;
22
21
use crate :: value:: Value ;
23
22
24
23
use rustc_codegen_ssa:: base:: maybe_create_entry_wrapper;
@@ -47,6 +46,21 @@ pub fn write_compressed_metadata<'tcx>(
47
46
use snap:: write:: FrameEncoder ;
48
47
use std:: io:: Write ;
49
48
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
+
50
64
let ( metadata_llcx, metadata_llmod) = ( & * llvm_module. llcx , llvm_module. llmod ( ) ) ;
51
65
let mut compressed = tcx. metadata_encoding_version ( ) ;
52
66
FrameEncoder :: new ( & mut compressed) . write_all ( & metadata. raw_data ) . unwrap ( ) ;
@@ -59,7 +73,6 @@ pub fn write_compressed_metadata<'tcx>(
59
73
unsafe { llvm:: LLVMAddGlobal ( metadata_llmod, common:: val_ty ( llconst) , buf. as_ptr ( ) ) } ;
60
74
unsafe {
61
75
llvm:: LLVMSetInitializer ( llglobal, llconst) ;
62
- let section_name = metadata:: metadata_section_name ( & tcx. sess . target ) ;
63
76
let name = SmallCStr :: new ( section_name) ;
64
77
llvm:: LLVMSetSection ( llglobal, name. as_ptr ( ) ) ;
65
78
0 commit comments