File tree 2 files changed +22
-6
lines changed
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ use indexmap::IndexSet;
20
20
pub ( crate ) use emit:: { DebugReloc , DebugRelocName } ;
21
21
pub ( crate ) use unwind:: UnwindContext ;
22
22
23
+ pub ( crate ) fn producer ( ) -> String {
24
+ format ! (
25
+ "cg_clif (rustc {}, cranelift {})" ,
26
+ rustc_interface:: util:: rustc_version_str( ) . unwrap_or( "unknown version" ) ,
27
+ cranelift_codegen:: VERSION ,
28
+ )
29
+ }
30
+
23
31
pub ( crate ) struct DebugContext {
24
32
endian : RunTimeEndian ,
25
33
@@ -57,11 +65,7 @@ impl DebugContext {
57
65
58
66
let mut dwarf = DwarfUnit :: new ( encoding) ;
59
67
60
- let producer = format ! (
61
- "cg_clif (rustc {}, cranelift {})" ,
62
- rustc_interface:: util:: rustc_version_str( ) . unwrap_or( "unknown version" ) ,
63
- cranelift_codegen:: VERSION ,
64
- ) ;
68
+ let producer = producer ( ) ;
65
69
let comp_dir = tcx
66
70
. sess
67
71
. opts
Original file line number Diff line number Diff line change @@ -169,10 +169,22 @@ fn emit_cgu(
169
169
fn emit_module (
170
170
output_filenames : & OutputFilenames ,
171
171
prof : & SelfProfilerRef ,
172
- object : cranelift_object:: object:: write:: Object < ' _ > ,
172
+ mut object : cranelift_object:: object:: write:: Object < ' _ > ,
173
173
kind : ModuleKind ,
174
174
name : String ,
175
175
) -> Result < CompiledModule , String > {
176
+ if object. format ( ) == cranelift_object:: object:: BinaryFormat :: Elf {
177
+ let comment_section = object. add_section (
178
+ Vec :: new ( ) ,
179
+ b".comment" . to_vec ( ) ,
180
+ cranelift_object:: object:: SectionKind :: OtherString ,
181
+ ) ;
182
+ let mut producer = vec ! [ 0 ] ;
183
+ producer. extend ( crate :: debuginfo:: producer ( ) . as_bytes ( ) ) ;
184
+ producer. push ( 0 ) ;
185
+ object. set_section_data ( comment_section, producer, 1 ) ;
186
+ }
187
+
176
188
let tmp_file = output_filenames. temp_path ( OutputType :: Object , Some ( & name) ) ;
177
189
let mut file = match File :: create ( & tmp_file) {
178
190
Ok ( file) => file,
You can’t perform that action at this time.
0 commit comments