Skip to content

Commit 689d62d

Browse files
Merge pull request #101 from TaurusTLS-Developers/fix_vcruntime
Refactor Windows builds
2 parents 6b086fa + 170ed6b commit 689d62d

1 file changed

Lines changed: 129 additions & 61 deletions

File tree

.github/workflows/build-openssl.yml

Lines changed: 129 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,17 @@ jobs:
228228
matrix:
229229
linkage: [shared, static]
230230
platform:
231-
- { label: Windows, os: windows-latest, arch: x64, target: VC-WIN64A-HYBRIDCRT, vcvars: amd64 }
232-
- { label: Windows, os: windows-latest, arch: x86, target: VC-WIN32-HYBRIDCRT, vcvars: x86 }
233-
# - { label: Windows, os: windows-latest, arch: arm64, target: VC-WIN64-ARM, vcvars: amd64_arm64 } # ARM64 build is currently disabled due possible confusion with ARM64EC
234-
- { label: Windows, os: windows-latest, arch: arm64ec, target: VC-WIN64-ARM, vcvars: amd64_arm64 }
231+
- { label: Windows, os: windows-latest, arch: x64, target: VC-WIN64A, vcvars: amd64 }
232+
- { label: Windows, os: windows-latest, arch: x86, target: VC-WIN32, vcvars: x86 }
233+
- { label: Windows, os: windows-latest, arch: arm64ec, target: VC-ARM64EC, vcvars: amd64_arm64 }
235234
- { label: Linux, os: ubuntu-latest, arch: x64, target: linux-x86_64 }
236235
- { label: Linux, os: ubuntu-latest, arch: arm64, target: linux-aarch64 }
237236
- { label: macOS, os: macos-14, arch: x64, target: darwin64-x86_64-cc, minos: "10.14" }
238237
- { label: macOS, os: macos-14, arch: arm64, target: darwin64-arm64-cc, minos: "11.0" }
239-
# - { label: Android, os: ubuntu-latest, arch: x64, target: android-x86_64, api: 21 } # Android x64 build is currently disabled as Delphi is not supporting Android x86 builds
240238
- { label: Android, os: ubuntu-latest, arch: arm64, target: android-arm64, api: 21 }
241239
- { label: Android, os: ubuntu-latest, arch: arm, target: android-arm, api: 21 }
242240
- { label: iOS, os: macos-14, arch: arm64, target: ios64-cross }
243241
- { label: iOS, os: macos-14, arch: sim-arm64, target: iossimulator-xcrun, minos: "11.0" }
244-
# - { label: iOS, os: macos-14, arch: sim-x64, target: iossimulator-xcrun, minos: "10.14" } # iOS x64 simulator is currently disabled
245242
exclude:
246243
- linkage: shared
247244
platform: { label: iOS } # iOS is static only
@@ -253,67 +250,141 @@ jobs:
253250
repository: ${{ needs.validate-version.outputs.target_repo }}
254251
ref: ${{ needs.validate-version.outputs.sha }}
255252

