[clang] d712ae4 - [Driver] Support -Wa, --defsym similar to -Wa, -defsym
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 14 00:40:38 PDT 2024
Author: Fangrui Song
Date: 2024-06-14T00:40:33-07:00
New Revision: d712ae4a21822a51817941e7007e0dd41343cde3
URL: https://github.com/llvm/llvm-project/commit/d712ae4a21822a51817941e7007e0dd41343cde3
DIFF: https://github.com/llvm/llvm-project/commit/d712ae4a21822a51817941e7007e0dd41343cde3.diff
LOG: [Driver] Support -Wa,--defsym similar to -Wa,-defsym
Missing part in c947709df7859bb7285873593adab70349a5ab3e
Added:
clang/test/Misc/cc1as-defsym.s
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/defsym.s
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 880221176027e..062fbd2e4c0a4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8124,7 +8124,7 @@ def show_inst : Flag<["-"], "show-inst">,
def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">,
HelpText<"The string to embed in the Dwarf debug AT_producer record.">;
-def defsym : Separate<["-"], "defsym">,
+def defsym : Separate<["--"], "defsym">,
HelpText<"Define a value for a symbol">;
} // let Visibility = [CC1AsOption]
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index acd32bddea6b6..331cf6e713d89 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2666,7 +2666,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
D.Diag(diag::err_drv_defsym_invalid_symval) << SVal;
break;
}
- CmdArgs.push_back(Value.data());
+ CmdArgs.push_back("--defsym");
TakeNextArg = true;
} else if (Value == "-fdebug-compilation-dir") {
CmdArgs.push_back("-fdebug-compilation-dir");
diff --git a/clang/test/Driver/defsym.s b/clang/test/Driver/defsym.s
index d152b326ae8b1..af66656cce15e 100644
--- a/clang/test/Driver/defsym.s
+++ b/clang/test/Driver/defsym.s
@@ -6,9 +6,10 @@
// RUN: %clang -### -c -no-integrated-as -target x86_64-unknown-unknown %s \
// RUN: -Wa,-defsym,abc=5 -Wa,--defsym,xyz=0xa \
-// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1-GAS
-// CHECK-DEFSYM1: "-defsym" "abc=5" "--defsym" "xyz=0xa"
+// CHECK-DEFSYM1: "--defsym" "abc=5" "--defsym" "xyz=0xa"
+// CHECK-DEFSYM1-GAS: "-defsym" "abc=5" "--defsym" "xyz=0xa"
// RUN: not %clang -c -integrated-as -o /dev/null %s \
// RUN: -Wa,-defsym,abc= \
diff --git a/clang/test/Misc/cc1as-defsym.s b/clang/test/Misc/cc1as-defsym.s
new file mode 100644
index 0000000000000..0dc7f24dac2c0
--- /dev/null
+++ b/clang/test/Misc/cc1as-defsym.s
@@ -0,0 +1,12 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang -cc1as -triple x86_64 -filetype obj --defsym A=1 %s -o %t.o
+// RUN: llvm-nm %t.o | FileCheck %s
+
+// CHECK: 0000000000000001 A foo
+
+.globl foo
+.ifdef A
+foo = 1
+.else
+foo = 0
+.endif
More information about the cfe-commits
mailing list