Skip to content

[ABIChecker] Use -Isystem and -Fsystem for swift-api-digester #82283

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
4 changes: 2 additions & 2 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def F_EQ : Joined<["-"], "F=">, Flags<[FrontendOption, ArgumentIsPath]>,

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

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

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

def import_underlying_module : Flag<["-"], "import-underlying-module">,
Expand Down
33 changes: 19 additions & 14 deletions lib/DriverTool/swift_api_digester_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "swift/Option/Options.h"
#include "swift/Parse/ParseVersion.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/VirtualOutputBackends.h"
#include "llvm/Support/raw_ostream.h"
#include <functional>
Expand Down Expand Up @@ -2261,11 +2262,12 @@ class SwiftAPIDigesterInvocation {
std::string BaselineSDK;
std::string Triple;
std::string SwiftVersion;
std::vector<std::string> CCSystemFrameworkPaths;
std::vector<std::string> SystemFrameworkPaths;
std::vector<std::string> BaselineFrameworkPaths;
std::vector<std::string> FrameworkPaths;
std::vector<std::string> BaselineModuleInputPaths;
std::vector<std::string> ModuleInputPaths;
std::vector<std::string> SystemModuleImportPaths;
std::vector<std::string> BaselineModuleImportPaths;
std::vector<std::string> ModuleImportPaths;
std::string ModuleList;
std::vector<std::string> ModuleNames;
std::vector<std::string> PreferInterfaceForModules;
Expand Down Expand Up @@ -2362,11 +2364,13 @@ class SwiftAPIDigesterInvocation {
BaselineSDK = ParsedArgs.getLastArgValue(OPT_bsdk).str();
Triple = ParsedArgs.getLastArgValue(OPT_target).str();
SwiftVersion = ParsedArgs.getLastArgValue(OPT_swift_version).str();
CCSystemFrameworkPaths = ParsedArgs.getAllArgValues(OPT_iframework);
SystemFrameworkPaths = ParsedArgs.getAllArgValues(OPT_Fsystem);
llvm::append_range(SystemFrameworkPaths, ParsedArgs.getAllArgValues(OPT_iframework));
BaselineFrameworkPaths = ParsedArgs.getAllArgValues(OPT_BF);
FrameworkPaths = ParsedArgs.getAllArgValues(OPT_F);
BaselineModuleInputPaths = ParsedArgs.getAllArgValues(OPT_BI);
ModuleInputPaths = ParsedArgs.getAllArgValues(OPT_I);
SystemModuleImportPaths = ParsedArgs.getAllArgValues(OPT_Isystem);
BaselineModuleImportPaths = ParsedArgs.getAllArgValues(OPT_BI);
ModuleImportPaths = ParsedArgs.getAllArgValues(OPT_I);
ModuleList = ParsedArgs.getLastArgValue(OPT_module_list_file).str();
ModuleNames = ParsedArgs.getAllArgValues(OPT_module);
PreferInterfaceForModules =
Expand Down Expand Up @@ -2421,7 +2425,7 @@ class SwiftAPIDigesterInvocation {
}

bool hasBaselineInput() {
return !BaselineModuleInputPaths.empty() ||
return !BaselineModuleImportPaths.empty() ||
!BaselineFrameworkPaths.empty() || !BaselineSDK.empty();
}

Expand Down Expand Up @@ -2476,29 +2480,30 @@ class SwiftAPIDigesterInvocation {
InitInvoke.setRuntimeResourcePath(ResourceDir);
}
std::vector<SearchPathOptions::SearchPath> FramePaths;
for (const auto &path : CCSystemFrameworkPaths) {
for (const auto &path : SystemFrameworkPaths) {
FramePaths.push_back({path, /*isSystem=*/true});
}
std::vector<SearchPathOptions::SearchPath> ImportPaths;
for (const auto &path : SystemModuleImportPaths) {
ImportPaths.push_back({path, /*isSystem=*/true});
}
if (IsBaseline) {
for (const auto &path : BaselineFrameworkPaths) {
FramePaths.push_back({path, /*isSystem=*/false});
}
std::vector<SearchPathOptions::SearchPath> ImportPaths;
for (const auto &path : BaselineModuleInputPaths) {
for (const auto &path : BaselineModuleImportPaths) {
ImportPaths.push_back({path, /*isSystem=*/false});
}
InitInvoke.setImportSearchPaths(ImportPaths);
} else {
for (const auto &path : FrameworkPaths) {
FramePaths.push_back({path, /*isSystem=*/false});
}
std::vector<SearchPathOptions::SearchPath> ImportPaths;
for (const auto &path : ModuleInputPaths) {
for (const auto &path : ModuleImportPaths) {
ImportPaths.push_back({path, /*isSystem=*/false});
}
InitInvoke.setImportSearchPaths(ImportPaths);
}
InitInvoke.setFrameworkSearchPaths(FramePaths);
InitInvoke.setImportSearchPaths(ImportPaths);
if (!ModuleList.empty()) {
if (readFileLineByLine(ModuleList, Modules))
exit(1);
Expand Down
2 changes: 1 addition & 1 deletion utils/api_checker/swift-api-checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def run(self, output, module, swift_ver, opts,
'/tmp/ModuleCache', '-swift-version',
swift_ver, '-abort-on-module-fail']
for path in self.frameworks:
cmd.extend(['-iframework', path])
cmd.extend(['-Fsystem', path])
for path in self.inputs:
cmd.extend(['-I', path])
if self.abi:
Expand Down
5 changes: 2 additions & 3 deletions utils/swift_build_sdk_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ def create_parser():
parser.add_argument('-F', dest='framework_dirs', metavar='DIR',
action='append', default=[],
help='Add additional framework search paths')
parser.add_argument('-Fsystem', '-iframework',
dest='system_framework_dirs', metavar='DIR',
action='append', default=[],
parser.add_argument('-Fsystem', dest='system_framework_dirs',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the input argument to swift_buil_sdk_interfaces.py which I think is deprecated already. @artemcm @nkcsgexi Is that correct?

Seems irrelevant to your fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I maybe have been a little too enthusiastic about removing -iframework. I'm still kind of tempted to drop it here, but I can put it back if you think that's better.

metavar='DIR', action='append', default=[],
help='Add additional system framework search paths')
parser.add_argument('-Fsystem-iosmac',
dest='iosmac_system_framework_dirs', metavar='DIR',
Expand Down