diff mbox

Actually fix libhsail-rt build on x86_64/i?86 32-bit (take 2)

Message ID 20170130173700.GH13290@tucnak
State New
Headers show

Commit Message

Jakub Jelinek Jan. 30, 2017, 5:37 p.m. UTC
Hi!

On Mon, Jan 30, 2017 at 05:56:36PM +0100, Bernhard Reutner-Fischer wrote:
> On 30 January 2017 10:56:59 CET, Jakub Jelinek <jakub@redhat.com> wrote:
> 
> >+++ libhsail-rt/rt/sat_arithmetic.c	2017-01-30 10:27:27.861325330 +0100
> >@@ -49,21 +49,18 @@ __hsail_sat_add_u16 (uint16_t a, uint16_
> > uint64_t
> > __hsail_sat_add_u64 (uint64_t a, uint64_t b)
> > {
> >-  __uint128_t c = (__uint128_t) a + (__uint128_t) b;
> >-  if (c > UINT64_MAX)
> >+  uint64_t c;
> >+  if (__builtin_add_overflow (a, b, &c))
> >     return UINT64_MAX;
> >-  else
> >-    return c;
> > }
> 
> Missing return c; ?

Oops, right, fixed thusly.  Note the previously posted patch passed
bootstrap/regtest on x86_64-linux (and bootstrapped on i686-linux, regtest
still ongoing there), so likely nothing in the testsuite tests
it.

> Or maybe dead code since I'd have expected a warning here about not returning?

No, but it seems libhsail-rt doesn't add any warnings at all (something that
really should be fixed too, config/*.m4 has lots of functions to enable
warnings that can be just added to configure.ac).

2017-01-23  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* config/s390/s390.c (s390_asan_shadow_offset): New function.
	(TARGET_ASAN_SHADOW_OFFSET): Redefine.
libsanitizer/
	* configure.tgt: Enable asan and ubsan on 64-bit s390*-*-linux*.



	Jakub

Comments

Bernhard Reutner-Fischer Jan. 30, 2017, 7:53 p.m. UTC | #1
On 30 January 2017 18:37:00 CET, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>On Mon, Jan 30, 2017 at 05:56:36PM +0100, Bernhard Reutner-Fischer
>wrote:
>> On 30 January 2017 10:56:59 CET, Jakub Jelinek <jakub@redhat.com>
>wrote:
>> 
>> >+++ libhsail-rt/rt/sat_arithmetic.c	2017-01-30 10:27:27.861325330
>+0100
>> >@@ -49,21 +49,18 @@ __hsail_sat_add_u16 (uint16_t a, uint16_
>> > uint64_t
>> > __hsail_sat_add_u64 (uint64_t a, uint64_t b)
>> > {
>> >-  __uint128_t c = (__uint128_t) a + (__uint128_t) b;
>> >-  if (c > UINT64_MAX)
>> >+  uint64_t c;
>> >+  if (__builtin_add_overflow (a, b, &c))
>> >     return UINT64_MAX;
>> >-  else
>> >-    return c;
>> > }
>> 
>> Missing return c; ?
>
>Oops, right, fixed thusly.  Note the previously posted patch passed
>bootstrap/regtest on x86_64-linux (and bootstrapped on i686-linux,
>regtest
>still ongoing there), so likely nothing in the testsuite tests
>it.
>
>> Or maybe dead code since I'd have expected a warning here about not
>returning?
>
>No, but it seems libhsail-rt doesn't add any warnings at all (something
>that
>really should be fixed too, config/*.m4 has lots of functions to enable
>warnings that can be just added to configure.ac).

As this will likely bri{ck,g} horribly I'll leave these to Martin and Pekka.
Thanks for fixing but note that you attached the wrong patch below.

Cheers,
>
>2017-01-23  Jakub Jelinek  <jakub@redhat.com>
>
>gcc/
>	* config/s390/s390.c (s390_asan_shadow_offset): New function.
>	(TARGET_ASAN_SHADOW_OFFSET): Redefine.
>libsanitizer/
>	* configure.tgt: Enable asan and ubsan on 64-bit s390*-*-linux*.
>
>--- gcc/config/s390/s390.c.jj	2017-01-19 16:58:25.000000000 +0100
>+++ gcc/config/s390/s390.c	2017-01-23 16:32:28.220398187 +0100
>@@ -15435,6 +15435,14 @@ s390_excess_precision (enum excess_preci
>   return FLT_EVAL_METHOD_UNPREDICTABLE;
> }
> 
>+/* Implement the TARGET_ASAN_SHADOW_OFFSET hook.  */
>+
>+static unsigned HOST_WIDE_INT
>+s390_asan_shadow_offset (void)
>+{
>+  return TARGET_64BIT ? HOST_WIDE_INT_1U << 52 : HOST_WIDE_INT_UC
>(0x20000000);
>+}
>+
> /* Initialize GCC target structure.  */
> 
> #undef  TARGET_ASM_ALIGNED_HI_OP
>@@ -15536,6 +15544,8 @@ s390_excess_precision (enum excess_preci
> #define TARGET_BUILD_BUILTIN_VA_LIST s390_build_builtin_va_list
> #undef TARGET_EXPAND_BUILTIN_VA_START
> #define TARGET_EXPAND_BUILTIN_VA_START s390_va_start
>+#undef TARGET_ASAN_SHADOW_OFFSET
>+#define TARGET_ASAN_SHADOW_OFFSET s390_asan_shadow_offset
> #undef TARGET_GIMPLIFY_VA_ARG_EXPR
> #define TARGET_GIMPLIFY_VA_ARG_EXPR s390_gimplify_va_arg
> 
>--- libsanitizer/configure.tgt.jj	2017-01-23 15:25:21.000000000 +0100
>+++ libsanitizer/configure.tgt	2017-01-23 15:36:40.787456320 +0100
>@@ -39,6 +39,11 @@ case "${target}" in
> 	;;
>   sparc*-*-linux*)
> 	;;
>+  s390*-*-linux*)
>+	if test x$ac_cv_sizeof_void_p = x4; then
>+		UNSUPPORTED=1
>+	fi
>+	;;
>   arm*-*-linux*)
> 	;;
>   aarch64*-*-linux*)
>
>
>	Jakub
diff mbox

