Skip to content

Commit 8bfb1e9

Browse files
committed
Add no-plt as a compiler option
# Conflicts: # src/librustc/session/config.rs
1 parent a6d644a commit 8bfb1e9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/librustc/session/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13871387
"output a json file with profiler results"),
13881388
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
13891389
"emits a section containing stack size metadata"),
1390+
no_plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
1391+
"skip the PLT when calling into ELF shared libraries
1392+
(default: true if full relro is also enabled)"),
13901393
}
13911394

13921395
pub fn default_lib_output() -> CrateType {

src/librustc_codegen_llvm/attributes.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,12 @@ pub fn from_fn_attrs(
174174
set_frame_pointer_elimination(cx, llfn);
175175
set_probestack(cx, llfn);
176176

177-
// Only enable this optimization if full relro is also enabled.
178-
// In this case, lazy binding was already unavailable, so nothing is lost.
179-
if let RelroLevel::Full = cx.sess().target.target.options.relro_level {
180-
Attribute::NonLazyBind.apply_llfn(Function, llfn);
177+
if cx.sess().opts.debugging_opts.no_plt.unwrap_or(true) {
178+
// Only enable this optimization if full relro is also enabled.
179+
// In this case, lazy binding was already unavailable, so nothing is lost.
180+
if let RelroLevel::Full = cx.sess().target.target.options.relro_level {
181+
Attribute::NonLazyBind.apply_llfn(Function, llfn);
182+
}
181183
}
182184

183185
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {

0 commit comments

Comments
 (0)