public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Workaround kernel-headers on s390x-linux
@ 2024-04-22 15:37 Jakub Jelinek
  2024-04-22 15:41 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2024-04-22 15:37 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

Hi!

We see
FAIL: 17_intro/headers/c++1998/all_attributes.cc   (test for excess errors)
FAIL: 17_intro/headers/c++2011/all_attributes.cc   (test for excess errors)
FAIL: 17_intro/headers/c++2014/all_attributes.cc   (test for excess errors)
FAIL: 17_intro/headers/c++2017/all_attributes.cc   (test for excess errors)
FAIL: 17_intro/headers/c++2020/all_attributes.cc   (test for excess errors)
FAIL: 17_intro/names.cc  -std=gnu++17 (test for excess errors)
on s390x-linux.
The first 5 are due to kernel-headers not using uglified attribute names,
where <asm/types.h> contains
__attribute__((packed, aligned(4)))
I've filed a downstream bugreport for this in
https://bugzilla.redhat.com/show_bug.cgi?id=2276084
(not really sure where to report kernel-headers issues upstream), while the
last one is due to <sys/ucontext.h> from glibc containing:
  #ifdef __USE_MISC
  # define __ctx(fld) fld
  #else
  # define __ctx(fld) __ ## fld
  #endif
  ...
  typedef union
    {
      double  __ctx(d);
      float   __ctx(f);
    } fpreg_t;
and g++ predefining -D_GNU_SOURCE which implies define __USE_MISC.

The following patch adds a workaround for this on the libstdc++ testsuite
side, ok for trunk?

2024-04-22  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/17_intro/names.cc (d, f): Undefine on s390*-linux*.
	* testsuite/17_intro/headers/c++1998/all_attributes.cc (packed): Don't
	define on s390.
	* testsuite/17_intro/headers/c++2011/all_attributes.cc (packed):
	Likewise.
	* testsuite/17_intro/headers/c++2014/all_attributes.cc (packed):
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_attributes.cc (packed):
	Likewise.
	* testsuite/17_intro/headers/c++2020/all_attributes.cc (packed):
	Likewise.

--- libstdc++-v3/testsuite/17_intro/names.cc.jj	2024-02-02 22:13:29.575359165 +0100
+++ libstdc++-v3/testsuite/17_intro/names.cc	2024-04-22 16:54:35.696710752 +0200
@@ -270,6 +270,12 @@
 #undef u
 #endif
 
+#if defined (__linux__) && defined (__s390__)
+// <sys/ucontext.h> defines fpreg_t::d and fpreg_t::f
+#undef d
+#undef f
+#endif
+
 #if defined (__linux__) && defined (__sparc__)
 #undef y
 #endif
--- libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc.jj	2024-01-03 12:08:09.603789437 +0100
+++ libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc	2024-04-22 17:11:04.734990469 +0200
@@ -29,7 +29,11 @@
 # define noreturn 1
 # define visibility 1
 #endif
+#ifndef __s390__
+// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
+// S390.
 #define packed 1
+#endif
 #define pure 1
 // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
 #ifndef __arm__
--- libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc.jj	2024-04-22 17:11:20.028805205 +0200
+++ libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc	2024-04-22 17:12:01.531302456 +0200
@@ -29,7 +29,11 @@
 # define visibility 1
 #endif
 #define no_unique_address 1
+#ifndef __s390__
+// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
+// S390.
 #define packed 1
+#endif
 #define pure 1
 // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
 #ifndef __arm__
--- libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc.jj	2024-01-03 12:08:09.556790095 +0100
+++ libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc	2024-04-22 17:12:20.630071099 +0200
@@ -29,7 +29,11 @@
 # define visibility 1
 #endif
 #define no_unique_address 1
+#ifndef __s390__
+// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
+// S390.
 #define packed 1
+#endif
 #define pure 1
 // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
 #ifndef __arm__
--- libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc.jj	2024-01-03 12:08:09.506790795 +0100
+++ libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc	2024-04-22 17:12:38.751851577 +0200
@@ -28,7 +28,11 @@
 # define visibility 1
 #endif
 #define no_unique_address 1
+#ifndef __s390__
+// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
+// S390.
 #define packed 1
+#endif
 #define pure 1
 // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
 #ifndef __arm__
--- libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc.jj	2024-01-03 12:08:09.502790851 +0100
+++ libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc	2024-04-22 17:12:56.043642110 +0200
@@ -27,7 +27,11 @@
 # define cold 1
 # define visibility 1
 #endif
+#ifndef __s390__
+// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
+// S390.
 #define packed 1
+#endif
 #define pure 1
 // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
 #ifndef __arm__

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libstdc++: Workaround kernel-headers on s390x-linux
  2024-04-22 15:37 [PATCH] libstdc++: Workaround kernel-headers on s390x-linux Jakub Jelinek
@ 2024-04-22 15:41 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2024-04-22 15:41 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: libstdc++, gcc-patches

