systemd-boot: Fix build on musl
PATCH 1/1 systemd-boot: Fix build on musl
--- .../0001-efi-Use-char16_t-on-musl.patch | 79 +++++++++++++++++++ meta/recipes-core/systemd/systemd-boot_254.bb | 2 + 2 files changed, 81 insertions(+) create mode 100644 meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +79 -0
@@ -0,0 +1,79 @@ +From efe1720de61534c814580fec61fe0025308482b2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 8 Aug 2023 00:57:12 -0700 +Subject: [PATCH] efi: Use char16_t on musl + +musl does not support configurations with under-sized definitions of +types like 16-bit wchar_t or 32-bit off_t. Only the sizes that can +represent the full range of values are supported. musl does however +have the C11 uchar.h functions which can operate on char16_t, so you +could use char16_t and the corresponding c16 conversion functions +instead of the wc versions + +Upstream-Status: Inappropriate [Musl specific] +Signed-off-by: Khem Raj <[email protected]> +--- + src/boot/efi/efi-string.c | 2 +- + src/boot/efi/efi.h | 2 ++ + src/boot/efi/meson.build | 1 - + src/fundamental/string-util-fundamental.h | 4 ++++ + 4 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c +index 4400591255..421b2c262d 100644 +--- a/src/boot/efi/efi-string.c ++++ b/src/boot/efi/efi-string.c +@@ -735,7 +735,7 @@ static bool handle_format_specifier(FormatContext *ctx, SpecifierContext *sp) { + case 's': + if (sp->long_arg) { + sp->wstr = va_arg(ctx->ap, const wchar_t *) ?: L"(null)"; +- sp->len = wcsnlen(sp->wstr, sp->len); ++ sp->len = wcsnlen((char16_t*)sp->wstr, sp->len); + } else { + sp->str = va_arg(ctx->ap, const char *) ?: "(null)"; + sp->len = strnlen8(sp->str, sp->len); +diff --git a/src/boot/efi/efi.h b/src/boot/efi/efi.h +index 5c34668383..459f675ea5 100644 +--- a/src/boot/efi/efi.h ++++ b/src/boot/efi/efi.h +@@ -21,7 +21,9 @@ assert_cc(sizeof(uint8_t) == 1); + assert_cc(sizeof(uint16_t) == 2); + assert_cc(sizeof(uint32_t) == 4); + assert_cc(sizeof(uint64_t) == 8); ++#if defined(__linux__) && defined(__GLIBC__) + assert_cc(sizeof(wchar_t) == 2); ++#endif + assert_cc(sizeof(char16_t) == 2); + assert_cc(sizeof(char32_t) == 4); + assert_cc(sizeof(size_t) == sizeof(void *)); +diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build +index 1c52629651..4a64838295 100644 +--- a/src/boot/efi/meson.build ++++ b/src/boot/efi/meson.build +@@ -132,7 +132,6 @@ efi_c_args = [ + '-DSD_BOOT=1', + '-ffreestanding', + '-fno-strict-aliasing', +- '-fshort-wchar', + '-include', 'efi_config.h', + ] + +diff --git a/src/fundamental/string-util-fundamental.h b/src/fundamental/string-util-fundamental.h +index 9019542b16..1b46f42995 100644 +--- a/src/fundamental/string-util-fundamental.h ++++ b/src/fundamental/string-util-fundamental.h +@@ -16,7 +16,11 @@ + # define strncmp strncmp16 + # define strcasecmp strcasecmp16 + # define strncasecmp strncasecmp16 ++#if defined (__linux__) && !defined(__GLIBC__) ++# define STR_C(str) (u ## str) ++#else + # define STR_C(str) (L ## str) ++#endif + typedef char16_t sd_char; + #else + # define STR_C(str) (str) +-- +2.41.0 +
meta/recipes-core/systemd/systemd-boot_254.bb +2 -0
@@ -1,6 +1,8 @@ require systemd.inc FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemd:" +SRC_URI:append:libc-musl = " file://0001-efi-Use-char16_t-on-musl.patch " + require conf/image-uefi.conf DEPENDS = "intltool-native libcap util-linux gperf-native python3-jinja2-native python3-pyelftools-native"
Signature · 1 line
2.41.0
Hello,
I tested this with the meson/systemd series from Ross and it actually breaks the build:
https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/7581/steps/12/logs/stdio
Quoted 118 lines · Khem Raj
Signed-off-by Khem Raj <[email protected]>--- .../0001-efi-Use-char16_t-on-musl.patch | 79 +++++++++++++++++++ meta/recipes-core/systemd/systemd-boot_254.bb | 2 + 2 files changed, 81 insertions(+) create mode 100644 meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchmeta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +79
-0@@ -0,0 +1,79 @@ +From efe1720de61534c814580fec61fe0025308482b2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 8 Aug 2023 00:57:12 -0700 +Subject: [PATCH] efi: Use char16_t on musl + +musl does not support configurations with under-sized definitions of +types like 16-bit wchar_t or 32-bit off_t. Only the sizes that can +represent the full range of values are supported. musl does however +have the C11 uchar.h functions which can operate on char16_t, so you +could use char16_t and the corresponding c16 conversion functions +instead of the wc versions + +Upstream-Status: Inappropriate [Musl specific] +Signed-off-by: Khem Raj <[email protected]> +--- + src/boot/efi/efi-string.c | 2 +- + src/boot/efi/efi.h | 2 ++ + src/boot/efi/meson.build | 1 - + src/fundamental/string-util-fundamental.h | 4 ++++ + 4 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c +index 4400591255..421b2c262d 100644 +--- a/src/boot/efi/efi-string.c ++++ b/src/boot/efi/efi-string.c +@@ -735,7 +735,7 @@ static bool handle_format_specifier(FormatContext *ctx, SpecifierContext *sp) { + case 's': + if (sp->long_arg) { + sp->wstr = va_arg(ctx->ap, const wchar_t *) ?: L"(null)"; +- sp->len = wcsnlen(sp->wstr, sp->len); ++ sp->len = wcsnlen((char16_t*)sp->wstr, sp->len); + } else { + sp->str = va_arg(ctx->ap, const char *) ?: "(null)"; + sp->len = strnlen8(sp->str, sp->len); +diff --git a/src/boot/efi/efi.h b/src/boot/efi/efi.h +index 5c34668383..459f675ea5 100644 +--- a/src/boot/efi/efi.h ++++ b/src/boot/efi/efi.h +@@ -21,7 +21,9 @@ assert_cc(sizeof(uint8_t) == 1); + assert_cc(sizeof(uint16_t) == 2); + assert_cc(sizeof(uint32_t) == 4); + assert_cc(sizeof(uint64_t) == 8); ++#if defined(__linux__) && defined(__GLIBC__) + assert_cc(sizeof(wchar_t) == 2); ++#endif + assert_cc(sizeof(char16_t) == 2); + assert_cc(sizeof(char32_t) == 4); + assert_cc(sizeof(size_t) == sizeof(void *)); +diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build +index 1c52629651..4a64838295 100644 +--- a/src/boot/efi/meson.build ++++ b/src/boot/efi/meson.build +@@ -132,7 +132,6 @@ efi_c_args = [ + '-DSD_BOOT=1', + '-ffreestanding', + '-fno-strict-aliasing', +- '-fshort-wchar', + '-include', 'efi_config.h', + ] + +diff --git a/src/fundamental/string-util-fundamental.h b/src/fundamental/string-util-fundamental.h +index 9019542b16..1b46f42995 100644 +--- a/src/fundamental/string-util-fundamental.h ++++ b/src/fundamental/string-util-fundamental.h +@@ -16,7 +16,11 @@ + # define strncmp strncmp16 + # define strcasecmp strcasecmp16 + # define strncasecmp strncasecmp16 ++#if defined (__linux__) && !defined(__GLIBC__) ++# define STR_C(str) (u ## str) ++#else + # define STR_C(str) (L ## str) ++#endif + typedef char16_t sd_char; + #else + # define STR_C(str) (str) +-- +2.41.0 +meta/recipes-core/systemd/systemd-boot_254.bb +2
-0@@ -1,6 +1,8 @@ require systemd.inc FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemd:" +SRC_URI:append:libc-musl = " file://0001-efi-Use-char16_t-on-musl.patch " + require conf/image-uefi.conf DEPENDS = "intltool-native libcap util-linux gperf-native python3-jinja2-native python3-pyelftools-native"Signature · 11 lines
2.41.0 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#185718): https://lists.openembedded.org/g/openembedded-core/message/185718 Mute This Topic: https://lists.openembedded.org/mt/100652047/3617179 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 7 lines · Alexandre Belloni
Hello,
I tested this with the meson/systemd series from Ross and it actually breaks the build:
https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/7581/steps/12/logs/stdio
Patch applies only to musl builds did you test a musl + systemd
Quoted 143 lines
<https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/7581/steps/12/logs/stdio>
Quoted 6 lines · Khem Raj
Signed-off-by Khem Raj <[email protected]>--- .../0001-efi-Use-char16_t-on-musl.patch | 79 +++++++++++++++++++ meta/recipes-core/systemd/systemd-boot_254.bb | 2 + 2 files changed, 81 insertions(+) create mode 100644
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchQuoted 2 lines
diff --git
a/meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchb/meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchQuoted 4 lines
new file mode 100644
index 00000000000..1988d50ac90
---/dev/null
+++
b/meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchQuoted 17 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +16
-0@@ -0,0 +1,79 @@ +From efe1720de61534c814580fec61fe0025308482b2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 8 Aug 2023 00:57:12 -0700 +Subject: [PATCH] efi: Use char16_t on musl + +musl does not support configurations with under-sized definitions of +types like 16-bit wchar_t or 32-bit off_t. Only the sizes that can +represent the full range of values are supported. musl does however +have the C11 uchar.h functions which can operate on char16_t, so you +could use char16_t and the corresponding c16 conversion functions +instead of the wc versions + +Upstream-Status: Inappropriate [Musl specific] +Signed-off-by: Khem Raj <[email protected]> +--- + src/boot/efi/efi-string.c | 2 +-meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch line 26
Quoted 10 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +10
-0+ src/boot/efi/efi.h | 2 ++ + src/boot/efi/meson.build | 1 - + src/fundamental/string-util-fundamental.h | 4 ++++ + 4 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c +index 4400591255..421b2c262d 100644 +--- a/src/boot/efi/efi-string.c ++++ b/src/boot/efi/efi-string.c +@@ -735,7 +735,7 @@ static bool handle_format_specifier(FormatContext*ctx, SpecifierContext *sp) {
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch
Quoted 3 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +3
-0+ case 's': + if (sp->long_arg) { + sp->wstr = va_arg(ctx->ap, const wchar_t *) ?:L"(null)";
Review line 31
Quoted 2 lines
(quoted diff) +2
-0+- sp->len = wcsnlen(sp->wstr, sp->len); ++ sp->len = wcsnlen((char16_t*)sp->wstr,
sp->len);Review line 33
Quoted 2 lines
(quoted diff) +2
-0+ } else { + sp->str = va_arg(ctx->ap, const char *) ?:"(null)";
Quoted 18 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +18
-0+ sp->len = strnlen8(sp->str, sp->len); +diff --git a/src/boot/efi/efi.h b/src/boot/efi/efi.h +index 5c34668383..459f675ea5 100644 +--- a/src/boot/efi/efi.h ++++ b/src/boot/efi/efi.h +@@ -21,7 +21,9 @@ assert_cc(sizeof(uint8_t) == 1); + assert_cc(sizeof(uint16_t) == 2); + assert_cc(sizeof(uint32_t) == 4); + assert_cc(sizeof(uint64_t) == 8); ++#if defined(__linux__) && defined(__GLIBC__) + assert_cc(sizeof(wchar_t) == 2); ++#endif + assert_cc(sizeof(char16_t) == 2); + assert_cc(sizeof(char32_t) == 4); + assert_cc(sizeof(size_t) == sizeof(void *)); +diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build +index 1c52629651..4a64838295 100644 +--- a/src/boot/efi/meson.buildmeta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch
Quoted 10 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +10
-0++++ b/src/boot/efi/meson.build +@@ -132,7 +132,6 @@ efi_c_args = [ + '-DSD_BOOT=1', + '-ffreestanding', + '-fno-strict-aliasing', +- '-fshort-wchar', + '-include', 'efi_config.h', + ] + +diff --git a/src/fundamental/string-util-fundamental.h
b/src/fundamental/string-util-fundamental.hReview
Quoted 19 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +18
-0+index 9019542b16..1b46f42995 100644 +--- a/src/fundamental/string-util-fundamental.h ++++ b/src/fundamental/string-util-fundamental.h +@@ -16,7 +16,11 @@ + # define strncmp strncmp16 + # define strcasecmp strcasecmp16 + # define strncasecmp strncasecmp16 ++#if defined (__linux__) && !defined(__GLIBC__) ++# define STR_C(str) (u ## str) ++#else + # define STR_C(str) (L ## str) ++#endif + typedef char16_t sd_char; + #else + # define STR_C(str) (str) +-- +2.41.0 +(quoted diff) +0
-0b/meta/recipes-core/systemd/systemd-boot_254.bb
meta/recipes-core/systemd/systemd-boot_254.bb line 4
Quoted 8 lines
index
5d69cf83abc..ae86450d2a6100644meta/recipes-core/systemd/systemd-boot_254.bb +1
-0@@ -1,6 +1,8 @@ require systemd.inc FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemd:" +SRC_URI:append:libc-musl = " file://0001-efi-Use-char16_t-on-musl.patch"
meta/recipes-core/systemd/systemd-boot_254.bb
Quoted 4 lines
meta/recipes-core/systemd/systemd-boot_254.bb +1
-0+ require conf/image-uefi.conf DEPENDS = "intltool-native libcap util-linux gperf-nativepython3-jinja2-native python3-pyelftools-native"
Quoted 8 lines
--
2.41.0-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#185718):https://lists.openembedded.org/g/openembedded-core/message/185718
Quoted 3 lines
Mute This Topic: https://lists.openembedded.org/mt/100652047/3617179
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 7 lines · Khem Raj
Quoted 3 lines · Alexandre Belloni
Hello,
Quoted 7 lines
Quoted 4 lines
I tested this with the meson/systemd series from Ross and it actually breaks the build:
https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/7581/steps/12/logs/stdio
Patch applies only to musl builds did you test a musl + systemd
ah 32bit, let me try to reproduce.
Quoted 128 lines
Quoted 128 lines · Khem Raj
Quoted 110 lines
Signed-off-by Khem Raj <[email protected]>--- .../0001-efi-Use-char16_t-on-musl.patch | 79 +++++++++++++++++++ meta/recipes-core/systemd/systemd-boot_254.bb | 2 + 2 files changed, 81 insertions(+) create mode 100644 meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchmeta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +79
-0@@ -0,0 +1,79 @@ +From efe1720de61534c814580fec61fe0025308482b2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 8 Aug 2023 00:57:12 -0700 +Subject: [PATCH] efi: Use char16_t on musl + +musl does not support configurations with under-sized definitions of +types like 16-bit wchar_t or 32-bit off_t. Only the sizes that can +represent the full range of values are supported. musl does however +have the C11 uchar.h functions which can operate on char16_t, so you +could use char16_t and the corresponding c16 conversion functions +instead of the wc versions + +Upstream-Status: Inappropriate [Musl specific] +Signed-off-by: Khem Raj <[email protected]> +--- + src/boot/efi/efi-string.c | 2 +- + src/boot/efi/efi.h | 2 ++ + src/boot/efi/meson.build | 1 - + src/fundamental/string-util-fundamental.h | 4 ++++ + 4 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c +index 4400591255..421b2c262d 100644 +--- a/src/boot/efi/efi-string.c ++++ b/src/boot/efi/efi-string.c +@@ -735,7 +735,7 @@ static bool handle_format_specifier(FormatContext *ctx, SpecifierContext *sp) { + case 's': + if (sp->long_arg) { + sp->wstr = va_arg(ctx->ap, const wchar_t *) ?: L"(null)"; +- sp->len = wcsnlen(sp->wstr, sp->len); ++ sp->len = wcsnlen((char16_t*)sp->wstr, sp->len); + } else { + sp->str = va_arg(ctx->ap, const char *) ?: "(null)"; + sp->len = strnlen8(sp->str, sp->len); +diff --git a/src/boot/efi/efi.h b/src/boot/efi/efi.h +index 5c34668383..459f675ea5 100644 +--- a/src/boot/efi/efi.h ++++ b/src/boot/efi/efi.h +@@ -21,7 +21,9 @@ assert_cc(sizeof(uint8_t) == 1); + assert_cc(sizeof(uint16_t) == 2); + assert_cc(sizeof(uint32_t) == 4); + assert_cc(sizeof(uint64_t) == 8); ++#if defined(__linux__) && defined(__GLIBC__) + assert_cc(sizeof(wchar_t) == 2); ++#endif + assert_cc(sizeof(char16_t) == 2); + assert_cc(sizeof(char32_t) == 4); + assert_cc(sizeof(size_t) == sizeof(void *)); +diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build +index 1c52629651..4a64838295 100644 +--- a/src/boot/efi/meson.build ++++ b/src/boot/efi/meson.build +@@ -132,7 +132,6 @@ efi_c_args = [ + '-DSD_BOOT=1', + '-ffreestanding', + '-fno-strict-aliasing', +- '-fshort-wchar', + '-include', 'efi_config.h', + ] + +diff --git a/src/fundamental/string-util-fundamental.h b/src/fundamental/string-util-fundamental.h +index 9019542b16..1b46f42995 100644 +--- a/src/fundamental/string-util-fundamental.h ++++ b/src/fundamental/string-util-fundamental.h +@@ -16,7 +16,11 @@ + # define strncmp strncmp16 + # define strcasecmp strcasecmp16 + # define strncasecmp strncasecmp16 ++#if defined (__linux__) && !defined(__GLIBC__) ++# define STR_C(str) (u ## str) ++#else + # define STR_C(str) (L ## str) ++#endif + typedef char16_t sd_char; + #else + # define STR_C(str) (str) +-- +2.41.0 +meta/recipes-core/systemd/systemd-boot_254.bb +2
-1@@ -1,6 +1,8 @@ require systemd.inc FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemd:" +SRC_URI:append:libc-musl = " file://0001-efi-Use-char16_t-on-musl.patch " + require conf/image-uefi.conf DEPENDS = "intltool-native libcap util-linux gperf-native python3-jinja2-native python3-pyelftools-native" --2.41.0
Quoted 8 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#185718): https://lists.openembedded.org/g/openembedded-core/message/185718
Mute This Topic: https://lists.openembedded.org/mt/100652047/3617179
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 11 lines · Khem Raj
Quoted 10 lines · Khem Raj
Quoted 6 lines · Alexandre Belloni
Hello,
I tested this with the meson/systemd series from Ross and it actually breaks the build:
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/7581/steps/12/logs/stdio
Patch applies only to musl builds did you test a musl + systemd
ah 32bit, let me try to reproduce.
It also happened on qemux86-64:
https://autobuilder.yoctoproject.org/typhoon/#/builders/45/builds/7604/steps/11/logs/stdio
Quoted 129 lines
Quoted 129 lines
Quoted 129 lines · Khem Raj
Quoted 110 lines
Signed-off-by Khem Raj <[email protected]>--- .../0001-efi-Use-char16_t-on-musl.patch | 79 +++++++++++++++++++ meta/recipes-core/systemd/systemd-boot_254.bb | 2 + 2 files changed, 81 insertions(+) create mode 100644 meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchmeta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +79
-0@@ -0,0 +1,79 @@ +From efe1720de61534c814580fec61fe0025308482b2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 8 Aug 2023 00:57:12 -0700 +Subject: [PATCH] efi: Use char16_t on musl + +musl does not support configurations with under-sized definitions of +types like 16-bit wchar_t or 32-bit off_t. Only the sizes that can +represent the full range of values are supported. musl does however +have the C11 uchar.h functions which can operate on char16_t, so you +could use char16_t and the corresponding c16 conversion functions +instead of the wc versions + +Upstream-Status: Inappropriate [Musl specific] +Signed-off-by: Khem Raj <[email protected]> +--- + src/boot/efi/efi-string.c | 2 +- + src/boot/efi/efi.h | 2 ++ + src/boot/efi/meson.build | 1 - + src/fundamental/string-util-fundamental.h | 4 ++++ + 4 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c +index 4400591255..421b2c262d 100644 +--- a/src/boot/efi/efi-string.c ++++ b/src/boot/efi/efi-string.c +@@ -735,7 +735,7 @@ static bool handle_format_specifier(FormatContext *ctx, SpecifierContext *sp) { + case 's': + if (sp->long_arg) { + sp->wstr = va_arg(ctx->ap, const wchar_t *) ?: L"(null)"; +- sp->len = wcsnlen(sp->wstr, sp->len); ++ sp->len = wcsnlen((char16_t*)sp->wstr, sp->len); + } else { + sp->str = va_arg(ctx->ap, const char *) ?: "(null)"; + sp->len = strnlen8(sp->str, sp->len); +diff --git a/src/boot/efi/efi.h b/src/boot/efi/efi.h +index 5c34668383..459f675ea5 100644 +--- a/src/boot/efi/efi.h ++++ b/src/boot/efi/efi.h +@@ -21,7 +21,9 @@ assert_cc(sizeof(uint8_t) == 1); + assert_cc(sizeof(uint16_t) == 2); + assert_cc(sizeof(uint32_t) == 4); + assert_cc(sizeof(uint64_t) == 8); ++#if defined(__linux__) && defined(__GLIBC__) + assert_cc(sizeof(wchar_t) == 2); ++#endif + assert_cc(sizeof(char16_t) == 2); + assert_cc(sizeof(char32_t) == 4); + assert_cc(sizeof(size_t) == sizeof(void *)); +diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build +index 1c52629651..4a64838295 100644 +--- a/src/boot/efi/meson.build ++++ b/src/boot/efi/meson.build +@@ -132,7 +132,6 @@ efi_c_args = [ + '-DSD_BOOT=1', + '-ffreestanding', + '-fno-strict-aliasing', +- '-fshort-wchar', + '-include', 'efi_config.h', + ] + +diff --git a/src/fundamental/string-util-fundamental.h b/src/fundamental/string-util-fundamental.h +index 9019542b16..1b46f42995 100644 +--- a/src/fundamental/string-util-fundamental.h ++++ b/src/fundamental/string-util-fundamental.h +@@ -16,7 +16,11 @@ + # define strncmp strncmp16 + # define strcasecmp strcasecmp16 + # define strncasecmp strncasecmp16 ++#if defined (__linux__) && !defined(__GLIBC__) ++# define STR_C(str) (u ## str) ++#else + # define STR_C(str) (L ## str) ++#endif + typedef char16_t sd_char; + #else + # define STR_C(str) (str) +-- +2.41.0 +meta/recipes-core/systemd/systemd-boot_254.bb +2
-1@@ -1,6 +1,8 @@ require systemd.inc FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemd:" +SRC_URI:append:libc-musl = " file://0001-efi-Use-char16_t-on-musl.patch " + require conf/image-uefi.conf DEPENDS = "intltool-native libcap util-linux gperf-native python3-jinja2-native python3-pyelftools-native" --2.41.0
Quoted 8 lines
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#185718): https://lists.openembedded.org/g/openembedded-core/message/185718
Mute This Topic: https://lists.openembedded.org/mt/100652047/3617179
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 17 lines · Alexandre Belloni
Quoted 5 lines · Khem Raj
Quoted 4 lines · Khem Raj
On Thu, Aug 10, 2023 at 6:05 AM Alexandre Belloni <
Quoted 7 lines · [email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Hello,
I tested this with the meson/systemd series from Ross and it actually breaks the build:
https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/7581/steps/12/logs/stdio
Quoted 2 lines
Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Patch applies only to musl builds did you test a musl + systemd
ah 32bit, let me try to reproduce.
It also happened on qemux86-64:
https://autobuilder.yoctoproject.org/typhoon/#/builders/45/builds/7604/steps/11/logs/stdio
Yeah it’s more of clang vs gcc then 32 vs 64bit in my env
Quoted 155 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Khem Raj
Quoted 3 lines
Signed-off-by Khem Raj <[email protected]>--- .../0001-efi-Use-char16_t-on-musl.patch | 79+++++++++++++++++++
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
meta/recipes-core/systemd/systemd-boot_254.bb | 2 + 2 files changed, 81 insertions(+) create mode 100644
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
diff --git
a/meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchb/meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
new file mode 100644
index 00000000000..1988d50ac90
---/dev/null
+++
b/meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patchQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review line 1
Quoted 2 lines
(quoted diff) +1
-0@@ -0,0 +1,79 @@ +From efe1720de61534c814580fec61fe0025308482b2 Mon Sep 17 00:00:002001
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch
Quoted 5 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +5
-0+From: Khem Raj <[email protected]> +Date: Tue, 8 Aug 2023 00:57:12 -0700 +Subject: [PATCH] efi: Use char16_t on musl + +musl does not support configurations with under-sized definitionsof
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch
Quoted 3 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +3
-0+types like 16-bit wchar_t or 32-bit off_t. Only the sizes that can +represent the full range of values are supported. musl does however +have the C11 uchar.h functions which can operate on char16_t, soyou
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +9
-0+could use char16_t and the corresponding c16 conversion functions +instead of the wc versions + +Upstream-Status: Inappropriate [Musl specific] +Signed-off-by: Khem Raj <[email protected]> +--- + src/boot/efi/efi-string.c | 2 +- + src/boot/efi/efi.h | 2 ++ + src/boot/efi/meson.build | 1 -Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch
Quoted 8 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +8
-0+ src/fundamental/string-util-fundamental.h | 4 ++++ + 4 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c +index 4400591255..421b2c262d 100644 +--- a/src/boot/efi/efi-string.c ++++ b/src/boot/efi/efi-string.c +@@ -735,7 +735,7 @@ static bool
handle_format_specifier(FormatContext *ctx, SpecifierContext *sp){Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch
Quoted 3 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +3
-0+ case 's': + if (sp->long_arg) { + sp->wstr = va_arg(ctx->ap, const wchar_t*) ?: L"(null)";
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review line 31
Quoted 2 lines
(quoted diff) +2
-0+- sp->len = wcsnlen(sp->wstr, sp->len); ++ sp->len = wcsnlen((char16_t*)sp->wstr,
sp->len);Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review line 33
Quoted 2 lines
(quoted diff) +2
-0+ } else { + sp->str = va_arg(ctx->ap, const char *)?: "(null)";
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +20
-0+ sp->len = strnlen8(sp->str, sp->len); +diff --git a/src/boot/efi/efi.h b/src/boot/efi/efi.h +index 5c34668383..459f675ea5 100644 +--- a/src/boot/efi/efi.h ++++ b/src/boot/efi/efi.h +@@ -21,7 +21,9 @@ assert_cc(sizeof(uint8_t) == 1); + assert_cc(sizeof(uint16_t) == 2); + assert_cc(sizeof(uint32_t) == 4); + assert_cc(sizeof(uint64_t) == 8); ++#if defined(__linux__) && defined(__GLIBC__) + assert_cc(sizeof(wchar_t) == 2); ++#endif + assert_cc(sizeof(char16_t) == 2); + assert_cc(sizeof(char32_t) == 4); + assert_cc(sizeof(size_t) == sizeof(void *)); +diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build +index 1c52629651..4a64838295 100644 +--- a/src/boot/efi/meson.build ++++ b/src/boot/efi/meson.build +@@ -132,7 +132,6 @@ efi_c_args = [Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch
Quoted 8 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +8
-0+ '-DSD_BOOT=1', + '-ffreestanding', + '-fno-strict-aliasing', +- '-fshort-wchar', + '-include', 'efi_config.h', + ] + +diff --git a/src/fundamental/string-util-fundamental.h
b/src/fundamental/string-util-fundamental.hQuoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +11
-0+index 9019542b16..1b46f42995 100644 +--- a/src/fundamental/string-util-fundamental.h ++++ b/src/fundamental/string-util-fundamental.h +@@ -16,7 +16,11 @@ + # define strncmp strncmp16 + # define strcasecmp strcasecmp16 + # define strncasecmp strncasecmp16 ++#if defined (__linux__) && !defined(__GLIBC__) ++# define STR_C(str) (u ## str) ++#else + # define STR_C(str) (L ## str)Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
meta/recipes-core/systemd/systemd-boot/0001-efi-Use-char16_t-on-musl.patch new file +7
-0++#endif + typedef char16_t sd_char; + #else + # define STR_C(str) (str) +-- +2.41.0 +(quoted diff) +0
-0b/meta/recipes-core/systemd/systemd-boot_254.bb
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/recipes-core/systemd/systemd-boot_254.bb line 4
Quoted 8 lines
index
5d69cf83abc..ae86450d2a6100644meta/recipes-core/systemd/systemd-boot_254.bb +1
-0@@ -1,6 +1,8 @@ require systemd.inc FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemd:" +SRC_URI:append:libc-musl = "file://0001-efi-Use-char16_t-on-musl.patch "
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/recipes-core/systemd/systemd-boot_254.bb
Quoted 4 lines
meta/recipes-core/systemd/systemd-boot_254.bb +1
-0+ require conf/image-uefi.conf DEPENDS = "intltool-native libcap util-linux gperf-nativepython3-jinja2-native python3-pyelftools-native"
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
--
2.41.0-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#185718):https://lists.openembedded.org/g/openembedded-core/message/185718
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Mute This Topic:
https://lists.openembedded.org/mt/100652047/3617179
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Group Owner: [email protected] Unsubscribe:
https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
-=-=-=-=-=-=-=-=-=-=-=-
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com