Opened 7 years ago

Closed 7 years ago

#1396 closed defect (fixed)

Compiling for win32 fails with VS2017

Reported by: Mardoxx@… Owned by:
Priority: minor Milestone:
Component: documentation Version: 1.13.x
Keywords: Cc:
uname -a:
nginx -V: nginx version: nginx/1.13.7
built by cl 19.11.25547 for x86
built with OpenSSL 1.0.2k 26 Jan 2017
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs/lib/pcre-8.41 --with-zlib=objs/lib/zlib-1.2.11 --with-select_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-openssl=objs/lib/openssl-1.0.2k --with-openssl-opt=no-asm --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --with-stream_ssl_preread_module

Description

Build fails with

 Assembling: tmp32\sha1-586.asm
tmp32\sha1-586.asm(1432) : error A2070:invalid instruction operands
tmp32\sha1-586.asm(1576) : error A2070:invalid instruction operands
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\bin\HostX86\x86\ml.EXE"' : return code '0x1'
Stop.

Workaround is to add no-asm option to openSSL configure.
i.e. edit line 9 of makefile.msvc to read perl Configure VC-WIN32 no-shared no-asm \

This workaround does not work with OpenSSL 1.0.2l.

Solution is change your build instructions to require nasm. OpenSSL only supports NASM, see INSTALL.W32. THen update makefile.msvc to the following:

# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.


all:
	cd $(OPENSSL)

	perl Configure VC-WIN32 no-shared				\
		--prefix="%cd%/openssl" 				\
		--openssldir="%cd%/openssl/ssl" 			\
		$(OPENSSL_OPT)

	if exist ms\do_nasm.bat (						\
		ms\do_nasm						\
		&& $(MAKE) -f ms\nt.mak					\
		&& $(MAKE) -f ms\nt.mak install				\
	) else (							\
		$(MAKE)							\
		&& $(MAKE) install_sw					\
	)

And update your build instructions to require installation of NASM. OpenSSL then builds fine and this allows you to build nginx with 1.0.2k and 1.0.2l. Can also build without --with-openssl-opt=no-asm

Change History (4)

comment:1 by Mardoxx@…, 7 years ago

Apparently your build script is not working for openSSL.

https://github.com/openssl/openssl/blob/f6f9a735cc691a57c01c0c99aacce86fd9138a05/INSTALL.W32#L44-L60

Correct usage is perl Configure VC-WIN32 no-shared no-asm if using do_ms.bat

--with-openssl-opt=no-asm should add no-asm to it, but it doesn't seem to work for me.

Last edited 7 years ago by Mardoxx@… (previous) (diff)

comment:2 by Maxim Dounin, 7 years ago

Component: otherdocumentation

This workaround does not work with OpenSSL 1.0.2l.

We use no-asm since OpenSSL started to use assembler by default in ms\do_ms.bat and then broke MASM support in 1.0.2, see 5def760fe95e. It works fine for official builds, including builds with OpenSSL 1.0.2l since 9b26edd391ab. If it doesn't work for you, consider re-trying the build with clean sources (notably clean OpenSSL sources).

Adding no-asm to the Building nginx on the Win32 platform with Visual C page probably make sense, so changing this ticket to documentation component.

comment:3 by Maxim Dounin <mdounin@…>, 7 years ago

In 2060:237b67ef69a6/nginx_org:

Improved win32 build instructions.

Added "--with-openssl-opt=no-asm" argument which is required since
OpenSSL 1.0.2, as OpenSSL started to use assembler by default in 1.0.0 and
then broke builds with MASM in OpenSSL 1.0.2 (ticket #1396).

While here, added "--with-debug", added missing "--http-scgi-temp-path" and
"--http-uwsgi-temp-path", updated OpenSSL to 1.0.2l, switched to slightly
more readable one-argument-per-line style in configure example, added
indentation to continuation lines, removed useless "--builddir=objs" argument
("objs" is the default), and removed useless "-f objs/Makefile" argument
in nmake (nginx generates appropriate Makefile in the current directory).

comment:4 by Maxim Dounin, 7 years ago

Resolution: fixed
Status: newclosed

Improvements to the Building nginx on the Win32 platform with Visual C page committed, thanks.

Note: See TracTickets for help on using tickets.