Skip to content

Commit 6db2c7d

Browse files
committed
Add test fixture for experimental-lto-mode
1 parent a0b3bc4 commit 6db2c7d

File tree

7 files changed

+54
-0
lines changed

7 files changed

+54
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// swift-tools-version: 5.9
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "SwiftAndCTargets",
7+
targets: [
8+
.target(name: "cLib"),
9+
.executableTarget(name: "exe", dependencies: ["cLib", "swiftLib"]),
10+
.target(name: "swiftLib"),
11+
]
12+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <stdio.h>
2+
3+
#include "include/cLib.h"
4+
5+
void cPrint(int value) {
6+
printf("c value: %i\n", value);
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
extern void cPrint(int);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import swiftLib
2+
import cLib
3+
4+
cPrint(1)
5+
swiftPrint(value: 2)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func swiftPrint(value: Int) {
2+
print("swift value: \(value)")
3+
}

Tests/FunctionalTests/MiscellaneousTests.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,22 @@ class MiscellaneousTestCase: XCTestCase {
358358
}
359359
}
360360

361+
func testLTO() throws {
362+
try fixture(name: "Miscellaneous/LTO/SwiftAndCTargets") { fixturePath in
363+
do {
364+
let output = try executeSwiftBuild(
365+
fixturePath,
366+
extraArgs: ["--experimental-lto-mode=full"])
367+
// FIXME: On macOS dsymutil cannot find temporary .o files? (#6890)
368+
// Ensure warnings like the following are not present in build output
369+
// warning: (arm64) /var/folders/ym/6l_0x8vj0b70sz_4h9d70p440000gn/T/main-e120de.o unable to open object file: No such file or directory
370+
// XCTAssertNoMatch(output.stdout, .contains("unable to open object file"))
371+
} catch {
372+
XCTFail("\(error)")
373+
}
374+
}
375+
}
376+
361377
func testUnicode() throws {
362378
#if !os(Linux) && !os(Android) // TODO: - Linux has trouble with this and needs investigation.
363379
try fixture(name: "Miscellaneous/Unicode") { fixturePath in

0 commit comments

Comments
 (0)