[PATCH] D119656: [Driver][DragonFly] -r: imply -nostdlib like GCC

Brad Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 12 22:33:57 PST 2022


brad created this revision.
brad added a reviewer: MaskRay.
brad requested review of this revision.
Herald added a project: clang.

Similar to D116843 <https://reviews.llvm.org/D116843> for Gnu.cpp


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119656

Files:
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/test/Driver/dragonfly.c


Index: clang/test/Driver/dragonfly.c
===================================================================
--- clang/test/Driver/dragonfly.c
+++ clang/test/Driver/dragonfly.c
@@ -4,4 +4,9 @@
 // CHECK: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-dragonfly"
 // CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/usr/libexec/ld-elf.so.{{.*}}" "--hash-style=gnu" "--enable-new-dtags" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-L{{.*}}gcc{{.*}}" "-rpath" "{{.*}}gcc{{.*}}" "-lc" "-lgcc" "{{.*}}crtend.o" "{{.*}}crtn.o"
 
-
+// -r suppresses default -l and crt*.o like -nostdlib.
+// RUN: %clang -### %s --target=x86_64-pc-dragonfly -r \
+// RUN:   2>&1 | FileCheck %s --check-prefix=RELOCATABLE
+// RELOCATABLE:     "-r"
+// RELOCATABLE-NOT: "-l
+// RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
Index: clang/lib/Driver/ToolChains/DragonFly.cpp
===================================================================
--- clang/lib/Driver/ToolChains/DragonFly.cpp
+++ clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -91,7 +91,8 @@
     assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+                   options::OPT_r)) {
     if (!Args.hasArg(options::OPT_shared)) {
       if (Args.hasArg(options::OPT_pg))
         CmdArgs.push_back(
@@ -119,7 +120,8 @@
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+                   options::OPT_r)) {
     CmdArgs.push_back("-L/usr/lib/gcc80");
 
     if (!Args.hasArg(options::OPT_static)) {
@@ -158,7 +160,8 @@
     }
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+                   options::OPT_r)) {
     if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
       CmdArgs.push_back(
           Args.MakeArgString(getToolChain().GetFilePath("crtendS.o")));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119656.408237.patch
Type: text/x-patch
Size: 2154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220213/b3450e29/attachment.bin>


More information about the cfe-commits mailing list