Skip to content

Commit 32d706a

Browse files
committed
[build] Use -fshort-wchar when building EFI host utilities
The EFI host utilities (such as elf2efi64, efirom, etc) include the EDK2 headers, which include static assertions to ensure that they are built with -fshort-wchar enabled. When building the host utilities, we currently bypass these assertions by defining MDE_CPU_EBC. The EBC compiler apparently does not support static assertions, and defining MDE_CPU_EBC therefore causes EDK2's Base.h to define STATIC_ASSERT() as a no-op. Newer versions of the EDK2 headers omit the check for MDE_CPU_EBC (and will presumably therefore fail to build with the EBC compiler). This causes our host utility builds to fail since the static assertion now detects that we are building with the host's default ABI (i.e. without enabling -fshort-wchar). Fix by enabling -fshort-wchar when building EFI host utilities. This produces binaries that are technically incompatible with the host ABI. However, since our host utilities never handle any wide-character strings, this nominal ABI incompatiblity has no effect. Signed-off-by: Michael Brown <[email protected]>
1 parent 82fac51 commit 32d706a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Makefile.housekeeping

+5-4
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ CFLAGS += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
484484
ASFLAGS += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
485485
LDFLAGS += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
486486
HOST_CFLAGS += -O2 -g
487+
HOST_EFI_CFLAGS += -fshort-wchar
487488

488489
# Inhibit -Werror if NO_WERROR is specified on make command line
489490
#
@@ -1449,22 +1450,22 @@ CLEANUP += $(ZBIN)
14491450

14501451
$(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
14511452
$(QM)$(ECHO) " [HOSTCC] $@"
1452-
$(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -DEFI_TARGET32 $< -o $@
1453+
$(Q)$(HOST_CC) $(HOST_CFLAGS) $(HOST_EFI_CFLAGS) -idirafter include -DEFI_TARGET32 $< -o $@
14531454
CLEANUP += $(ELF2EFI32)
14541455

14551456
$(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
14561457
$(QM)$(ECHO) " [HOSTCC] $@"
1457-
$(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -DEFI_TARGET64 $< -o $@
1458+
$(Q)$(HOST_CC) $(HOST_CFLAGS) $(HOST_EFI_CFLAGS) -idirafter include -DEFI_TARGET64 $< -o $@
14581459
CLEANUP += $(ELF2EFI64)
14591460

14601461
$(EFIROM) : util/efirom.c util/eficompress.c $(MAKEDEPS)
14611462
$(QM)$(ECHO) " [HOSTCC] $@"
1462-
$(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1463+
$(Q)$(HOST_CC) $(HOST_CFLAGS) $(HOST_EFI_CFLAGS) -idirafter include -o $@ $<
14631464
CLEANUP += $(EFIROM)
14641465

14651466
$(EFIFATBIN) : util/efifatbin.c $(MAKEDEPS)
14661467
$(QM)$(ECHO) " [HOSTCC] $@"
1467-
$(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1468+
$(Q)$(HOST_CC) $(HOST_CFLAGS) $(HOST_EFI_CFLAGS) -idirafter include -o $@ $<
14681469
CLEANUP += $(EFIFATBIN)
14691470

14701471
###############################################################################

0 commit comments

Comments
 (0)