diff mbox

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

Message ID 20170809231441.22691-2-robdclark@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Rob Clark Aug. 9, 2017, 11:14 p.m. UTC
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@gmail.com>
---
 Kconfig                | 8 ++++++++
 Makefile               | 4 ++++
 lib/efi_loader/Kconfig | 1 +
 3 files changed, 13 insertions(+)

Comments

Tom Rini Aug. 10, 2017, 2:28 a.m. UTC | #1
On Wed, Aug 09, 2017 at 07:14:31PM -0400, Rob Clark wrote:

> 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@gmail.com>

So, I kludged this to just globally pass -fshort-wchar and I see no size
changes in a world build
(https://gist.github.com/trini/60c4e58c662553ca902b4e878a9a8dc5).  I
feel we should explain why, and enable this along with the stdc-2011
change.
diff mbox

Patch

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)