Skip to content

Commit 5484c13

Browse files
Don't override -masm option if set in the command arguments
1 parent 1b60286 commit 5484c13

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/base.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_
8787
// Instantiate monomorphizations without filling out definitions yet...
8888
//let llvm_module = ModuleLlvm::new(tcx, &cgu_name.as_str());
8989
let context = Context::default();
90-
// TODO(antoyo): only set on x86 platforms.
91-
context.add_command_line_option("-masm=intel");
9290
// TODO(antoyo): only add the following cli argument if the feature is supported.
9391
context.add_command_line_option("-msse2");
9492
context.add_command_line_option("-mavx2");
@@ -111,15 +109,21 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_
111109
context.add_command_line_option("-mvpclmulqdq");
112110
context.add_command_line_option("-mavx");
113111

112+
let mut has_set_asm_syntax = false;
114113
for arg in &tcx.sess.opts.cg.llvm_args {
115114
if arg.starts_with("--x86-asm-syntax=") {
116115
// LLVM uses the two same arguments as GCC: `att` and `intel`.
117116
let syntax = arg.splitn(2, '=').skip(1).next().expect("missing argument");
118117
context.add_command_line_option(&format!("-masm={}", syntax));
118+
has_set_asm_syntax = true;
119119
} else {
120120
context.add_command_line_option(arg);
121121
}
122122
}
123+
if !has_set_asm_syntax {
124+
// TODO(antoyo): only set on x86 platforms.
125+
context.add_command_line_option("-masm=intel");
126+
}
123127
// NOTE: This is needed to compile the file src/intrinsic/archs.rs during a bootstrap of rustc.
124128
context.add_command_line_option("-fno-var-tracking-assignments");
125129
// NOTE: an optimization (https://github.com/rust-lang/rustc_codegen_gcc/issues/53).

0 commit comments

Comments
 (0)