From 5a629b3ccd801a1f0647e971d01481c55d3381c2 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Fri, 14 Apr 2023 11:59:17 +0800 Subject: Enable SLANG_ENABLE_DXIL_SUPPORT on non-Windows platforms (#2750) * Enable SLANG_ENABLE_DXIL_SUPPORT on non-Windows platforms This currently grabs the DXC headers from the system, rather than from external/dxc We should make this consistent by either pulling in the Windows adapter from DXC into external/dxc or by making the Windows builds use * Update dxcapi and add DXC's WinAdapter * Use our copy of dxcapi.h for non-windows DXC usage * Only set -fms-extensions where necessary * Work around dxc dlclose bug * Neaten and comment dxc-compiler.cpp --- source/core/slang-platform.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/core/slang-platform.cpp') diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index dc2d563df..bb612932c 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -177,9 +177,14 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); /* static */SlangResult SharedLibrary::loadWithPlatformPath(char const* platformFileName, Handle& handleOut) { handleOut = nullptr; + const auto dxcName = "libdxcompiler"; + const bool isDXC = strncmp(platformFileName, dxcName, strlen(dxcName)) == 0; if (strlen(platformFileName) == 0) platformFileName = nullptr; - void *h = dlopen(platformFileName, RTLD_NOW | RTLD_GLOBAL); + // Work around https://github.com/microsoft/DirectXShaderCompiler/issues/5119 + // libdxcompiler.so invokes UB on dlclose + const auto mode = RTLD_NOW | RTLD_GLOBAL | (isDXC ? RTLD_NODELETE : 0); + void *h = dlopen(platformFileName, mode); if (!h) { #if 0 -- cgit v1.2.3