Repository navigation
Conversation
GNU ld is pathologically slow at linking the static LLVM/Clang archives into a PE/COFF DLL (tens of minutes for libpocl). ld.lld is far faster, but its COFF driver doesn't implement GNU ld's --exclude-libs, which libpocl used to keep the static-lib symbols out of its auto-generated export table. Without that, auto-exporting the whole static LLVM blob overflows the 64K PE export-ordinal limit. Switch MinGW to the MSVC-style export model, which works with both GNU ld and lld: - stamp __declspec(dllexport) on the OpenCL API for any Windows toolchain (defined(_WIN32)), not just _MSC_VER; - define EXPORT_POCL_LIB / IMPORT_POCL_LIB for any WIN32 shared build, not just MSVC; - export only the dllexport'd symbols (--exclude-all-symbols) instead of auto-export-minus-static-libs (--exclude-libs). Because libpocl now exports only its public API, its internal symbols are no longer visible to separately-dlopen'd driver modules, so consumers must build with ENABLE_LOADABLE_DRIVERS=OFF (drivers linked into libpocl). Also make the spirv_fix_atomic_compare_exchange helper compile its own copy of spirv_parser.cc in the non-ICD case, mirroring the ICD branch, so it no longer relies on SPIRVParser being exported from libpocl. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets libpocl be built for MinGW with the Clang/lld toolchain. GNU ld takes tens of minutes to link the static LLVM/Clang archives into a PE/COFF DLL; ld.lld is much faster, but its COFF driver lacks
--exclude-libs, which libpocl used to keep the static libraries' symbols out of its auto-generated export table. Auto-exporting all of LLVM overflows the 64K PE export-ordinal limit.MinGW now uses the MSVC-style export model, which works with both GNU ld and lld:
__declspec(dllexport)on the OpenCL API for any Windows toolchain,EXPORT_POCL_LIB/IMPORT_POCL_LIBfor any WIN32 shared build, and--exclude-all-symbolsinstead of--exclude-libs. The catch is that libpocl only exports its public API, so loadable driver modules can no longer reach its internals: builds have to useENABLE_LOADABLE_DRIVERS=OFF. That's why this isn't proposed upstream. Thespirv_fix_atomic_compare_exchangehelper now compiles its own copy ofspirv_parser.ccin the non-ICD case too, as it already did for ICD builds, instead of relying on libpocl exportingSPIRVParser.The JuliaGPU PoCL JLLs build Windows this way; this is the first patch of their series (Yggdrasil
P/pocl, 0001 in bothpoclandpocl_next).