@@ -12,6 +12,7 @@ import Foundation
12
12
/// process.
13
13
/// - returns: The standard output of the process, or nil if it was empty.
14
14
func run( _ path: String , args: [ String ] = [ ] ) -> String ? {
15
+ print ( " Running \( path) \( args. joined ( separator: " " ) ) ... " )
15
16
let pipe = Pipe ( )
16
17
let process = Process ( )
17
18
process. launchPath = path
@@ -63,22 +64,23 @@ func makeFile() throws {
63
64
64
65
print ( " Found llvm-config at \( llvmConfig) ... " )
65
66
66
- print ( " Running llvm-config --version... " )
67
67
let version = run ( llvmConfig, args: [ " --version " ] ) !
68
68
. replacing ( charactersIn: . newlines, with: " " )
69
69
70
70
guard version. hasPrefix ( " 3.9 " ) else {
71
71
throw " LLVMSwift requires LLVM version >=3.9.0, but you have \( version) "
72
72
}
73
73
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: " " )
77
80
78
81
// SwiftPM has a whitelisted set of cflags that it understands, and
79
82
// unfortunately that includes almost everything but the include dir.
80
83
81
- print ( " Running llvm-config --cflags... " )
82
84
let cFlags = run ( llvmConfig, args: [ " --cflags " ] ) !
83
85
. replacing ( charactersIn: . newlines, with: " " )
84
86
. components ( separatedBy: " " )
@@ -91,7 +93,7 @@ func makeFile() throws {
91
93
" Name: cllvm " ,
92
94
" Description: The llvm library " ,
93
95
" Version: \( version) " ,
94
- " Libs: \( ldFlags) " ,
96
+ " Libs: \( ldFlags) -lc++ " ,
95
97
" Requires.private: " ,
96
98
" Cflags: \( cFlags) " ,
97
99
] . joined ( separator: " \n " )
0 commit comments