Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add missing lto linker flags
  • Loading branch information
rauhul authored and MaxDesiatov committed Dec 7, 2023
commit 55fc055d63b1f51523079471c7ef208dd7a56cdd
10 changes: 10 additions & 0 deletions Sources/Build/BuildDescription/ProductBuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
// User arguments (from -Xlinker) should follow generated arguments to allow user overrides
args += self.buildParameters.flags.linkerFlags.asSwiftcLinkerFlags()

// Enable the correct lto mode if requested.
switch self.buildParameters.linkingParameters.linkTimeOptimizationMode {
case nil:
break
case .full:
args += ["-lto=llvm-full"]
case .thin:
args += ["-lto=llvm-thin"]
}

// Pass default library paths from the toolchain.
for librarySearchPath in self.buildParameters.toolchain.librarySearchPaths {
args += ["-L", librarySearchPath.pathString]
Expand Down