From 706a3f989e0cda2d5b9bb4d9d91edb8e3da93709 Mon Sep 17 00:00:00 2001 From: Michael D Kinney Date: Fri, 26 Dec 2025 11:41:39 -0800 Subject: [PATCH] CryptoPkg: Use Openssl NASM for Windows host-based unit tests The optimized NASM assembly files from Openssl project for IA32/X64 assume a Windows calling convention. Those NASM files must be used for both firmware builds where the default compiler calling convention is the Windows calling convention and host-based unit tests built using any of the compilers supported in Windows environment. All the VS20xx tool chains in the MSFT tool family use a Windows calling convention. The CLANGPDB tool chain under both Windows and Linux environments also use a Windows calling convention. Set PcdOpensslLibAssemblySourceStyleNasm to TRUE for these conditions. Host-based unit tests built in a Windows environment also use a Windows calling convention. If WIN_HOST_BUILD is set indicating a Windows build environment and HOST_BASED_UNIT_TESTING_ENABLED is also set indicating host-based unit tests, then PcdOpensslLibAssemblySourceStyleNasm must be set to TRUE. Otherwise a Linux calling convention is assumed and PcdOpensslLibAssemblySourceStyleNasm uses its DEC default value of FALSE that uses the Openssl project optimized .S files that assume a Linux calling convention. Signed-off-by: Michael D Kinney --- CryptoPkg/CryptoPkgFeatureFlagPcds.dsc.inc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CryptoPkg/CryptoPkgFeatureFlagPcds.dsc.inc b/CryptoPkg/CryptoPkgFeatureFlagPcds.dsc.inc index 662aaf2ff2..c3eb8049ca 100644 --- a/CryptoPkg/CryptoPkgFeatureFlagPcds.dsc.inc +++ b/CryptoPkg/CryptoPkgFeatureFlagPcds.dsc.inc @@ -8,6 +8,17 @@ ## [PcdsFeatureFlag] +# +# Use Openssl NASM assembly source files that assume Windows calling convention +# if the family is MSFT or the toolchain is CLANGPDB for Windows or Linux. +# Also use Openssl NASM assembly source files that assume Windows calling +# convention if host-based unit tests are being build for Windows. +# Otherwise, the Openssl .S assembly source files that assume the Linux calling +# convention. +# !if "$(FAMILY)" == "MSFT" || "$(TOOL_CHAIN_TAG)" == "CLANGPDB" gEfiCryptoPkgTokenSpaceGuid.PcdOpensslLibAssemblySourceStyleNasm|TRUE !endif +!if $(HOST_BASED_UNIT_TESTING_ENABLED) AND $(WIN_HOST_BUILD) +gEfiCryptoPkgTokenSpaceGuid.PcdOpensslLibAssemblySourceStyleNasm|TRUE +!endif