diff options
| author | sapir <yasapir@gmail.com> | 2024-08-05 00:37:59 +0300 |
|---|---|---|
| committer | sapir <yasapir@gmail.com> | 2024-08-05 00:37:59 +0300 |
| commit | f579dee206eec8b914487d52fc65843bbae795db (patch) | |
| tree | 3b6e4732417751f71ec01eaff4b3b21f96563de7 /src | |
| parent | f7f9a3fb28faab90cf59d2e11b30e8ebc19d5845 (diff) | |
| download | rust-f579dee206eec8b914487d52fc65843bbae795db.tar.gz rust-f579dee206eec8b914487d52fc65843bbae795db.zip | |
Implement CodeModel
Diffstat (limited to 'src')
| -rw-r--r-- | src/base.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/base.rs b/src/base.rs index be149ffe5a1..e3558b6b875 100644 --- a/src/base.rs +++ b/src/base.rs @@ -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"); } |
