public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132
@ 2021-07-08 14:34 clyon at gcc dot gnu.org
  2021-07-08 14:47 ` [Bug tree-optimization/101379] " schwab@linux-m68k.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: clyon at gcc dot gnu.org @ 2021-07-08 14:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

            Bug ID: 101379
           Summary: libatomic build failure on arm after r12-2132
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: clyon at gcc dot gnu.org
  Target Milestone: ---

After r12-2132, I've noticed a build failure in libatomic for arm. It can be
reproduced with --target arm-linux-gnueabi (not with arm-eabi):

In file included from
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/config/arm/host-config.h:4,
                 from
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/libatomic_i.h:232,
                 from
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/gstore.c:25:
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/gstore.c: In
function 'libat_store':
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/config/linux/arm/host-config.h:42:34:
error: array subscript 0 is outside array bounds of 'unsigned int[0]'
[-Werror=array-bounds]
   42 | #define __kernel_helper_version (*(unsigned int *)0xffff0ffc)
      |                                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/config/linux/arm/host-config.h:104:26:
note: in expansion of macro '__kernel_helper_version'
  104 | # define IFUNC_COND_2   (__kernel_helper_version >= 5)
      |                          ^~~~~~~~~~~~~~~~~~~~~~~
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/config/linux/arm/host-config.h:169:57:
note: in expansion of macro 'IFUNC_COND_2'
  169 | # define MAYBE_HAVE_ATOMIC_CAS_8        (IFUNC_COND_1 | IFUNC_COND_2)
      |                                                         ^~~~~~~~~~~~
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/libatomic_i.h:40:25:
note: in expansion of macro 'MAYBE_HAVE_ATOMIC_CAS_8'
   40 | #define C2_(X,Y)        X ## Y            
      |                         ^                 
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/libatomic_i.h:41:25:
note: in expansion of macro 'C2_'
   41 | #define C2(X,Y)         C2_(X,Y)    
      |                         ^~~  
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/gstore.c:58:10:
note: in expansion of macro 'C2'
   58 |     if (!C2(MAYBE_HAVE_ATOMIC_CAS_,N)) break;                   \
      |          ^~                                                      
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/gstore.c:95:25:
note: in expansion of macro 'LARGER'
   95 |     case 5 ... 7: L8:   LARGER(8);      /* FALLTHRU */
      |                         ^~~~~~
cc1: all warnings being treated as errors
make[4]: *** [Makefile:586: gstore.lo] Error 1

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

* [Bug tree-optimization/101379] libatomic build failure on arm after r12-2132
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
@ 2021-07-08 14:47 ` schwab@linux-m68k.org
  2021-07-08 19:06 ` msebor at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: schwab@linux-m68k.org @ 2021-07-08 14:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
dup

*** This bug has been marked as a duplicate of bug 101374 ***

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

* [Bug tree-optimization/101379] libatomic build failure on arm after r12-2132
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
  2021-07-08 14:47 ` [Bug tree-optimization/101379] " schwab@linux-m68k.org
@ 2021-07-08 19:06 ` msebor at gcc dot gnu.org
  2021-07-08 22:40 ` msebor at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-08 19:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|DUPLICATE                   |---

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
This is not a duplicate of pr101374.  Constant addresses are often the result
of null pointer arithmetic and not considered valid (point to an object of zero
size).  When they're deliberate the code needs to suppress the warning somehow.
 It can be done via #pragma GCC diagnostic or by making the pointer variable
volatile (or otherwise obscuring its constness).

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

* [Bug tree-optimization/101379] libatomic build failure on arm after r12-2132
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
  2021-07-08 14:47 ` [Bug tree-optimization/101379] " schwab@linux-m68k.org
  2021-07-08 19:06 ` msebor at gcc dot gnu.org
