diff mbox series

[meta,kirkstone] pseudo: Fix compile error on centos7

Message ID 20250102054451.500564-1-guocai.he.cn@windriver.com
State Under Review
Delegated to: Steve Sakoman
Headers show
Series [meta,kirkstone] pseudo: Fix compile error on centos7 | expand

Commit Message

guocai he Jan. 2, 2025, 5:44 a.m. UTC
From: Guocai He <guocai.he.cn@windriver.com>

When host is centos7, fix the following build errors:

In file included from pseudolog.c:21:
/usr/include/sys/stat.h:366:31: error: array type has incomlete element type

In file included from pseudolog.c:21:
/usr/include/sys/stat.h:366:31: error: array type has incomplete element type "struct timespec"
  366 |         const struct timespec __times[2],
      |                               ^~~~~~~
pseudolog.c: In function "parse_file_type":
pseudolog.c:214:10: error: "S_IFSOCK" undeclared (first use in this function)
  214 |   return S_IFSOCK;
      |          ^~~~~~~~
pseudolog.c: In function "format_one":
pseudolog.c:754:43: error: "ALLPERM"  undeclared (first use in this function)
  754 |   printf(fmtbuf, (unsigned int) e->mode & ALLPERMS);
      |                                           ^~~~~~~~

upstream commit:
https://git.yoctoproject.org/pseudo/commit/?id=15b4f4ca25593f684e6517d0b809605b443d1953
When the host is older system,such as centos7, this upstream commit will introduce 
the build errors. To add "#define _BSD_SOURCE" is mainly to avoid issues on older 
systems that do not recognize _DEFAULT_SOURCE.

Signed-off-by: Guocai He <guocai.he.cn@windriver.com>
---
 meta/recipes-devtools/pseudo/files/glibc238.patch | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Richard Purdie Jan. 6, 2025, 10:22 a.m. UTC | #1
On Thu, 2025-01-02 at 13:44 +0800, guocai he via lists.openembedded.org wrote:
> From: Guocai He <guocai.he.cn@windriver.com>
> 
> When host is centos7, fix the following build errors:
> 
> In file included from pseudolog.c:21:
> /usr/include/sys/stat.h:366:31: error: array type has incomlete element type
> 
> In file included from pseudolog.c:21:
> /usr/include/sys/stat.h:366:31: error: array type has incomplete element type "struct timespec"
>   366 |         const struct timespec __times[2],
>       |                               ^~~~~~~
> pseudolog.c: In function "parse_file_type":
> pseudolog.c:214:10: error: "S_IFSOCK" undeclared (first use in this function)
>   214 |   return S_IFSOCK;
>       |          ^~~~~~~~
> pseudolog.c: In function "format_one":
> pseudolog.c:754:43: error: "ALLPERM"  undeclared (first use in this function)
>   754 |   printf(fmtbuf, (unsigned int) e->mode & ALLPERMS);
>       |                                           ^~~~~~~~
> 
> upstream commit:
> https://git.yoctoproject.org/pseudo/commit/?id=15b4f4ca25593f684e6517d0b809605b443d1953
> When the host is older system,such as centos7, this upstream commit will introduce 
> the build errors. To add "#define _BSD_SOURCE" is mainly to avoid issues on older 
> systems that do not recognize _DEFAULT_SOURCE.
> 
> Signed-off-by: Guocai He <guocai.he.cn@windriver.com>
> ---
>  meta/recipes-devtools/pseudo/files/glibc238.patch | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/meta/recipes-devtools/pseudo/files/glibc238.patch b/meta/recipes-devtools/pseudo/files/glibc238.patch
> index dfb5c283f6..9a7cd3744d 100644
> --- a/meta/recipes-devtools/pseudo/files/glibc238.patch
> +++ b/meta/recipes-devtools/pseudo/files/glibc238.patch
> @@ -28,6 +28,20 @@ Index: git/pseudo_wrappers.c
>   #include <assert.h>
>   #include <stdlib.h>
>   #include <limits.h>
> +Index: git/pseudolog.c
> +===================================================================
> +--- git.orig/pseudolog.c
> ++++ git/pseudolog.c
> +@@ -10,6 +10,9 @@
> +  * we then don't get S_IFSOCK... _GNU_SOURCE turns on everything. */
> + #define _DEFAULT_SOURCE
> + #define _XOPEN_SOURCE
> ++/* This is mainly to avoid issues on older systems that do not
> ++ * recognize _DEFAULT_SOURCE. */
> ++#define _BSD_SOURCE
> +
> + #include <ctype.h>
> + #include <limits.h>
>  Index: git/pseudo_util.c
>  ===================================================================
>  --- git.orig/pseudo_util.c

Whilst this may fix centos 7 I suspect it may break other newer distros :(

Cheers,

Richard
guocai he Jan. 13, 2025, 6:21 a.m. UTC | #2
Richard:
Thanks for your feedback and sorry for the late response on this.

In fact, It is possible to define both _BSD_SOURCE and _DEFAULT_SOURCE simultaneously.

To define _BSD_SOURCE is mainly to avoid issues on older systems that do not recognize _DEFAULT_SOURCE.

On other newer distros, the effect is the same as defining _DEFAULT_SOURCE alone.

we verified on centos7 - ubuntu2004_64 - ubuntu2004_64_dash - opensuse153-64 - ubuntu2204_64 by automation.

And I have verified on ubuntu2204_64 - ubuntu2404_64 - fedora41-64 by manual, that works well.


Cheers,

Guocai
diff mbox series

Patch

diff --git a/meta/recipes-devtools/pseudo/files/glibc238.patch b/meta/recipes-devtools/pseudo/files/glibc238.patch
index dfb5c283f6..9a7cd3744d 100644
--- a/meta/recipes-devtools/pseudo/files/glibc238.patch
+++ b/meta/recipes-devtools/pseudo/files/glibc238.patch
@@ -28,6 +28,20 @@  Index: git/pseudo_wrappers.c
  #include <assert.h>
  #include <stdlib.h>
  #include <limits.h>
+Index: git/pseudolog.c
+===================================================================
+--- git.orig/pseudolog.c
++++ git/pseudolog.c
+@@ -10,6 +10,9 @@
+  * we then don't get S_IFSOCK... _GNU_SOURCE turns on everything. */
+ #define _DEFAULT_SOURCE
+ #define _XOPEN_SOURCE
++/* This is mainly to avoid issues on older systems that do not
++ * recognize _DEFAULT_SOURCE. */
++#define _BSD_SOURCE
+
+ #include <ctype.h>
+ #include <limits.h>
 Index: git/pseudo_util.c
 ===================================================================
 --- git.orig/pseudo_util.c