From 9c41da69dbe5c9b82c840beff967f237c1cd1dfb Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Sat, 9 Aug 2025 01:24:17 -0400 Subject: [PATCH] Add Windows fixes so abc compiles natively with GCC. --- Makefile | 21 +++++++++++++++++++-- src/sat/cadical/cadical_congruence.cpp | 2 +- src/sat/cadical/cadical_vivify.cpp | 4 ++-- src/sat/kissat/colors.c | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2dfc1c691b..b566935292 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,11 @@ $(info $(MSG_PREFIX)Using AR=$(AR)) $(info $(MSG_PREFIX)Using LD=$(LD)) PROG := abc + OS := $(shell uname -s) +ifneq ($(filter MINGW%,$(OS)),) +OS := MINGW +endif MODULES := \ $(wildcard src/ext*) \ @@ -142,10 +146,15 @@ ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD NetBSD)) LIBS += -ldl endif -ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD NetBSD Darwin)) +ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD NetBSD Darwin MINGW)) LIBS += -lrt endif +# For PathMatchSpecA. +ifeq ($(OS), MINGW) + LIBS = -lshlwapi +endif + ifdef ABC_USE_LIBSTDCXX LIBS += -lstdc++ $(info $(MSG_PREFIX)Using explicit -lstdc++) @@ -155,7 +164,7 @@ $(info $(MSG_PREFIX)Using CFLAGS=$(CFLAGS)) CXXFLAGS += $(CFLAGS) -std=c++17 -fno-exceptions SRC := -GARBAGE := core core.* *.stackdump ./tags $(PROG) arch_flags +GARBAGE := core core.* *.stackdump ./tags $(PROG) arch_flags $(PROG).in .PHONY: all default tags clean docs cmake_info @@ -221,9 +230,17 @@ clean: tags: etags `find . -type f -regex '.*\.\(c\|h\)'` +ifeq ($(OS), MINGW) +$(PROG): $(OBJ) + @echo "$(MSG_PREFIX)\`\` Constructing Response File:" $(notdir @$@.in) + $(file >$@.in,$^ $(LDFLAGS) $(LIBS)) + @echo "$(MSG_PREFIX)\`\` Building binary:" $(notdir $@) + $(VERBOSE)$(LD) -o $@ @$@.in +else $(PROG): $(OBJ) @echo "$(MSG_PREFIX)\`\` Building binary:" $(notdir $@) $(VERBOSE)$(LD) -o $@ $^ $(LDFLAGS) $(LIBS) +endif lib$(PROG).a: $(LIBOBJ) @echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@) diff --git a/src/sat/cadical/cadical_congruence.cpp b/src/sat/cadical/cadical_congruence.cpp index 8fbceee24e..01e2d53356 100644 --- a/src/sat/cadical/cadical_congruence.cpp +++ b/src/sat/cadical/cadical_congruence.cpp @@ -5981,7 +5981,7 @@ void Closure::rewrite_ite_gate (Gate *g, int dst, int src) { #endif } else { CADICAL_assert (false); -#ifdef WIN32 +#ifdef _MSC_VER __assume(false); #else __builtin_unreachable (); diff --git a/src/sat/cadical/cadical_vivify.cpp b/src/sat/cadical/cadical_vivify.cpp index 8d99c29323..b077dd24a9 100644 --- a/src/sat/cadical/cadical_vivify.cpp +++ b/src/sat/cadical/cadical_vivify.cpp @@ -1501,7 +1501,7 @@ inline std::vector ¤t_refs_schedule (Vivifier &vivifier) { return vivifier.refs_schedule_irred; break; } -#ifdef WIN32 +#ifdef _MSC_VER __assume(false); #else __builtin_unreachable (); @@ -1523,7 +1523,7 @@ inline std::vector ¤t_schedule (Vivifier &vivifier) { return vivifier.schedule_irred; break; } -#ifdef WIN32 +#ifdef _MSC_VER __assume(false); #else __builtin_unreachable (); diff --git a/src/sat/kissat/colors.c b/src/sat/kissat/colors.c index f45260b297..c0041f2530 100644 --- a/src/sat/kissat/colors.c +++ b/src/sat/kissat/colors.c @@ -1,6 +1,6 @@ #include "colors.h" -#ifdef WIN32 +#ifdef _MSC_VER #define isatty _isatty #else #include