From 1224d57ba533c8cda8a5b610588b7032b07492e1 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Tue, 26 Oct 2021 10:56:17 +0200 Subject: [PATCH] sd-boot: Always compile with -ffreestanding and -fshort-wchar MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is not a hosted environment and we should not pretend otherwise if -ffreestanding is not supported. With EFI strings being in UCS2, it is not supported to build without -fshort-wchar as gcc/clang default to a w_char_t size of 4 bytes. This also makes the charset for wide chars explicit on gcc. This way we get a nice error message if anyone ever tries to add 💩 to strings. --- src/boot/efi/meson.build | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build index e6bb7d7c6af..5108cfa59eb 100644 --- a/src/boot/efi/meson.build +++ b/src/boot/efi/meson.build @@ -197,11 +197,10 @@ if have_gnu_efi compile_args = cc.get_supported_arguments( basic_disabled_warnings + possible_common_cc_flags + [ - '-ffreestanding', '-fno-stack-protector', '-fno-strict-aliasing', '-fpic', - '-fshort-wchar', + '-fwide-exec-charset=UCS2', '-Wall', '-Wextra', '-Wsign-compare', @@ -209,6 +208,8 @@ if have_gnu_efi ) + [ '-nostdlib', '-std=gnu99', + '-ffreestanding', + '-fshort-wchar', '-isystem', efi_incdir, '-isystem', efi_incdir / gnu_efi_path_arch, '-I', fundamental_path, -- 2.47.3