From c5607e9d68e9082ada9441f1949937f6b16d5c7f Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 10 Sep 2025 11:50:30 -0700 Subject: Fix crash when compiling specialized generic entrypoint containing a static const decl. (#8392) Closes #8184. We fixed three issues with this regression test: 1. After generating IR for a `SpecializeComponentType`, we should also strip the frontend decorations from the IR so there is no HighLevelDeclDecoration that will go into the backend. 2. When lowering a static const inside a generic function, we should not give the static const a linkage, because it won't such constant will not appear in global scope. Trying to give it a linkage decoration will lead to the parent generic (for the function) to have two duplicate Export/Import decorations with different mangle names, and confuses the linker. 3. Make sure internal exceptions does not leak through `IComponentType::getEntryPointCode`/`getTargetCode`. --- source/slang/slang-target-program.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'source/slang/slang-target-program.cpp') diff --git a/source/slang/slang-target-program.cpp b/source/slang/slang-target-program.cpp index ffb859b55..d7e7a73bb 100644 --- a/source/slang/slang-target-program.cpp +++ b/source/slang/slang-target-program.cpp @@ -98,16 +98,28 @@ IArtifact* TargetProgram::getOrCreateEntryPointResult(Int entryPointIndex, Diagn if (IArtifact* artifact = m_entryPointResults[entryPointIndex]) return artifact; - // If we haven't yet computed a layout for this target - // program, we need to make sure that is done before - // code generation. - // - if (!getOrCreateIRModuleForLayout(sink)) + try + { + // If we haven't yet computed a layout for this target + // program, we need to make sure that is done before + // code generation. + // + if (!getOrCreateIRModuleForLayout(sink)) + { + return nullptr; + } + + return _createEntryPointResult(entryPointIndex, sink); + } + catch (const Exception& e) { + sink->diagnose( + SourceLoc(), + Diagnostics::compilationAbortedDueToException, + typeid(e).name(), + e.Message); return nullptr; } - - return _createEntryPointResult(entryPointIndex, sink); } } // namespace Slang -- cgit v1.2.3