From 49e912a9d0d6ca5f762ec11cd8cb918f182eb76e Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 17 Dec 2024 12:42:24 -0800 Subject: Fix entrypoint auto discovery logic. (#5885) * Fix entrypoint auto discovery logic. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- source/slang/slang.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 9e9b5fbe3..7d18cb50b 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -5171,22 +5171,24 @@ IArtifact* ComponentType::getTargetArtifact(Int targetIndex, slang::IBlob** outD entryPointsDiscovered = true; } } - // If no entry points were discovered, then we should return nullptr. - if (!entryPointsDiscovered) - { - return nullptr; - } - RefPtr composite = new CompositeComponentType(linkage, components); - ComPtr linkedComponentType; - SLANG_RETURN_NULL_ON_FAIL(composite->link(linkedComponentType.writeRef(), outDiagnostics)); - auto targetArtifact = static_cast(linkedComponentType.get()) - ->getTargetArtifact(targetIndex, outDiagnostics); - if (targetArtifact) + // If any entry points were discovered, then we should emit the program with entrypoints + // linked. + if (entryPointsDiscovered) { - m_targetArtifacts[targetIndex] = targetArtifact; + RefPtr composite = + new CompositeComponentType(linkage, components); + ComPtr linkedComponentType; + SLANG_RETURN_NULL_ON_FAIL( + composite->link(linkedComponentType.writeRef(), outDiagnostics)); + auto targetArtifact = static_cast(linkedComponentType.get()) + ->getTargetArtifact(targetIndex, outDiagnostics); + if (targetArtifact) + { + m_targetArtifacts[targetIndex] = targetArtifact; + } + return targetArtifact; } - return targetArtifact; } auto target = linkage->targets[targetIndex]; -- cgit v1.2.3