Skip to content

Commit 6390b16

Browse files
Merge pull request #4650 from swiftwasm/maxd/5.6-merge
Resolve conflicts with upstream 5.6 branch
2 parents b7abc09 + 581b6fc commit 6390b16

File tree

6 files changed

+39
-12
lines changed

6 files changed

+39
-12
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
170170
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
171171
# can be reused when a new version of Swift comes out (assuming the user hasn't
172172
# manually set it as part of their own CMake configuration).
173-
set(SWIFT_VERSION "5.6.1")
173+
set(SWIFT_VERSION "5.6.2")
174174

175175
set(SWIFT_VENDOR "" CACHE STRING
176176
"The vendor name of the Swift compiler")

lib/DriverTool/autolink_extract_main.cpp

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class AutolinkExtractInvocation {
113113
static bool
114114
extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile,
115115
std::vector<std::string> &LinkerFlags,
116+
std::unordered_map<std::string, bool> &SwiftRuntimeLibraries,
116117
CompilerInstance &Instance) {
117118
// Search for the section we hold autolink entries in
118119
for (auto &Section : ObjectFile->sections()) {
@@ -140,8 +141,13 @@ extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile,
140141
llvm::SmallVector<llvm::StringRef, 4> SplitFlags;
141142
SectionData->split(SplitFlags, llvm::StringRef("\0", 1), -1,
142143
/*KeepEmpty=*/false);
143-
for (const auto &Flag : SplitFlags)
144-
LinkerFlags.push_back(Flag.str());
144+
for (const auto &Flag : SplitFlags) {
145+
auto RuntimeLibEntry = SwiftRuntimeLibraries.find(Flag.str());
146+
if (RuntimeLibEntry == SwiftRuntimeLibraries.end())
147+
LinkerFlags.emplace_back(Flag.str());
148+
else
149+
RuntimeLibEntry->second = true;
150+
}
145151
}
146152
}
147153
return false;
@@ -154,12 +160,13 @@ extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile,
154160
static bool extractLinkerFlags(const llvm::object::Binary *Bin,
155161
CompilerInstance &Instance,
156162
StringRef BinaryFileName,
157-
std::vector<std::string> &LinkerFlags) {
163+
std::vector<std::string> &LinkerFlags,
164+
std::unordered_map<std::string, bool> &SwiftRuntimeLibraries) {
158165
if (auto *ObjectFile = llvm::dyn_cast<llvm::object::ELFObjectFileBase>(Bin)) {
159-
return extractLinkerFlagsFromObjectFile(ObjectFile, LinkerFlags, Instance);
166+
return extractLinkerFlagsFromObjectFile(ObjectFile, LinkerFlags, SwiftRuntimeLibraries, Instance);
160167
} else if (auto *ObjectFile =
161168
llvm::dyn_cast<llvm::object::WasmObjectFile>(Bin)) {
162-
return extractLinkerFlagsFromObjectFile(ObjectFile, LinkerFlags, Instance);
169+
return extractLinkerFlagsFromObjectFile(ObjectFile, LinkerFlags, SwiftRuntimeLibraries, Instance);
163170
} else if (auto *Archive = llvm::dyn_cast<llvm::object::Archive>(Bin)) {
164171
llvm::Error Error = llvm::Error::success();
165172
for (const auto &Child : Archive->children(Error)) {
@@ -173,7 +180,7 @@ static bool extractLinkerFlags(const llvm::object::Binary *Bin,
173180
return true;
174181
}
175182
if (extractLinkerFlags(ChildBinary->get(), Instance, BinaryFileName,
176-
LinkerFlags)) {
183+
LinkerFlags, SwiftRuntimeLibraries)) {
177184
return true;
178185
}
179186
}
@@ -205,6 +212,15 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
205212

206213
std::vector<std::string> LinkerFlags;
207214

215+
// Keep track of whether we've already added the common
216+
// Swift libraries that ususally have autolink directives
217+
// in most object fiels
218+
std::unordered_map<std::string, bool> SwiftRuntimeLibraries = {
219+
{"-lswiftSwiftOnoneSupport", false},
220+
{"-lswiftCore", false},
221+
{"-lswift_Concurrency", false},
222+
};
223+
208224
// Extract the linker flags from the objects.
209225
for (const auto &BinaryFileName : Invocation.getInputFilenames()) {
210226
auto BinaryOwner = llvm::object::createBinary(BinaryFileName);
@@ -221,7 +237,7 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
221237
}
222238

223239
if (extractLinkerFlags(BinaryOwner->getBinary(), Instance, BinaryFileName,
224-
LinkerFlags)) {
240+
LinkerFlags, SwiftRuntimeLibraries)) {
225241
return 1;
226242
}
227243
}
@@ -240,5 +256,11 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
240256
OutOS << Flag << '\n';
241257
}
242258

