Skip to content

Commit b552faa

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 b552faa

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,16 @@ 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+
commandLine.appendFlag(.I)
198+
let path = try VirtualPath(path: matching.argument.asSingle)
199+
let needRemap = jobNeedPathRemap && isCachingEnabled
200+
commandLine.appendPath(needRemap ? remapPath(path) : path)
201+
}
202+
}
194203
try addAllArgumentsWithPath(.F, .Fsystem, to: &commandLine, remap: jobNeedPathRemap)
195204
try addAllArgumentsWithPath(.vfsoverlay, to: &commandLine, remap: jobNeedPathRemap)
196205

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)