256-
- name: Compile Windows (Standard)
257-
if: matrix.platform.label == 'Windows' && matrix.platform.arch != 'arm64ec'
258-
shell: cmd
253+
- name: Prepare Windows Targets
254+
if: matrix.platform.label == 'Windows'
255+
shell: bash
259256
run: |
260-
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.platform.vcvars }}
261-
262-
set "PREFIX=%GITHUB_WORKSPACE%\raw_artifact\usr\local"
263-
set "TARGET=${{ matrix.platform.target }}"
264-
265-
:: --- SHARED BUILD ---
266-
if "${{ matrix.linkage }}"=="shared" (
267-
perl Configure %TARGET% --prefix="%PREFIX%" shared no-makedepend no-tests no-docs "CFLAGS=-D_WIN32_WINNT=0x0A00"
268-
)
269-
270-
:: --- STATIC BUILD ---
271-
if "${{ matrix.linkage }}"=="static" (
272-
perl Configure %TARGET% --prefix="%PREFIX%" no-shared no-apps no-module no-makedepend no-tests no-docs "CFLAGS=-D_WIN32_WINNT=0x0A00" || perl Configure %TARGET% --prefix="%PREFIX%" no-shared no-module no-makedepend no-tests no-docs "CFLAGS=-D_WIN32_WINNT=0x0A00"
273-
)
274-
275-
nmake && nmake install_sw
257+
cat << 'EOF' > Configurations/99-win-hybridcrt.conf
258+
my %targets = (
259+
# =========================================================================
260+
# x64 HybridCRT Targets
261+
# =========================================================================
262+
"VC-WIN64A-SHARED" => {
263+
inherit_from => [ "VC-WIN64A" ],
264+
disable => [ "tests", "makedepend", "docs" ],
265+
cflags => sub {
266+
my $f = join(" ", @_);
267+
$f =~ s/\/MDd?\b//g; # Remove Dynamic CRT
268+
return "$f /MT /Zi"; # Force Static CRT + Debug Symbols
269+
},
270+
lflags => sub {
271+
my $f = join(" ", @_);
272+
return "$f /debug /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib";
273+
},
274+
},
275+
"VC-WIN64A-STATIC" => {
276+
inherit_from => [ "VC-WIN64A" ],
277+
disable => [ "shared", "module", "tests", "makedepend", "docs" ],
278+
cflags => sub {
279+
my $f = join(" ", @_);
280+
$f =~ s/\/MDd?\b//g;
281+
return "$f /MT /Zi";
282+
},
283+
lflags => sub {
284+
my $f = join(" ", @_);
285+
return "$f /debug /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib";
286+
},
287+
},
288+
289+
# =========================================================================
290+
# x86 HybridCRT Targets
291+
# =========================================================================
292+
"VC-WIN32-SHARED" => {
293+
inherit_from => [ "VC-WIN32" ],
294+
disable => [ "tests", "makedepend", "docs" ],
295+
cflags => sub {
296+
my $f = join(" ", @_);
297+
$f =~ s/\/MDd?\b//g;
298+
return "$f /MT /Zi";
299+
},
300+
lflags => sub {
301+
my $f = join(" ", @_);
302+
return "$f /debug /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib";
303+
},
304+
},
305+
"VC-WIN32-STATIC" => {
306+
inherit_from => [ "VC-WIN32" ],
307+
disable => [ "shared", "module", "tests", "makedepend", "docs" ],
308+
cflags => sub {
309+
my $f = join(" ", @_);
310+
$f =~ s/\/MDd?\b//g;
311+
return "$f /MT /Zi";
312+
},
313+
lflags => sub {
314+
my $f = join(" ", @_);
315+
return "$f /debug /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib";
316+
},
317+
},
318+
319+
# =========================================================================
320+
# ARM64EC HybridCRT Targets
321+
# =========================================================================
322+
"VC-ARM64EC-SHARED" => {
323+
inherit_from => [ "VC-WIN64-ARM" ],
324+
disable => [ "asm", "tests", "makedepend", "docs" ],
325+
CFLAGS => "/W3 /wd4090 /wd4267 /wd4244 /nologo /O1 /Zi",
326+
ARFLAGS => "/nologo /MACHINE:ARM64EC",
327+
cflags => sub {
328+
my $f = join(" ", @_);
329+
$f =~ s/\/MDd?\b//g; # Remove Dynamic CRT
330+
$f =~ s/\/arm64\b//ig; # Remove standard ARM64 flag
331+
return "$f /MT /arm64EC /D_WIN32_WINNT=0x0A00";
332+
},
333+
lflags => sub {
334+
my $f = join(" ", @_);
335+
$f =~ s/\/MACHINE:ARM64\b//ig; # Remove conflicting machine type
336+
return "$f /debug /MACHINE:ARM64EC /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib";
337+
},
338+
},
339+
"VC-ARM64EC-STATIC" => {
340+
inherit_from => [ "VC-WIN64-ARM" ],
341+
disable => [ "shared", "module", "asm", "tests", "makedepend", "docs" ],
342+
CFLAGS => "/W3 /wd4090 /wd4267 /wd4244 /nologo /O1 /Zi",
343+
ARFLAGS => "/nologo /MACHINE:ARM64EC",
344+
cflags => sub {
345+
my $f = join(" ", @_);
346+
$f =~ s/\/MDd?\b//g;
347+
$f =~ s/\/arm64\b//ig;
348+
return "$f /MT /arm64EC /D_WIN32_WINNT=0x0A00";
349+
},
350+
lflags => sub {
351+
my $f = join(" ", @_);
352+
$f =~ s/\/MACHINE:ARM64\b//ig;
353+
return "$f /debug /MACHINE:ARM64EC /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib";
354+
},
355+
},
356+
);
357+
EOF
276358
277-
- name: Compile Windows (ARM64EC)
278-
if: matrix.platform.label == 'Windows' && matrix.platform.arch == 'arm64ec'
359+
- name: Compile and Stage Windows Binaries
360+
if: matrix.platform.label == 'Windows'
279361
shell: cmd
280362
run: |
281363
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.platform.vcvars }}
282364
283-
set "PREFIX=%GITHUB_WORKSPACE%\raw_artifact\usr\local"
284-
set "TARGET=${{ matrix.platform.target }}"
285-
286-
:: --- SHARED BUILD ---
287-
if "${{ matrix.linkage }}"=="shared" (
288-
perl Configure %TARGET% --prefix="%PREFIX%" shared no-makedepend no-tests no-docs no-asm "CFLAGS=/nologo /arm64EC /O1 /Zi /D_WIN32_WINNT=0x0A00" "LDFLAGS=/MACHINE:ARM64EC /nodefaultlib:libucrt.lib /defaultlib:ucrt.lib /DEBUG" "ARFLAGS=/MACHINE:ARM64EC"
289-
)
290-
291-
:: --- STATIC BUILD ---
292-
if "${{ matrix.linkage }}"=="static" (
293-
perl Configure %TARGET% --prefix="%PREFIX%" no-shared no-apps no-module no-makedepend no-tests no-docs no-asm "CFLAGS=/nologo /arm64EC /O1 /Zi /D_WIN32_WINNT=0x0A00 /MD" "LDFLAGS=/MACHINE:ARM64EC /DEBUG" "ARFLAGS=/MACHINE:ARM64EC" || perl Configure %TARGET% --prefix="%PREFIX%" no-shared no-apps no-module no-makedepend no-tests no-docs no-asm "CFLAGS=/nologo /arm64EC /O1 /Zi /D_WIN32_WINNT=0x0A00 /MD" "LDFLAGS=/MACHINE:ARM64EC /DEBUG" "ARFLAGS=/MACHINE:ARM64EC"
294-
)
295-
365+
set "INSTALL_TEMP=%GITHUB_WORKSPACE%\temp_install"
366+
:: Use the original raw_artifact\dist path so it matches POSIX perfectly
367+
set "STAGED=%GITHUB_WORKSPACE%\raw_artifact\dist"
368+
mkdir "%STAGED%\lib\static" "%STAGED%\lib\import" "%STAGED%\engines" "%STAGED%\providers"
369+
370+
:: Construct Target Name dynamically (e.g., VC-WIN64A-SHARED)
371+
set "LINK_UPPER=${{ matrix.linkage }}"
372+
if "%LINK_UPPER%"=="shared" (set "TARGET_NAME=${{ matrix.platform.target }}-SHARED") else (set "TARGET_NAME=${{ matrix.platform.target }}-STATIC")
373+
374+
cd openssl-src
375+
perl Configure %TARGET_NAME% --prefix="%INSTALL_TEMP%"
296376
nmake && nmake install_sw
297377
298-
- name: Organize Windows Binaries
299-
if: matrix.platform.label == 'Windows'
300-
shell: cmd
301-
run: |
302-
set "PREFIX=%GITHUB_WORKSPACE%\raw_artifact\usr\local"
303-
mkdir raw_artifact\dist
304-
378+
:: Organize into Staged Structure (Matching the ORIGINAL layout)
305379
if "${{ matrix.linkage }}"=="shared" (
306-
mkdir raw_artifact\dist\engines
307-
mkdir raw_artifact\dist\providers
308-
mkdir raw_artifact\dist\lib\import
309-
copy "%PREFIX%\bin\openssl.exe" raw_artifact\dist\
310-
copy "%PREFIX%\bin\*.dll" raw_artifact\dist\
311-
for /d %%d in ("%PREFIX%\lib\engines-*") do copy "%%d\*.dll" raw_artifact\dist\engines\
312-
for /d %%d in ("%PREFIX%\lib\ossl-modules*") do copy "%%d\*.dll" raw_artifact\dist\providers\
313-
copy "%PREFIX%\lib\*.lib" raw_artifact\dist\lib\import\
380+
:: Copy exe and dlls to the ROOT of the artifact, not a bin/ folder!
381+
if exist "%INSTALL_TEMP%\bin\openssl.exe" copy "%INSTALL_TEMP%\bin\openssl.exe" "%STAGED%\"
382+
copy "%INSTALL_TEMP%\bin\*.dll" "%STAGED%\"
383+
copy "%INSTALL_TEMP%\lib\*.lib" "%STAGED%\lib\import\"
384+
if exist "%INSTALL_TEMP%\lib\engines-3" copy "%INSTALL_TEMP%\lib\engines-3\*.dll" "%STAGED%\engines\"
385+
if exist "%INSTALL_TEMP%\lib\ossl-modules" copy "%INSTALL_TEMP%\lib\ossl-modules\*.dll" "%STAGED%\providers\"
314386
) else (
315-
mkdir raw_artifact\dist\lib\static
316-
copy "%PREFIX%\lib\*.lib" raw_artifact\dist\lib\static\
387+
copy "%INSTALL_TEMP%\lib\*.lib" "%STAGED%\lib\static\"
317388
)
318389
319390
- name: Install Linux Dependencies
@@ -448,7 +519,7 @@ jobs:
448519
name: raw-${{ matrix.platform.label }}-${{ matrix.platform.arch }}-${{ matrix.linkage }}-${{ github.run_id }}
449520
path: raw_artifact/dist
450521
retention-days: 1
451-
522+
452523
# =========================================================================
453524
# 3. PACKAGE RELEASE (Fan-In Matrix)
454525
# =========================================================================
@@ -462,21 +533,18 @@ jobs:
462533
# Windows packaging moved to ubuntu-latest for speed and native 'zip' support
463534
- { label: Windows, arch: x64, runner: ubuntu-latest }
464535
- { label: Windows, arch: x86, runner: ubuntu-latest }
465-
# - { label: Windows, arch: arm64, runner: ubuntu-latest } # Windows arm64 package is disabled
466536
- { label: Windows, arch: arm64ec, runner: ubuntu-latest }
467537

468538
# Linux & Android
469539
- { label: Linux, arch: x64, runner: ubuntu-latest }
470540
- { label: Linux, arch: arm64, runner: ubuntu-latest }
471-
# - { label: Android, arch: x64, runner: ubuntu-latest } # Android x64 package is disabled
472541
- { label: Android, arch: arm64, runner: ubuntu-latest }
473542
- { label: Android, arch: arm, runner: ubuntu-latest }
474543

475544
# Apple platforms MUST use macOS runners for lipo, otool, install_name_tool, and Apple strip
476545
- { label: macOS, arch: universal, runner: macos-14 }
477546
- { label: iOS, arch: arm64, runner: macos-14 }
478547
- { label: iOS, arch: sim-arm64, runner: macos-14 }
479-
# - { label: iOS, arch: sim-x64, runner: macos-14 } #iOS x64 simulator package is disabled
480548

481549
runs-on: ${{ matrix.runner }}
482550
steps:

0 commit comments

Comments
 (0)