Skip to content

Commit fb9f842

Browse files
[ABIChecker] Use -Isystem and -Fsystem for swift-api-digester
Use the Swift -Fsystem flag for swift-api-digester instead of the clang -iframework flag. Add support for -Isystem for parity. rdar://152747420
1 parent 020dde5 commit fb9f842

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

include/swift/Option/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def F_EQ : Joined<["-"], "F=">, Flags<[FrontendOption, ArgumentIsPath]>,
328328

329329
def Fsystem : Separate<["-"], "Fsystem">,
330330
Flags<[FrontendOption, ArgumentIsPath, SwiftSymbolGraphExtractOption,
331-
SwiftSynthesizeInterfaceOption]>,
331+
SwiftAPIDigesterOption, SwiftSynthesizeInterfaceOption]>,
332332
HelpText<"Add directory to system framework search path">;
333333

334334
def I : JoinedOrSeparate<["-"], "I">,
@@ -340,7 +340,7 @@ def I_EQ : Joined<["-"], "I=">, Flags<[FrontendOption, ArgumentIsPath]>,
340340

341341
def Isystem : Separate<["-"], "Isystem">,
342342
Flags<[FrontendOption, ArgumentIsPath, SwiftSymbolGraphExtractOption,
343-
SwiftSynthesizeInterfaceOption]>,
343+
SwiftAPIDigesterOption, SwiftSynthesizeInterfaceOption]>,
344344
HelpText<"Add directory to the system import search path">;
345345

346346
def import_underlying_module : Flag<["-"], "import-underlying-module">,

