Skip to content

Commit f579dee

Browse files
committed
Implement CodeModel
1 parent f7f9a3f commit f579dee

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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)