r354210 - [Driver][Gnu] Support -nolibc flag
Petr Hosek via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 16 18:42:48 PST 2019
Author: phosek
Date: Sat Feb 16 18:42:48 2019
New Revision: 354210
URL: http://llvm.org/viewvc/llvm-project?rev=354210&view=rev
Log:
[Driver][Gnu] Support -nolibc flag
This can be used to disable libc linking. This flag is supported by
GCC since version 9 as well as some Clang target toolchains.
Differential Revision: https://reviews.llvm.org/D58326
Added:
cfe/trunk/test/Driver/nolibc.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/nodefaultlib.c
Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=354210&r1=354209&r2=354210&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Sat Feb 16 18:42:48 2019
@@ -518,7 +518,8 @@ void tools::gnutools::Linker::ConstructJ
if (Args.hasArg(options::OPT_fsplit_stack))
CmdArgs.push_back("--wrap=pthread_create");
- CmdArgs.push_back("-lc");
+ if (!Args.hasArg(options::OPT_nolibc))
+ CmdArgs.push_back("-lc");
// Add IAMCU specific libs, if needed.
if (IsIAMCU)
Modified: cfe/trunk/test/Driver/nodefaultlib.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nodefaultlib.c?rev=354210&r1=354209&r2=354210&view=diff
==============================================================================
--- cfe/trunk/test/Driver/nodefaultlib.c (original)
+++ cfe/trunk/test/Driver/nodefaultlib.c Sat Feb 16 18:42:48 2019
@@ -1,4 +1,4 @@
-// RUN: %clang -target i686-pc-linux-gnu -### -nodefaultlibs %s 2>&1 | FileCheck -check-prefix=TEST1 %s
+// RUN: %clang -target i686-pc-linux-gnu -### -rtlib=libgcc -nodefaultlibs %s 2>&1 | FileCheck -check-prefix=TEST1 %s
// TEST1-NOT: start-group
// TEST1-NOT: "-lgcc"
// TEST1-NOT: "-lc"
Added: cfe/trunk/test/Driver/nolibc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nolibc.c?rev=354210&view=auto
==============================================================================
--- cfe/trunk/test/Driver/nolibc.c (added)
+++ cfe/trunk/test/Driver/nolibc.c Sat Feb 16 18:42:48 2019
@@ -0,0 +1,5 @@
+// RUN: %clang -target i686-pc-linux-gnu -### -rtlib=libgcc -nolibc %s 2>&1 | FileCheck %s
+// CHECK: crtbegin
+// CHECK: "-lgcc"
+// CHECK-NOT: "-lc"
+// CHECK: crtend
More information about the cfe-commits
mailing list