Skip to content

Commit

Permalink
Handle static relocation model
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Sep 14, 2023
1 parent 6611142 commit 32df826
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 32df826

Please sign in to comment.