Skip to content

Commit abd02ac

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 abd02ac

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-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: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "swift/Option/Options.h"
3939
#include "swift/Parse/ParseVersion.h"
4040
#include "llvm/ADT/IntrusiveRefCntPtr.h"
41+
#include "llvm/ADT/STLExtras.h"
4142
#include "llvm/Support/VirtualOutputBackends.h"
4243
#include "llvm/Support/raw_ostream.h"
4344
#include <functional>
@@ -2261,11 +2262,12 @@ class SwiftAPIDigesterInvocation {
22612262
std::string BaselineSDK;
22622263
std::string Triple;
22632264
std::string SwiftVersion;
2264-
std::vector<std::string> CCSystemFrameworkPaths;
2265+
std::vector<std::string> SystemFrameworkPaths;
22652266
std::vector<std::string> BaselineFrameworkPaths;
22662267
std::vector<std::string> FrameworkPaths;
2267-
std::vector<std::string> BaselineModuleInputPaths;
2268-
std::vector<std::string> ModuleInputPaths;
2268+
std::vector<std::string> SystemModuleImportPaths;
2269+
std::vector<std::string> BaselineModuleImportPaths;
2270+
std::vector<std::string> ModuleImportPaths;
22692271
std::string ModuleList;
22702272
std::vector<std::string> ModuleNames;
22712273
std::vector<std::string> PreferInterfaceForModules;
@@ -2362,11 +2364,13 @@ class SwiftAPIDigesterInvocation {
23622364
BaselineSDK = ParsedArgs.getLastArgValue(OPT_bsdk).str();
23632365
Triple = ParsedArgs.getLastArgValue(OPT_target).str();
23642366
SwiftVersion = ParsedArgs.getLastArgValue(OPT_swift_version).str();
2365-
CCSystemFrameworkPaths = ParsedArgs.getAllArgValues(OPT_iframework);
2367+
SystemFrameworkPaths = ParsedArgs.getAllArgValues(OPT_Fsystem);
2368+
llvm::append_range(SystemFrameworkPaths, ParsedArgs.getAllArgValues(OPT_iframework));
23662369
BaselineFrameworkPaths = ParsedArgs.getAllArgValues(OPT_BF);
23672370
FrameworkPaths = ParsedArgs.getAllArgValues(OPT_F);
2368-
BaselineModuleInputPaths = ParsedArgs.getAllArgValues(OPT_BI);
2369-
ModuleInputPaths = ParsedArgs.getAllArgValues(OPT_I);
2371+
SystemModuleImportPaths = ParsedArgs.getAllArgValues(OPT_Isystem);
2372+
BaselineModuleImportPaths = ParsedArgs.getAllArgValues(OPT_BI);
2373+
ModuleImportPaths = ParsedArgs.getAllArgValues(OPT_I);
23702374
ModuleList = ParsedArgs.getLastArgValue(OPT_module_list_file).str();
23712375
ModuleNames = ParsedArgs.getAllArgValues(OPT_module);
23722376
PreferInterfaceForModules =
@@ -2421,7 +2425,7 @@ class SwiftAPIDigesterInvocation {
24212425
}
24222426

24232427
bool hasBaselineInput() {
2424-
return !BaselineModuleInputPaths.empty() ||
2428+
return !BaselineModuleImportPaths.empty() ||
24252429
!BaselineFrameworkPaths.empty() || !BaselineSDK.empty();
24262430
}
24272431

@@ -2476,29 +2480,30 @@ class SwiftAPIDigesterInvocation {
24762480
InitInvoke.setRuntimeResourcePath(ResourceDir);
24772481
}
24782482
std::vector<SearchPathOptions::SearchPath> FramePaths;
2479-
for (const auto &path : CCSystemFrameworkPaths) {
2483+
for (const auto &path : SystemFrameworkPaths) {
24802484
FramePaths.push_back({path, /*isSystem=*/true});
24812485
}
2486+
std::vector<SearchPathOptions::SearchPath> ImportPaths;
2487+
for (const auto &path : SystemModuleImportPaths) {
2488+
ImportPaths.push_back({path, /*isSystem=*/true});
2489+
}
24822490
if (IsBaseline) {
24832491
for (const auto &path : BaselineFrameworkPaths) {
24842492
FramePaths.push_back({path, /*isSystem=*/false});
24852493
}
2486-
std::vector<SearchPathOptions::SearchPath> ImportPaths;
2487-
for (const auto &path : BaselineModuleInputPaths) {
2494+
for (const auto &path : BaselineModuleImportPaths) {
24882495
ImportPaths.push_back({path, /*isSystem=*/false});
24892496
}
2490-
InitInvoke.setImportSearchPaths(ImportPaths);
24912497
} else {
24922498
for (const auto &path : FrameworkPaths) {
24932499
FramePaths.push_back({path, /*isSystem=*/false});
24942500
}
2495-
std::vector<SearchPathOptions::SearchPath> ImportPaths;
2496-
for (const auto &path : ModuleInputPaths) {
2501+
for (const auto &path : ModuleImportPaths) {
24972502
ImportPaths.push_back({path, /*isSystem=*/false});
24982503
}
2499-
InitInvoke.setImportSearchPaths(ImportPaths);
25002504
}
25012505
InitInvoke.setFrameworkSearchPaths(FramePaths);
2506+
InitInvoke.setImportSearchPaths(ImportPaths);
25022507
if (!ModuleList.empty()) {
25032508
if (readFileLineByLine(ModuleList, Modules))
25042509
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)