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 the variable LINK:
In Visual Studion, the compiler ist 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 tot he envVars "LINK" and "CL".
This error was observed with MS VS2012 Update 1 but applies to older Visual
Studios as well.
## Example with the CURRENT (WRONG) status #####
Environment:
SET LINK=<my global linker flags>
Makefile
SET LINK=link.exe
SET LINKER_ARGS=<my linker args>
The call is:
$(LINK) $(LINKER_ARGS)
Which is extened by the MSVC build system to (because MSVC adds the content oft
he 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 invokation of linkexe which causes link to try linking
itself, which of course fails.
### CORRECTED Example #####
Environment:
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 extened 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 cortect 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 scritps to generate such corrected makefiles
Thank you for your help
Torben Dannhauer
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 the variable LINK: In Visual Studion, the compiler ist 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 tot he envVars „LINK“ and „CL“. This error was observed with MS VS2012 Update 1 but applies to older Visual Studios as well. ## Example with the ?CURRENT (WRONG) status ##### Environment: SET LINK=<my global linker flags> Makefile SET LINK=link.exe SET LINKER_ARGS=<my linker args> The call is: $(LINK) $(LINKER_ARGS) Which is extened by the MSVC build system to (because MSVC adds the content oft he 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 invokation of linkexe which causes link to try linking itself, which of course fails. ### ?CORRECTED Example ##### Environment: 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 extened 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 cortect 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 scritps to generate such corrected makefiles Thank you for your help Torben Dannhauer |
