diff options
| author | antoyo <antoyo@users.noreply.github.com> | 2024-08-05 13:36:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-05 13:36:46 -0400 |
| commit | 0475182ddc1fcd04a29a85b2f0a3082e1b36af50 (patch) | |
| tree | 3b6e4732417751f71ec01eaff4b3b21f96563de7 | |
| parent | 98ed962c7d3eebe12c97588e61245273d265e72f (diff) | |
| parent | f579dee206eec8b914487d52fc65843bbae795db (diff) | |
| download | rust-0475182ddc1fcd04a29a85b2f0a3082e1b36af50.tar.gz rust-0475182ddc1fcd04a29a85b2f0a3082e1b36af50.zip | |
Merge pull request #548 from sapir/code-model
Code model
| -rw-r--r-- | Cargo.lock | 10 | ||||
| -rw-r--r-- | src/base.rs | 13 |
2 files changed, 18 insertions, 5 deletions
diff --git a/Cargo.lock b/Cargo.lock index cd693835ded..915229f7e7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,16 +79,18 @@ dependencies = [ [[package]] name = "gccjit" -version = "2.0.0" -source = "git+https://github.com/rust-lang/gccjit.rs#328cb1b414f67dfa15162ba7a55ed01931f1b219" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62e0ba949ebee07c5cc21f02cb48f28f2c8db7fcbc15fdc5120476a6c43b4636" dependencies = [ "gccjit_sys", ] [[package]] name = "gccjit_sys" -version = "0.1.0" -source = "git+https://github.com/rust-lang/gccjit.rs#328cb1b414f67dfa15162ba7a55ed01931f1b219" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5bbf85e12c2593772329a9d4e8310271f6706e6045ce4f41b041dd34fba6603" dependencies = [ "libc", ] 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"); } |
