Skip to content

Commit 7cd58d6

Browse files
shahmishalartemcmabertelrud
authored
[5.4] [Bootstrap] Do not pass -Ddispatch_DIR to the Yams CMake build (#3363) (#3423)
* [Bootstrap] Do not pass `-Ddispatch_DIR` to the Yams CMake build (#3363) With the version-bump of Yams in swiftlang/swift#36366, Yams `4.0.2` now actually expresses the dependency on Dispatch in its CMake config. With the current behavior of passing `-Ddispatch_DIR` to its CMake build, we have the following problem on Linux: - `swift`'s `build-script` installs Dispatch into a just-built toolchain which we use to build SwiftPM, which will contain, among other things, the Dispatch `.swiftmodule`. - The compiler workspace checkout of `swift-corelibs-libdispatch` also contains a copy of the Dispatch `.swiftmodule`. Both of these will be found, leading to build failures like: ``` /home/buildnode/jenkins/workspace/swift-PR-Linux/branch-main/swift-nightly-install/usr/lib/swift/dispatch/module.modulemap:1:8: error: redefinition of module 'Dispatch' 19:37:47 module Dispatch { 19:37:47 ^ 19:37:47 /home/buildnode/jenkins/workspace/swift-PR-Linux/branch-main/swift-corelibs-libdispatch/dispatch/module.modulemap:1:8: note: previously defined here 19:37:47 module Dispatch { 19:37:47 ^ 19:37:47 ``` We also cannot put off building `libDispatch` until SwiftPM is built, because the `libDispatch` dylib is required to link SwiftPM. Not passing `-Ddispatch_DIR` to Yams' CMake build causes it to successfully locate the Dispatch package in the just-built toolchain on its own. (cherry picked from commit 6af862d) * Fix invalid assumptions leading to unit test failures on Apple Silicon. (#3328) rdar://75113176 (cherry picked from commit 3ff6f8b) * Disable `testExplicitSwiftPackageBuild` on Apple Silicon because it relies on compiler fixes from later compiler versions, on this platform. Co-authored-by: Artem Chikin <[email protected]> Co-authored-by: Anders Bertelrud <[email protected]>
1 parent cfbe360 commit 7cd58d6

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

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

77
See http://swift.org/LICENSE.txt for license information
@@ -142,7 +142,7 @@ final class BuildPlanTests: XCTestCase {
142142
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
143143
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
144144
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
145-
"-target", "x86_64-apple-macosx10.10", "-Xlinker", "-add_ast_path",
145+
"-target", defaultTargetTriple, "-Xlinker", "-add_ast_path",
146146
"-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule", "-Xlinker", "-add_ast_path",
147147
"-Xlinker", "/path/to/build/debug/lib.swiftmodule",
148148
]
@@ -169,6 +169,11 @@ final class BuildPlanTests: XCTestCase {
169169
}
170170

171171
func testExplicitSwiftPackageBuild() throws {
172+
#if os(macOS) && arch(arm64)
173+
// Disabled on Apple Silicon on the 5.4 branch
174+
// because relies on fixes from later compiler versions.
175+
throw XCTSkip()
176+
#endif
172177
try withTemporaryDirectory { path in
173178
// Create a test package with three targets:
174179
// A -> B -> C
@@ -454,7 +459,7 @@ final class BuildPlanTests: XCTestCase {
454459
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
455460
"@/path/to/build/release/exe.product/Objects.LinkFileList",
456461
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
457-
"-target", "x86_64-apple-macosx10.10",
462+
"-target", defaultTargetTriple,
458463
])
459464
#else
460465
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -556,7 +561,7 @@ final class BuildPlanTests: XCTestCase {
556561
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
557562
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
558563
"-runtime-compatibility-version", "none",
559-
"-target", "x86_64-apple-macosx10.10",
564+
"-target", defaultTargetTriple,
560565
])
561566
#else
562567
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -707,7 +712,7 @@ final class BuildPlanTests: XCTestCase {
707712
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
708713
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
709714
"-runtime-compatibility-version", "none",
710-
"-target", "x86_64-apple-macosx10.10",
715+
"-target", defaultTargetTriple,
711716
])
712717
#else
713718
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -783,7 +788,7 @@ final class BuildPlanTests: XCTestCase {
783788
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
784789
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
785790
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
786-
"-target", "x86_64-apple-macosx10.10",
791+
"-target", defaultTargetTriple,
787792
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
788793
])
789794
#else
@@ -936,7 +941,7 @@ final class BuildPlanTests: XCTestCase {
936941
"-Xlinker", "-rpath", "-Xlinker", "@loader_path/../../../",
937942
"@/path/to/build/debug/PkgPackageTests.product/Objects.LinkFileList",
938943
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
939-
"-target", "x86_64-apple-macosx\(version)",
944+
"-target", "\(hostTriple.tripleString(forPlatformVersion: version))",
940945
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.swiftmodule",
941946
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/FooTests.swiftmodule",
942947
])
@@ -993,7 +998,7 @@ final class BuildPlanTests: XCTestCase {
993998
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
994999
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
9951000
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
996-
"-target", "x86_64-apple-macosx10.10",
1001+
"-target", defaultTargetTriple,
9971002
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
9981003
])
9991004
#else
@@ -1091,7 +1096,7 @@ final class BuildPlanTests: XCTestCase {
10911096
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
10921097
"@/path/to/build/debug/Foo.product/Objects.LinkFileList",
10931098
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
1094-
"-target", "x86_64-apple-macosx10.10",
1099+
"-target", defaultTargetTriple,
10951100
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.build/Foo.swiftmodule"
10961101
])
10971102

