[PATCH] powerpc/math-emu: Fix building with clang

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE2822d

8 messages, 3 authors, 2018-11-12 · open the first message on its own page

[PATCH] powerpc/math-emu: Fix building with clang

From: Joel Stanley <joel@jms.id.au>
Date: 2018-11-02 03:39:53

  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  ppc44x_defconfig
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-

  ...

  arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
  inline asm context requiring an l-value: remove the cast or build with
  -fheinous-gnu-extensions
          FP_ADD_D(R, T, B);
          ^~~~~~~~~~~~~~~~~
  ./include/math-emu/double.h:110:27: note: expanded from macro 'FP_ADD_D'
  #define FP_ADD_D(R,X,Y)                 _FP_ADD(D,2,R,X,Y)
                                          ^~~~~~~~~~~~~~~~~~
  ./include/math-emu/op-common.h:367:34: note: expanded from macro '_FP_ADD'
  #define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ./include/math-emu/op-common.h:264:4: note: expanded from macro '_FP_ADD_INTERNAL'
            _FP_FRAC_ADD_##wc(R, X, Y);                                        \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~
  note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
  ./include/math-emu/op-2.h:94:27: note: expanded from macro '_FP_FRAC_ADD_2'
    __FP_FRAC_ADD_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link: https://github.com/ClangBuiltLinux/linux/issues/260
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 arch/powerpc/math-emu/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/arch/powerpc/math-emu/Makefile b/arch/powerpc/math-emu/Makefile
index 494df26c5988..b9cb797445ac 100644
--- a/arch/powerpc/math-emu/Makefile
+++ b/arch/powerpc/math-emu/Makefile
@@ -18,3 +18,7 @@ CFLAGS_fabs.o = -fno-builtin-fabs
 CFLAGS_math.o = -fno-builtin-fabs
 
 ccflags-y = -I. -Iinclude/math-emu -w
+
+ifdef CONFIG_CC_IS_CLANG
+ccflags-y += -fheinous-gnu-extensions
+endif
-- 
2.19.1

Re: [PATCH] powerpc/math-emu: Fix building with clang

From: Nick Desaulniers <ndesaulniers@google.com>
Date: 2018-11-02 16:56:41

On Thu, Nov 1, 2018 at 8:37 PM Joel Stanley [off-list ref] wrote:
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  ppc44x_defconfig
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-

  ...

  arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
  inline asm context requiring an l-value: remove the cast or build with
  -fheinous-gnu-extensions
          FP_ADD_D(R, T, B);
          ^~~~~~~~~~~~~~~~~
  ./include/math-emu/double.h:110:27: note: expanded from macro 'FP_ADD_D'
  #define FP_ADD_D(R,X,Y)                 _FP_ADD(D,2,R,X,Y)
                                          ^~~~~~~~~~~~~~~~~~
  ./include/math-emu/op-common.h:367:34: note: expanded from macro '_FP_ADD'
  #define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ./include/math-emu/op-common.h:264:4: note: expanded from macro '_FP_ADD_INTERNAL'
            _FP_FRAC_ADD_##wc(R, X, Y);                                        \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~
  note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
^^^ Hi Joel, would you mind recompiling with
`-fmacro-backtrace-limit=0` hacked in and including the full
backtrace?  I'm curious if there's a more appropriate fix, but can't
tell where the inline asm is that clang is complaining about.
quoted hunk
  ./include/math-emu/op-2.h:94:27: note: expanded from macro '_FP_FRAC_ADD_2'
    __FP_FRAC_ADD_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link: https://github.com/ClangBuiltLinux/linux/issues/260
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 arch/powerpc/math-emu/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/arch/powerpc/math-emu/Makefile b/arch/powerpc/math-emu/Makefile
index 494df26c5988..b9cb797445ac 100644
--- a/arch/powerpc/math-emu/Makefile
+++ b/arch/powerpc/math-emu/Makefile
@@ -18,3 +18,7 @@ CFLAGS_fabs.o = -fno-builtin-fabs
 CFLAGS_math.o = -fno-builtin-fabs

 ccflags-y = -I. -Iinclude/math-emu -w
+
+ifdef CONFIG_CC_IS_CLANG
+ccflags-y += -fheinous-gnu-extensions
+endif
--
2.19.1

-- 
Thanks,
~Nick Desaulniers

Re: [PATCH] powerpc/math-emu: Fix building with clang

From: Segher Boessenkool <hidden>
Date: 2018-11-02 17:36:47

On Fri, Nov 02, 2018 at 02:07:13PM +1030, Joel Stanley wrote:
  arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
  inline asm context requiring an l-value: remove the cast or build with
  -fheinous-gnu-extensions
(It is spelled lvalue).

*All* of extended asm is a GNU extension, what is clang trying to say here?
Confused :-)


Segher

Re: [PATCH] powerpc/math-emu: Fix building with clang

From: Nick Desaulniers <ndesaulniers@google.com>
Date: 2018-11-02 17:41:54

On Fri, Nov 2, 2018 at 10:34 AM Segher Boessenkool
[off-list ref] wrote:
On Fri, Nov 02, 2018 at 02:07:13PM +1030, Joel Stanley wrote:
quoted
  arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
  inline asm context requiring an l-value: remove the cast or build with
  -fheinous-gnu-extensions
(It is spelled lvalue).

*All* of extended asm is a GNU extension, what is clang trying to say here?
Confused :-)
Isn't the result of a cast a temporary value?  Probably just need to
move the case out of the inline asm block to a separate statement.
Having the full backtrace should help.

-- 
Thanks,
~Nick Desaulniers

Re: [PATCH] powerpc/math-emu: Fix building with clang

