Skip to content

Commit c3fd430

Browse files
committed
The purpose of these headers is to fix issues with mingw v4.0, as described in #9246.
This works by adding this directory to GCC include search path before mingw system headers directories, so we can intercept their inclusions and add missing definitions without having to modify files in mingw/include.
1 parent d1c0550 commit c3fd430

File tree

7 files changed

+38
-3
lines changed

7 files changed

+38
-3
lines changed

mk/llvm.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LLVM_STAMP_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-auto-clean-stamp
2828

2929
$$(LLVM_CONFIG_$(1)): $$(LLVM_DEPS) $$(LLVM_STAMP_$(1))
3030
@$$(call E, make: llvm)
31-
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) $$(CFG_LLVM_BUILD_ENV)
31+
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) $$(CFG_LLVM_BUILD_ENV_$(1))
3232
$$(Q)touch $$(LLVM_CONFIG_$(1))
3333
endif
3434

mk/platform.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ AR_i686-pc-mingw32=$(AR)
352352
CFG_LIB_NAME_i686-pc-mingw32=$(1).dll
353353
CFG_LIB_GLOB_i686-pc-mingw32=$(1)-*.dll
354354
CFG_LIB_DSYM_GLOB_i686-pc-mingw32=$(1)-*.dylib.dSYM
355-
CFG_GCCISH_CFLAGS_i686-pc-mingw32 := -Wall -Werror -g -m32 -march=i686 -D_WIN32_WINNT=0x0600
355+
CFG_GCCISH_CFLAGS_i686-pc-mingw32 := -Wall -Werror -g -m32 -march=i686 -D_WIN32_WINNT=0x0600 -I$(CFG_SRC_DIR)src/etc/mingw-fix-include
356356
CFG_GCCISH_CXXFLAGS_i686-pc-mingw32 := -fno-rtti
357357
CFG_GCCISH_LINK_FLAGS_i686-pc-mingw32 := -shared -fPIC -g -m32
358358
CFG_GCCISH_DEF_FLAG_i686-pc-mingw32 :=
@@ -361,6 +361,7 @@ CFG_GCCISH_POST_LIB_FLAGS_i686-pc-mingw32 :=
361361
CFG_DEF_SUFFIX_i686-pc-mingw32 := .mingw32.def
362362
CFG_INSTALL_NAME_i686-pc-mingw32 =
363363
CFG_LIBUV_LINK_FLAGS_i686-pc-mingw32 := -lWs2_32 -lpsapi -liphlpapi
364+
CFG_LLVM_BUILD_ENV_i686-pc-mingw32 := CPATH=$(CFG_SRC_DIR)src/etc/mingw-fix-include
364365
CFG_EXE_SUFFIX_i686-pc-mingw32 := .exe
365366
CFG_WINDOWSY_i686-pc-mingw32 := 1
366367
CFG_UNIXY_i686-pc-mingw32 :=

mk/rt.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# working under these assumptions).
2525

2626
# Hack for passing flags into LIBUV, see below.
27-
LIBUV_FLAGS_i386 = -m32 -fPIC
27+
LIBUV_FLAGS_i386 = -m32 -fPIC -I$(S)src/etc/mingw-fix-include
2828
LIBUV_FLAGS_x86_64 = -m64 -fPIC
2929
ifeq ($(OSTYPE_$(1)), linux-androideabi)
3030
LIBUV_FLAGS_arm = -fPIC -DANDROID -std=gnu99

src/etc/mingw-fix-include/README.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The purpose of these headers is to fix issues with mingw v4.0, as described in #9246.
2+
3+
This works by adding this directory to GCC include search path before mingw system headers directories,
4+
so we can intercept their inclusions and add missing definitions without having to modify files in mingw/include.
5+
6+
Once mingw fixes all 3 issues mentioned in #9246, this directory and all references to it from rust/mk/* may be removed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _FIX_CXXCONFIG_H
2+
#define _FIX_CXXCONFIG_H 1
3+
4+
#define _GLIBCXX_HAVE_FENV_H 1
5+
6+
#include_next <bits/c++config.h>
7+
8+
#endif

src/etc/mingw-fix-include/winbase.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _FIX_WINBASE_H
2+
#define _FIX_WINBASE_H 1
3+
4+
#define NTDDK_VERSION NTDDI_VERSION
5+
6+
#include_next <winbase.h>
7+
8+
#endif

src/etc/mingw-fix-include/winsock2.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef _FIX_WINSOCK2_H
2+
#define _FIX_WINSOCK2_H 1
3+
4+
#include_next <winsock2.h>
5+
6+
typedef struct pollfd {
7+
SOCKET fd;
8+
short events;
9+
short revents;
10+
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
11+
12+
#endif

0 commit comments

Comments
 (0)