diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 7923fa2..3639679 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -158,6 +158,46 @@ jobs: path-to-lcov: ${{ github.workspace }}/build/coverage.info github-token: ${{ secrets.GITHUB_TOKEN }} + # Windows MSYS2 builds (MinGW64, UCRT64, Clang64) + windows-msys2: + runs-on: windows-2022 + strategy: + fail-fast: false + matrix: + include: + - { sys: mingw64, env: x86_64, compiler: gcc } + - { sys: ucrt64, env: ucrt-x86_64, compiler: gcc } + - { sys: clang64, env: clang-x86_64, compiler: clang } + + name: Windows MSYS2 ${{ matrix.sys }} (${{ matrix.compiler }}) + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.sys }} + update: true + install: >- + mingw-w64-${{ matrix.env }}-cmake + mingw-w64-${{ matrix.env }}-ninja + mingw-w64-${{ matrix.env }}-${{ matrix.compiler }} + + - name: Configure + shell: msys2 {0} + run: | + cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DGHC_FILESYSTEM_BUILD_STD_TESTING=NO + + - name: Build + shell: msys2 {0} + run: cmake --build build + + - name: Test + shell: msys2 {0} + run: cd build && ctest --output-on-failure + # Legacy compilers via Docker # Tests with officially supported minimum versions (GCC 5.5+, Clang 6+) legacy-compilers: diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index a14b88f..1b292c2 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -1941,7 +1941,7 @@ GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, ec = detail::make_error_code(detail::portable_error::not_supported); return; } -#if defined(__GNUC__) && __GNUC__ >= 8 +#if defined(__GNUC__) && __GNUC__ >= 8 || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-function-type" #elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) @@ -1949,7 +1949,7 @@ GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, #pragma warning(disable : 4191) #endif static CreateSymbolicLinkW_fp api_call = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateSymbolicLinkW")); -#if defined(__GNUC__) && __GNUC__ >= 8 +#if defined(__GNUC__) && __GNUC__ >= 8 || defined(__clang__) #pragma GCC diagnostic pop #elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) #pragma warning(pop) @@ -1970,7 +1970,7 @@ GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, GHC_INLINE void create_hardlink(const path& target_name, const path& new_hardlink, std::error_code& ec) { -#if defined(__GNUC__) && __GNUC__ >= 8 +#if defined(__GNUC__) && __GNUC__ >= 8 || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-function-type" #elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) @@ -1978,7 +1978,7 @@ GHC_INLINE void create_hardlink(const path& target_name, const path& new_hardlin #pragma warning(disable : 4191) #endif static CreateHardLinkW_fp api_call = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW")); -#if defined(__GNUC__) && __GNUC__ >= 8 +#if defined(__GNUC__) && __GNUC__ >= 8 || defined(__clang__) #pragma GCC diagnostic pop #elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) #pragma warning(pop) @@ -2116,6 +2116,13 @@ private: element_type _handle; }; +// It seems GCC doesn't catch this, but Clang does +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72751 +#if defined(__clang__) && defined(__MINGW32__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnested-anon-types" +#endif + #ifndef REPARSE_DATA_BUFFER_HEADER_SIZE typedef struct _REPARSE_DATA_BUFFER { @@ -2152,6 +2159,10 @@ typedef struct _REPARSE_DATA_BUFFER #endif #endif +#if defined(__clang__) && defined(__MINGW32__) +#pragma clang diagnostic pop +#endif + template struct free_deleter { @@ -2247,7 +2258,7 @@ GHC_INLINE void timeToFILETIME(time_t t, FILETIME& ft) } template -GHC_INLINE uintmax_t hard_links_from_INFO(const INFO* info) +GHC_INLINE uintmax_t hard_links_from_INFO(const INFO*) { return static_cast(-1); } @@ -5594,7 +5605,8 @@ public: if (!_base.empty()) { ZeroMemory(&_findData, sizeof(WIN32_FIND_DATAW)); if ((_dirHandle = FindFirstFileW(GHC_NATIVEWP((_base / "*")), &_findData)) != INVALID_HANDLE_VALUE) { - if (std::wstring(_findData.cFileName) == L"." || std::wstring(_findData.cFileName) == L"..") { + if (wcscmp(_findData.cFileName, L".") == 0 || + wcscmp(_findData.cFileName, L"..") == 0) { increment(_ec); } else { @@ -5652,7 +5664,7 @@ public: _dir_entry._path.clear(); break; } - } while (std::wstring(_findData.cFileName) == L"." || std::wstring(_findData.cFileName) == L".."); + } while (wcscmp(_findData.cFileName, L".") == 0 || wcscmp(_findData.cFileName, L"..") == 0); } else { ec = _ec;