From: Segher Boessenkool <hidden>
Date: 2018-11-02 18:48:13

On Fri, Nov 02, 2018 at 10:38:36AM -0700, Nick Desaulniers wrote:
On Fri, Nov 2, 2018 at 10:34 AM Segher Boessenkool
[off-list ref] wrote:
quoted
On Fri, Nov 02, 2018 at 02:07:13PM +1030, Joel Stanley wrote:
quoted
  arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
  inline asm context requiring an l-value: remove the cast or build with
  -fheinous-gnu-extensions
(It is spelled lvalue).

*All* of extended asm is a GNU extension, what is clang trying to say here?
Confused :-)
Isn't the result of a cast a temporary value?  Probably just need to
move the case out of the inline asm block to a separate statement.
Having the full backtrace should help.
The kernel's sfp-machine.h has casts in lvalues, inside macros.  All such
casts seem to be casts to compatible types (and if not, it probably won't
work with GCC either).


Segher

Re: [PATCH] powerpc/math-emu: Fix building with clang

From: Joel Stanley <joel@jms.id.au>
Date: 2018-11-12 11:36:33

On Sat, 3 Nov 2018 at 03:24, Nick Desaulniers [off-list ref] wrote:
On Thu, Nov 1, 2018 at 8:37 PM Joel Stanley [off-list ref] wrote:
quoted
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  ppc44x_defconfig
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-

  ...

  arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
  inline asm context requiring an l-value: remove the cast or build with
  -fheinous-gnu-extensions
          FP_ADD_D(R, T, B);
          ^~~~~~~~~~~~~~~~~
  ./include/math-emu/double.h:110:27: note: expanded from macro 'FP_ADD_D'
  #define FP_ADD_D(R,X,Y)                 _FP_ADD(D,2,R,X,Y)
                                          ^~~~~~~~~~~~~~~~~~
  ./include/math-emu/op-common.h:367:34: note: expanded from macro '_FP_ADD'
  #define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ./include/math-emu/op-common.h:264:4: note: expanded from macro '_FP_ADD_INTERNAL'
            _FP_FRAC_ADD_##wc(R, X, Y);                                        \
            ^~~~~~~~~~~~~~~~~~~~~~~~~~
  note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
^^^ Hi Joel, would you mind recompiling with
`-fmacro-backtrace-limit=0` hacked in and including the full
backtrace?  I'm curious if there's a more appropriate fix, but can't
tell where the inline asm is that clang is complaining about.
Sure. Here's the full backtrace:

arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
inline asm context requiring an l-value: remove
      the cast or build with -fheinous-gnu-extensions
        FP_ADD_D(R, T, B);
        ^~~~~~~~~~~~~~~~~
./include/math-emu/double.h:110:27: note: expanded from macro 'FP_ADD_D'
#define FP_ADD_D(R,X,Y)                 _FP_ADD(D,2,R,X,Y)
                                        ^~~~~~~~~~~~~~~~~~
./include/math-emu/op-common.h:367:34: note: expanded from macro '_FP_ADD'
#define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/math-emu/op-common.h:274:4: note: expanded from macro
'_FP_ADD_INTERNAL'
          _FP_FRAC_SUB_##wc(R, X, Y);                                        \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
<scratch space>:268:1: note: expanded from here
_FP_FRAC_SUB_2
^
./include/math-emu/op-2.h:97:19: note: expanded from macro '_FP_FRAC_SUB_2'
  __FP_FRAC_SUB_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<scratch space>:269:1: note: expanded from here
R_f1
^
./arch/powerpc/include/asm/sfp-machine.h:283:27: note: expanded from
macro 'sub_ddmmss'
               : "=r" ((USItype)(sh)),                                  \
                       ~~~~~~~~~~^~~

Re: [PATCH] powerpc/math-emu: Fix building with clang

From: Segher Boessenkool <hidden>
Date: 2018-11-12 12:45:31

On Mon, Nov 12, 2018 at 10:03:34PM +1030, Joel Stanley wrote:
arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
inline asm context requiring an l-value: remove
      the cast or build with -fheinous-gnu-extensions
...
./arch/powerpc/include/asm/sfp-machine.h:283:27: note: expanded from
macro 'sub_ddmmss'
               : "=r" ((USItype)(sh)),                                  \
                       ~~~~~~~~~~^~~
This was fixed in GCC over 16 years ago ( https://gcc.gnu.org/r56600 ),
and in GMP (where it comes from) presumably before that.

There are many projects around which still have old GMP snippets in
them.  Like, the Linux kernel for powerpc, or GCC for x86!


Segher

Re: [PATCH] powerpc/math-emu: Fix building with clang

From: Nick Desaulniers <ndesaulniers@google.com>
Date: 2018-11-12 19:19:31

On Mon, Nov 12, 2018 at 3:33 AM Joel Stanley [off-list ref] wrote:
quoted
On Thu, Nov 1, 2018 at 8:37 PM Joel Stanley [off-list ref] wrote:
quoted
  arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
  inline asm context requiring an l-value: remove the cast or build with
  -fheinous-gnu-extensions
./arch/powerpc/include/asm/sfp-machine.h:283:27: note: expanded from
macro 'sub_ddmmss'
               : "=r" ((USItype)(sh)),                                  \
                       ~~~~~~~~~~^~~
Eek, I can of think that add_ssaaaa(), sub_ddmmss(), and umul_ppmm()
should be rewritten from the form:

asm("..." : "=r" (USItype)(arg) : ...);

to the form:

USItype temp = (USItype) arg;
asm("..." : "=r" (temp) : ...);
arg = (typeof(arg)) temp;

Rather than the flag being added.
-- 
Thanks,
~Nick Desaulniers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help