Skip to content

Commit a16f1b5

Browse files
Added complete libs to make-pkgconfig (#36)
1 parent c310d3b commit a16f1b5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

utils/make-pkgconfig.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Foundation
1212
/// process.
1313
/// - returns: The standard output of the process, or nil if it was empty.
1414
func run(_ path: String, args: [String] = []) -> String? {
15+
print("Running \(path) \(args.joined(separator: " "))...")
1516
let pipe = Pipe()
1617
let process = Process()
1718
process.launchPath = path
@@ -63,22 +64,23 @@ func makeFile() throws {
6364

6465
print("Found llvm-config at \(llvmConfig)...")
6566

66-
print("Running llvm-config --version...")
6767
let version = run(llvmConfig, args: ["--version"])!
6868
.replacing(charactersIn: .newlines, with: "")
6969

7070
guard version.hasPrefix("3.9") else {
7171
throw "LLVMSwift requires LLVM version >=3.9.0, but you have \(version)"
7272
}
7373

74-
print("Running llvm-config --libs all...")
75-
let ldFlags = run(llvmConfig, args: ["--libs", "all"])!
76-
.replacing(charactersIn: .newlines, with: "")
74+
let ldFlags = run(llvmConfig, args: ["--ldflags", "--libs", "all",
75+
"--system-libs"])!
76+
.replacing(charactersIn: .newlines, with: " ")
77+
.components(separatedBy: " ")
78+
.filter { !$0.hasPrefix("-W") }
79+
.joined(separator: " ")
7780

7881
// SwiftPM has a whitelisted set of cflags that it understands, and
7982
// unfortunately that includes almost everything but the include dir.
8083

81-
print("Running llvm-config --cflags...")
8284
let cFlags = run(llvmConfig, args: ["--cflags"])!
8385
.replacing(charactersIn: .newlines, with: "")
8486
.components(separatedBy: " ")
@@ -91,7 +93,7 @@ func makeFile() throws {
9193
"Name: cllvm",
9294
"Description: The llvm library",
9395
"Version: \(version)",
94-
"Libs: \(ldFlags)",
96+
"Libs: \(ldFlags) -lc++",
9597
"Requires.private:",
9698
"Cflags: \(cFlags)",
9799
].joined(separator: "\n")

0 commit comments

Comments
 (0)