Skip to content

Commit 388630a

Browse files
mstemberazamar
authored andcommitted
Allow cross compilation of Windows binaries on a Linux system
that are PGO, LTO, and statically linked. Credit: pasquale....@gmail.com No functional change Resolves official-stockfish#505
1 parent 79f3930 commit 388630a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ endif
159159

160160
ifeq ($(COMP),mingw)
161161
comp=mingw
162-
CXX=g++
162+
ifeq ($(UNAME),Linux)
163+
CXX=x86_64-w64-mingw32-g++-posix
164+
else
165+
CXX=g++
166+
endif
163167
CXXFLAGS += -Wextra -Wshadow
164168
LDFLAGS += -static
165169
endif
@@ -307,7 +311,7 @@ ifeq ($(pext),yes)
307311
endif
308312
endif
309313

310-
### 3.11 Link Time Optimization, it works since gcc 4.5 but not on mingw.
314+
### 3.11 Link Time Optimization, it works since gcc 4.5 but not on mingw under windows.
311315
### This is a mix of compile and link time options because the lto link phase
312316
### needs access to the optimization flags.
313317
ifeq ($(comp),gcc)
@@ -319,6 +323,17 @@ ifeq ($(comp),gcc)
319323
endif
320324
endif
321325

326+
ifeq ($(UNAME),Linux)
327+
ifeq ($(comp),mingw)
328+
ifeq ($(optimize),yes)
329+
ifeq ($(debug),no)
330+
CXXFLAGS += -flto
331+
LDFLAGS += $(CXXFLAGS)
332+
endif
333+
endif
334+
endif
335+
endif
336+
322337
### 3.12 Android 5 can only run position independent executables. Note that this
323338
### breaks Android 4.0 and earlier.
324339
ifeq ($(arch),armv7)

0 commit comments

Comments
 (0)