@@ -1102,7 +1107,7 @@ final class BuildPlanTests: XCTestCase {
11021107
"-Xlinker", "-install_name", "-Xlinker", "@rpath/libBar-Baz.dylib",
11031108
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
11041109
"@/path/to/build/debug/Bar-Baz.product/Objects.LinkFileList",
1105-
"-target", "x86_64-apple-macosx10.10",
1110+
"-target", defaultTargetTriple,
11061111
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Bar.swiftmodule"
11071112
])
11081113
#else
@@ -1182,7 +1187,7 @@ final class BuildPlanTests: XCTestCase {
11821187
"-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib",
11831188
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
11841189
"@/path/to/build/debug/lib.product/Objects.LinkFileList",
1185-
"-target", "x86_64-apple-macosx10.10",
1190+
"-target", defaultTargetTriple,
11861191
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/lib.swiftmodule",
11871192
]
11881193
#else
@@ -1252,9 +1257,9 @@ final class BuildPlanTests: XCTestCase {
12521257
XCTAssertEqual(lib.moduleMap, AbsolutePath("/path/to/build/debug/lib.build/module.modulemap"))
12531258

12541259
#if os(macOS)
1255-
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"])
1260+
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])
12561261

1257-
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"])
1262+
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])
12581263
#else
12591264
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])
12601265
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])
@@ -1811,14 +1816,14 @@ final class BuildPlanTests: XCTestCase {
18111816

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

18191824
let bTarget = try result.target(for: "BTarget").swiftTarget().compileArguments()
18201825
#if os(macOS)
1821-
XCTAssertMatch(bTarget, ["-target", "x86_64-apple-macosx10.12", .anySequence])
1826+
XCTAssertMatch(bTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.12")), .anySequence])
18221827
#else
18231828
XCTAssertMatch(bTarget, [.equal("-target"), .equal(defaultTargetTriple), .anySequence] )
18241829
#endif

Utilities/bootstrap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,6 @@ def build_yams(args):
536536
cmake_flags.append("-DCMAKE_C_FLAGS=-target %s%s" % (get_build_target(args), g_macos_deployment_target))
537537
cmake_flags.append("-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % g_macos_deployment_target)
538538
else:
539-
if args.dispatch_build_dir:
540-
cmake_flags.append(get_dispatch_cmake_arg(args))
541-
542539
if args.foundation_build_dir:
543540
cmake_flags.append(get_foundation_cmake_arg(args))
544541

0 commit comments

Comments
 (0)