Skip to content

Commit 32df826

Browse files
committed
Handle static relocation model
1 parent 6611142 commit 32df826

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/base.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Arc<
140140
// NOTE: Rust relies on LLVM doing wrapping on overflow.
141141
context.add_command_line_option("-fwrapv");
142142

143+
if tcx.sess.opts.cg.relocation_model == Some(rustc_target::spec::RelocModel::Static) {
144+
context.add_command_line_option("-mcmodel=kernel");
145+
context.add_command_line_option("-fno-pie");
146+
}
147+
143148
if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) {
144149
context.add_command_line_option("-ffunction-sections");
145150
context.add_command_line_option("-fdata-sections");

0 commit comments

Comments
 (0)