Skip to content

Commit

Permalink
Merge pull request #331 from rust-lang/feature/static-relocation
Browse files Browse the repository at this point in the history
Handle static relocation model
  • Loading branch information
antoyo authored Sep 14, 2023
2 parents 6611142 + 32df826 commit 067bfc0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 067bfc0

Please sign in to comment.