diff mbox series

debugedit: fix build failure when enabling DEBUG_BUILD

Message ID 20250120073321.3859875-1-Qi.Chen@windriver.com
State New
Headers show
Series debugedit: fix build failure when enabling DEBUG_BUILD | expand

Commit Message

ChenQi Jan. 20, 2025, 7:33 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

When DEBUG_BUILD is enabled, we use "-Og -g" gcc options. In such
case, the xxhash functions are considered not inline, yet debugedit.c
defined XXH_INLINE_ALL to force inline, thus causing build failure.

This patch fixes this issue by not assuming those are always inline and
instead link the xxhash library.

The 0003-Makefile.am-do-not-update-manual.patch is moved from musl
specific patch to SRC_URI, because we now have a patch to modify debugedit.c
and this will cause manual to be generated again. This is unnecessary and
will report help2man missing.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../debugedit/debugedit_5.1.bb                |  4 +-
 ...-not-assume-xxhash-can-always-inline.patch | 48 +++++++++++++++++++
 2 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch

Comments

Randy MacLeod Jan. 29, 2025, 7:06 p.m. UTC | #1
On 2025-01-20 2:33 a.m., Chen Qi via lists.openembedded.org wrote:
> From: Chen Qi<Qi.Chen@windriver.com>
>
> When DEBUG_BUILD is enabled, we use "-Og -g" gcc options. In such
> case, the xxhash functions are considered not inline, yet debugedit.c
> defined XXH_INLINE_ALL to force inline, thus causing build failure.

I asked people about this PR on IRC yesterday and they said they wanted 
to hear what
upstream had to say. So far there is no reply to your email. Maybe 
create a defect in:

https://sourceware.org/bugzilla/buglist.cgi?quicksearch=debugedit
to get the upstream devs attention?

This inlining gcc-14 compile error has been discussed in the context of 
xxhash.

In the Binary Size control section of the README.md for:
https://github.com/Cyan4973/xxHash

we have:

|XXH_NO_INLINE_HINTS|:
By default, xxHash uses |__attribute__((always_inline))| and 
|__forceinline| to improve performance at the cost of code size.
Defining this macro to 1 will mark all internal functions as |static|, 
allowing the compiler to decide whether to
inline a function or not. This is very useful when optimizing for 
smallest binary size, and is automatically defined
when compiling with |-O0|, |-Os|, |-Oz|, or |-fno-inline| on GCC and Clang.
*It may also be required to successfully compile  using |-Og|, depending 
on compiler version.*


This was updated in:
https://github.com/Cyan4973/xxHash/commit/574aabad87b2ab9440403e92e1075ef48554eb87

and mentioned in:
https://github.com/Cyan4973/xxHash/issues/943#issuecomment-2563205130


Hope that helps push things along when you're back from holiday and
have time to work on this Qi.


../Randy


