Fossil SCM

Forward XPCFLAGS and XPLDFLAGS to the OpenSSL build process to fix Windows XP builds with MSVC. This affects builds with FOSSIL_ENABLE_WINXP=1 and FOSSIL_BUILD_SSL=1. XPLDFLAGS is only relevant if FOSSIL_DYNAMIC_BUILD=1 also set, and is applied in a post-build step to work around the difficulties to append (MSVC) linker flags to the OpenSSL defaults. NOTE: Pending more tests, and back-porting to tools/makemake.tcl.

florian 2022-01-21 06:49 trunk
Commit b9d40d68dc778347c4afb618f428e14b34849733fc0c9da1a1f8ecaefb72cc50
1 file changed +34 -6
+34 -6
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -116,11 +116,10 @@
116116
!if $(FOSSIL_DYNAMIC_BUILD)!=0
117117
SSLLIBDIR = $(SSLDIR)
118118
!else
119119
SSLLIBDIR = $(SSLDIR)
120120
!endif
121
-SSLLFLAGS = /nologo /opt:ref /debug
122121
SSLLIB = libssl.lib libcrypto.lib user32.lib gdi32.lib crypt32.lib
123122
!if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
124123
!message Using 'x64' platform for OpenSSL...
125124
SSLCONFIG = VC-WIN64A no-asm no-ssl3 no-weak-ssl-ciphers
126125
!if $(FOSSIL_DYNAMIC_BUILD)!=0
@@ -188,16 +187,24 @@
188187
!endif
189188
190189
!if $(FOSSIL_ENABLE_WINXP)!=0
191190
XPCFLAGS = $(XPCFLAGS) /D_WIN32_WINNT=0x0501 /D_USING_V110_SDK71_=1
192191
CFLAGS = $(CFLAGS) $(XPCFLAGS)
192
+#
193
+# NOTE: For regular builds, /OSVERSION defaults to the /SUBSYSTEM version and
194
+# explicit initialization is redundant, but is required for post-built edits.
195
+#
193196
!if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
194
-XPLDFLAGS = $(XPLDFLAGS) /SUBSYSTEM:CONSOLE,5.02
197
+XPLDFLAGS = $(XPLDFLAGS) /OSVERSION:5.02 /SUBSYSTEM:CONSOLE,5.02
195198
!else
196
-XPLDFLAGS = $(XPLDFLAGS) /SUBSYSTEM:CONSOLE,5.01
199
+XPLDFLAGS = $(XPLDFLAGS) /OSVERSION:5.01 /SUBSYSTEM:CONSOLE,5.01
197200
!endif
198201
LDFLAGS = $(LDFLAGS) $(XPLDFLAGS)
202
+!if $(FOSSIL_ENABLE_SSL)!=0
203
+!message Passing XPCFLAGS = [ $(XPCFLAGS) ] to the OpenSSL configuration...
204
+SSLCONFIG = $(SSLCONFIG) $(XPCFLAGS)
205
+!endif
199206
!endif
200207
201208
!if $(FOSSIL_DYNAMIC_BUILD)!=0
202209
!if $(DEBUG)!=0
203210
CRTFLAGS = /MDd
@@ -799,14 +806,35 @@
799806
!ifdef PERLDIR
800807
@pushd "$(SSLDIR)" && "$(PERLDIR)\$(PERL)" Configure $(SSLCONFIG) && popd
801808
!else
802809
@pushd "$(SSLDIR)" && "$(PERL)" Configure $(SSLCONFIG) && popd
803810
!endif
804
-!if $(FOSSIL_ENABLE_WINXP)!=0
805
- @pushd "$(SSLDIR)" && $(MAKE) "CC=cl $(XPCFLAGS)" "LFLAGS=$(XPLDFLAGS)" && popd
806
-!else
807811
@pushd "$(SSLDIR)" && $(MAKE) && popd
812
+!if $(FOSSIL_ENABLE_WINXP)!=0 && $(FOSSIL_DYNAMIC_BUILD)!=0
813
+#
814
+# NOTE: Appending custom linker flags to the OpenSSL default linker flags is
815
+# somewhat difficult, as summarized in this Fossil Forum post:
816
+#
817
+# https://fossil-scm.org/forum/forumpost/a9a2d6af28b
818
+#
819
+# Therefore the custom linker flags required for Windows XP dynamic builds are
820
+# applied in a separate post-build step.
821
+#
822
+# If the build stops here, or if the custom linker flags are outside the scope
823
+# of `editbin` or `link /EDIT` (i.e. additional libraries), consider tweaking
824
+# the OpenSSL makefile by hand (or the templates, as the OpenSSL makefile can
825
+# rebuild itself when tampered).
826
+#
827
+# Also note that this step changes the subsystem for the OpenSSL DLLs from
828
+# WINDOWS to CONSOLE, but which has no effect on DLLs.
829
+#
830
+ @echo Applying XPLDFLAGS = [ $(XPLDFLAGS) ] to the OpenSSL DLLs...
831
+ @for /F "usebackq delims=" %F in (`dir /A:-D/B "$(SSLDIR)\*.dll" 2^>nul`) \
832
+ do @( \
833
+ echo %~nxF & \
834
+ link /EDIT /NOLOGO $(XPLDFLAGS) "$(SSLDIR)\%~F" \
835
+ )
808836
!endif
809837
810838
clean-openssl:
811839
@pushd "$(SSLDIR)" && $(MAKE) clean && popd
812840
!endif
813841
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -116,11 +116,10 @@
116 !if $(FOSSIL_DYNAMIC_BUILD)!=0
117 SSLLIBDIR = $(SSLDIR)
118 !else
119 SSLLIBDIR = $(SSLDIR)
120 !endif
121 SSLLFLAGS = /nologo /opt:ref /debug
122 SSLLIB = libssl.lib libcrypto.lib user32.lib gdi32.lib crypt32.lib
123 !if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
124 !message Using 'x64' platform for OpenSSL...
125 SSLCONFIG = VC-WIN64A no-asm no-ssl3 no-weak-ssl-ciphers
126 !if $(FOSSIL_DYNAMIC_BUILD)!=0
@@ -188,16 +187,24 @@
188 !endif
189
190 !if $(FOSSIL_ENABLE_WINXP)!=0
191 XPCFLAGS = $(XPCFLAGS) /D_WIN32_WINNT=0x0501 /D_USING_V110_SDK71_=1
192 CFLAGS = $(CFLAGS) $(XPCFLAGS)
 
 
 
 
193 !if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
194 XPLDFLAGS = $(XPLDFLAGS) /SUBSYSTEM:CONSOLE,5.02
195 !else
196 XPLDFLAGS = $(XPLDFLAGS) /SUBSYSTEM:CONSOLE,5.01
197 !endif
198 LDFLAGS = $(LDFLAGS) $(XPLDFLAGS)
 
 
 
 
199 !endif
200
201 !if $(FOSSIL_DYNAMIC_BUILD)!=0
202 !if $(DEBUG)!=0
203 CRTFLAGS = /MDd
@@ -799,14 +806,35 @@
799 !ifdef PERLDIR
800 @pushd "$(SSLDIR)" && "$(PERLDIR)\$(PERL)" Configure $(SSLCONFIG) && popd
801 !else
802 @pushd "$(SSLDIR)" && "$(PERL)" Configure $(SSLCONFIG) && popd
803 !endif
804 !if $(FOSSIL_ENABLE_WINXP)!=0
805 @pushd "$(SSLDIR)" && $(MAKE) "CC=cl $(XPCFLAGS)" "LFLAGS=$(XPLDFLAGS)" && popd
806 !else
807 @pushd "$(SSLDIR)" && $(MAKE) && popd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808 !endif
809
810 clean-openssl:
811 @pushd "$(SSLDIR)" && $(MAKE) clean && popd
812 !endif
813
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -116,11 +116,10 @@
116 !if $(FOSSIL_DYNAMIC_BUILD)!=0
117 SSLLIBDIR = $(SSLDIR)
118 !else
119 SSLLIBDIR = $(SSLDIR)
120 !endif
 
