From 2bccd2b4350f887cc7fea1cc488690f58186c440 Mon Sep 17 00:00:00 2001 From: Pengxuan Zheng Date: Fri, 4 Sep 2020 13:56:06 -0700 Subject: [PATCH] [Driver] Allow -specs and -nostartfiles to be forwarded to GCC With 6a75496836ea14bcfd2f4b59d35a1cad4ac58cee, these two options are no longer forwarded to GCC. This patch restores the original behavior. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D87162 --- clang/include/clang/Driver/Options.td | 4 ++-- clang/test/Driver/gcc_forward.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 5f1668e..4ba5d40 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2760,7 +2760,7 @@ def no_pie : Flag<["-"], "no-pie">, Alias; def noprebind : Flag<["-"], "noprebind">; def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; -def nostartfiles : Flag<["-"], "nostartfiles">; +def nostartfiles : Flag<["-"], "nostartfiles">, Group; def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>; def nostdlibinc : Flag<["-"], "nostdlibinc">; def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>, @@ -2861,7 +2861,7 @@ def segs__read__ : Joined<["-"], "segs_read_">; def shared_libgcc : Flag<["-"], "shared-libgcc">; def shared : Flag<["-", "--"], "shared">, Group; def single__module : Flag<["-"], "single_module">; -def specs_EQ : Joined<["-", "--"], "specs=">; +def specs_EQ : Joined<["-", "--"], "specs=">, Group; def specs : Separate<["-", "--"], "specs">, Flags<[Unsupported]>; def static_libgcc : Flag<["-"], "static-libgcc">; def static_libstdcxx : Flag<["-"], "static-libstdc++">; diff --git a/clang/test/Driver/gcc_forward.c b/clang/test/Driver/gcc_forward.c index a99944f..e6b0670 100644 --- a/clang/test/Driver/gcc_forward.c +++ b/clang/test/Driver/gcc_forward.c @@ -1,7 +1,8 @@ // RUN: %clang -### %s -target aarch64-none-elf \ -// RUN: --coverage -e _start -fuse-ld=lld --ld-path=ld -nostdlib -r -rdynamic -static -static-pie \ +// RUN: --coverage -e _start -fuse-ld=lld --ld-path=ld -nostartfiles \ +// RUN: -nostdlib -r -rdynamic -specs=nosys.specs -static -static-pie \ // RUN: 2>&1 | FileCheck --check-prefix=FORWARD %s -// FORWARD: gcc{{[^"]*}}" "--coverage" "-fuse-ld=lld" "--ld-path=ld" "-nostdlib" "-rdynamic" "-static" "-static-pie" "-o" "a.out" "{{.*}}.o" "-e" "_start" "-r" +// FORWARD: gcc{{[^"]*}}" "--coverage" "-fuse-ld=lld" "--ld-path=ld" "-nostartfiles" "-nostdlib" "-rdynamic" "-specs=nosys.specs" "-static" "-static-pie" "-o" "a.out" "{{.*}}.o" "-e" "_start" "-r" // Check that we don't try to forward -Xclang or -mlinker-version to GCC. // PR12920 -- Check also we may not forward W_Group options to GCC. -- 2.7.4