AdaptiveCpp: Debug build DLL hangs on LoadLibrary (Windows)
I’m encountering an issue where a DLL built in Debug configuration hangs when loaded using LoadLibrary. Dependency Walker also freezes when attempting to load the DLL. This issue does not occur in Release mode.
The hang occurs during the DLL loading process, specifically when using the SYCL parallel_for construct. Removing this construct allows the DLL to load correctly.
Minimal Reproducible Example:
#include <sycl/sycl.hpp>
extern "C" __declspec(dllexport) void acpp_dll_function()
{
auto d_selector{ sycl::cpu_selector_v };
sycl::queue q(d_selector);
q.submit([&](sycl::handler& h)
{
h.parallel_for(sycl::range<1>(1), [=](auto i) {});
});
}
This simple DLL hangs on load in Debug mode.
Build:
Using command line:
python "c:/adaptivecpp/bin/acpp" -g -D_DEBUG -shared -o dynamiclib.dll dynamiclib.cpp --acpp-targets="omp" -D_MT -lmsvcrtd -Xlinker /NODEFAULTLIB:libcmt
Using cmake: CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(dynamiclib)
set(AdaptiveCpp_DIR "C:/AdaptiveCpp/lib/cmake/AdaptiveCpp")
set(ACPP_TARGETS "omp")
set(CMAKE_C_COMPILER "C:/llvm/bin/clang.exe")
set(CMAKE_CXX_COMPILER "C:/llvm/bin/clang++.exe")
find_package(AdaptiveCpp CONFIG REQUIRED)
include_directories(${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR})
add_library(dynamiclib SHARED "dynamiclib.cpp")
add_sycl_to_target(TARGET dynamiclib SOURCES "dynamiclib.cpp")
cmake .. -G Ninja -DCMAKE_C_COMPILER=clang.exe -DCMAKE_CXX_COMPILER=clang++.exe -DCMAKE_BUILD_TYPE=Debug
ninja
Trying to load DLL:
HMODULE acpp_dll = LoadLibrary(L"dynamiclib.dll"); // hangs here
Dependency Walker also freezes while trying to load this DLL.
Any insights or suggestions would be greatly appreciated.
About this issue
- Original URL
- State: open
- Created 6 months ago
- Comments: 16 (8 by maintainers)
Jup, don’t mix Debug and Release on windows, they have different abi and when linking normally (I.e. not at runtime), you will be notified about this by erroring out with “iterator level x in file X doesn’t match level y in file Y”