Skip to content

Commit 2c5a1c1

Browse files
[Options] -Isystem doesn't work everywhere -I does
Pass -Isystem along everywhere that -I is. rdar://152331718
1 parent c2307e1 commit 2c5a1c1

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Sources/SwiftDriver/Jobs/APIDigesterJobs.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ extension Driver {
194194
commandLine.appendPath(VirtualPath.lookup(frontendTargetInfo.runtimeResourcePath.path))
195195

196196
try commandLine.appendAll(.I, from: &parsedOptions)
197+
for systemImport in parsedOptions.arguments(for: .Isystem) {
198+
commandLine.appendFlag(.isystem)
199+
commandLine.appendFlag(systemImport.argument.asSingle)
200+
}
197201
try commandLine.appendAll(.F, from: &parsedOptions)
198202
for systemFramework in parsedOptions.arguments(for: .Fsystem) {
199203
commandLine.appendFlag(.iframework)

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

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

192192
// TODO: Can we drop all search paths for compile jobs for explicit module build?
193-
try addAllArgumentsWithPath(.I, to: &commandLine, remap: jobNeedPathRemap)
193+
try addAllArgumentsWithPath(.I, .Isystem, to: &commandLine, remap: jobNeedPathRemap)
194194
try addAllArgumentsWithPath(.F, .Fsystem, to: &commandLine, remap: jobNeedPathRemap)
195195
try addAllArgumentsWithPath(.vfsoverlay, to: &commandLine, remap: jobNeedPathRemap)
196196

Sources/SwiftOptions/Options.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ extension Option {
601601
public static let h: Option = Option("-h", .flag, alias: Option.help)
602602
public static let IEQ: Option = Option("-I=", .joined, alias: Option.I, attributes: [.frontend, .argumentIsPath])
603603
public static let iframework: Option = Option("-iframework", .joinedOrSeparate, attributes: [.noDriver, .argumentIsPath], helpText: "add a directory to the clang importer system framework search path")
604+
public static let isystem: Option = Option("-isystem", .joinedOrSeparate, attributes: [.noDriver, .argumentIsPath], helpText: "add a directory to the clang importer system header search path")
604605
public static let ignoreAlwaysInline: Option = Option("-ignore-always-inline", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Ignore @inline(__always) attributes.")
605606
public static let ignoreModuleSourceInfo: Option = Option("-ignore-module-source-info", .flag, attributes: [.frontend, .noDriver], helpText: "Avoid getting source location from .swiftsourceinfo files")
606607
public static let ignoreSpiGroups: Option = Option("-ignore-spi-group", .separate, attributes: [.noDriver], helpText: "SPI group name to not diagnose about")

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,23 @@ final class SwiftDriverTests: XCTestCase {
219219
func testRelativeOptionOrdering() throws {
220220
var driver = try Driver(args: ["swiftc", "foo.swift",
221221
"-F", "/path/to/frameworks",
222+
"-I", "/path/to/modules",
222223
"-Fsystem", "/path/to/systemframeworks",
223-
"-F", "/path/to/more/frameworks"])
224+
"-Isystem", "/path/to/systemmodules",
225+
"-F", "/path/to/more/frameworks",
226+
"-I", "/path/to/more/modules"])
224227
let jobs = try driver.planBuild()
225228
XCTAssertEqual(jobs[0].kind, .compile)
226229
// The relative ordering of -F and -Fsystem options should be preserved.
230+
// The relative ordering of -I and -Isystem, and -F and -Fsystem options should be preserved,
231+
// but all -I options should come before all -F options.
227232
try XCTAssertJobInvocationMatches(jobs[0],
233+
.flag("-I"),
234+
.path(.absolute(.init(validating: "/path/to/modules"))),
235+
.flag("-Isystem"),
236+
.path(.absolute(.init(validating: "/path/to/systemmodules"))),
237+
.flag("-I"),
238+
.path(.absolute(.init(validating: "/path/to/more/modules"))),
228239
.flag("-F"),
229240
.path(.absolute(.init(validating: "/path/to/frameworks"))),
230241
.flag("-Fsystem"),

0 commit comments

Comments
 (0)