@@ -112,6 +112,7 @@ pub struct Build {
112
112
archiver : Option < PathBuf > ,
113
113
cargo_metadata : bool ,
114
114
pic : Option < bool > ,
115
+ use_plt : Option < bool > ,
115
116
static_crt : Option < bool > ,
116
117
shared_flag : Option < bool > ,
117
118
static_flag : Option < bool > ,
@@ -319,6 +320,7 @@ impl Build {
319
320
archiver : None ,
320
321
cargo_metadata : true ,
321
322
pic : None ,
323
+ use_plt : None ,
322
324
static_crt : None ,
323
325
warnings : None ,
324
326
extra_warnings : None ,
@@ -822,6 +824,25 @@ impl Build {
822
824
self
823
825
}
824
826
827
+ /// Configures whether the Procedure Linkage Table is used for indirect
828
+ /// calls into shared libraries.
829
+ ///
830
+ /// The PLT is used to provide features like lazy binding, but introduces
831
+ /// a small performance loss due to extra pointer indirection.
832
+ ///
833
+ /// Note that skipping the PLT requires a recent version of GCC/Clang,
834
+ /// therefore this option should only be considered a hint to disable the
835
+ /// PLT where supported.
836
+ ///
837
+ /// The PLT is disabled by default when PIC is enabled, with the exception
838
+ /// of `powerpc64-unknown-linux-gnu`.
839
+ ///
840
+ /// This only applies to ELF targets. It has no effect on other platforms.
841
+ pub fn use_plt ( & mut self , use_plt : bool ) -> & mut Build {
842
+ self . use_plt = Some ( use_plt) ;
843
+ self
844
+ }
845
+
825
846
/// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools.
826
847
///
827
848
/// This option defaults to `false`, and affect only msvc targets.
@@ -1123,6 +1144,11 @@ impl Build {
1123
1144
}
1124
1145
if self . pic . unwrap_or ( !target. contains ( "windows-gnu" ) ) {
1125
1146
cmd. push_cc_arg ( "-fPIC" . into ( ) ) ;
1147
+ if !self . use_plt . unwrap_or ( target. contains ( "powerpc64-unknown-linux" ) ) {
1148
+ if self . is_flag_supported ( "-fno-plt" ) . unwrap_or ( false ) {
1149
+ cmd. push_cc_arg ( "-fno-plt" . into ( ) ) ;
1150
+ }
1151
+ }
1126
1152
}
1127
1153
}
1128
1154
}
0 commit comments