[Driver] Exclude options::LinkerInput for GCC linking

options::LinkerInput options may get duplicated after 6a75496836ea14bcfd2f4b59d35a1cad4ac58cee..
This commit is contained in:
Fangrui Song 2020-07-31 00:04:09 -07:00
parent fcf8ada18f
commit c06e22fe07
2 changed files with 5 additions and 2 deletions

View File

@ -38,6 +38,9 @@ using tools::addMultilibFlag;
using tools::addPathIfExists; using tools::addPathIfExists;
static bool forwardToGCC(const Option &O) { static bool forwardToGCC(const Option &O) {
// LinkerInput options have been forwarded. Don't duplicate.
if (O.hasFlag(options::LinkerInput))
return false;
return O.matches(options::OPT_Link_Group) || O.hasFlag(options::LinkOption); return O.matches(options::OPT_Link_Group) || O.hasFlag(options::LinkOption);
} }

View File

@ -1,7 +1,7 @@
// RUN: %clang -### %s -target aarch64-none-elf \ // RUN: %clang -### %s -target aarch64-none-elf \
// RUN: --coverage -fuse-ld=lld --ld-path=ld -nostdlib -r -rdynamic -static -static-pie \ // RUN: --coverage -e _start -fuse-ld=lld --ld-path=ld -nostdlib -r -rdynamic -static -static-pie \
// RUN: 2>&1 | FileCheck --check-prefix=FORWARD %s // RUN: 2>&1 | FileCheck --check-prefix=FORWARD %s
// FORWARD: gcc{{[^"]*}}" "--coverage" "-fuse-ld=lld" "--ld-path=ld" "-nostdlib" "-r" "-rdynamic" "-static" "-static-pie" // FORWARD: gcc{{[^"]*}}" "--coverage" "-fuse-ld=lld" "--ld-path=ld" "-nostdlib" "-rdynamic" "-static" "-static-pie" "-o" "a.out" "{{.*}}.o" "-e" "_start" "-r"
// Check that we don't try to forward -Xclang or -mlinker-version to GCC. // 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. // PR12920 -- Check also we may not forward W_Group options to GCC.