|
10 | 10 | //
|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
13 |
| -import struct Foundation.Data |
| 13 | +import Foundation |
14 | 14 |
|
15 | 15 | import Testing
|
16 | 16 |
|
@@ -8657,6 +8657,64 @@ fileprivate struct TaskConstructionTests: CoreBasedTests {
|
8657 | 8657 | }
|
8658 | 8658 | }
|
8659 | 8659 |
|
| 8660 | + @Test(.requireSDKs(.host)) |
| 8661 | + func crossPlatformDeadCodeStripping() async throws { |
| 8662 | + try await withTemporaryDirectory { tmpDir in |
| 8663 | + let testProject = TestProject( |
| 8664 | + "aProject", |
| 8665 | + sourceRoot: tmpDir, |
| 8666 | + groupTree: TestGroup( |
| 8667 | + "SomeFiles", path: "Sources", |
| 8668 | + children: [ |
| 8669 | + TestFile("SourceFile.c"), |
| 8670 | + ]), |
| 8671 | + buildConfigurations: [ |
| 8672 | + TestBuildConfiguration("Debug", buildSettings: [ |
| 8673 | + "DEAD_CODE_STRIPPING": "YES", |
| 8674 | + "ONLY_ACTIVE_ARCH": "YES" |
| 8675 | + ]) |
| 8676 | + ], |
| 8677 | + targets: [ |
| 8678 | + TestStandardTarget( |
| 8679 | + "Library", |
| 8680 | + type: .dynamicLibrary, |
| 8681 | + buildConfigurations: [ |
| 8682 | + TestBuildConfiguration("Debug") |
| 8683 | + ], |
| 8684 | + buildPhases: [ |
| 8685 | + TestSourcesBuildPhase([ |
| 8686 | + "SourceFile.c", |
| 8687 | + ]) |
| 8688 | + ] |
| 8689 | + )] |
| 8690 | + ) |
| 8691 | + |
| 8692 | + let fs = PseudoFS() |
| 8693 | + |
| 8694 | + let core = try await getCore() |
| 8695 | + let tester = try TaskConstructionTester(core, testProject) |
| 8696 | + |
| 8697 | + try await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: [:]), runDestination: .host, fs: fs) { results in |
| 8698 | + try results.checkTask(.matchRuleType("Ld")) { task in |
| 8699 | + switch try ProcessInfo.processInfo.hostOperatingSystem() { |
| 8700 | + case .macOS: |
| 8701 | + task.checkCommandLineContains(["-dead_strip"]) |
| 8702 | + task.checkCommandLineDoesNotContain("--gc-sections") |
| 8703 | + task.checkCommandLineDoesNotContain("/OPT:REF") |
| 8704 | + case .windows: |
| 8705 | + task.checkCommandLineDoesNotContain("-dead_strip") |
| 8706 | + task.checkCommandLineDoesNotContain("--gc-sections") |
| 8707 | + task.checkCommandLineContains(["/OPT:REF"]) |
| 8708 | + default: |
| 8709 | + task.checkCommandLineDoesNotContain("-dead_strip") |
| 8710 | + task.checkCommandLineContains(["--gc-sections"]) |
| 8711 | + task.checkCommandLineDoesNotContain("/OPT:REF") |
| 8712 | + } |
| 8713 | + } |
| 8714 | + } |
| 8715 | + } |
| 8716 | + } |
| 8717 | + |
8660 | 8718 | @Test(.requireSDKs(.macOS))
|
8661 | 8719 | func warningSuppression() async throws {
|
8662 | 8720 | try await withTemporaryDirectory { tmpDir in
|
|
0 commit comments