Skip to content

Instantly share code, notes, and snippets.

@kateinoigakukun
Created April 24, 2020 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kateinoigakukun/c8226d8a881a7611d9799f1512e786f2 to your computer and use it in GitHub Desktop.
Save kateinoigakukun/c8226d8a881a7611d9799f1512e786f2 to your computer and use it in GitHub Desktop.
diff --git a/lib/Driver/UnixToolChains.cpp b/lib/Driver/UnixToolChains.cpp
index 59f24a4eafe..4a988a05943 100644
--- a/lib/Driver/UnixToolChains.cpp
+++ b/lib/Driver/UnixToolChains.cpp
@@ -218,6 +218,16 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
Arguments.push_back("-pie");
}
+ switch (context.OI.LTOVariant) {
+ case OutputInfo::LTOKind::LLVMThin:
+ Arguments.push_back("-flto=thin");
+ break;
+ case OutputInfo::LTOKind::LLVMFull:
+ Arguments.push_back("-flto=full");
+ break;
+ case OutputInfo::LTOKind::None: break;
+ }
+
bool staticExecutable = false;
bool staticStdlib = false;
@@ -252,8 +262,8 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
Arguments.push_back(context.Args.MakeArgString(swiftrtPath));
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
- file_types::TY_Object);
- addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
+ job.getInputType());
+ addInputsOfType(Arguments, context.InputActions, job.getInputType());
for (const Arg *arg :
context.Args.filtered(options::OPT_F, options::OPT_Fsystem)) {
@@ -375,8 +385,8 @@ toolchains::GenericUnix::constructInvocation(const StaticLinkJobAction &job,
context.Args.MakeArgString(context.Output.getPrimaryOutputFilename()));
addPrimaryInputsOfType(Arguments, context.Inputs, context.Args,
- file_types::TY_Object);
- addInputsOfType(Arguments, context.InputActions, file_types::TY_Object);
+ job.getInputType());
+ addInputsOfType(Arguments, context.InputActions, job.getInputType());
InvocationInfo II{AR, Arguments};
diff --git a/test/Driver/link-time-opt.swift b/test/Driver/link-time-opt.swift
index 2174de7345a..858f678cdcb 100644
--- a/test/Driver/link-time-opt.swift
+++ b/test/Driver/link-time-opt.swift
@@ -1,6 +1,7 @@
-// RUN: %target-swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -lto=llvm | %FileCheck %s --check-prefix=CHECK-%target-os
-// CHECK-macosx: bin/swift -frontend -emit-bc
+// RUN: %target-swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -lto=llvm | %FileCheck %s --check-prefix=CHECK-%target-os --check-prefix=CHECK
+// CHECK: bin/swift -frontend -emit-bc
// CHECK-macosx-NEXT: bin/ld {{.+}} -lto_library {{.+}}/lib/libLTO.dylib
+// CHECK-linux-gnu-NEXT: bin/clang {{.+}} -flto=thin
// RUN: rm -rf %t
// RUN: %empty-directory(%t/thin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment