[PATCH] D153907: [AIX] [TOC] Add -mtocdata/-mno-tocdata options on AIX

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 13 08:56:50 PDT 2023


MaskRay added a comment.

For non-Driver tests, use `%clang %s -###`

In D153907#4497602 <https://reviews.llvm.org/D153907#4497602>, @alexgatea wrote:

>> You can use `-###` to dump cc1 options and find the useful one for your `%clang_cc1` command.
>
> I've done this and determined which options need to be added but I don't see any precedent for this in CodeGen tests. For example no CodeGen test has -I /usr/include. It seems either way, using clang++ or adding these extra options, I will break a precedent

No CodeGen test has `-I /usr/include`, as we try to avoid inclusion which may be different from one machine to another.

Your test doesn't need any `#include`. Even if it does, try faking them, e.g. many C++ tests use `namespace std { ... class initializer_list` to declare std declarations they need.



================
Comment at: lib/Driver/ToolChains/Clang.cpp:7043
+  // Forward last mtocdata/mno_tocdata options to -cc1
+  if (Args.hasArg(options::OPT_mtocdata_EQ, options::OPT_mno_tocdata_EQ,
+                  options::OPT_mtocdata, options::OPT_mno_tocdata)) {
----------------
hasArg performs `claim` internally.


================
Comment at: lib/Driver/ToolChains/Clang.cpp:7046
+    // Claim all arguments.
+    Args.ClaimAllArgs(options::OPT_mtocdata_EQ);
+    Args.ClaimAllArgs(options::OPT_mno_tocdata_EQ);
----------------
`Args.claimAllArgs(options::OPT_mtocdata_EQ, options::OPT_mno_tocdata_EQ, ...)`


================
Comment at: lib/Driver/ToolChains/Clang.cpp:7051
+
+    // Diagnose option on unsupported platforms.
+    if (!Triple.isOSAIX()) {
----------------
This is not needed. Making the options `TargetSpecific` gets the `err_drv_unsupported_opt_for_target` checking: D151590


================
Comment at: test/Driver/toc-conf.c:1
+// RUN: %clang %s -target powerpc-unknown-aix -S -mno-tocdata -mtocdata -mno-tocdata -### 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG1
+// RUN: %clang %s -target powerpc-unknown-aix -S -mno-tocdata -mtocdata -mno-tocdata -mtocdata -### 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG2
----------------
For `%clang`, avoid Clang 3.4 deprecated `-target `. Use `--target=` for new tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153907/new/

https://reviews.llvm.org/D153907



More information about the llvm-commits mailing list