]> granicus.if.org Git - clang/commitdiff
[Driver][Fuchsia] Pass LTO flags to linker
authorPetr Hosek <phosek@chromium.org>
Tue, 5 Jun 2018 01:50:59 +0000 (01:50 +0000)
committerPetr Hosek <phosek@chromium.org>
Tue, 5 Jun 2018 01:50:59 +0000 (01:50 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333979 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/Fuchsia.cpp
test/Driver/fuchsia.c

index cfdb3d80a58f6fafe12f822e8fab7e6e3801bbb6..c54cf60ef8209b7c78d7307f5efaf2594e150089 100644 (file)
@@ -100,6 +100,12 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
   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);
index 1ec79356412c256685ce89e2519528c610599d0b..c2b02522ab141a0508e0837db4c7806ce42f08db 100644 (file)
 // 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"