Skip to content

Commit 51c4a38

Browse files
committed
feature: added 64-bit windows building/packaging support using the MSYS2/MinGW toolchain.
1 parent f0e621b commit 51c4a38

File tree

3 files changed

+74
-31
lines changed

3 files changed

+74
-31
lines changed
Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
Name
22
====
33

4-
README-win32 - README for the Windows 32-bit build of OpenResty
4+
README-windows - README for the official 32-bit and 64-bit Windows builds of OpenResty
5+
6+
Table of Contents
7+
=================
8+
9+
* [Name](#name)
10+
* [Description](#description)
11+
* [Debugging](#debugging)
12+
* [Caveats](#caveats)
13+
* [TODO](#todo)
14+
* [Details About The Building Process](#details-about-the-building-process)
15+
* [Author](#author)
16+
* [Copyright & License](#copyright--license)
517

618
Description
719
===========
820

9-
The official binary Win32 distribution of OpenResty can be downloaded from the following web page:
21+
The official binary Win32 and Win64 distributions of OpenResty can be downloaded from the following web page:
1022

1123
https://openresty.org/en/download.html
1224

@@ -37,7 +49,7 @@ nginx.exe 5836 Console 1 7,800 K
3749

3850
One of the two processes is the master process while the other is the worker.
3951

40-
If you are using the MSYS bash instead of the `cmd.exe` console, then you should replace the `/fi` option
52+
If you are using the MSYS2 bash instead of the `cmd.exe` console, then you should replace the `/fi` option
4153
with `-fi` in the command above instead.
4254

4355
You can quickly shut down the server like this:
@@ -60,7 +72,7 @@ C:\> taskkill /pid 5488 /F
6072

6173
where the PID (5488 in this example) can be found via the aforementioned `tasklist` command.
6274

63-
Again, you should use the form `-pid` and `-F` for the options if you are in an MSYS bash
75+
Again, you should use the form `-pid` and `-F` for the options if you are in an MSYS2 bash
6476
session.
6577

6678
Similarly, you can use the `nginx -s reload` command to reload nginx configurations without
@@ -76,14 +88,14 @@ Hello, OpenResty!
7688

7789
The `resty` command-line utility requires a Perl interpreter installed in your
7890
system and visible to your PATH environment. Any perl distributions should
79-
work, including StrawberryPerl, ActivePerl, and MSYS perl (the former two are
91+
work, including StrawberryPerl, ActivePerl, and MSYS2 perl.
8092
recommended though).
8193

8294
Debugging
8395
=========
8496

8597
Debug symbosl are enabled even in release builds. So that when things go very wrong,
86-
one can still debug things with tools like MSYS GDB.
98+
one can still debug things with tools like MSYS2 GDB.
8799

88100
Inclusion of debug symbols make the binary files (`.exe` and `.dll` files) much larger,
89101
but it generally will not load into memory during normal execution on a modern operating
@@ -92,14 +104,16 @@ system.
92104
Caveats
93105
=======
94106

95-
The Win32 port of the NGINX core supports the good old `select` IO multiplexing mechanism
107+
The Win32/Win64 port of the NGINX core supports the good old `select` IO multiplexing mechanism
96108
only.
97109
The I/O Completion Ports (IOCP) feature is *not* supported (yet). So do not use this build
98110
for production environments with very high concurrency levels.
99111

100-
This Win32 build of OpenResty is mainly for developers who want to develop their applications
112+
This Win32/Win64 build of OpenResty is mainly for developers who want to develop their applications
101113
in native Windows environment (though they eventually push the finished work onto a Linux or *BSD box, most of the time).
102114

115+
[Back to TOC](#table-of-contents)
116+
103117
TODO
104118
====
105119

@@ -109,24 +123,25 @@ TODO
109123
package redistribution.
110124
* Bundle StrawberryPerl to make command-line utilities like `resty` work out of the box (without
111125
manually installing a Perl).
112-
* Deliver an alternative Win32 binary package built with best debuggin capabilities (like enabling
126+
* Deliver an alternative Win32/Win64 binary package built with best debuggin capabilities (like enabling
113127
NGINX debugging logs, disabling C compiler optimizations, and enabling all the assertions and checks).
114-
* Deliver binary packages for 64-bit Windows (Win64).
128+
129+
[Back to TOC](#table-of-contents)
115130

116131
Details About The Building Process
117132
==================================
118133

119-
Usually you do not need to worry about how the Win32 binaries were built on the maintainers''
134+
Usually you do not need to worry about how the Win32/Win64 binaries were built on the maintainers''
120135
side. But if you do, please read on.
121136

122-
The Win32 build of OpenResty is currently built via the MinGW/MSYS toolchain, including
123-
MinGW gcc 4.8.1, MSYS perl, MSYS bash, MSYS make, and etc. Basically, it is currently built via
137+
The Win32/Win64 build of OpenResty is currently built via the MSYS2/MinGW toolchain, including
138+
MinGW gcc 7.2.3, MSYS2 perl 5.24.4, MSYS2 bash, MSYS2 make, and etc. Basically, it is currently built via
124139
the following cmmands:
125140

126141
```bash
127-
PCRE=pcre-8.39
128-
ZLIB=zlib-1.2.8
129-
OPENSSL=openssl-1.0.2j
142+
PCRE=pcre-8.42
143+
ZLIB=zlib-1.2.11
144+
OPENSSL=openssl-1.1.0h
130145

131146
mkdir -p objs/lib || exit 1
132147
cd objs/lib || exit 1
@@ -137,7 +152,7 @@ tar -xf ../../../$PCRE.tar.gz || exit 1
137152
cd ../..
138153

139154
cd objs/lib/$OPENSSL || exit 1
140-
patch -p1 < ../../../patches/openssl-1.0.2h-sess_set_get_cb_yield.patch || exit 1
155+
patch -p1 < ../../../patches/openssl-1.1.0d-sess_set_get_cb_yield.patch || exit 1
141156
cd ../../..
142157

143158
./configure \
@@ -174,9 +189,9 @@ cd ../../..
174189
--with-pcre=objs/lib/$PCRE \
175190
--with-zlib=objs/lib/$ZLIB \
176191
--with-openssl=objs/lib/$OPENSSL \
177-
-j5 || exit 1
192+
-j9 || exit 1
178193

179-
make
194+
make -j9
180195
make install
181196
```
182197

@@ -192,17 +207,21 @@ script.
192207
Usually you can just download and use the binary distribution of OpenResty without
193208
installing the build toolchain.
194209

210+
[Back to TOC](#table-of-contents)
211+
195212
Author
196213
======
197214

198215
Yichun "agentzh" Zhang <[email protected]>, OpenResty Inc.
199216

217+
[Back to TOC](#table-of-contents)
218+
200219
Copyright & License
201220
===================
202221

203222
This module is licensed under the BSD license.
204223

205-
Copyright (C) 2015-2016, by Yichun "agentzh" Zhang (章亦春) <[email protected]>, OpenResty Inc.
224+
Copyright (C) 2015-2018, by Yichun "agentzh" Zhang (章亦春) <[email protected]>, OpenResty Inc.
206225

207226
All rights reserved.
208227

@@ -213,3 +232,6 @@ Redistribution and use in source and binary forms, with or without modification,
213232
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
214233

215234
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
235+
236+
[Back to TOC](#table-of-contents)
237+

util/build-win32.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
PCRE=pcre-8.42
44
ZLIB=zlib-1.2.11
5-
OPENSSL=openssl-1.0.2n
5+
OPENSSL=openssl-1.1.0h
6+
JOBS=9
67

7-
# wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
8+
# wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
89
# wget http://zlib.net/zlib-1.2.11.tar.gz
9-
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
10+
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz
1011

1112
rm -rf objs || exit 1
1213
mkdir -p objs/lib || exit 1
@@ -18,7 +19,8 @@ tar -xf ../../../$PCRE.tar.gz || exit 1
1819
cd ../..
1920

2021
cd objs/lib/$OPENSSL || exit 1
21-
patch -p1 < ../../../patches/openssl-1.0.2h-sess_set_get_cb_yield.patch || exit 1
22+
patch -p1 < ../../../patches/openssl-1.1.0d-sess_set_get_cb_yield.patch \
23+
|| exit 1
2224
cd ../../..
2325

2426
#--with-openssl-opt="no-asm" \
@@ -57,7 +59,7 @@ cd ../../..
5759
--with-pcre=objs/lib/$PCRE \
5860
--with-zlib=objs/lib/$ZLIB \
5961
--with-openssl=objs/lib/$OPENSSL \
60-
-j5 || exit 1
61-
#gmake -j5
62-
make || exit 1
63-
make install
62+
-j$JOBS || exit 1
63+
64+
make -j$JOBS || exit 1
65+
exec make install

util/package-win32.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
#!/bin/bash
22

3+
mingw32=/c/msys64/mingw32
4+
5+
info=`uname -a`
6+
if [[ "$info" == MINGW64* ]]; then
7+
arch="win64";
8+
else
9+
if [[ "$info" == MINGW32* ]]; then
10+
arch="win32";
11+
else
12+
echo "Unknown architecture: $info" > /dev/stderr
13+
exit 1
14+
fi
15+
fi
16+
17+
echo $arch
18+
319
name=`pwd|perl -e '$d=<>;$d=~s{.*?/}{}g;$d=~s/$//g;print $d'`
4-
name="$name-win32"
20+
name="$name-$arch"
521
echo $name
622
if [ -d $name ]; then
723
rm -rf $name
824
fi
925
mkdir $name || exit 1
1026
cp -r resty restydoc restydoc-index nginx.exe luajit.exe lua51.dll lua include lualib html conf logs pod $name/ || exit 1
1127
cp COPYRIGHT $name/ || exit 1
12-
cp /c/MinGW/bin/libgcc_s_dw2-1.dll $name/ || exit 1
28+
if [[ "$arch" == "win32" ]]; then
29+
cp $mingw32/bin/libgcc_s_dw2-1.dll $name/ || exit 1
30+
cp $mingw32/bin/libwinpthread-1.dll $name/ || exit 1
31+
fi
1332
cd $name || exit 1
1433
PATH=/c/Strawberry/perl/bin:$PATH cmd /c 'pl2bat.bat resty' || exit 1
1534
PATH=/c/Strawberry/perl/bin:$PATH cmd /c 'pl2bat.bat restydoc' || exit 1
1635
PATH=/c/Strawberry/perl/bin:$PATH cmd /c 'pl2bat.bat restydoc-index' || exit 1
17-
cp ../README-win32.txt README.txt
36+
cp ../README-windows.txt README.txt
1837
unix2dos conf/* html/*.html resty || exit 1
1938
cd .. || exit 1
2039
zip -r $name.zip $name || exit 1

0 commit comments

Comments
 (0)