Skip to content

Commit 08af25f

Browse files
[Options] Switch -Isystem to -I if the front end doesn't support -Isystem
If the front end doesn't support -Isystem, pass it as -I instead. rdar://152602098
1 parent 1e7b2be commit 08af25f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,17 @@ extension Driver {
190190
}
191191

192192
// TODO: Can we drop all search paths for compile jobs for explicit module build?
193-
try addAllArgumentsWithPath(.I, .Isystem, to: &commandLine, remap: jobNeedPathRemap)
193+
if isFrontendArgSupported(.Isystem) {
194+
try addAllArgumentsWithPath(.I, .Isystem, to: &commandLine, remap: jobNeedPathRemap)
195+
} else {
196+
for matching in parsedOptions.arguments(for: .I, .Isystem) {
197+
var parsedOption = matching
198+
if parsedOption.option == .Isystem {
199+
parsedOption = ParsedOption(option: .I, argument: parsedOption.argument, index: parsedOption.index)
200+
}
201+
try addPathOption(parsedOption, to: &commandLine, remap: jobNeedPathRemap)
202+
}
203+
}
194204
try addAllArgumentsWithPath(.F, .Fsystem, to: &commandLine, remap: jobNeedPathRemap)
195205
try addAllArgumentsWithPath(.vfsoverlay, to: &commandLine, remap: jobNeedPathRemap)
196206

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,11 @@ final class SwiftDriverTests: XCTestCase {
229229
// The relative ordering of -F and -Fsystem options should be preserved.
230230
// The relative ordering of -I and -Isystem, and -F and -Fsystem options should be preserved,
231231
// but all -I options should come before all -F options.
232+
let IsystemFlag = driver.isFrontendArgSupported(.Isystem) ? "-Isystem" : "-I"
232233
try XCTAssertJobInvocationMatches(jobs[0],
233234
.flag("-I"),
234235
.path(.absolute(.init(validating: "/path/to/modules"))),
235-
.flag("-Isystem"),
236+
.flag(IsystemFlag),
236237
.path(.absolute(.init(validating: "/path/to/systemmodules"))),
237238
.flag("-I"),
238239
.path(.absolute(.init(validating: "/path/to/more/modules"))),

0 commit comments

Comments
 (0)