mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Filter out '-Xcc' search paths from Swift module compilation commands
These search paths will not get used during Swift module compilation and can only hinder module sharing among different targets. Resolves rdar://119217774
This commit is contained in:
@@ -1756,17 +1756,32 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
|
||||
clangImporterOpts.DetailedPreprocessingRecord;
|
||||
subClangImporterOpts.CASOpts = clangImporterOpts.CASOpts;
|
||||
|
||||
// If the compiler has been asked to be strict with ensuring downstream dependencies
|
||||
// get the parent invocation's context, or this is an Explicit build, inherit the
|
||||
// extra Clang arguments also.
|
||||
if (LoaderOpts.strictImplicitModuleContext || LoaderOpts.disableImplicitSwiftModule ||
|
||||
LoaderOpts.requestedAction == FrontendOptions::ActionType::ScanDependencies) {
|
||||
// Inherit any clang-specific state of the compilation (macros, clang flags, etc.)
|
||||
subClangImporterOpts.ExtraArgs = clangImporterOpts.ExtraArgs;
|
||||
for (auto arg : subClangImporterOpts.ExtraArgs) {
|
||||
GenericArgs.push_back("-Xcc");
|
||||
GenericArgs.push_back(ArgSaver.save(arg));
|
||||
}
|
||||
std::vector<std::string> inheritedParentContextClangArgs;
|
||||
if (LoaderOpts.requestedAction ==
|
||||
FrontendOptions::ActionType::ScanDependencies) {
|
||||
// For a dependency scanning action, interface build command generation must
|
||||
// inherit
|
||||
// `-Xcc` flags used for configuration of the building instance's
|
||||
// `ClangImporter`. However, we can ignore Clang search path flags because
|
||||
// explicit Swift module build tasks will not rely on them and they may be
|
||||
// source-target-context-specific and hinder module sharing across
|
||||
// compilation source targets.
|
||||
// Clang module dependecies of this Swift dependency will be distinguished by
|
||||
// their context hash for different variants, so would still cause a difference
|
||||
// in the Swift compile commands, when different.
|
||||
inheritedParentContextClangArgs =
|
||||
clangImporterOpts.getReducedExtraArgsForSwiftModuleDependency();
|
||||
} else if (LoaderOpts.strictImplicitModuleContext) {
|
||||
// If the compiler has been asked to be strict with ensuring downstream
|
||||
// dependencies get the parent invocation's context, inherit the extra Clang
|
||||
// arguments also. Inherit any clang-specific state of the compilation
|
||||
// (macros, clang flags, etc.)
|
||||
inheritedParentContextClangArgs = clangImporterOpts.ExtraArgs;
|
||||
}
|
||||
subClangImporterOpts.ExtraArgs = inheritedParentContextClangArgs;
|
||||
for (auto arg : subClangImporterOpts.ExtraArgs) {
|
||||
GenericArgs.push_back("-Xcc");
|
||||
GenericArgs.push_back(ArgSaver.save(arg));
|
||||
}
|
||||
|
||||
subClangImporterOpts.EnableClangSPI = clangImporterOpts.EnableClangSPI;
|
||||
|
||||
Reference in New Issue
Block a user