Skip to content

[Options] Switch -Isystem to -I if the front end doesn't support -Isystem #1918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,17 @@ extension Driver {
}

// TODO: Can we drop all search paths for compile jobs for explicit module build?
try addAllArgumentsWithPath(.I, .Isystem, to: &commandLine, remap: jobNeedPathRemap)
if isFrontendArgSupported(.Isystem) {
try addAllArgumentsWithPath(.I, .Isystem, to: &commandLine, remap: jobNeedPathRemap)
} else {
for matching in parsedOptions.arguments(for: .I, .Isystem) {
var parsedOption = matching
if parsedOption.option == .Isystem {
parsedOption = ParsedOption(option: .I, argument: parsedOption.argument, index: parsedOption.index)
}
try addPathOption(parsedOption, to: &commandLine, remap: jobNeedPathRemap)
}
}
try addAllArgumentsWithPath(.F, .Fsystem, to: &commandLine, remap: jobNeedPathRemap)
try addAllArgumentsWithPath(.vfsoverlay, to: &commandLine, remap: jobNeedPathRemap)

Expand Down
3 changes: 2 additions & 1 deletion Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ final class SwiftDriverTests: XCTestCase {
// The relative ordering of -F and -Fsystem options should be preserved.
// The relative ordering of -I and -Isystem, and -F and -Fsystem options should be preserved,
// but all -I options should come before all -F options.
let IsystemFlag = driver.isFrontendArgSupported(.Isystem) ? "-Isystem" : "-I"
try XCTAssertJobInvocationMatches(jobs[0],
.flag("-I"),
.path(.absolute(.init(validating: "/path/to/modules"))),
.flag("-Isystem"),
.flag(IsystemFlag),
.path(.absolute(.init(validating: "/path/to/systemmodules"))),
.flag("-I"),
.path(.absolute(.init(validating: "/path/to/more/modules"))),
Expand Down