121 SSLLIB = libssl.lib libcrypto.lib user32.lib gdi32.lib crypt32.lib
122 !if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
123 !message Using 'x64' platform for OpenSSL...
124 SSLCONFIG = VC-WIN64A no-asm no-ssl3 no-weak-ssl-ciphers
125 !if $(FOSSIL_DYNAMIC_BUILD)!=0
@@ -188,16 +187,24 @@
187 !endif
188
189 !if $(FOSSIL_ENABLE_WINXP)!=0
190 XPCFLAGS = $(XPCFLAGS) /D_WIN32_WINNT=0x0501 /D_USING_V110_SDK71_=1
191 CFLAGS = $(CFLAGS) $(XPCFLAGS)
192 #
193 # NOTE: For regular builds, /OSVERSION defaults to the /SUBSYSTEM version and
194 # explicit initialization is redundant, but is required for post-built edits.
195 #
196 !if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
197 XPLDFLAGS = $(XPLDFLAGS) /OSVERSION:5.02 /SUBSYSTEM:CONSOLE,5.02
198 !else
199 XPLDFLAGS = $(XPLDFLAGS) /OSVERSION:5.01 /SUBSYSTEM:CONSOLE,5.01
200 !endif
201 LDFLAGS = $(LDFLAGS) $(XPLDFLAGS)
202 !if $(FOSSIL_ENABLE_SSL)!=0
203 !message Passing XPCFLAGS = [ $(XPCFLAGS) ] to the OpenSSL configuration...
204 SSLCONFIG = $(SSLCONFIG) $(XPCFLAGS)
205 !endif
206 !endif
207
208 !if $(FOSSIL_DYNAMIC_BUILD)!=0
209 !if $(DEBUG)!=0
210 CRTFLAGS = /MDd
@@ -799,14 +806,35 @@
806 !ifdef PERLDIR
807 @pushd "$(SSLDIR)" && "$(PERLDIR)\$(PERL)" Configure $(SSLCONFIG) && popd
808 !else
809 @pushd "$(SSLDIR)" && "$(PERL)" Configure $(SSLCONFIG) && popd
810 !endif
 
 
 
