[PATCH] D122524: [clang][AVR] Eliminate link warnings when '-S' is specified

Ben Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 26 00:39:56 PDT 2022


benshi001 created this revision.
benshi001 added reviewers: aykevl, MaskRay.
Herald added subscribers: StephenFan, Jim, dylanmckay.
Herald added a project: All.
benshi001 requested review of this revision.
Herald added subscribers: cfe-commits, jacquesguan.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122524

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===================================================================
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -35,3 +35,10 @@
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck --check-prefix=NOSTDINC %s
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
 // NOSTDINC-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | FileCheck --check-prefix=LINK %s
+// LINK: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree -S 2>&1 | FileCheck --check-prefix=NOLINK %s
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree -c 2>&1 | FileCheck --check-prefix=NOLINK %s
+// NOLINK-NOT: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
Index: clang/lib/Driver/ToolChains/AVR.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -372,6 +372,7 @@
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nodefaultlibs) &&
+      !Args.hasArg(options::OPT_S) &&
       !Args.hasArg(options::OPT_c /* does not apply when not linking */)) {
     std::string CPU = getCPUName(D, Args, Triple);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122524.418382.patch
Type: text/x-patch
Size: 1668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220326/f23a2b7a/attachment.bin>


More information about the cfe-commits mailing list