[openssl-dev] [openssl.org #4289] OpenSSL 1.0.2f serious bug in Win32 makefiles, easy to fix, solution provided (was: [OpenSSL Bug #2928])

Dannhauer Torben via RT rt at openssl.org
Wed Feb 3 15:23:34 UTC 2016


This bug affects 1.0.2.f and supposedly also 1.1.0 alpha, I reported it already 3 years (!!) ago as Bug #2928 for OpenSSL 1.0.1c, but it was closed yesterday since 1.0.1 development is finished.

Please find attached the Bug description again for OpenSSL 1.0.2f. I provide already a solution, so please apply the bug fix to trunk, 1.0.2 and 1.1.0 branches

The bug is not obvious since only few people use the MSBuild System in this extend. However, it is clearly defined by MS how it's build system works and thus why OpenSSL building fails in certain conditions.



-- BUG DESCRIPTION (Copied and updated from Bug #2928) --

Dear OpenSSL Team,

I recently tried to build OpenSSL with Visual Studio and I discovered a very annoying but easy to fix bug:

In the makefile created by Perl, the linker binary name is assigned to a variable named LINK. This variable $(LINK) is called to execute the linker call.
This causes a serious collision with the MS Visual Studio build system which also relies on a variable named LINK:

In Visual Studio, the compiler is called cl.exe and the linker is called link.exe.
On invocation, they append the command line arguments to the environment variable identical to their name (if they exist). This allows to define "global" linker or compiler flags which are not part of the makefile.
On the backside this also implies that a makefile must not use internal variable names identical to the build systems env-vars "LINK" and "CL".

This error was observed with MS VS 2013 Update 5 but applies to older Visual Studios as well.



## Example with the CURRENT (WRONG) status #####
Build Environment (Visual Studio Command line):
SET LINK=<my global linker flags>

Makefile of OpenSSL
SET LINK=link.exe
SET LINKER_ARGS=<my linker args>

The resulting linker call triggered by the makefile script is then:
$(LINK) $(LINKER_ARGS)
Which is extended by the MSVC build system to (because MSVC adds the content of the variable LINK after the linker command)
$(LINK) $(LINK) $(LINKER_ARGS)
and finally stripped to:
link.exe link.exe <my linker args>


This is a double invocation of link.exe which causes link to try linking itself, which of course fails.



### CORRECTED Example #####
Build Environment (Visual Studio Command line):
SET LINK=<my global linker flags>

Makefile:
SET LINKER_BIN=link.exe
SET LINKER_ARGS=<my linker flags>

The call should be:
$(LINKER_BIN) $(LINKER_ARGS)
Which would be extended by the MSVC build system to
$(LINKER_BIN) $(LINK) $(LINKER_ARGS)
and finally be stripped to:
link.exe <my global linker flags> <my linker flags>

==>This would be correct and working



#### How to solve it: #####


- Never use the variables named LINK and CL inside the makefiles or their generator scripts.

- Please call the binary variables different, e.g. LINKER_BIN and COMPILER_BIN

- Adapt your build scripts to generate such corrected makefiles


Thank you for your help

Kind regards,
Torben Dannhauer



More information about the openssl-dev mailing list