r333979 - [Driver][Fuchsia] Pass LTO flags to linker
Petr Hosek via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 4 18:50:59 PDT 2018
Author: phosek
Date: Mon Jun 4 18:50:59 2018
New Revision: 333979
URL: http://llvm.org/viewvc/llvm-project?rev=333979&view=rev
Log:
[Driver][Fuchsia] Pass LTO flags to linker
Even though we use lld by default for Fuchsia, we use Gold plugin
arguments like all other drivers as lld supports Gold plugin options.
Differential Revision: https://reviews.llvm.org/D47668
Modified:
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/test/Driver/fuchsia.c
Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=333979&r1=333978&r2=333979&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Mon Jun 4 18:50:59 2018
@@ -100,6 +100,12 @@ void fuchsia::Linker::ConstructJob(Compi
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ if (D.isUsingLTO()) {
+ assert(!Inputs.empty() && "Must have at least one input.");
+ AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+ D.getLTOMode() == LTOK_Thin);
+ }
+
addSanitizerRuntimes(ToolChain, Args, CmdArgs);
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
Modified: cfe/trunk/test/Driver/fuchsia.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=333979&r1=333978&r2=333979&view=diff
==============================================================================
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Mon Jun 4 18:50:59 2018
@@ -114,3 +114,16 @@
// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
// CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo"
// CHECK-SCUDO-SHARED: "{{.*[/\\]}}libclang_rt.scudo-x86_64.so"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -O3 -flto -mcpu=cortex-a53 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-LTO
+// CHECK-LTO: "-plugin-opt=mcpu=cortex-a53"
+// CHECK-LTO: "-plugin-opt=O3"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -flto=thin -flto-jobs=8 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTO
+// CHECK-THINLTO: "-plugin-opt=mcpu=x86-64"
+// CHECK-THINLTO: "-plugin-opt=thinlto"
+// CHECK-THINLTO: "-plugin-opt=jobs=8"
More information about the cfe-commits
mailing list