mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Don't serialize relative resource dir module paths
This commit is contained in:
@@ -105,6 +105,12 @@ bool ExplicitModuleInterfaceBuilder::collectDepsForSerialization(
|
||||
path::native(SDKPath);
|
||||
SmallString<128> ResourcePath(Opts.RuntimeResourcePath);
|
||||
path::native(ResourcePath);
|
||||
// When compiling with a relative resource dir, the clang
|
||||
// importer will track inputs with absolute paths. To avoid
|
||||
// serializing resource dir inputs we need to check for
|
||||
// relative _and_ absolute prefixes.
|
||||
SmallString<128> AbsResourcePath(ResourcePath);
|
||||
llvm::sys::fs::make_absolute(AbsResourcePath);
|
||||
|
||||
auto DTDeps = Instance.getDependencyTracker()->getDependencies();
|
||||
SmallVector<std::string, 16> InitialDepNames(DTDeps.begin(), DTDeps.end());
|
||||
@@ -146,7 +152,7 @@ bool ExplicitModuleInterfaceBuilder::collectDepsForSerialization(
|
||||
}
|
||||
|
||||
// Don't serialize compiler-relative deps so the cache is relocatable.
|
||||
if (DepName.starts_with(ResourcePath))
|
||||
if (DepName.starts_with(ResourcePath) || DepName.starts_with(AbsResourcePath))
|
||||
continue;
|
||||
|
||||
auto Status = fs.status(DepName);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Name: ClangModule
|
||||
Globals:
|
||||
- Name: CMThing
|
||||
SwiftName: SwiftThing
|
||||
@@ -0,0 +1 @@
|
||||
struct CMThing {};
|
||||
@@ -0,0 +1,3 @@
|
||||
module ClangModule [system] {
|
||||
header "ClangModuleHeader.h"
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
// swift-module-flags: -target arm64-apple-macosx15.0 -module-name OtherModule -O
|
||||
|
||||
import Swift
|
||||
import ClangModule
|
||||
|
||||
public struct OtherStruct {
|
||||
var x : Int
|
||||
|
||||
13
test/ModuleInterface/relative-resource-path.swift
Normal file
13
test/ModuleInterface/relative-resource-path.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
// REQUIRES: OS=macosx
|
||||
|
||||
// RUN: %empty-directory(%t.relative_resource_path)
|
||||
// RUN: %empty-directory(%t.mcp)
|
||||
// RUN: cp -R %S/Inputs/resource_dir %t.relative_resource_path/
|
||||
// RUN: cd %t.relative_resource_path
|
||||
|
||||
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs/stdlib_rebuild -module-cache-path %t.mcp) -target arm64-apple-macosx15.0 \
|
||||
// RUN: -resource-dir resource_dir -compile-module-from-interface -o OtherModule.swiftmodule \
|
||||
// RUN: %S/Inputs/stdlib_rebuild/usr/lib/swift/OtherModule.swiftmodule/arm64-apple-macos.swiftinterface
|
||||
// RUN: llvm-bcanalyzer -dump OtherModule.swiftmodule | %FileCheck %s
|
||||
|
||||
// CHECK-NOT: <DEPENDENCY_DIRECTORY abbrevid=11/> blob data = '/
|
||||
Reference in New Issue
Block a user