Skip to content

Commit

Permalink
User: Fix Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
PMheart committed Sep 27, 2023
1 parent cfd127a commit 43bc1e4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions User/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,33 @@ ifeq ($(WERROR),1)
CFLAGS += -Werror
endif

ifeq ($(shell echo 'int a;' | "${CC}" -Wno-unused-parameter -x c -c - -o /dev/null 2>&1),)
#
# On Windows, output file cannot be null.
# Ref: https://github.com/msys2/MINGW-packages/issues/10520
#
ifeq ($(DIST),Windows)
OUT_BIN := /tmp/windows_out
else
OUT_BIN := /dev/null
endif

ifeq ($(shell echo 'int a;' | "${CC}" -Wno-unused-parameter -x c -c - -o "${OUT_BIN}" 2>&1),)
CFLAGS += -Wno-unused-parameter
endif

ifeq ($(shell echo 'int a;' | "${CC}" -Wno-implicit-fallthrough -x c -c - -o /dev/null 2>&1),)
ifeq ($(shell echo 'int a;' | "${CC}" -Wno-implicit-fallthrough -x c -c - -o "${OUT_BIN}" 2>&1),)
CFLAGS += -Wno-implicit-fallthrough
endif

ifeq ($(shell echo 'int a;' | "${CC}" -Wno-strict-aliasing -x c -c - -o /dev/null 2>&1),)
ifeq ($(shell echo 'int a;' | "${CC}" -Wno-strict-aliasing -x c -c - -o "${OUT_BIN}" 2>&1),)
CFLAGS += -Wno-strict-aliasing
endif

ifeq ($(shell echo 'int a;' | "${CC}" -Wno-address -x c -c - -o /dev/null 2>&1),)
ifeq ($(shell echo 'int a;' | "${CC}" -Wno-address -x c -c - -o "${OUT_BIN}" 2>&1),)
CFLAGS += -Wno-address
endif

ifeq ($(shell echo 'int a;' | "${CC}" -Wno-stringop-overflow -x c -c - -o /dev/null 2>&1),)
ifeq ($(shell echo 'int a;' | "${CC}" -Wno-stringop-overflow -x c -c - -o "${OUT_BIN}" 2>&1),)
CFLAGS += -Wno-stringop-overflow
endif

Expand Down

0 comments on commit 43bc1e4

Please sign in to comment.