[PATCH] D58326: [Driver][Gnu] Support -nolibc flag
Eric Christopher via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 16 17:28:54 PST 2019
Weird. Ok.
On Sat, Feb 16, 2019, 5:20 PM Petr Hosek via Phabricator <
reviews at reviews.llvm.org> wrote:
> phosek created this revision.
> phosek added reviewers: echristo, mcgrathr.
> Herald added a project: clang.
> Herald added a subscriber: cfe-commits.
>
> This can be used to disable libc linking. This flag is supported by
> GCC since version 9 as well as some Clang target toolchains.
>
>
> Repository:
> rC Clang
>
> https://reviews.llvm.org/D58326
>
> Files:
> clang/lib/Driver/ToolChains/Gnu.cpp
> clang/test/Driver/nodefaultlib.c
> clang/test/Driver/nolibc.c
>
>
> Index: clang/test/Driver/nolibc.c
> ===================================================================
> --- /dev/null
> +++ clang/test/Driver/nolibc.c
> @@ -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
> Index: clang/test/Driver/nodefaultlib.c
> ===================================================================
> --- clang/test/Driver/nodefaultlib.c
> +++ clang/test/Driver/nodefaultlib.c
> @@ -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"
> Index: clang/lib/Driver/ToolChains/Gnu.cpp
> ===================================================================
> --- clang/lib/Driver/ToolChains/Gnu.cpp
> +++ clang/lib/Driver/ToolChains/Gnu.cpp
> @@ -518,7 +518,8 @@
> 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)
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190216/b65aa2d6/attachment.html>
More information about the cfe-commits
mailing list