lib/DriverTool/swift_api_digester_main.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,11 +2261,12 @@ class SwiftAPIDigesterInvocation {
22612261
std::string BaselineSDK;
22622262
std::string Triple;
22632263
std::string SwiftVersion;
2264-
std::vector<std::string> CCSystemFrameworkPaths;
2264+
std::vector<std::string> SystemFrameworkPaths;
22652265
std::vector<std::string> BaselineFrameworkPaths;
22662266
std::vector<std::string> FrameworkPaths;
2267-
std::vector<std::string> BaselineModuleInputPaths;
2268-
std::vector<std::string> ModuleInputPaths;
2267+
std::vector<std::string> SystemModuleImportPaths;
2268+
std::vector<std::string> BaselineModuleImportPaths;
2269+
std::vector<std::string> ModuleImportPaths;
22692270
std::string ModuleList;
22702271
std::vector<std::string> ModuleNames;
22712272
std::vector<std::string> PreferInterfaceForModules;
@@ -2362,11 +2363,17 @@ class SwiftAPIDigesterInvocation {
23622363
BaselineSDK = ParsedArgs.getLastArgValue(OPT_bsdk).str();
23632364
Triple = ParsedArgs.getLastArgValue(OPT_target).str();
23642365
SwiftVersion = ParsedArgs.getLastArgValue(OPT_swift_version).str();
2365-
CCSystemFrameworkPaths = ParsedArgs.getAllArgValues(OPT_iframework);
2366+
SystemFrameworkPaths = ParsedArgs.getAllArgValues(OPT_Fsystem);
2367+
std::vector<std::string> OldSystemFrameworkPaths =
2368+
ParsedArgs.getAllArgValues(OPT_iframework);
2369+
SystemFrameworkPaths.insert(SystemFrameworkPaths.end(),
2370+
OldSystemFrameworkPaths.begin(),
2371+
OldSystemFrameworkPaths.end());
23662372
BaselineFrameworkPaths = ParsedArgs.getAllArgValues(OPT_BF);
23672373
FrameworkPaths = ParsedArgs.getAllArgValues(OPT_F);
2368-
BaselineModuleInputPaths = ParsedArgs.getAllArgValues(OPT_BI);
2369-
ModuleInputPaths = ParsedArgs.getAllArgValues(OPT_I);
2374+
SystemModuleImportPaths = ParsedArgs.getAllArgValues(OPT_Isystem);
2375+
BaselineModuleImportPaths = ParsedArgs.getAllArgValues(OPT_BI);
2376+
ModuleImportPaths = ParsedArgs.getAllArgValues(OPT_I);
23702377
ModuleList = ParsedArgs.getLastArgValue(OPT_module_list_file).str();
23712378
ModuleNames = ParsedArgs.getAllArgValues(OPT_module);
23722379
PreferInterfaceForModules =
@@ -2421,7 +2428,7 @@ class SwiftAPIDigesterInvocation {
24212428
}
24222429

24232430
bool hasBaselineInput() {
2424-
return !BaselineModuleInputPaths.empty() ||
2431+
return !BaselineModuleImportPaths.empty() ||
24252432
!BaselineFrameworkPaths.empty() || !BaselineSDK.empty();
24262433
}
24272434

@@ -2476,29 +2483,30 @@ class SwiftAPIDigesterInvocation {
24762483
InitInvoke.setRuntimeResourcePath(ResourceDir);
24772484
}
24782485
std::vector<SearchPathOptions::SearchPath> FramePaths;
2479-
for (const auto &path : CCSystemFrameworkPaths) {
2486+
for (const auto &path : SystemFrameworkPaths) {
24802487
FramePaths.push_back({path, /*isSystem=*/true});
24812488
}
2489+
std::vector<SearchPathOptions::SearchPath> ImportPaths;
2490+
for (const auto &path : SystemModuleImportPaths) {
2491+
ImportPaths.push_back({path, /*isSystem=*/true});
2492+
}
24822493
if (IsBaseline) {
24832494
for (const auto &path : BaselineFrameworkPaths) {
24842495
FramePaths.push_back({path, /*isSystem=*/false});
24852496
}
2486-
std::vector<SearchPathOptions::SearchPath> ImportPaths;
2487-
for (const auto &path : BaselineModuleInputPaths) {
2497+
for (const auto &path : BaselineModuleImportPaths) {
24882498
ImportPaths.push_back({path, /*isSystem=*/false});
24892499
}
2490-
InitInvoke.setImportSearchPaths(ImportPaths);
24912500
} else {
24922501
for (const auto &path : FrameworkPaths) {
24932502
FramePaths.push_back({path, /*isSystem=*/false});
24942503
}
2495-
std::vector<SearchPathOptions::SearchPath> ImportPaths;
2496-
for (const auto &path : ModuleInputPaths) {
2504+
for (const auto &path : ModuleImportPaths) {
24972505
ImportPaths.push_back({path, /*isSystem=*/false});
24982506
}
2499-
InitInvoke.setImportSearchPaths(ImportPaths);
25002507
}
25012508
InitInvoke.setFrameworkSearchPaths(FramePaths);
2509+
InitInvoke.setImportSearchPaths(ImportPaths);
25022510
if (!ModuleList.empty()) {
25032511
if (readFileLineByLine(ModuleList, Modules))
25042512
exit(1);

utils/api_checker/swift-api-checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def run(self, output, module, swift_ver, opts,
146146
'/tmp/ModuleCache', '-swift-version',
147147
swift_ver, '-abort-on-module-fail']
148148
for path in self.frameworks:
149-
cmd.extend(['-iframework', path])
149+
cmd.extend(['-Fsystem', path])
150150
for path in self.inputs:
151151
cmd.extend(['-I', path])
152152
if self.abi:

utils/swift_build_sdk_interfaces.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ def create_parser():
5454
parser.add_argument('-F', dest='framework_dirs', metavar='DIR',
5555
action='append', default=[],
5656
help='Add additional framework search paths')
57-
parser.add_argument('-Fsystem', '-iframework',
58-
dest='system_framework_dirs', metavar='DIR',
59-
action='append', default=[],
57+
parser.add_argument('-Fsystem', dest='system_framework_dirs',
58+
metavar='DIR', action='append', default=[],
6059
help='Add additional system framework search paths')
6160
parser.add_argument('-Fsystem-iosmac',
6261
dest='iosmac_system_framework_dirs', metavar='DIR',

0 commit comments

Comments
 (0)