259+
for (const auto &RuntimeLib : SwiftRuntimeLibraries) {
260+
if (RuntimeLib.second)
261+
OutOS << RuntimeLib.first << '\n';
262+
}
263+
264+
243265
return 0;
244266
}

test/AutolinkExtract/import.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
// RUN: %target-swiftc_driver -emit-module -emit-module-path %t/empty.swiftmodule -module-name empty -module-link-name empty %S/empty.swift
33
// RUN: %target-swiftc_driver -c %s -I %t -o %t/import_experimental.o
44
// RUN: %target-swift-autolink-extract %t/import_experimental.o -o - | %FileCheck --check-prefix CHECK-%target-object-format %s
5+
// RUN: %target-swiftc_driver -c %s -I %t -o %t/import_experimental_again.o
6+
// RUN: %target-swift-autolink-extract %t/import_experimental.o %t/import_experimental_again.o -o - | %FileCheck --check-prefix CHECK-%target-object-format %s
7+
// RUN: %target-swift-autolink-extract %t/import_experimental.o %t/import_experimental_again.o -o - | %FileCheck --check-prefix UNIQUE %s
58

69
// REQUIRES: autolink-extract
710

11+
// UNIQUE-COUNT-1: -lswiftCore
12+
813
// CHECK-elf-DAG: -lswiftCore
914
// CHECK-elf-DAG: -lempty
1015

test/Serialization/Recovery/types-5-to-4.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import Lib
1616
func requiresConformance(_: B_RequiresConformance<B_ConformsToProto>) {}
1717
func requiresConformance(_: B_RequiresConformance<C_RelyOnConformanceImpl.Assoc>) {}
1818

19-
class Sub: Base {} // expected-error {{cannot inherit from class 'Base' (compiled with Swift 5.6.1) because it has overridable members that could not be loaded in Swift 4.1.50}}
20-
class Impl: Proto {} // expected-error {{type 'Impl' cannot conform to protocol 'Proto' (compiled with Swift 5.6.1) because it has requirements that could not be loaded in Swift 4.1.50}}
19+
class Sub: Base {} // expected-error {{cannot inherit from class 'Base' (compiled with Swift 5.6.2) because it has overridable members that could not be loaded in Swift 4.1.50}}
20+
class Impl: Proto {} // expected-error {{type 'Impl' cannot conform to protocol 'Proto' (compiled with Swift 5.6.2) because it has requirements that could not be loaded in Swift 4.1.50}}
2121

2222
#else // TEST
2323

test/SourceKit/Misc/compiler_version.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
// CHECK: key.version_major: 5
44
// CHECK: key.version_minor: 6
5-
// CHECK: key.version_patch: 1
5+
// CHECK: key.version_patch: 2

utils/build_swift/build_swift/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
CMAKE_GENERATOR = 'Ninja'
5050

5151
COMPILER_VENDOR = 'none'
52-
SWIFT_USER_VISIBLE_VERSION = Version('5.6.1')
52+
SWIFT_USER_VISIBLE_VERSION = Version('5.6.2')
5353
CLANG_USER_VISIBLE_VERSION = Version('13.0.0')
5454
SWIFT_ANALYZE_CODE_COVERAGE = 'false'
5555

0 commit comments

Comments
 (0)