[clang] c947709 - [Driver] Support -Wa, --defsym similar to -Wa, -defsym

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 14 00:30:07 PDT 2024


Author: Fangrui Song
Date: 2024-06-14T00:30:03-07:00
New Revision: c947709df7859bb7285873593adab70349a5ab3e

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

LOG: [Driver] Support -Wa,--defsym similar to -Wa,-defsym

When the integrated assembler is enabled, clangDriver implements a small
set of popular -Wa, options. "-defsym" is implemented
(https://reviews.llvm.org/D26213), but the more common "--defsym" is
not. Support "--defsym".

Close #95386

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/defsym.s

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index b8d8ff3db5d1f..acd32bddea6b6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2647,7 +2647,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
       } else if (Value.starts_with("-mcpu") || Value.starts_with("-mfpu") ||
                  Value.starts_with("-mhwdiv") || Value.starts_with("-march")) {
         // Do nothing, we'll validate it later.
-      } else if (Value == "-defsym") {
+      } else if (Value == "-defsym" || Value == "--defsym") {
         if (A->getNumValues() != 2) {
           D.Diag(diag::err_drv_defsym_invalid_format) << Value;
           break;

diff  --git a/clang/test/Driver/defsym.s b/clang/test/Driver/defsym.s
index 165c71b2eae97..d152b326ae8b1 100644
--- a/clang/test/Driver/defsym.s
+++ b/clang/test/Driver/defsym.s
@@ -1,17 +1,14 @@
 // XFAIL: target={{.*}}-aix{{.*}}
 
 // RUN: %clang -### -c -integrated-as %s \
-// RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
+// RUN: -Wa,-defsym,abc=5 -Wa,--defsym,xyz=0xa \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
 
 // RUN: %clang -### -c -no-integrated-as -target x86_64-unknown-unknown %s \
-// RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
+// RUN: -Wa,-defsym,abc=5 -Wa,--defsym,xyz=0xa \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
 
-// CHECK-DEFSYM1: "-defsym"
-// CHECK-DEFSYM1: "abc=5"
-// CHECK-DEFSYM1: "-defsym"
-// CHECK-DEFSYM1: "xyz=0xa"
+// CHECK-DEFSYM1: "-defsym" "abc=5" "--defsym" "xyz=0xa"
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym,abc= \


        


More information about the cfe-commits mailing list