Skip to content

Fix invalid assumptions leading to unit test failures on Apple Silicon #3328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See http://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -141,7 +141,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
"-target", "x86_64-apple-macosx10.10", "-Xlinker", "-add_ast_path",
"-target", defaultTargetTriple, "-Xlinker", "-add_ast_path",
"-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule", "-Xlinker", "-add_ast_path",
"-Xlinker", "/path/to/build/debug/lib.swiftmodule",
]
Expand Down Expand Up @@ -453,7 +453,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/release/exe.product/Objects.LinkFileList",
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
"-target", "x86_64-apple-macosx10.10",
"-target", defaultTargetTriple,
])
#else
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
Expand Down Expand Up @@ -555,7 +555,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
"-runtime-compatibility-version", "none",
"-target", "x86_64-apple-macosx10.10",
"-target", defaultTargetTriple,
])
#else
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
Expand Down Expand Up @@ -706,7 +706,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
"-runtime-compatibility-version", "none",
"-target", "x86_64-apple-macosx10.10",
"-target", defaultTargetTriple,
])
#else
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
Expand Down Expand Up @@ -782,7 +782,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
"-target", "x86_64-apple-macosx10.10",
"-target", defaultTargetTriple,
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
])
#else
Expand Down Expand Up @@ -935,7 +935,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-rpath", "-Xlinker", "@loader_path/../../../",
"@/path/to/build/debug/PkgPackageTests.product/Objects.LinkFileList",
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
"-target", "x86_64-apple-macosx\(version)",
"-target", "\(hostTriple.tripleString(forPlatformVersion: version))",
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.swiftmodule",
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/FooTests.swiftmodule",
])
Expand Down Expand Up @@ -992,7 +992,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
"-target", "x86_64-apple-macosx10.10",
"-target", defaultTargetTriple,
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
])
#else
Expand Down Expand Up @@ -1090,7 +1090,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/debug/Foo.product/Objects.LinkFileList",
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
"-target", "x86_64-apple-macosx10.10",
"-target", defaultTargetTriple,
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.build/Foo.swiftmodule"
])

Expand All @@ -1101,7 +1101,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-install_name", "-Xlinker", "@rpath/libBar-Baz.dylib",
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/debug/Bar-Baz.product/Objects.LinkFileList",
"-target", "x86_64-apple-macosx10.10",
"-target", defaultTargetTriple,
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Bar.swiftmodule"
])
#else
Expand Down Expand Up @@ -1181,7 +1181,7 @@ final class BuildPlanTests: XCTestCase {
"-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib",
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
"@/path/to/build/debug/lib.product/Objects.LinkFileList",
"-target", "x86_64-apple-macosx10.10",
"-target", defaultTargetTriple,
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/lib.swiftmodule",
]
#else
Expand Down Expand Up @@ -1251,9 +1251,9 @@ final class BuildPlanTests: XCTestCase {
XCTAssertEqual(lib.moduleMap, AbsolutePath("/path/to/build/debug/lib.build/module.modulemap"))

#if os(macOS)
XCTAssertEqual(try result.buildProduct(for: "lib").linkArguments(), ["/fake/path/to/swiftc", "-lc++", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/liblib.dylib", "-module-name", "lib", "-emit-library", "-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib", "-Xlinker", "-rpath", "-Xlinker", "@loader_path", "@/path/to/build/debug/lib.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", "x86_64-apple-macosx10.10"])
XCTAssertEqual(try result.buildProduct(for: "lib").linkArguments(), ["/fake/path/to/swiftc", "-lc++", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/liblib.dylib", "-module-name", "lib", "-emit-library", "-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib", "-Xlinker", "-rpath", "-Xlinker", "@loader_path", "@/path/to/build/debug/lib.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", defaultTargetTriple])

XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), ["/fake/path/to/swiftc", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/exe", "-module-name", "exe", "-emit-executable", "-Xlinker", "-rpath", "-Xlinker", "@loader_path", "@/path/to/build/debug/exe.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", "x86_64-apple-macosx10.10"])
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), ["/fake/path/to/swiftc", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/exe", "-module-name", "exe", "-emit-executable", "-Xlinker", "-rpath", "-Xlinker", "@loader_path", "@/path/to/build/debug/exe.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", defaultTargetTriple])
#else
XCTAssertEqual(try result.buildProduct(for: "lib").linkArguments(), ["/fake/path/to/swiftc", "-lstdc++", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/liblib.so", "-module-name", "lib", "-emit-library", "-Xlinker", "-rpath=$ORIGIN", "@/path/to/build/debug/lib.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", defaultTargetTriple])
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), ["/fake/path/to/swiftc", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/exe", "-module-name", "exe", "-emit-executable", "-Xlinker", "-rpath=$ORIGIN", "@/path/to/build/debug/exe.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", defaultTargetTriple])
Expand Down Expand Up @@ -1810,14 +1810,14 @@ final class BuildPlanTests: XCTestCase {

let aTarget = try result.target(for: "ATarget").swiftTarget().compileArguments()
#if os(macOS)
XCTAssertMatch(aTarget, ["-target", "x86_64-apple-macosx10.13", .anySequence])
XCTAssertMatch(aTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.13")), .anySequence])
#else
XCTAssertMatch(aTarget, [.equal("-target"), .equal(defaultTargetTriple), .anySequence] )
#endif

let bTarget = try result.target(for: "BTarget").swiftTarget().compileArguments()
#if os(macOS)
XCTAssertMatch(bTarget, ["-target", "x86_64-apple-macosx10.12", .anySequence])
XCTAssertMatch(bTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.12")), .anySequence])
#else
XCTAssertMatch(bTarget, [.equal("-target"), .equal(defaultTargetTriple), .anySequence] )
#endif
Expand Down