Skip to content

Commit 63856bb

Browse files
authored
Merge pull request #2899 from swiftwasm/release/5.4
[pull] swiftwasm-release/5.4 from release/5.4
2 parents 3d2a882 + 66e146e commit 63856bb

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/Driver/UnixToolChains.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
273273
Arguments.push_back(context.Args.MakeArgString(context.OI.SDKPath));
274274
}
275275

276+
// If we are linking statically, we need to add all
277+
// dependencies to a library search group to resolve
278+
// potential circular dependencies
279+
if (staticExecutable || staticStdlib) {
280+
Arguments.push_back("-Xlinker");
281+
Arguments.push_back("--start-group");
282+
}
283+
276284
// Add any autolinking scripts to the arguments
277285
for (const Job *Cmd : context.Inputs) {
278286
auto &OutputInfo = Cmd->getOutput();
@@ -281,6 +289,11 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
281289
Twine("@") + OutputInfo.getPrimaryOutputFilename()));
282290
}
283291

292+
if (staticExecutable || staticStdlib) {
293+
Arguments.push_back("-Xlinker");
294+
Arguments.push_back("--end-group");
295+
}
296+
284297
// Add the runtime library link paths.
285298
for (auto path : RuntimeLibPaths) {
286299
Arguments.push_back("-L");

lib/SIL/IR/SILModule.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,17 @@ void SILModule::checkForLeaks() const {
167167
}
168168

169169
void SILModule::checkForLeaksAfterDestruction() {
170+
// Disabled in release (non-assert) builds because this check fails in rare
171+
// cases in lldb, causing crashes. rdar://70826934
172+
#ifndef NDEBUG
170173
int numAllocated = SILInstruction::getNumCreatedInstructions() -
171174
SILInstruction::getNumDeletedInstructions();
172175

173176
if (numAllocated != 0) {
174177
llvm::errs() << "Leaking " << numAllocated << " instructions!\n";
175178
llvm_unreachable("leaking instructions");
176179
}
180+
#endif
177181
}
178182

179183
std::unique_ptr<SILModule> SILModule::createEmptyModule(

test/Driver/linker-args-order-linux.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ print("hello world!")
66
// RUN: %target-swiftc_driver -driver-print-jobs -static-stdlib -o %t/static-stdlib %s -Xlinker --no-allow-multiple-definition 2>&1| %FileCheck %s
77
// CHECK: {{.*}}/swift-frontend -frontend -c -primary-file {{.*}}/linker-args-order-linux.swift
88
// CHECK: {{.*}}/swift-autolink-extract{{.*}}
9-
// CHECK: {{.*}}swiftrt.o /{{.*}}/linker-args-order-linux-{{[a-z0-9]+}}.o @/{{.*}}/linker-args-order-linux-{{[a-z0-9]+}}.autolink {{.*}} @{{.*}}/static-stdlib-args.lnk {{.*}} -Xlinker --no-allow-multiple-definition
9+
// CHECK: {{.*}}swiftrt.o /{{.*}}/linker-args-order-linux-{{[a-z0-9]+}}.o -Xlinker --start-group @/{{.*}}/linker-args-order-linux-{{[a-z0-9]+}}.autolink -Xlinker --end-group {{.*}} @{{.*}}/static-stdlib-args.lnk {{.*}} -Xlinker --no-allow-multiple-definition

0 commit comments

Comments
 (0)