Author: Fangrui Song
Date: 2023-06-26T12:28:02-07:00
New Revision: fe5bab537270e21469b8dfe09aae2ec11f1aca7f

URL: 
https://github.com/llvm/llvm-project/commit/fe5bab537270e21469b8dfe09aae2ec11f1aca7f
DIFF: 
https://github.com/llvm/llvm-project/commit/fe5bab537270e21469b8dfe09aae2ec11f1aca7f.diff

LOG: [Driver][ARM] Warn about -mabi= for assembler input

Previously, Clang Driver reported a warning when assembler input was assembled
with the -mabi= option. D152856 added TargetSpecific to -mabi= option and
reported an error for such a case. This change restores the previous behavior by
reporting a warning.

GCC translates -mabi={apcs-gnu,atpcs} to gas -meabi=gnu and other -mabi= values
to -meabi=5. We don't support setting e_flags to any value other than
EF_ARM_EABI_VER5.

Close https://github.com/ClangBuiltLinux/linux/issues/1878

Reviewed By: michaelplatings

Differential Revision: https://reviews.llvm.org/D153691

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Arch/ARM.cpp
    clang/test/Driver/arm-abi.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 4f2475efa18b8..15b370fa7d014 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -524,6 +524,12 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
         }
       }
     }
+
+    // The integrated assembler doesn't implement e_flags setting behavior for
+    // -meabi=gnu (gcc -mabi={apcs-gnu,atpcs} passes -meabi=gnu to gas). For
+    // compatibility we accept but warn.
+    if (Arg *A = Args.getLastArgNoClaim(options::OPT_mabi_EQ))
+      A->ignoreTargetSpecific();
   }
 
   if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::TPIDRURW)

diff  --git a/clang/test/Driver/arm-abi.c b/clang/test/Driver/arm-abi.c
index 548704965b247..38076f092c8e6 100644
--- a/clang/test/Driver/arm-abi.c
+++ b/clang/test/Driver/arm-abi.c
@@ -61,3 +61,9 @@
 // CHECK-APCS-GNU: "-target-abi" "apcs-gnu"
 // CHECK-AAPCS: "-target-abi" "aapcs"
 // CHECK-AAPCS-LINUX: "-target-abi" "aapcs-linux"
+
+// RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o 
/dev/null 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASM %s
+
+/// The combination -x assember & -mabi is not implemented, but for GCC 
compatibility we accept with a warning.
+// CHECK-ASM: warning: argument unused during compilation: '-mabi={{.*}}'


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to