Skip to content

Commit b209f72

Browse files
authored
Merge pull request #36185 from xymus/move-lock-files
[Frontend] Lock the swiftmodule when rebuilding from the swiftinterface
2 parents 7f79783 + a18c2a1 commit b209f72

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

lib/Frontend/ModuleInterfaceBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ bool ModuleInterfaceBuilder::buildSwiftModule(StringRef OutPath,
293293
// processes are doing the same.
294294
// FIXME: We should surface the module building step to the build system so
295295
// we don't need to synchronize here.
296-
llvm::LockFileManager Locked(interfacePath);
296+
llvm::LockFileManager Locked(OutPath);
297297
switch (Locked) {
298298
case llvm::LockFileManager::LFS_Error:{
299299
// ModuleInterfaceBuilder takes care of correctness and locks are only

test/APIJSON/access.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// REQUIRES: objc_interop, OS=macosx
66
// RUN: %empty-directory(%t)
77
// RUN: cp %s %t/MyModule.swiftinterface
8-
// RUN: %target-swift-api-extract -target x86_64-apple-macos11.0 -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule | %FileCheck %s
8+
// RUN: %target-swift-api-extract -target x86_64-apple-macos11.0 -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule -module-cache-path %t | %FileCheck %s
99

1010
public func publicFunction()
1111
internal func internalFunction()

test/APIJSON/apigen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: objc_interop, OS=macosx
22
// RUN: %empty-directory(%t)
3-
// RUN: %target-swift-frontend %s -typecheck -emit-module-interface-path %t/MyModule.swiftinterface -enable-library-evolution -module-name MyModule -swift-version 5
4-
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule | %FileCheck %s
3+
// RUN: %target-swift-frontend %s -typecheck -emit-module-interface-path %t/MyModule.swiftinterface -enable-library-evolution -module-name MyModule -swift-version 5
4+
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule -module-cache-path %t | %FileCheck %s
55

66
import Foundation
77

test/APIJSON/non-objc-class.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: objc_interop, OS=macosx
22
// RUN: %empty-directory(%t)
33
// RUN: %target-swift-frontend %s -typecheck -emit-module-interface-path %t/MyModule.swiftinterface -enable-library-evolution -module-name MyModule -swift-version 5
4-
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule | %FileCheck %s
4+
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule -module-cache-path %t | %FileCheck %s
55

66
import Foundation
77

test/APIJSON/spi.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: objc_interop, OS=macosx
22
// RUN: %empty-directory(%t)
33
// RUN: %target-swift-frontend %s -typecheck -emit-module-interface-path %t/MyModule.swiftinterface -enable-library-evolution -module-name MyModule -swift-version 5
4-
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule | %FileCheck %s
4+
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule -module-cache-path %t | %FileCheck %s
55

66
import Foundation
77

test/APIJSON/struct.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: objc_interop, OS=macosx
22
// RUN: %empty-directory(%t)
33
// RUN: %target-swift-frontend %s -typecheck -emit-module-interface-path %t/MyModule.swiftinterface -enable-library-evolution -module-name MyModule -swift-version 5
4-
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule | %FileCheck %s
4+
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule -module-cache-path %t | %FileCheck %s
55

66
// Struct has no objc data.
77
@available(macOS 10.13, *)

test/Driver/lock_interface.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
// REQUIRES: rdar59977439
21
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/sdk)
33
// RUN: %empty-directory(%t/module-cache-lock)
44
// RUN: %empty-directory(%t/module-cache-no-lock)
5-
// RUN: echo 'public func foo() {}' > %t/Foo.swift
6-
// RUN: %target-swift-frontend-typecheck -emit-module-interface-path %t/Foo.swiftinterface %t/Foo.swift -enable-library-evolution
5+
// RUN: echo 'public func foo() {}' > %t/sdk/Foo.swift
6+
// RUN: %target-swift-frontend-typecheck -emit-module-interface-path %t/sdk/Foo.swiftinterface %t/sdk/Foo.swift -enable-library-evolution
7+
// RUN: chmod a-w %t/sdk
8+
79
// RUN: touch %t/main.swift %t/file-01.swift %t/file-02.swift %t/file-03.swift
810
// RUN: echo 'import Foo' > %t/file-01.swift
911
// RUN: echo 'import Foo' > %t/file-02.swift
1012
// RUN: echo 'import Foo' > %t/file-03.swift
11-
// RUN: %target-swiftc_driver -j20 %t/main.swift %t/file-01.swift %t/file-02.swift %t/file-03.swift -I %t -Xfrontend -Rmodule-interface-rebuild -module-cache-path %t/module-cache &> %t/result.txt
13+
// RUN: %target-swiftc_driver -j20 %t/main.swift %t/file-01.swift %t/file-02.swift %t/file-03.swift -I %t/sdk -Xfrontend -Rmodule-interface-rebuild -module-cache-path %t/module-cache &> %t/result.txt
1214
// RUN: %FileCheck %s -check-prefix=CHECK-REBUILD < %t/result.txt
1315

14-
// RUN: %target-swiftc_driver -j20 %t/main.swift %t/file-01.swift %t/file-02.swift %t/file-03.swift -I %t -Xfrontend -Rmodule-interface-rebuild -Xfrontend -disable-interface-lock -module-cache-path %t/module-cache-no-lock &> %t/result.txt
16+
// RUN: %target-swiftc_driver -j20 %t/main.swift %t/file-01.swift %t/file-02.swift %t/file-03.swift -I %t/sdk -Xfrontend -Rmodule-interface-rebuild -Xfrontend -disable-interface-lock -module-cache-path %t/module-cache-no-lock &> %t/result.txt
1517

1618
// RUN: %FileCheck %s -check-prefix=CHECK-REBUILD-NO-LOCK < %t/result.txt
1719

20+
// Reset the permissions
21+
// RUN: chmod a+w %t/sdk
22+
1823
// Ensure we only build Foo module once from the interface
1924
// CHECK-REBUILD: rebuilding module 'Foo' from interface
2025
// CHECK-REBUILD-NOT: rebuilding module 'Foo' from interface
26+
// CHECK-REBUILD-NOT: building module interface without lock file
2127

2228
// CHECK-REBUILD-NO-LOCK: rebuilding module 'Foo' from interface
2329
// CHECK-REBUILD-NO-LOCK: rebuilding module 'Foo' from interface

0 commit comments

Comments
 (0)