[U-Boot] [PATCH 1/5] Kconfig: add option to build with -fshort-wchar

Rob Clark robdclark at gmail.com
Wed Aug 9 23:14:31 UTC 2017


UEFI expects strings to be UTF-16.  So add an option so that when
EFI_LOADER is enabled, we can use the expected unicode string size.

Signed-off-by: Rob Clark <robdclark at gmail.com>
---
 Kconfig                | 8 ++++++++
 Makefile               | 4 ++++
 lib/efi_loader/Kconfig | 1 +
 3 files changed, 13 insertions(+)

diff --git a/Kconfig b/Kconfig
index c1451bceda..7319f1fa94 100644
--- a/Kconfig
+++ b/Kconfig
@@ -53,6 +53,14 @@ config CC_OPTIMIZE_FOR_SIZE
 
 	  This option is enabled by default for U-Boot.
 
+config CC_SHORT_WCHAR
+	bool "Use 16b wchar"
+	default n
+	help
+	  Enabling this option will pass "-fshort-wchar" to gcc, for
+	  16bit unicode strings.  This is used by EFI_LOADER, as the
+	  UEFI spec defines strings to be UTF-16.
+
 config DISTRO_DEFAULTS
 	bool "Select defaults suitable for booting general purpose Linux distributions"
 	default y if ARCH_SUNXI || TEGRA
diff --git a/Makefile b/Makefile
index 50a002e72f..91b11f5a7b 100644
--- a/Makefile
+++ b/Makefile
@@ -590,6 +590,10 @@ else
 KBUILD_CFLAGS	+= -O2
 endif
 
+ifdef CONFIG_CC_SHORT_WCHAR
+KBUILD_CFLAGS	+= -fshort-wchar
+endif
+
 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
 
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index d2b6327119..e28ef51ad4 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -1,6 +1,7 @@
 config EFI_LOADER
 	bool "Support running EFI Applications in U-Boot"
 	depends on (ARM || X86) && OF_LIBFDT
+	select CC_SHORT_WCHAR
 	default y
 	help
 	  Select this option if you want to run EFI applications (like grub2)
-- 
2.13.0



More information about the U-Boot mailing list