Skip to content

Commit 8c513a1

Browse files
committed
Add missing lto linker flags
1 parent 6db2c7d commit 8c513a1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/Build/BuildDescription/ProductBuildDescription.swift

+10
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,16 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
322322
// User arguments (from -Xlinker) should follow generated arguments to allow user overrides
323323
args += self.buildParameters.flags.linkerFlags.asSwiftcLinkerFlags()
324324

325+
// Enable the correct lto mode if requested.
326+
switch self.buildParameters.linkTimeOptimizationMode {
327+
case nil:
328+
break
329+
case .full:
330+
args += ["-lto=llvm-full"]
331+
case .thin:
332+
args += ["-lto=llvm-thin"]
333+
}
334+
325335
// Pass default library paths from the toolchain.
326336
for librarySearchPath in self.buildParameters.toolchain.librarySearchPaths {
327337
args += ["-L", librarySearchPath.pathString]

0 commit comments

Comments
 (0)