Skip to content

Commit

Permalink
fix: dev: prep msvc cl and github environment for conda on windows
Browse files Browse the repository at this point in the history
* disable pthreads when using msvc compiler
* fix build errors on windows, including the following:
  missing symbols, non-const, designated initializers
* uncork sys/stat.h and add missing win32 define for S_ISDIR

Signed-off-by: Stephen L Arnold <[email protected]>
  • Loading branch information
sarnold committed Mar 8, 2025
1 parent 26edc35 commit ffd433e
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 5 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/conda-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,54 @@ jobs:
- os: 'windows-2019'
generator: 'Ninja'
build_type: 'Debug'
extra_args: '-DBUILD_SHARED_LIBS=OFF -DABC_USE_NO_READLINE=ON -DVENDOR_GTEST=ON'
extra_args: '-DBUILD_SHARED_LIBS=OFF -DABC_USE_NO_PTHREADS=ON -DABC_USE_NO_READLINE=ON -DVENDOR_GTEST=ON'
env:
OS: ${{ matrix.os }}
PY_VER: ${{ matrix.python-version }}
PYTHONIOENCODING: utf-8
CMAKE_ARGS: ${{ matrix.use_namespace && '-DABC_USE_NAMESPACE=xxx' || '' }}

steps:
#- if: matrix.os == 'windows-2019'
#name: Install newer windows compiler
#id: install_cc
#uses: rlalik/setup-cpp-compiler@master
#with:
#compiler: g++-11.2.0

#- if: matrix.os == 'windows-2019'
#name: Use compiler
#shell: bash -l {0}
#env:
#CC: ${{ steps.install_cc.outputs.cc }}
#CXX: ${{ steps.install_cc.outputs.cxx }}
#run: |

- uses: actions/checkout@v4

- name: Setup base python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Prepare build environment for windows
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Env (Windows)
if: runner.os == 'Windows'
run: |
echo "CXX=cl.exe" >> $GITHUB_ENV
echo "CC=cl.exe" >> $GITHUB_ENV
- name: Cache conda
id: cache
uses: actions/cache@v4
env:
# Increase this value to reset cache if environment.devenv.yml has not changed
CACHE_NUMBER: 1
CACHE_NUMBER: 2
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.devenv.yml') }}
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
"_MBCS"
"_SCL_SECURE_NO_WARNINGS"
"_CRT_SECURE_NO_WARNINGS"
"_CRT_INTERNAL_NONSTDC_NAMES"
"_XKEYCHECK_H"
"_ALLOW_KEYWORD_MACROS=1"
)
Expand Down
2 changes: 1 addition & 1 deletion src/base/abc/abcHieNew.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ Gia_Man_t * Au_ManDeriveTest( Abc_Ntk_t * pRoot )
extern Vec_Ptr_t * Abc_NtkCollectHie( Abc_Ntk_t * pNtk );

// char * pModelName = NULL;
char * pModelName = "path_0_r_x_lhs";
char pModelName[] = "path_0_r_x_lhs";
Gia_Man_t * pGia = NULL;
Vec_Ptr_t * vOrder, * vModels;
Abc_Ntk_t * pMod;
Expand Down
1 change: 1 addition & 0 deletions src/sat/kissat/colors.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "colors.h"

#if defined(WIN32) && !defined(__MINGW32__)
#include <io.h>
#define isatty _isatty
#else
#include <unistd.h>
Expand Down
5 changes: 5 additions & 0 deletions src/sat/kissat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>

#include <sys/stat.h>
#include <sys/types.h>

#ifdef WIN32
#include <io.h>
#define unlink _unlink
#define access _access
#define R_OK 4
#define W_OK 2
#ifndef S_ISDIR
# define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR)
#endif
#else
#include <unistd.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/sat/kissat/proplit.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static inline void kissat_watch_large_delayed (kissat *solver,
while (d != end_delayed) {
const unsigned lit = *d++;
KISSAT_assert (d != end_delayed);
const watch watch = {.raw = *d++};
const watch watch = {/*.raw =*/ *d++}; // c++20 only
KISSAT_assert (!watch.type.binary);
KISSAT_assert (lit < LITS);
watches *const lit_watches = all_watches + lit;
Expand Down
2 changes: 1 addition & 1 deletion src/sat/kissat/walk.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct tagged {

static inline tagged make_tagged (bool binary, unsigned ref) {
KISSAT_assert (ref <= MAX_WALK_REF);
tagged res = {.ref = ref, .binary = binary};
tagged res = {/*.ref = */ref, /*.binary = */binary}; // c++20 only
return res;
}

Expand Down

0 comments on commit ffd433e

Please sign in to comment.