@@ -105,6 +105,7 @@ pub struct Build {
105
105
out_dir : Option < PathBuf > ,
106
106
opt_level : Option < String > ,
107
107
debug : Option < bool > ,
108
+ force_frame_pointer : Option < bool > ,
108
109
env : Vec < ( OsString , OsString ) > ,
109
110
compiler : Option < PathBuf > ,
110
111
archiver : Option < PathBuf > ,
@@ -209,8 +210,17 @@ impl ToolFamily {
209
210
}
210
211
ToolFamily :: Gnu | ToolFamily :: Clang => {
211
212
cmd. push_cc_arg ( "-g" . into ( ) ) ;
213
+ }
214
+ }
215
+ }
216
+
217
+ /// What the flag to force frame pointers.
218
+ fn add_force_frame_pointer ( & self , cmd : & mut Tool ) {
219
+ match * self {
220
+ ToolFamily :: Gnu | ToolFamily :: Clang => {
212
221
cmd. push_cc_arg ( "-fno-omit-frame-pointer" . into ( ) ) ;
213
222
}
223
+ _ => ( ) ,
214
224
}
215
225
}
216
226
@@ -286,6 +296,7 @@ impl Build {
286
296
out_dir : None ,
287
297
opt_level : None ,
288
298
debug : None ,
299
+ force_frame_pointer : None ,
289
300
env : Vec :: new ( ) ,
290
301
compiler : None ,
291
302
archiver : None ,
@@ -758,6 +769,17 @@ impl Build {
758
769
self
759
770
}
760
771
772
+ /// Configures whether the compiler will emit instructions to store
773
+ /// frame pointers during codegen.
774
+ ///
775
+ /// This option is automatically enabled when debug information is emitted.
776
+ /// Otherwise the target platform compiler's default will be used.
777
+ /// You can use this option to force a specific setting.
778
+ pub fn force_frame_pointer ( & mut self , force : bool ) -> & mut Build {
779
+ self . force_frame_pointer = Some ( force) ;
780
+ self
781
+ }
782
+
761
783
/// Configures the output directory where all object files and static
762
784
/// libraries will be located.
763
785
///
@@ -1348,6 +1370,11 @@ impl Build {
1348
1370
family. add_debug_flags ( cmd) ;
1349
1371
}
1350
1372
1373
+ if self . get_force_frame_pointer ( ) {
1374
+ let family = cmd. family ;
1375
+ family. add_force_frame_pointer ( cmd) ;
1376
+ }
1377
+
1351
1378
// Target flags
1352
1379
match cmd. family {
1353
1380
ToolFamily :: Clang => {
@@ -2227,6 +2254,10 @@ impl Build {
2227
2254
} )
2228
2255
}
2229
2256
2257
+ fn get_force_frame_pointer ( & self ) -> bool {
2258
+ self . force_frame_pointer . unwrap_or_else ( || self . get_debug ( ) )
2259
+ }
2260
+
2230
2261
fn get_out_dir ( & self ) -> Result < PathBuf , Error > {
2231
2262
match self . out_dir . clone ( ) {
2232
2263
Some ( p) => Ok ( p) ,
0 commit comments