about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2022-10-18 22:45:22 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2022-10-18 22:45:22 +0200
commit5484c131a5edbaee9a88bb4c7e9f14cced5afc8d (patch)
tree588ed9ca8e0e7476ce2c3adf114bfad3640d76dd
parent1b60286103affa47bc28b2c505c78a0b5d16e4dc (diff)
downloadrust-5484c131a5edbaee9a88bb4c7e9f14cced5afc8d.tar.gz
rust-5484c131a5edbaee9a88bb4c7e9f14cced5afc8d.zip
Don't override -masm option if set in the command arguments
-rw-r--r--src/base.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/base.rs b/src/base.rs
index 788d4d9ae36..c19a62a6cdc 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -87,8 +87,6 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_
         // Instantiate monomorphizations without filling out definitions yet...
         //let llvm_module = ModuleLlvm::new(tcx, &cgu_name.as_str());
         let context = Context::default();
-        // TODO(antoyo): only set on x86 platforms.
-        context.add_command_line_option("-masm=intel");
         // TODO(antoyo): only add the following cli argument if the feature is supported.
         context.add_command_line_option("-msse2");
         context.add_command_line_option("-mavx2");
@@ -111,15 +109,21 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_
         context.add_command_line_option("-mvpclmulqdq");
         context.add_command_line_option("-mavx");
 
+        let mut has_set_asm_syntax = false;
         for arg in &tcx.sess.opts.cg.llvm_args {
             if arg.starts_with("--x86-asm-syntax=") {
                 // LLVM uses the two same arguments as GCC: `att` and `intel`.
                 let syntax = arg.splitn(2, '=').skip(1).next().expect("missing argument");
                 context.add_command_line_option(&format!("-masm={}", syntax));
+                has_set_asm_syntax = true;
             } else {
                 context.add_command_line_option(arg);
             }
         }
+        if !has_set_asm_syntax {
+            // TODO(antoyo): only set on x86 platforms.
+            context.add_command_line_option("-masm=intel");
+        }
         // NOTE: This is needed to compile the file src/intrinsic/archs.rs during a bootstrap of rustc.
         context.add_command_line_option("-fno-var-tracking-assignments");
         // NOTE: an optimization (https://github.com/rust-lang/rustc_codegen_gcc/issues/53).