Skip to content

Commit 0475182

Browse files
authored
Merge pull request #548 from sapir/code-model
Code model
2 parents 98ed962 + f579dee commit 0475182

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Diff for: Cargo.lock

+6-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/base.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,19 @@ pub fn compile_codegen_unit(
129129
// NOTE: Rust relies on LLVM doing wrapping on overflow.
130130
context.add_command_line_option("-fwrapv");
131131

132+
if let Some(model) = tcx.sess.code_model() {
133+
use rustc_target::spec::CodeModel;
134+
135+
context.add_command_line_option(match model {
136+
CodeModel::Tiny => "-mcmodel=tiny",
137+
CodeModel::Small => "-mcmodel=small",
138+
CodeModel::Kernel => "-mcmodel=kernel",
139+
CodeModel::Medium => "-mcmodel=medium",
140+
CodeModel::Large => "-mcmodel=large",
141+
});
142+
}
143+
132144
if tcx.sess.relocation_model() == rustc_target::spec::RelocModel::Static {
133-
context.add_command_line_option("-mcmodel=kernel");
134145
context.add_command_line_option("-fno-pie");
135146
}
136147

0 commit comments

Comments
 (0)