811 @pushd "$(SSLDIR)" && $(MAKE) && popd
812 !if $(FOSSIL_ENABLE_WINXP)!=0 && $(FOSSIL_DYNAMIC_BUILD)!=0
813 #
814 # NOTE: Appending custom linker flags to the OpenSSL default linker flags is
815 # somewhat difficult, as summarized in this Fossil Forum post:
816 #
817 # https://fossil-scm.org/forum/forumpost/a9a2d6af28b
818 #
819 # Therefore the custom linker flags required for Windows XP dynamic builds are
820 # applied in a separate post-build step.
821 #
822 # If the build stops here, or if the custom linker flags are outside the scope
823 # of `editbin` or `link /EDIT` (i.e. additional libraries), consider tweaking
824 # the OpenSSL makefile by hand (or the templates, as the OpenSSL makefile can
825 # rebuild itself when tampered).
826 #
827 # Also note that this step changes the subsystem for the OpenSSL DLLs from
828 # WINDOWS to CONSOLE, but which has no effect on DLLs.
829 #
830 @echo Applying XPLDFLAGS = [ $(XPLDFLAGS) ] to the OpenSSL DLLs...
831 @for /F "usebackq delims=" %F in (`dir /A:-D/B "$(SSLDIR)\*.dll" 2^>nul`) \
832 do @( \
833 echo %~nxF & \
834 link /EDIT /NOLOGO $(XPLDFLAGS) "$(SSLDIR)\%~F" \
835 )
836 !endif
837
838 clean-openssl:
839 @pushd "$(SSLDIR)" && $(MAKE) clean && popd
840 !endif
841

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button