diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 243d3b079..71e58732c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,23 +2,50 @@ name: CI on: push: - branches: [ master, dev ] + branches: [ master, dev, windows_compatibility ] pull_request: branches: [ master ] jobs: - build: + build-msys2-clang: + runs-on: windows-latest + strategy: + matrix: + build_type: [Release, Debug] + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v2 + + - uses: msys2/setup-msys2@v2 + with: + msystem: CLANG64 + update: true + install: git binutils mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-toolchain + + - name: CMake + run: | + mkdir build && cd build + /clang64/bin/cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + /clang64/bin/cmake --build . + - name: Build testproject + run: | + cd resources/testproject + ../../build/c3c build + + build-linux: runs-on: ubuntu-latest strategy: matrix: build_type: [Release, Debug] - + steps: - uses: actions/checkout@v1 - name: (Ubuntu) Download LLVM run: | sudo apt-get install zlib1g zlib1g-dev clang-11 libllvm11 llvm-11 llvm-11-dev llvm-11-runtime liblld-11-dev liblld-11 - + - name: CMake run: | mkdir build && cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index b41798e96..efb134261 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,5 +161,12 @@ target_link_libraries(c3c_wrappers ${llvm_libs} ${lld_libs}) #target_link_libraries(c3c m ${llvm_libs} c3c_wrappers lldCommon lldCore lldCOFF lldWASM lldMinGW lldELF lldDriver lldReaderWriter lldMachO lldYAML) target_link_libraries(c3c m ${llvm_libs} c3c_wrappers ${lld_libs}) +if (WIN32) + if (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILE_ID STREQUAL "GNU") + target_link_options(c3c PRIVATE -pthread) + target_compile_definitions(c3c PRIVATE USE_PTHREAD=1) + endif() +endif() + install(TARGETS c3c DESTINATION bin) diff --git a/src/utils/common.h b/src/utils/common.h index 03d25ed65..3633ca3de 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -28,11 +28,13 @@ #define PLATFORM_POSIX 1 #endif +#ifndef USE_PTHREAD #if PLATFORM_POSIX #define USE_PTHREAD 1 #else #define USE_PTHREAD 0 #endif +#endif #define IS_GCC 0 #define IS_CLANG 0