Skip to content

Commit bee2369

Browse files
committed
[Embedded] Treat the entrypoint function as having a unique definition
This ensures that one can use deferred code generation everywhere with Embedded Swift and still get the appropriate entry symbol emitted.
1 parent ed93b46 commit bee2369

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/SIL/IR/SILFunction.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,10 @@ bool SILFunction::hasNonUniqueDefinition() const {
558558
if (!getASTContext().LangOpts.hasFeature(Feature::Embedded))
559559
return false;
560560

561+
// If this function is the entrypoint, it is unique.
562+
if (getName() == getASTContext().getEntryPointFunctionName())
563+
return false;
564+
561565
// If this is for a declaration, ask it.
562566
if (auto declRef = getDeclRef()) {
563567
return declRef.hasNonUniqueDefinition();

test/embedded/linkage/diamond.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@
5656
// RUN: %target-run %t/Application | %FileCheck %s
5757

5858
// Test #%: All "intermediate", all the time. Main drives code generation
59-
// TODO: @main needs to drive the generation of code here.
6059
// RUN: %target-swift-frontend -c -emit-module -o %t/Root.o %t/Root.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library
6160
// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/ClientA.o %t/ClientA.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library
6261
// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/ClientB.o %t/ClientB.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library
6362
// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/Application.o %t/Application.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library
64-
// RUN-TODO: %target-clang %target-clang-resource-dir-opt %t/Root.o %t/ClientA.o %t/ClientB.o %t/Application.o -o %t/Application
65-
// RUN-TODO: %target-run %t/Application | %FileCheck %s
63+
// RUN: %target-clang %target-clang-resource-dir-opt %t/Root.o %t/ClientA.o %t/ClientB.o %t/Application.o -o %t/Application
64+
// RUN: %target-run %t/Application | %FileCheck %s
6665

6766

6867
// REQUIRES: swift_in_compiler

0 commit comments

Comments
 (0)