Skip to content

Commit 37b015f

Browse files
committed
Fix error message for invalid code/reloc models
1 parent 8b22e70 commit 37b015f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/librustc_back/target/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ pub struct TargetOptions {
311311
pub relocation_model: String,
312312
/// Code model to use. Corresponds to `llc -code-model=$code_model`. Defaults to "default".
313313
pub code_model: String,
314+
/// TLS model to use. Options are "global-dynamic" (default), "local-dynamic", "initial-exec"
315+
/// and "local-exec". This is similar to the -ftls-model option in GCC/Clang.
316+
pub tls_model: String,
314317
/// Do not emit code that uses the "red zone", if the ABI has one. Defaults to false.
315318
pub disable_redzone: bool,
316319
/// Eliminate frame pointers from stack frames if possible. Defaults to true.
@@ -450,6 +453,7 @@ impl Default for TargetOptions {
450453
executables: false,
451454
relocation_model: "pic".to_string(),
452455
code_model: "default".to_string(),
456+
tls_model: "global-dynamic".to_string(),
453457
disable_redzone: false,
454458
eliminate_frame_pointer: true,
455459
function_sections: true,
@@ -696,6 +700,7 @@ impl Target {
696700
key!(executables, bool);
697701
key!(relocation_model);
698702
key!(code_model);
703+
key!(tls_model);
699704
key!(disable_redzone, bool);
700705
key!(eliminate_frame_pointer, bool);
701706
key!(function_sections, bool);
@@ -888,6 +893,7 @@ impl ToJson for Target {
888893
target_option_val!(executables);
889894
target_option_val!(relocation_model);
890895
target_option_val!(code_model);
896+
target_option_val!(tls_model);
891897
target_option_val!(disable_redzone);
892898
target_option_val!(eliminate_frame_pointer);
893899
target_option_val!(function_sections);

src/librustc_trans/back/write.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ pub fn target_machine_factory(sess: &Session)
173173
Some(x) => x.1,
174174
_ => {
175175
sess.err(&format!("{:?} is not a valid code model",
176-
sess.opts
177-
.cg
178-
.code_model));
176+
code_model_arg));
179177
sess.abort_if_errors();
180178
bug!();
181179
}

src/librustc_trans/context.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ pub fn get_reloc_model(sess: &Session) -> llvm::RelocMode {
159159
Some(x) => x.1,
160160
_ => {
161161
sess.err(&format!("{:?} is not a valid relocation mode",
162-
sess.opts
163-
.cg
164-
.code_model));
162+
reloc_model_arg));
165163
sess.abort_if_errors();
166164
bug!();
167165
}

0 commit comments

Comments
 (0)