Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#2422 closed defect (invalid)

Issue with OpenSSL Makefile Perl Command and %cd% not resolving properly

Reported by: justdan23@… Owned by:
Priority: blocker Milestone:
Component: nginx-core Version: 1.22.x
Keywords: Cc: justdan23@…
uname -a: justdan23@gmail.com
nginx -V: Not Able to Build on Windows using MSYS2 and MingW64

Description (last modified by justdan23@…)

Version: master (and) stable-1.22 branches
File: nginx/auto/lib/openssl/Makefile
Platform: VC-WIN64A on Windows OS using MSYS2 (64-bit) and Mingw64 (64-bit)

Issue: perl Configure changed to VC-WIN64A manually (but occurs with VC-WIN32), and results in %cd% not resolving to objs/lib/ folder causing an error where it is unable to find the folder pre location.

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

all:
	export cd=/home/justd/nginx/dist

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

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

Error Output:

$ make
make -f objs/Makefile
make[1]: Entering directory '/home/justd/nginx'
make -f auto/lib/openssl/makefile.msvc                                  OPENSSL="objs/lib/openssl" OPENSSL_OPT=""
make[2]: Entering directory '/home/justd/nginx'
export cd=/home/justd/nginx/dist
cd objs/lib/openssl
perl Configure VC-WIN64A no-shared no-threads                   \
        --prefix="%cd%/openssl"                                 \
        --openssldir="%cd%/openssl/ssl"                         \

Can't open perl script "Configure": No such file or directory
make[2]: *** [auto/lib/openssl/makefile.msvc:10: all] Error 2
make[2]: Leaving directory '/home/justd/nginx'
make[1]: *** [objs/Makefile:1825: objs/lib/openssl/openssl/include/openssl/ssl.h] Error 2
make[1]: Leaving directory '/home/justd/nginx'
make: *** [Makefile:10: build] Error 2

I uploaded the zip of the entire dev environment at the URL below:
https://1drv.ms/u/s!AqtOkpGwHMQ2rBP002wedbn5n1Lx?e=W3zXoP

Attachments (3)

Makefile (67.7 KB ) - added by justdan23@… 2 years ago.
objs/Makefile
makefile.msvc (446 bytes ) - added by justdan23@… 2 years ago.
From nginx-dev\auto\lib\openssl\Makefile.msvc
makefile.2.msvc (446 bytes ) - added by justdan23@… 2 years ago.
From nginx-dev\auto\cc

Download all attachments as: .zip

Change History (9)

by justdan23@…, 2 years ago

Attachment: Makefile added

objs/Makefile

by justdan23@…, 2 years ago

Attachment: makefile.msvc added

From nginx-dev\auto\lib\openssl\Makefile.msvc

by justdan23@…, 2 years ago

Attachment: makefile.2.msvc added

From nginx-dev\auto\cc

comment:1 by Maxim Dounin, 2 years ago

Resolution: invalid
Status: newclosed

For MSVC builds, you are expected to use nmake as provided by MSVC, not GNU make. See Building nginx on the Win32 platform with Visual C for details.

comment:2 by justdan23@…, 2 years ago

I uploaded the zip of the entire dev environment at the URL below:
https://1drv.ms/u/s!AqtOkpGwHMQ2rBP002wedbn5n1Lx?e=W3zXoP

comment:3 by justdan23@…, 2 years ago

Description: modified (diff)
Resolution: invalid
Status: closedreopened

I tried with 'nmake' and the result is the same:

$ nmake

Microsoft (R) Program Maintenance Utility Version 14.34.31935.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\nmake.exe" -f objs/Makefile

Microsoft (R) Program Maintenance Utility Version 14.34.31935.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\nmake.exe" -f auto/lib/openssl/makefile.msvc                                    OPENSSL="objs/lib/openssl" OPENSSL_OPT=""

Microsoft (R) Program Maintenance Utility Version 14.34.31935.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cd objs/lib/openssl
        perl Configure VC-WIN64A no-shared no-threads                    --prefix="%cd%/openssl"                                 --openssldir="%cd%/openssl/ssl"
Configuring OpenSSL version 3.0.8-dev for target VC-WIN64A
Using os-specific seed configuration

Failure!  makefile wasn't produced.
Please read INSTALL.md and associated NOTES-* files.  You may also have to
look over your available compiler tool chain or change your configuration.


******************************************************************************
This perl implementation doesn't produce Windows like paths (with backward
slash directory separators).  Please use an implementation that matches your
building platform.

This Perl version: 5.36.0 for x86_64-msys-thread-multi
******************************************************************************
NMAKE : fatal error U1077: 'perl' : return code '0xff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
Stop.

comment:4 by Maxim Dounin, 2 years ago

Resolution: invalid
Status: reopenedclosed

With nmake, the error is reported by the OpenSSL's Configure script, and it says that OpenSSL doesn't like your Perl:

This perl implementation doesn't produce Windows like paths (with backward
slash directory separators).  Please use an implementation that matches your
building platform.

Consider installing Strawberry Perl as recommended by Building nginx on the Win32 platform with Visual C.

If you have further help with compiling nginx, please consider using nginx@ mailing list instead.

comment:5 by justdan23@…, 2 years ago

It appears to have an issue resolving %cd% for some reason. I am using Strawberry Perl following the install instructions, but I'll go back to retry.

When I build it from the openssl folder, it works so the openssl branch is good. There is a diff between the process they use when calling 'perl Configure' and the process when nginx is calling it.

I tried various ways to resolve it without modifying the Makefile.msvc located within nginx/auto/lib/openssl but no luck.

I could try to hard code the paths, but if there is better way to make this work within an MSYS2 prompt, let me know and I'll be glad to help test it out.

Ok, I'll reach out to the mailing list too and post back if there is still an issue here.

Version 2, edited 2 years ago by justdan23@… (previous) (next) (diff)

comment:6 by Maxim Dounin, 2 years ago

It appears to have an issue resolving %cd% for some reason.

Nothing in the details you've provided suggests it's the case. Note that %cd% is a pseudo environment variable provided by cmd.exe, and it is not expected to be expanded by nmake, so the expanded value will be only visible to the Configure script and not expected to be shown on the console.

Further, the fact that OpenSSL's Configure prints an error about incorrect Perl suggests that these are properly expanded: if they weren't, Configure would instead complained about paths not being absolute.

I am using Strawberry Perl following the install instructions, but I'll go back to retry.

The error from OpenSSL suggests there is a different Perl sitting in your path, note

This Perl version: 5.36.0 for x86_64-msys-thread-multi

in the error output you've provided. This looks like a Perl from MSYS2, and it is clearly incompatible with what OpenSSL needs. Make sure to adjust PATH so the Strawberry Perl will be used, or remove the conflicting Perl.

When I build it from the openssl folder, it works so the openssl branch is good. There is a diff between the process they use when calling 'perl Configure' and the process when nginx's 'objs/Makefile' is calling it.

The process nginx uses matches the one described in OpenSSL's NOTES-WINDOWS.md as "Native builds using Visual C++". If it works for you when calling relevant steps manually, but fails when you ask nginx to do the same, the first thing I would recommend to check is that if your nginx build environment matches the one you use in your manual tests. In particular, running the manual tests from the same environment might be a good idea.

Note: See TracTickets for help on using tickets.