>
> This patch fixes this issue by not assuming those are always inline and
> instead link the xxhash library.
>
> The 0003-Makefile.am-do-not-update-manual.patch is moved from musl
> specific patch to SRC_URI, because we now have a patch to modify debugedit.c
> and this will cause manual to be generated again. This is unnecessary and
> will report help2man missing.
>
> Signed-off-by: Chen Qi<Qi.Chen@windriver.com>
> ---
>   .../debugedit/debugedit_5.1.bb                |  4 +-
>   ...-not-assume-xxhash-can-always-inline.patch | 48 +++++++++++++++++++
>   2 files changed, 49 insertions(+), 3 deletions(-)
>   create mode 100644 meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch
>
> diff --git a/meta/recipes-devtools/debugedit/debugedit_5.1.bb b/meta/recipes-devtools/debugedit/debugedit_5.1.bb
> index 00c40473c4..02429afcda 100644
> --- a/meta/recipes-devtools/debugedit/debugedit_5.1.bb
> +++ b/meta/recipes-devtools/debugedit/debugedit_5.1.bb
> @@ -10,9 +10,7 @@ LIC_FILES_CHKSUM ="file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \ 
> file://COPYING3;md5=d32239bcb673463ab874e80d47fae504"
>   
>   SRC_URI ="https://sourceware.org/ftp/debugedit/${PV}/debugedit-${PV}.tar.xz \ - "
> -
> -SRC_URI:append:libc-musl = "\
> +file://0001-Do-not-assume-xxhash-can-always-inline.patch \
>              file://0003-Makefile.am-do-not-update-manual.patch \
>              "
>   
> diff --git a/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch b/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch
> new file mode 100644
> index 0000000000..8e9256ec01
> --- /dev/null
> +++ b/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch
> @@ -0,0 +1,48 @@
> +From 76eb6ce69349a05d0ff069062182550ebd88f146 Mon Sep 17 00:00:00 2001
> +From: Chen Qi<Qi.Chen@windriver.com>
> +Date: Sun, 19 Jan 2025 22:56:36 -0800
> +Subject: [PATCH] Do not assume xxhash can always inline
> +
> +When building with "-Og -g", we'll get errors like below:
> +
> +  include/xxhash.h:5210:1: error: inlining failed in call to
> +  'always_inline' 'XXH3_scrambleAcc_sse2': function not considered for inlining
> +
> +Upstream-Status: Submitted [https://sourceware.org/pipermail/debugedit/2025-January/000359.html]
> +
> +Signed-off-by: Chen Qi<Qi.Chen@windriver.com>
> +---
> + Makefile.am       | 4 ++--
> + tools/debugedit.c | 1 -
> + 2 files changed, 2 insertions(+), 3 deletions(-)
> +
> +diff --git a/Makefile.am b/Makefile.am
> +index c590edf..35fd947 100644
> +--- a/Makefile.am
> ++++ b/Makefile.am
> +@@ -42,8 +42,8 @@ find-debuginfo: $(top_srcdir)/scripts/find-debuginfo.in Makefile
> +
> + debugedit_SOURCES = tools/debugedit.c \
> + 		    tools/hashtab.c
> +-debugedit_CFLAGS = @LIBELF_CFLAGS@ @LIBDW_CFLAGS@ $(AM_CFLAGS)
> +-debugedit_LDADD = @LIBELF_LIBS@ @LIBDW_LIBS@
> ++debugedit_CFLAGS = @LIBELF_CFLAGS@ @LIBDW_CFLAGS@ @XXHASH_CFLAGS@ $(AM_CFLAGS)
> ++debugedit_LDADD = @LIBELF_LIBS@ @LIBDW_LIBS@ @XXHASH_LIBS@
> +
> + sepdebugcrcfix_SOURCES = tools/sepdebugcrcfix.c
> + sepdebugcrcfix_CFLAGS = @LIBELF_CFLAGS@ $(AM_CFLAGS)
> +diff --git a/tools/debugedit.c b/tools/debugedit.c
> +index beefd65..43f9cee 100644
> +--- a/tools/debugedit.c
> ++++ b/tools/debugedit.c
> +@@ -82,7 +82,6 @@ typedef struct Ebl_Strtab	Strtab;
> +
> + #include "tools/hashtab.h"
> +
> +-#define XXH_INLINE_ALL
> + #include "xxhash.h"
> +
> + #define DW_TAG_partial_unit 0x3c
> +--
> +2.25.1
> +
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#210023):https://lists.openembedded.org/g/openembedded-core/message/210023
> Mute This Topic:https://lists.openembedded.org/mt/110711482/3616765
> Group Owner:openembedded-core+owner@lists.openembedded.org
> Unsubscribe:https://lists.openembedded.org/g/openembedded-core/unsub [randy.macleod@windriver.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
ChenQi Feb. 6, 2025, 3:50 a.m. UTC | #2
Hi Randy,

Thanks a lot for the information. I’ve created a bug for upstream: 32648 – debugedit fails to build with '-Og' option and gcc 14<https://sourceware.org/bugzilla/show_bug.cgi?id=32648>
I’ve put the information you provided there and also added a comment to link to my patch. Hope upstream will have time to take a look at it.

Regards,
Qi

From: MacLeod, Randy <Randy.MacLeod@windriver.com>
Sent: Thursday, January 30, 2025 3:07 AM
To: Chen, Qi <Qi.Chen@windriver.com>; openembedded-core@lists.openembedded.org
Subject: Re: [OE-core][PATCH] debugedit: fix build failure when enabling DEBUG_BUILD

On 2025-01-20 2:33 a.m., Chen Qi via lists.openembedded.org wrote:

From: Chen Qi <Qi.Chen@windriver.com><mailto:Qi.Chen@windriver.com>



When DEBUG_BUILD is enabled, we use "-Og -g" gcc options. In such

case, the xxhash functions are considered not inline, yet debugedit.c

defined XXH_INLINE_ALL to force inline, thus causing build failure.

I asked people about this PR on IRC yesterday and they said they wanted to hear what
upstream had to say. So far there is no reply to your email. Maybe create a defect in:

   https://sourceware.org/bugzilla/buglist.cgi?quicksearch=debugedit
to get the upstream devs attention?

This inlining gcc-14 compile error has been discussed in the context of xxhash.

In the Binary Size control section of the README.md for:
   https://github.com/Cyan4973/xxHash

we have:

XXH_NO_INLINE_HINTS:
By default, xxHash uses __attribute__((always_inline)) and __forceinline to improve performance at the cost of code size.
Defining this macro to 1 will mark all internal functions as static, allowing the compiler to decide whether to
inline a function or not. This is very useful when optimizing for smallest binary size, and is automatically defined
when compiling with -O0, -Os, -Oz, or -fno-inline on GCC and Clang.
It may also be required to successfully compile  using -Og, depending on compiler version.



This was updated in:
   https://github.com/Cyan4973/xxHash/commit/574aabad87b2ab9440403e92e1075ef48554eb87

and mentioned in:
   https://github.com/Cyan4973/xxHash/issues/943#issuecomment-2563205130



Hope that helps push things along when you're back from holiday and
have time to work on this Qi.



../Randy







This patch fixes this issue by not assuming those are always inline and

instead link the xxhash library.



The 0003-Makefile.am-do-not-update-manual.patch is moved from musl

specific patch to SRC_URI, because we now have a patch to modify debugedit.c

and this will cause manual to be generated again. This is unnecessary and

will report help2man missing.



Signed-off-by: Chen Qi <Qi.Chen@windriver.com><mailto:Qi.Chen@windriver.com>

---

 .../debugedit/debugedit_5.1.bb                |  4 +-

 ...-not-assume-xxhash-can-always-inline.patch | 48 +++++++++++++++++++

 2 files changed, 49 insertions(+), 3 deletions(-)

 create mode 100644 meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch



diff --git a/meta/recipes-devtools/debugedit/debugedit_5.1.bb b/meta/recipes-devtools/debugedit/debugedit_5.1.bb

index 00c40473c4..02429afcda 100644

--- a/meta/recipes-devtools/debugedit/debugedit_5.1.bb

+++ b/meta/recipes-devtools/debugedit/debugedit_5.1.bb

@@ -10,9 +10,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \<file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552/file:/COPYING3;md5=d32239bcb673463ab874e80d47fae504>

                     file://COPYING3;md5=d32239bcb673463ab874e80d47fae504"<file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552/file:/COPYING3;md5=d32239bcb673463ab874e80d47fae504>



 SRC_URI = "https://sourceware.org/ftp/debugedit/${PV}/debugedit-${PV}.tar.xz \<https://sourceware.org/ftp/debugedit/$%7bPV%7d/debugedit-$%7bPV%7d.tar.xz/->

-           "<https://sourceware.org/ftp/debugedit/$%7bPV%7d/debugedit-$%7bPV%7d.tar.xz/->

-

-SRC_URI:append:libc-musl = "\

+           file://0001-Do-not-assume-xxhash-can-always-inline.patch \

            file://0003-Makefile.am-do-not-update-manual.patch \

            "



diff --git a/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch b/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch

new file mode 100644

index 0000000000..8e9256ec01

--- /dev/null

+++ b/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch

@@ -0,0 +1,48 @@

+From 76eb6ce69349a05d0ff069062182550ebd88f146 Mon Sep 17 00:00:00 2001

+From: Chen Qi <Qi.Chen@windriver.com><mailto:Qi.Chen@windriver.com>

+Date: Sun, 19 Jan 2025 22:56:36 -0800

+Subject: [PATCH] Do not assume xxhash can always inline

+

+When building with "-Og -g", we'll get errors like below:

+

+  include/xxhash.h:5210:1: error: inlining failed in call to

+  'always_inline' 'XXH3_scrambleAcc_sse2': function not considered for inlining

+

+Upstream-Status: Submitted [https://sourceware.org/pipermail/debugedit/2025-January/000359.html]

+

+Signed-off-by: Chen Qi <Qi.Chen@windriver.com><mailto:Qi.Chen@windriver.com>

+---

+ Makefile.am       | 4 ++--

+ tools/debugedit.c | 1 -

+ 2 files changed, 2 insertions(+), 3 deletions(-)

+

+diff --git a/Makefile.am b/Makefile.am

+index c590edf..35fd947 100644

+--- a/Makefile.am

++++ b/Makefile.am

+@@ -42,8 +42,8 @@ find-debuginfo: $(top_srcdir)/scripts/find-debuginfo.in Makefile

+

+ debugedit_SOURCES = tools/debugedit.c \

+                    tools/hashtab.c

+-debugedit_CFLAGS = @LIBELF_CFLAGS@ @LIBDW_CFLAGS@ $(AM_CFLAGS)

+-debugedit_LDADD = @LIBELF_LIBS@ @LIBDW_LIBS@

++debugedit_CFLAGS = @LIBELF_CFLAGS@ @LIBDW_CFLAGS@ @XXHASH_CFLAGS@ $(AM_CFLAGS)

++debugedit_LDADD = @LIBELF_LIBS@ @LIBDW_LIBS@ @XXHASH_LIBS@

+

+ sepdebugcrcfix_SOURCES = tools/sepdebugcrcfix.c

+ sepdebugcrcfix_CFLAGS = @LIBELF_CFLAGS@ $(AM_CFLAGS)

+diff --git a/tools/debugedit.c b/tools/debugedit.c

+index beefd65..43f9cee 100644

+--- a/tools/debugedit.c

++++ b/tools/debugedit.c

+@@ -82,7 +82,6 @@ typedef struct Ebl_Strtab       Strtab;

+

+ #include "tools/hashtab.h"

+

+-#define XXH_INLINE_ALL

+ #include "xxhash.h"

+

+ #define DW_TAG_partial_unit 0x3c

+--

+2.25.1

+



-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.

View/Reply Online (#210023): https://lists.openembedded.org/g/openembedded-core/message/210023

Mute This Topic: https://lists.openembedded.org/mt/110711482/3616765

Group Owner: openembedded-core+owner@lists.openembedded.org<mailto:openembedded-core+owner@lists.openembedded.org>

Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [randy.macleod@windriver.com<mailto:randy.macleod@windriver.com>]

-=-=-=-=-=-=-=-=-=-=-=-





--

# Randy MacLeod

# Wind River Linux
diff mbox series

Patch

diff --git a/meta/recipes-devtools/debugedit/debugedit_5.1.bb b/meta/recipes-devtools/debugedit/debugedit_5.1.bb
index 00c40473c4..02429afcda 100644
--- a/meta/recipes-devtools/debugedit/debugedit_5.1.bb
+++ b/meta/recipes-devtools/debugedit/debugedit_5.1.bb
@@ -10,9 +10,7 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \
                     file://COPYING3;md5=d32239bcb673463ab874e80d47fae504"
 
 SRC_URI = "https://sourceware.org/ftp/debugedit/${PV}/debugedit-${PV}.tar.xz \
-           "
-
-SRC_URI:append:libc-musl = "\
+           file://0001-Do-not-assume-xxhash-can-always-inline.patch \
            file://0003-Makefile.am-do-not-update-manual.patch \
            "
 
diff --git a/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch b/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch
new file mode 100644
index 0000000000..8e9256ec01
--- /dev/null
+++ b/meta/recipes-devtools/debugedit/files/0001-Do-not-assume-xxhash-can-always-inline.patch
@@ -0,0 +1,48 @@ 
+From 76eb6ce69349a05d0ff069062182550ebd88f146 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Sun, 19 Jan 2025 22:56:36 -0800
+Subject: [PATCH] Do not assume xxhash can always inline
+
+When building with "-Og -g", we'll get errors like below:
+
+  include/xxhash.h:5210:1: error: inlining failed in call to
+  'always_inline' 'XXH3_scrambleAcc_sse2': function not considered for inlining
+
+Upstream-Status: Submitted [https://sourceware.org/pipermail/debugedit/2025-January/000359.html]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ Makefile.am       | 4 ++--
+ tools/debugedit.c | 1 -
+ 2 files changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index c590edf..35fd947 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -42,8 +42,8 @@ find-debuginfo: $(top_srcdir)/scripts/find-debuginfo.in Makefile
+ 
+ debugedit_SOURCES = tools/debugedit.c \
+ 		    tools/hashtab.c 
+-debugedit_CFLAGS = @LIBELF_CFLAGS@ @LIBDW_CFLAGS@ $(AM_CFLAGS)
+-debugedit_LDADD = @LIBELF_LIBS@ @LIBDW_LIBS@
++debugedit_CFLAGS = @LIBELF_CFLAGS@ @LIBDW_CFLAGS@ @XXHASH_CFLAGS@ $(AM_CFLAGS)
++debugedit_LDADD = @LIBELF_LIBS@ @LIBDW_LIBS@ @XXHASH_LIBS@
+ 
+ sepdebugcrcfix_SOURCES = tools/sepdebugcrcfix.c
+ sepdebugcrcfix_CFLAGS = @LIBELF_CFLAGS@ $(AM_CFLAGS)
+diff --git a/tools/debugedit.c b/tools/debugedit.c
+index beefd65..43f9cee 100644
+--- a/tools/debugedit.c
++++ b/tools/debugedit.c
+@@ -82,7 +82,6 @@ typedef struct Ebl_Strtab	Strtab;
+ 
+ #include "tools/hashtab.h"
+ 
+-#define XXH_INLINE_ALL
+ #include "xxhash.h"
+ 
+ #define DW_TAG_partial_unit 0x3c
+-- 
+2.25.1
+