diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml new file mode 100644 index 000000000..52dcfdea7 --- /dev/null +++ b/.github/workflows/mingw.yml @@ -0,0 +1,57 @@ +name: MinGW Clang64 Full Pipeline + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + profile: [RelWithDebInfo, Debug] + + name: MinGW Clang64 Build (${{ matrix.profile }}) + runs-on: windows-2025 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + + - name: Setup MSYS2 + id: msys2 + uses: msys2/setup-msys2@v2 + with: + msystem: clang64 + update: true + install: >- + git + mingw-w64-clang-x86_64-toolchain + mingw-w64-clang-x86_64-cmake + mingw-w64-clang-x86_64-ninja + + - name: Configure + shell: msys2 {0} + run: > + cmake -GNinja + -B"$(cygpath -u "$GITHUB_WORKSPACE")/build" + -DCMAKE_BUILD_TYPE=${{ matrix.profile }} + -DCMAKE_CXX_COMPILER=clang++ + -DCMAKE_C_COMPILER=clang + + - name: Build + shell: msys2 {0} + run: > + cmake + --build "$(cygpath -u "$GITHUB_WORKSPACE")/build" + --parallel + + - name: Test + shell: msys2 {0} + run: | + cd "$(cygpath -u "$GITHUB_WORKSPACE")/build" + ctest + diff --git a/CMakeLists.txt b/CMakeLists.txt index cad25ef65..3d41c7042 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -280,6 +280,12 @@ if(MSVC) target_compile_options(snmalloc INTERFACE "/Zc:__cplusplus") endif() +if(MINGW) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(snmalloc INTERFACE "-fms-extensions") + endif() +endif() + if (CMAKE_SYSTEM_NAME STREQUAL NetBSD) target_include_directories(snmalloc INTERFACE /usr/pkg/include) target_link_directories(snmalloc INTERFACE /usr/pkg/lib) @@ -381,9 +387,10 @@ function(add_warning_flags name) $<$:/Zi /W4 /WX /wd4127 /wd4324 /wd4201> $<$,$>>:-fno-rtti -Wall -Wextra -Werror -Wundef> $<$:-Wsign-conversion -Wconversion>) + target_link_options(${name} PRIVATE $<$:-Wl,--no-undefined> - $<$:$<${ci_or_debug}:/DEBUG>>) + $<$:$<${ci_or_debug}:LINKER:/DEBUG>>) endfunction() # To build with just the header library target define SNMALLOC_HEADER_ONLY_LIBRARY diff --git a/src/snmalloc/pal/pal_windows.h b/src/snmalloc/pal/pal_windows.h index a44079dea..46d3fa034 100644 --- a/src/snmalloc/pal/pal_windows.h +++ b/src/snmalloc/pal/pal_windows.h @@ -41,8 +41,10 @@ * be destroyed when the program exits or the DLL is * unloaded. */ -# pragma warning(disable : 4075) -# pragma init_seg(".CRT$XCB") +# ifndef __MINGW32__ +# pragma warning(disable : 4075) +# pragma init_seg(".CRT$XCB") +# endif namespace snmalloc { diff --git a/src/test/func/protect_fork/protect_fork.cc b/src/test/func/protect_fork/protect_fork.cc index 28a8f4c7a..dd7b73a4d 100644 --- a/src/test/func/protect_fork/protect_fork.cc +++ b/src/test/func/protect_fork/protect_fork.cc @@ -1,7 +1,7 @@ #include #include -#ifndef SNMALLOC_PTHREAD_ATFORK_WORKS +#if !defined(SNMALLOC_PTHREAD_ATFORK_WORKS) || defined(__MINGW32__) int main() { std::cout << "Test did not run" << std::endl; @@ -78,4 +78,4 @@ int main() return 0; } -#endif \ No newline at end of file +#endif