From 8904dc1850f1efda5e9fe913f4a65efa7b615cf2 Mon Sep 17 00:00:00 2001 From: Jakub Rosner Date: Tue, 8 Sep 2026 14:38:15 +0200 Subject: [PATCH] fix: validate_global_mappings should only check external declarations Globals with external linkage that are *defined* in the module are allocated by the JIT itself and need no address from the renderer, but the check tested only hasExternalLinkage() and so reported every such definition as unmapped. This is only an issue on Windows: When rs_simplerend.cpp is compiled to bitcode, OSLEXECPUBLIC expands to __declspec(dllimport) in dist\include\OSL\export.h and clang emits them as zero-initialized globals with a global constructor that stores to them. Those globals survive pruning and report "was not mapped to an address" error. On other platforms the same references become constants, and are erased by prune_and_internalize_module() before validation runs. Restricting the check to declarations removes the false positive errors Assisted-by: Claude / Claude Opus 5 Signed-off-by: Jakub Rosner --- src/liboslexec/llvm_util.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/liboslexec/llvm_util.cpp b/src/liboslexec/llvm_util.cpp index 012a1ae98..dd8734b0e 100644 --- a/src/liboslexec/llvm_util.cpp +++ b/src/liboslexec/llvm_util.cpp @@ -2731,7 +2731,10 @@ LLVM_Util::validate_global_mappings( std::vector& names_of_unmapped_globals) { for (llvm::GlobalVariable& global : m_llvm_module->globals()) { - if (global.hasExternalLinkage()) { + // Only external *declarations* need an address supplied from outside + // the module. A definition with external linkage is allocated by the + // JIT itself, so reporting it as unmapped is a false positive. + if (global.hasExternalLinkage() && global.isDeclaration()) { void* global_addr = llvm::sys::DynamicLibrary::SearchForAddressOfSymbol( global.getName().data());