Patch

--- gcc/config/s390/s390.c.jj	2017-01-19 16:58:25.000000000 +0100
+++ gcc/config/s390/s390.c	2017-01-23 16:32:28.220398187 +0100
@@ -15435,6 +15435,14 @@  s390_excess_precision (enum excess_preci
   return FLT_EVAL_METHOD_UNPREDICTABLE;
 }
 
+/* Implement the TARGET_ASAN_SHADOW_OFFSET hook.  */
+
+static unsigned HOST_WIDE_INT
+s390_asan_shadow_offset (void)
+{
+  return TARGET_64BIT ? HOST_WIDE_INT_1U << 52 : HOST_WIDE_INT_UC (0x20000000);
+}
+
 /* Initialize GCC target structure.  */
 
 #undef  TARGET_ASM_ALIGNED_HI_OP
@@ -15536,6 +15544,8 @@  s390_excess_precision (enum excess_preci
 #define TARGET_BUILD_BUILTIN_VA_LIST s390_build_builtin_va_list
 #undef TARGET_EXPAND_BUILTIN_VA_START
 #define TARGET_EXPAND_BUILTIN_VA_START s390_va_start
+#undef TARGET_ASAN_SHADOW_OFFSET
+#define TARGET_ASAN_SHADOW_OFFSET s390_asan_shadow_offset
 #undef TARGET_GIMPLIFY_VA_ARG_EXPR
 #define TARGET_GIMPLIFY_VA_ARG_EXPR s390_gimplify_va_arg
 
--- libsanitizer/configure.tgt.jj	2017-01-23 15:25:21.000000000 +0100
+++ libsanitizer/configure.tgt	2017-01-23 15:36:40.787456320 +0100
@@ -39,6 +39,11 @@  case "${target}" in
 	;;
   sparc*-*-linux*)
 	;;
+  s390*-*-linux*)
+	if test x$ac_cv_sizeof_void_p = x4; then
+		UNSUPPORTED=1
+	fi
+	;;
   arm*-*-linux*)
 	;;
   aarch64*-*-linux*)