On Mon, 22 Apr 2024 at 16:37, Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> We see
> FAIL: 17_intro/headers/c++1998/all_attributes.cc   (test for excess errors)
> FAIL: 17_intro/headers/c++2011/all_attributes.cc   (test for excess errors)
> FAIL: 17_intro/headers/c++2014/all_attributes.cc   (test for excess errors)
> FAIL: 17_intro/headers/c++2017/all_attributes.cc   (test for excess errors)
> FAIL: 17_intro/headers/c++2020/all_attributes.cc   (test for excess errors)
> FAIL: 17_intro/names.cc  -std=gnu++17 (test for excess errors)
> on s390x-linux.
> The first 5 are due to kernel-headers not using uglified attribute names,
> where <asm/types.h> contains
> __attribute__((packed, aligned(4)))
> I've filed a downstream bugreport for this in
> https://bugzilla.redhat.com/show_bug.cgi?id=2276084
> (not really sure where to report kernel-headers issues upstream), while the
> last one is due to <sys/ucontext.h> from glibc containing:
>   #ifdef __USE_MISC
>   # define __ctx(fld) fld
>   #else
>   # define __ctx(fld) __ ## fld
>   #endif
>   ...
>   typedef union
>     {
>       double  __ctx(d);
>       float   __ctx(f);
>     } fpreg_t;
> and g++ predefining -D_GNU_SOURCE which implies define __USE_MISC.
>
> The following patch adds a workaround for this on the libstdc++ testsuite
> side, ok for trunk?

OK, thanks.


>
> 2024-04-22  Jakub Jelinek  <jakub@redhat.com>
>
>         * testsuite/17_intro/names.cc (d, f): Undefine on s390*-linux*.
>         * testsuite/17_intro/headers/c++1998/all_attributes.cc (packed): Don't
>         define on s390.
>         * testsuite/17_intro/headers/c++2011/all_attributes.cc (packed):
>         Likewise.
>         * testsuite/17_intro/headers/c++2014/all_attributes.cc (packed):
>         Likewise.
>         * testsuite/17_intro/headers/c++2017/all_attributes.cc (packed):
>         Likewise.
>         * testsuite/17_intro/headers/c++2020/all_attributes.cc (packed):
>         Likewise.
>
> --- libstdc++-v3/testsuite/17_intro/names.cc.jj 2024-02-02 22:13:29.575359165 +0100
> +++ libstdc++-v3/testsuite/17_intro/names.cc    2024-04-22 16:54:35.696710752 +0200
> @@ -270,6 +270,12 @@
>  #undef u
>  #endif
>
> +#if defined (__linux__) && defined (__s390__)
> +// <sys/ucontext.h> defines fpreg_t::d and fpreg_t::f
> +#undef d
> +#undef f
> +#endif
> +
>  #if defined (__linux__) && defined (__sparc__)
>  #undef y
>  #endif
> --- libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc.jj        2024-01-03 12:08:09.603789437 +0100
> +++ libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc   2024-04-22 17:11:04.734990469 +0200
> @@ -29,7 +29,11 @@
>  # define noreturn 1
>  # define visibility 1
>  #endif
> +#ifndef __s390__
> +// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
> +// S390.
>  #define packed 1
> +#endif
>  #define pure 1
>  // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
>  #ifndef __arm__
> --- libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc.jj        2024-04-22 17:11:20.028805205 +0200
> +++ libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc   2024-04-22 17:12:01.531302456 +0200
> @@ -29,7 +29,11 @@
>  # define visibility 1
>  #endif
>  #define no_unique_address 1
> +#ifndef __s390__
> +// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
> +// S390.
>  #define packed 1
> +#endif
>  #define pure 1
>  // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
>  #ifndef __arm__
> --- libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc.jj        2024-01-03 12:08:09.556790095 +0100
> +++ libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc   2024-04-22 17:12:20.630071099 +0200
> @@ -29,7 +29,11 @@
>  # define visibility 1
>  #endif
>  #define no_unique_address 1
> +#ifndef __s390__
> +// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
> +// S390.
>  #define packed 1
> +#endif
>  #define pure 1
>  // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
>  #ifndef __arm__
> --- libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc.jj        2024-01-03 12:08:09.506790795 +0100
> +++ libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc   2024-04-22 17:12:38.751851577 +0200
> @@ -28,7 +28,11 @@
>  # define visibility 1
>  #endif
>  #define no_unique_address 1
> +#ifndef __s390__
> +// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
> +// S390.
>  #define packed 1
> +#endif
>  #define pure 1
>  // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
>  #ifndef __arm__
> --- libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc.jj        2024-01-03 12:08:09.502790851 +0100
> +++ libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc   2024-04-22 17:12:56.043642110 +0200
> @@ -27,7 +27,11 @@
>  # define cold 1
>  # define visibility 1
>  #endif
> +#ifndef __s390__
> +// kernel-headers <asm/types.h> uses __attribute__((packed,aligned(4))) on
> +// S390.
>  #define packed 1
> +#endif
>  #define pure 1
>  // glibc's sysdeps/unix/sysv/linux/arm/sys/ucontext.h uses this on ARM.
>  #ifndef __arm__
>
>         Jakub
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-22 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-22 15:37 [PATCH] libstdc++: Workaround kernel-headers on s390x-linux Jakub Jelinek
2024-04-22 15:41 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).