Skip to content

Commit 8c8dfef

Browse files
committed
Add missing lto linker flags
1 parent 1a50013 commit 8c8dfef

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/Build/BuildDescription/ProductBuildDescription.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,16 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
331331
// User arguments (from -Xlinker) should follow generated arguments to allow user overrides
332332
args += self.buildParameters.flags.linkerFlags.asSwiftcLinkerFlags()
333333

334+
// Enable the correct lto mode if requested.
335+
switch self.buildParameters.linkTimeOptimizationMode {
336+
case nil:
337+
break
338+
case .full:
339+
args += ["-lto=llvm-full"]
340+
case .thin:
341+
args += ["-lto=llvm-thin"]
342+
}
343+
334344
// Pass default library paths from the toolchain.
335345
for librarySearchPath in self.buildParameters.toolchain.librarySearchPaths {
336346
args += ["-L", librarySearchPath.pathString]

0 commit comments

Comments
 (0)