Repository navigation
SctPkg: Replace global -mabi=ms with EFIAPI macro for GCC IA32/X64 - #358
Open
r1chard-lyu wants to merge 3 commits into
Open
r1chard-lyu wants to merge 3 commits into
r1chard-lyu wants to merge 3 commits into
Conversation
tianocore-assign-reviewers
Bot
requested review from
anncheng-arm,
cgjertsen,
edhay,
shellyki-intel and
sunnywang-arm
June 12, 2026 08:56
REF: tianocore#285 The edk2 community prefers adding the missing EFIAPI annotation to each public interface over using '-mabi=ms' as a global declaration, so that only functions that genuinely cross the UEFI ABI boundary carry the Microsoft calling convention, while the rest of the code stays on the host System V ABI. Following that direction, replace the global '-mabi=ms' compiler flag with an explicit EFIAPI macro definition '-DEFIAPI=__attribute__((ms_abi))' for GCC IA32 and X64 toolchains. This makes the ABI boundary explicit at the declaration site instead of implicit at the build-system level. Signed-off-by: Richard Lyu <richard.lyu@suse.com>
Annotate the public print function declarations (SctPrintAt, SctPrint, SctAPrint, SctSPrint, SctVSPrint, SctAVSPrint, SctASPrint, SctPoolPrint, SctCatPrint) with EFIAPI to match their definitions in SctLib/Print.c, ensuring a consistent calling convention across the call sites once EFIAPI is explicitly defined for GCC IA32/X64. Signed-off-by: Richard Lyu <richard.lyu@suse.com>
With -mabi=ms removed and EFIAPI explicitly defined for GCC IA32/X64, the va_list calling chain in SctLib/Print.c requires careful handling to keep a consistent ABI across the entire print pipeline: - SCT_PRINT_STATE.Output and .SetAttr changed to EFIAPI function pointer types to match UEFI EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL - Type casts for OutputString and SetAttribute updated to include EFIAPI - All variadic functions (SctPrint, SctSPrint, SctPoolPrint, etc.) and VA_LIST consumers (SctVSPrint, _IPrint, _PoolCatPrint, etc.) annotated with EFIAPI to ensure consistent va_list ABI throughout the call chain - All static internal helpers that participate in the print pipeline (_Print, PFLUSH, PPUTC, PITEM, PGETC, PSETATTR, etc.) annotated with EFIAPI accordingly Signed-off-by: Richard Lyu <richard.lyu@suse.com>
r1chard-lyu
force-pushed
the
sctpkg-efiapi-macro
branch
from
June 12, 2026 12:54
7057674 to
c9279cb
Compare
edhay
reviewed
Aug 6, 2026
edhay
left a comment
Contributor
There was a problem hiding this comment.
Thank you for the updates.
|
|
||
| # GCC:*_*_IA32_CC_FLAGS = -D EFI32 $(GCC_VER_MACRO) -ffreestanding -nostdinc -nostdlib -Wno-error -mno-red-zone -Wno-address -mno-stack-arg-probe "-DEFIAPI=__attribute__((ms_abi))" -m32 -mabi=ms -D MDE_CPU_X32 | ||
| GCC:*_*_IA32_CC_FLAGS = -D EFIX64 $(GCC_VER_MACRO) -Wno-error -mabi=ms | ||
| GCC:*_*_IA32_CC_FLAGS = -D EFIX64 $(GCC_VER_MACRO) -Wno-error "-DEFIAPI=__attribute__((ms_abi))" |
Contributor
There was a problem hiding this comment.
Is this change tested for all functions in a edk2-test run?
Contributor
Author
There was a problem hiding this comment.
Yes, I ran a full SCT run. All test suites were executed, 7079 cases total, on
OVMF/QEMU, and the results are identical before and after the patch. This change
is expected to affect the x86 platform only.
| without patch | with patch | |
|---|---|---|
| Total | 7079 | 7079 |
| Passed | 7047 | 7047 |
| Failed | 32 | 32 |
Contributor
Author
|
@edhay When can we expect this to be merged? Currently, this should only affect IA32/X64 GCC builds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
REF: #285
The edk2 community prefers annotating public interfaces with
EFIAPIover forcing the Microsoft x64 calling convention globally via
-mabi=ms. The global flag obscures which symbols actually cross theUEFI ABI boundary and silently changes the calling convention of
internal helpers that should follow the host System V ABI.
This series replaces the global
-mabi=msflag for GCC IA32/X64 withan explicit
EFIAPImacro, then annotates the SctLib print pipelineso the
va_listABI stays consistent end-to-end.Changes
SctPkg/UEFI— Replace-mabi=mswith-DEFIAPI=__attribute__((ms_abi))for the GCC IA32/X64 toolchainsin
UEFI_SCT.dsc.SctPkg/Include— AddEFIAPIto the public print functiondeclarations (
SctPrint,SctSPrint,SctVSPrint, etc.) so callsites pick up the correct calling convention.
SctPkg/Library/SctLib— AddEFIAPIto print functiondefinitions, internal helpers, and
VA_LISTconsumers so theva_listABI is consistent through the entire print pipeline.