diff --git a/CHANGELOG.md b/CHANGELOG.md index 950892e64..63dfde46a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [WIP] + +This release is WIP + +### Fixed + +- Re-enable Windows support by fixing a range of Windows-specific and dependency-related issues (#336) + ## [0.7.0] - 2025-08-18 This release includes changes that may require adjustments when upgrading: diff --git a/include/utils.h b/include/utils.h index 4794966b1..c0d4640dc 100644 --- a/include/utils.h +++ b/include/utils.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/include/workaround.h b/include/workaround.h index e236b72ac..52e4369bc 100644 --- a/include/workaround.h +++ b/include/workaround.h @@ -6,6 +6,16 @@ #include +#ifdef _WIN32 +// Prevent Windows headers from polluting global namespace with min/max macros. +#ifndef NOMINMAX +#define NOMINMAX +#endif +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#endif + #if CELERITY_SYCL_IS_DPCPP #define CELERITY_WORKAROUND_DPCPP 1 @@ -47,9 +57,14 @@ #if __has_cpp_attribute(no_unique_address) // C++20, but implemented as an extension for earlier standards in Clang #define CELERITY_DETAIL_HAS_NO_UNIQUE_ADDRESS true #define CELERITY_DETAIL_NO_UNIQUE_ADDRESS [[no_unique_address]] +#elif __has_cpp_attribute(msvc::no_unique_address) +#define CELERITY_DETAIL_HAS_NO_UNIQUE_ADDRESS true +#define CELERITY_DETAIL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] #else #define CELERITY_DETAIL_HAS_NO_UNIQUE_ADDRESS false #define CELERITY_DETAIL_NO_UNIQUE_ADDRESS +#warning \ + "Compiler does not support [[no_unique_address]] or equivalent, which may lead to incorrect behavior of 0-dimensional accessors and other edge cases where empty base optimization is required for correct layout. Random failures and crashes may occur." #endif #if CELERITY_ACCESSOR_BOUNDARY_CHECK diff --git a/src/backend/sycl_backend.cc b/src/backend/sycl_backend.cc index 4631a96da..dff8cd7ed 100644 --- a/src/backend/sycl_backend.cc +++ b/src/backend/sycl_backend.cc @@ -116,7 +116,7 @@ struct sycl_backend::impl { sycl::context sycl_context; std::vector queues; std::optional submission_thread; - std::atomic_flag active_async_error_check = false; + std::atomic_flag active_async_error_check; // since c++20 atomic_flag is set to clear by default (false) device_state() = default; explicit device_state(const sycl::device& dev) : sycl_device(dev), sycl_context(sycl_device) {} diff --git a/src/dry_run_executor.cc b/src/dry_run_executor.cc index 1c029aa12..845507a39 100644 --- a/src/dry_run_executor.cc +++ b/src/dry_run_executor.cc @@ -4,7 +4,7 @@ #include "instruction_graph.h" #include "log.h" #include "named_threads.h" - +#include "pilot.h" namespace celerity::detail { diff --git a/src/utils.cc b/src/utils.cc index 6227787ae..c88efda7a 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -20,7 +20,7 @@ #include -#if !defined(_MSC_VER) +#if __has_include() // Required for kernel name demangling in Clang #include #endif @@ -28,16 +28,68 @@ namespace celerity::detail::utils { +#if !__has_include() +static std::string msvc_undecorate_type_name(std::string s) { + static constexpr const char* ptr_suffixes[] = { + " * __ptr64", + " * __ptr32", + " *", + " & __ptr64", + " &", + " && __ptr64", + " &&", + }; + for(const char* suffix : ptr_suffixes) { + std::string_view sv(suffix); + if(s.size() >= sv.size() && s.compare(s.size() - sv.size(), sv.size(), sv) == 0) { + s.erase(s.size() - sv.size()); + break; + } + } + + static constexpr const char* cv_suffixes[] = { + " const volatile", + " volatile", + " const", + }; + for(const char* suffix : cv_suffixes) { + std::string_view sv(suffix); + if(s.size() >= sv.size() && s.compare(s.size() - sv.size(), sv.size(), sv) == 0) { + s.erase(s.size() - sv.size()); + break; + } + } + + static constexpr const char* prefixes[] = { + "class ", + "struct ", + "union ", + "enum ", + }; + for(const char* prefix : prefixes) { + std::string_view sv(prefix); + if(s.compare(0, sv.size(), sv) == 0) { + s.erase(0, sv.size()); + break; + } + } + + return s; +} +#endif + std::string get_simplified_type_name_from_pointer(const std::type_info& pointer_type_info) { -#if !defined(_MSC_VER) +// This type of demangling can be done if the abi header is available. This also works for Clang on Windows, if +// compiled with Itanium ABI on Windows (e.g. MinGW/MSYS2). MSVC +#if __has_include() const std::unique_ptr demangle_buffer(abi::__cxa_demangle(pointer_type_info.name(), nullptr, nullptr, nullptr), std::free); std::string demangled_type_name = demangle_buffer.get(); -#else - std::string demangled_type_name = pointer_type_info.name(); -#endif // get rid of the pointer "*" if(!demangled_type_name.empty() && demangled_type_name.back() == '*') { demangled_type_name.pop_back(); } +#else + std::string demangled_type_name = msvc_undecorate_type_name(pointer_type_info.name()); +#endif if(demangled_type_name.length() < 2) return demangled_type_name; bool templated = false; diff --git a/test/accessor_tests.cc b/test/accessor_tests.cc index ea738bc0c..66d885991 100644 --- a/test/accessor_tests.cc +++ b/test/accessor_tests.cc @@ -5,6 +5,7 @@ #include #include +#include #include "test_utils.h" diff --git a/test/runtime_tests.cc b/test/runtime_tests.cc index 0645718d4..59477f298 100644 --- a/test/runtime_tests.cc +++ b/test/runtime_tests.cc @@ -1,4 +1,8 @@ +#ifdef _WIN32 +// pthread isn't available on Windows; only include on Unix-like systems +#else #include +#endif #include #include diff --git a/test/test_utils.cc b/test/test_utils.cc index 9f89271f8..b4e562f3b 100644 --- a/test/test_utils.cc +++ b/test/test_utils.cc @@ -9,7 +9,7 @@ #include #include -#include +#include // we need this inl as windows has problems with the non-inlined version #include namespace celerity::test_utils_detail {