[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

Michael Francis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 8 15:50:38 PDT 2023


francii updated this revision to Diff 520502.
francii added a comment.

Remove leftover marker


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/unsupported-target-K.c


Index: clang/test/Driver/unsupported-target-K.c
===================================================================
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:        --target=powerpc64-unknown-linux-gnu \
+// RUN:        --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:        --unwindlib=libunwind \
+// RUN:        -K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===================================================================
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1096,3 +1096,27 @@
 // CHECK-RELOCATABLE-NOT:     "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o"
 // CHECK-RELOCATABLE-NOT:     "-l{{.*}}"
 // CHECK-RELOCATABLE-NOT:     "-L{{.*}}"
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:        --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:        --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:        --unwindlib=libunwind \
+// RUN:        -K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K:     "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K:     "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K:     "{{.*}}ld{{(.exe)?}}"
+// CHECK-K:     "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o"
+// CHECK-K:     "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o"
+// CHECK-K:     "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:        --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:        --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:        --unwindlib=libunwind \
+// RUN:        -K \
+// RUN:        -c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused [-Wunused-command-line-argument]
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6326,6 +6326,11 @@
     }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
+      A && !TC.getTriple().isOSAIX())
+    D.Diag(diag::err_drv_unsupported_opt_for_target)
+        << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
       (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
     CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3421,6 +3421,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real file system. "
            "Additionally, pass this overlay file to the linker if it supports it">;
 def imultilib : Separate<["-"], "imultilib">, Group<gfortran_Group>;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
         Group<Link_Group>;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146399.520502.patch
Type: text/x-patch
Size: 3249 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230508/e83c681d/attachment-0001.bin>


More information about the cfe-commits mailing list