@@ -16,6 +16,7 @@ use std::fs;
16
16
use back:: archive;
17
17
use session:: Session ;
18
18
use session:: config;
19
+ use session:: config:: DebugInfoLevel :: { NoDebugInfo , LimitedDebugInfo , FullDebugInfo } ;
19
20
20
21
/// Linker abstraction used by back::link to build up the command to invoke a
21
22
/// linker.
@@ -39,6 +40,7 @@ pub trait Linker {
39
40
fn gc_sections ( & mut self , is_dylib : bool ) ;
40
41
fn position_independent_executable ( & mut self ) ;
41
42
fn optimize ( & mut self ) ;
43
+ fn debuginfo ( & mut self ) ;
42
44
fn no_default_libraries ( & mut self ) ;
43
45
fn build_dylib ( & mut self , out_filename : & Path ) ;
44
46
fn args ( & mut self , args : & [ String ] ) ;
@@ -143,6 +145,10 @@ impl<'a> Linker for GnuLinker<'a> {
143
145
}
144
146
}
145
147
148
+ fn debuginfo ( & mut self ) {
149
+ // Don't do anything special here for GNU-style linkers.
150
+ }
151
+
146
152
fn no_default_libraries ( & mut self ) {
147
153
// Unfortunately right now passing -nodefaultlibs to gcc on windows
148
154
// doesn't work so hot (in terms of native dependencies). This if
@@ -265,6 +271,21 @@ impl<'a> Linker for MsvcLinker<'a> {
265
271
fn optimize ( & mut self ) {
266
272
// Needs more investigation of `/OPT` arguments
267
273
}
274
+
275
+ fn debuginfo ( & mut self ) {
276
+ match self . sess . opts . debuginfo {
277
+ NoDebugInfo => {
278
+ // Do nothing if debuginfo is disabled
279
+ } ,
280
+ LimitedDebugInfo |
281
+ FullDebugInfo => {
282
+ // This will cause the Microsoft linker to generate a PDB file
283
+ // from the CodeView line tables in the object files.
284
+ self . cmd . arg ( "/DEBUG" ) ;
285
+ }
286
+ }
287
+ }
288
+
268
289
fn whole_archives ( & mut self ) {
269
290
// hints not supported?
270
291
}
0 commit comments