diff options
| author | Antoni Boucher <bouanto@zoho.com> | 2023-09-14 19:02:00 -0400 |
|---|---|---|
| committer | Antoni Boucher <bouanto@zoho.com> | 2023-09-14 19:02:00 -0400 |
| commit | 32df82648d0d8f7687a22f470c7e56fccb5b4b2f (patch) | |
| tree | 6c682959e3a903036f26b332bd303964cbb9d07c | |
| parent | 661114246ac769fdfe22208a0df2963c31801f97 (diff) | |
| download | rust-32df82648d0d8f7687a22f470c7e56fccb5b4b2f.tar.gz rust-32df82648d0d8f7687a22f470c7e56fccb5b4b2f.zip | |
Handle static relocation model
| -rw-r--r-- | src/base.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/base.rs b/src/base.rs index 266d60da10c..ef3db24f708 100644 --- a/src/base.rs +++ b/src/base.rs @@ -140,6 +140,11 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Arc< // NOTE: Rust relies on LLVM doing wrapping on overflow. context.add_command_line_option("-fwrapv"); + if tcx.sess.opts.cg.relocation_model == Some(rustc_target::spec::RelocModel::Static) { + context.add_command_line_option("-mcmodel=kernel"); + context.add_command_line_option("-fno-pie"); + } + if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) { context.add_command_line_option("-ffunction-sections"); context.add_command_line_option("-fdata-sections"); |