@ 2021-07-08 22:40 ` msebor at gcc dot gnu.org
  2021-07-09  7:07 ` [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-08 22:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Christophe, does this patch work for you?  Another alternative is to add
#pragma GCC diagnostic ignored around the dereference.

diff --git a/libatomic/config/linux/arm/host-config.h
b/libatomic/config/linux/arm/host-config.h
index 1520f237d73..f866b8a1160 100644
--- a/libatomic/config/linux/arm/host-config.h
+++ b/libatomic/config/linux/arm/host-config.h
@@ -39,8 +39,12 @@ typedef void (__kernel_dmb_t) (void);
 #define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0)

 /* Kernel helper page version number.  */
-#define __kernel_helper_version (*(unsigned int *)0xffff0ffc)
-
+static inline unsigned
+__kernel_helper_version ()
+{
+  const unsigned *volatile addr = (unsigned int *)0xffff0ffc;
+  return *addr;
+}

 #ifndef HAVE_STREX
 static inline bool

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

* [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-08 22:40 ` msebor at gcc dot gnu.org
@ 2021-07-09  7:07 ` rguenth at gcc dot gnu.org
  2021-07-09 13:46 ` clyon at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-09  7:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|9.0                         |12.0

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
As said elsewhere I don't think we should diagnose _constant_ address accesses.

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

* [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-07-09  7:07 ` [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address rguenth at gcc dot gnu.org
@ 2021-07-09 13:46 ` clyon at gcc dot gnu.org
  2021-07-09 17:11 ` msebor at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: clyon at gcc dot gnu.org @ 2021-07-09 13:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

--- Comment #5 from Christophe Lyon <clyon at gcc dot gnu.org> ---
The patch does not work, I'm now getting this error:
In file included from
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/config/arm/host-config.h:4,
                 from
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/libatomic_i.h:232,
                 from
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/gstore.c:25:
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/gstore.c: In
function 'libat_store':
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/config/linux/arm/host-config.h:109:50:
error: comparison between pointer and integer [-Werror]
  109 | # define IFUNC_COND_2   (__kernel_helper_version >= 5)
      |                                                  ^~
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/config/linux/arm/host-config.h:174:57:
note: in expansion of macro 'IFUNC_COND_2'
  174 | # define MAYBE_HAVE_ATOMIC_CAS_8        (IFUNC_COND_1 | IFUNC_COND_2)
      |                                                         ^~~~~~~~~~~~
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/libatomic_i.h:40:25:
note: in expansion of macro 'MAYBE_HAVE_ATOMIC_CAS_8'
   40 | #define C2_(X,Y)        X ## Y
      |                         ^
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/libatomic_i.h:41:25:
note: in expansion of macro 'C2_'
   41 | #define C2(X,Y)         C2_(X,Y)
      |                         ^~~
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/gstore.c:58:10:
note: in expansion of macro 'C2'
   58 |     if (!C2(MAYBE_HAVE_ATOMIC_CAS_,N)) break;                   \
      |          ^~
/home/christophe.lyon/src/GCC/sources/gcc-fsf-git/trunk/libatomic/gstore.c:95:25:
note: in expansion of macro 'LARGER'
   95 |     case 5 ... 7: L8:   LARGER(8);      /* FALLTHRU */
      |                         ^~~~~~
cc1: all warnings being treated as errors
make[4]: *** [Makefile:586: gstore.lo] Error 1

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

* [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-07-09 13:46 ` clyon at gcc dot gnu.org
@ 2021-07-09 17:11 ` msebor at gcc dot gnu.org
  2021-07-09 21:23 ` clyon at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-09 17:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
I have no easy way to test the patch so it might need a little tweaking.  It
looks like the __kernel_helper_version macro is used as an lvalue so the macro
needs to expand to a call to the __kernel_helper_version() function which
should then return a pointer (or perhaps a reference), e.g., like so:

diff --git a/libatomic/config/linux/arm/host-config.h
b/libatomic/config/linux/arm/host-config.h
index 1520f237d73..777d08a2b85 100644
--- a/libatomic/config/linux/arm/host-config.h
+++ b/libatomic/config/linux/arm/host-config.h
@@ -39,8 +39,14 @@ typedef void (__kernel_dmb_t) (void);
 #define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0)

 /* Kernel helper page version number.  */
-#define __kernel_helper_version (*(unsigned int *)0xffff0ffc)
+static inline unsigned*
+__kernel_helper_version ()
+{
+  unsigned *volatile addr = (unsigned int *)0xffff0ffc;
+  return addr;
+}

+#define __kernel_helper_version (*__kernel_helper_version())

 #ifndef HAVE_STREX
 static inline bool

Another approach is to define a __kernel_helper_version variable as an extern
unsigned*, initialize it in some .c file, and have the __kernel_helper_version
macro expand to *__kernel_helper_version.

As I mentioned to Richard and Jeff in our discussions of this class of warnings
that all treat hardcoded addresses as invalid to detect the results of
arithmetic on null pointers, a better approach is to detect the invalid
arithmetic itself.  That needs to happen early on, before the results turn into
constant addresses that are indistinguishable from hardcoded addresses.  When
this detection is implemented (I'm hoping to get it done for GCC 12) the
existing warnings can be relaxed.

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

* [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-07-09 17:11 ` msebor at gcc dot gnu.org
@ 2021-07-09 21:23 ` clyon at gcc dot gnu.org
  2021-07-09 23:12 ` msebor at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: clyon at gcc dot gnu.org @ 2021-07-09 21:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

--- Comment #7 from Christophe Lyon <clyon at gcc dot gnu.org> ---
The patch in comment #6 lets the build complete, thanks!

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

* [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-07-09 21:23 ` clyon at gcc dot gnu.org
@ 2021-07-09 23:12 ` msebor at gcc dot gnu.org
  2021-07-21 15:55 ` msebor at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-09 23:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-07-09
   Target Milestone|---                         |12.0
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1
           Keywords|                            |patch
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
Thanks for testing.  I've submitted the patch for review:
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574880.html

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

* [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-07-09 23:12 ` msebor at gcc dot gnu.org
@ 2021-07-21 15:55 ` msebor at gcc dot gnu.org
  2021-07-21 16:52 ` cvs-commit at gcc dot gnu.org
  2021-07-21 16:55 ` msebor at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-21 15:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tnfchris at gcc dot gnu.org

--- Comment #9 from Martin Sebor <msebor at gcc dot gnu.org> ---
*** Bug 101553 has been marked as a duplicate of this bug. ***

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

* [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-07-21 15:55 ` msebor at gcc dot gnu.org
@ 2021-07-21 16:52 ` cvs-commit at gcc dot gnu.org
  2021-07-21 16:55 ` msebor at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-21 16:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:b937dbf2577e0fa3018c562312da7b08bbe72d70

commit r12-2438-gb937dbf2577e0fa3018c562312da7b08bbe72d70
Author: Martin Sebor <msebor@redhat.com>
Date:   Wed Jul 21 10:48:55 2021 -0600

    Adjust macro to avoid warning [PR101379].

    Resolves:
    PR bootstrap/101379 - libatomic arm build failure after r12-2132 due to
-Warray-bounds on a constant address

    libatomic/ChangeLog:
            PR bootstrap/101379
            * config/linux/arm/host-config.h (__kernel_helper_version): New
            function.  Adjust shadow macro.

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

* [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address
  2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2021-07-21 16:52 ` cvs-commit at gcc dot gnu.org
@ 2021-07-21 16:55 ` msebor at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-21 16:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #11 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch committed in r12-2438.

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

end of thread, other threads:[~2021-07-21 16:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 14:34 [Bug tree-optimization/101379] New: libatomic build failure on arm after r12-2132 clyon at gcc dot gnu.org
2021-07-08 14:47 ` [Bug tree-optimization/101379] " schwab@linux-m68k.org
2021-07-08 19:06 ` msebor at gcc dot gnu.org
2021-07-08 22:40 ` msebor at gcc dot gnu.org
2021-07-09  7:07 ` [Bug bootstrap/101379] libatomic arm build failure after r12-2132 due -Warray-bounds on a constant address rguenth at gcc dot gnu.org
2021-07-09 13:46 ` clyon at gcc dot gnu.org
2021-07-09 17:11 ` msebor at gcc dot gnu.org
2021-07-09 21:23 ` clyon at gcc dot gnu.org
2021-07-09 23:12 ` msebor at gcc dot gnu.org
2021-07-21 15:55 ` msebor at gcc dot gnu.org
2021-07-21 16:52 ` cvs-commit at gcc dot gnu.org
2021-07-21 16:55 ` msebor at gcc dot gnu.org

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).