Repository navigation
[linux-port] Cross-platform critical section - #235
Conversation
|
❌ Build DirectXShaderCompiler 1.0.154 failed (commit cc5a32c29b by @pow2clk) |
|
Okay well I learned that clang-spirv-tests doesn't replace a simple dxc run test. This means this has a rather larger prerequisite. Either an ugly violation of hierarchy or a conversion to explicit loading like Windows does. |
InitializeCriticalSection, DeleteCriticalSection, EnterCriticalSection, and LeaveCriticalSection serve to create a mutual exclusion section of code, but they are stubbed out currently for non-win platforms. There is multi-platform support for the same functionality in LLVM in the form of SmartMutex. This switches from the Windows specific to the abstraction, allowing the same code to work on other platforms. Fixes half of google#198
|
I hit upon a simpler solution that ignores the larger problem based on the fact that I am completely certain that "dxil.dll" will never be found successfully on a linux system. So the function that boils down to if it is or ever was found will always be false and the premature use of a critical section can be avoided. This ignores two issues: the critical section/ mutex is initialized as part of the initialization of the dxcompiler library, which is completely bypassed by linux currently. So far we've managed to make do without it, but at the least it represents a significant difference between the overall behavior of the linux and windows build. There are options to make this work similarly on linux. It might be worth it only to make it work more like Windows does for the sake of fewer surprises. The root of the problem seems to be that Linux dynamically links dxcompiler instead of loading it. I haven't conclusively identified why the cmake files do that yet. |
|
✅ Build DirectXShaderCompiler 1.0.155 completed (commit 2fcbef4930 by @pow2clk) |
|
Given the following code by MS: DirectXShaderCompiler/lib/Support/Windows/Mutex.inc Lines 25 to 52 in 18610e7 and that lock() and unlock() call the impl's acquire() and release(), your change looks very reasonable to me. |
| #define OutputDebugStringA(msg) fputs(msg, stderr) | ||
| #define OutputDebugFormatA(...) fprintf(stderr, __VA_ARGS__) | ||
|
|
||
| // Note: This will *disable* the CRITICAL_SECTION structures in the code. |
|
LGTM. I'd just wait a bit and see if MS responds to the issue . If we don't get a response soon, we can just merge this change and improve it in a future CL. |
|
Yeah. The microsoft change to the original class puzzled me. It wouldn't have been strictly necessary for this change, but there's another static Mutex lurking somewhere that gets initialized as a static object, so before the TLS Malloc gets set, so it fails if it has to allocate anything. |
InitializeCriticalSection, DeleteCriticalSection, EnterCriticalSection,
and LeaveCriticalSection serve to create a mutual exclusion section of
code, but they are stubbed out currently for non-win platforms.
There is multi-platform support for the same functionality in LLVM
in the form of SmartMutex. This switches from the Windows specific
to the abstraction, allowing the same code to work on other platforms.
Fixes half of #198