Skip to content

Commit

Permalink
Merge pull request #548 from sapir/code-model
Browse files Browse the repository at this point in the history
Code model
  • Loading branch information
antoyo authored Aug 5, 2024
2 parents 98ed962 + f579dee commit 0475182
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,19 @@ pub fn compile_codegen_unit(
// NOTE: Rust relies on LLVM doing wrapping on overflow.
context.add_command_line_option("-fwrapv");

if let Some(model) = tcx.sess.code_model() {
use rustc_target::spec::CodeModel;

context.add_command_line_option(match model {
CodeModel::Tiny => "-mcmodel=tiny",
CodeModel::Small => "-mcmodel=small",
CodeModel::Kernel => "-mcmodel=kernel",
CodeModel::Medium => "-mcmodel=medium",
CodeModel::Large => "-mcmodel=large",
});
}

if tcx.sess.relocation_model() == rustc_target::spec::RelocModel::Static {
context.add_command_line_option("-mcmodel=kernel");
context.add_command_line_option("-fno-pie");
}

Expand Down

0 comments on commit 0475182

Please sign in to comment.