All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/math-emu: Fix building with clang
@ 2018-11-02  3:37 Joel Stanley
  2018-11-02 16:54 ` Nick Desaulniers
  2018-11-02 17:34 ` Segher Boessenkool
  0 siblings, 2 replies; 8+ messages in thread
From: Joel Stanley @ 2018-11-02  3:37 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nick Desaulniers

  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


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

* Re: [PATCH] powerpc/math-emu: Fix building with clang
  2018-11-02  3:37 [PATCH] powerpc/math-emu: Fix building with clang Joel Stanley
@ 2018-11-02 16:54 ` Nick Desaulniers
  2018-11-12 11:33   ` Joel Stanley
  2018-11-02 17:34 ` Segher Boessenkool
  1 sibling, 1 reply; 8+ messages in thread
From: Nick Desaulniers @ 2018-11-02 16:54 UTC (permalink / raw)
  To: joel; +Cc: linuxppc-dev

On Thu, Nov 1, 2018 at 8:37 PM Joel Stanley <joel@jms.id.au> 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.

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

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

* Re: [PATCH] powerpc/math-emu: Fix building with clang
  2018-11-02  3:37 [PATCH] powerpc/math-emu: Fix building with clang Joel Stanley
  2018-11-02 16:54 ` Nick Desaulniers
@ 2018-11-02 17:34 ` Segher Boessenkool
  2018-11-02 17:38   ` Nick Desaulniers
  1 sibling, 1 reply; 8+ messages in thread
From: Segher Boessenkool @ 2018-11-02 17:34 UTC (permalink / raw)
  To: Joel Stanley; +Cc: Nick Desaulniers, linuxppc-dev

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

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

* Re: [PATCH] powerpc/math-emu: Fix building with clang
  2018-11-02 17:34 ` Segher Boessenkool
@ 2018-11-02 17:38   ` Nick Desaulniers
  2018-11-02 18:44     ` Segher Boessenkool
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Desaulniers @ 2018-11-02 17:38 UTC (permalink / raw)
  To: segher; +Cc: linuxppc-dev, joel

On Fri, Nov 2, 2018 at 10:34 AM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> 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 :-)

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

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

* Re: [PATCH] powerpc/math-emu: Fix building with clang
  2018-11-02 17:38   ` Nick Desaulniers
@ 2018-11-02 18:44     ` Segher Boessenkool
  0 siblings, 0 replies; 8+ messages in thread
From: Segher Boessenkool @ 2018-11-02 18:44 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: linuxppc-dev, joel

On Fri, Nov 02, 2018 at 10:38:36AM -0700, Nick Desaulniers wrote:
> On Fri, Nov 2, 2018 at 10:34 AM Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> >
> > 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 :-)
> 
> 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

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

* Re: [PATCH] powerpc/math-emu: Fix building with clang
  2018-11-02 16:54 ` Nick Desaulniers
@ 2018-11-12 11:33   ` Joel Stanley
  2018-11-12 12:43     ` Segher Boessenkool
  2018-11-12 19:17     ` Nick Desaulniers
  0 siblings, 2 replies; 8+ messages in thread
From: Joel Stanley @ 2018-11-12 11:33 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: linuxppc-dev

On Sat, 3 Nov 2018 at 03:24, Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Thu, Nov 1, 2018 at 8:37 PM Joel Stanley <joel@jms.id.au> 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.

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)),                                  \
                       ~~~~~~~~~~^~~

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

* Re: [PATCH] powerpc/math-emu: Fix building with clang
  2018-11-12 11:33   ` Joel Stanley
@ 2018-11-12 12:43     ` Segher Boessenkool
  2018-11-12 19:17     ` Nick Desaulniers
  1 sibling, 0 replies; 8+ messages in thread
From: Segher Boessenkool @ 2018-11-12 12:43 UTC (permalink / raw)
  To: Joel Stanley; +Cc: linuxppc-dev, Nick Desaulniers

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

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

* Re: [PATCH] powerpc/math-emu: Fix building with clang
  2018-11-12 11:33   ` Joel Stanley
  2018-11-12 12:43     ` Segher Boessenkool
@ 2018-11-12 19:17     ` Nick Desaulniers
  1 sibling, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2018-11-12 19:17 UTC (permalink / raw)
  To: joel; +Cc: linuxppc-dev

On Mon, Nov 12, 2018 at 3:33 AM Joel Stanley <joel@jms.id.au> wrote:
> > On Thu, Nov 1, 2018 at 8:37 PM Joel Stanley <joel@jms.id.au> 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)),                                  \
>                        ~~~~~~~~~~^~~

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

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

end of thread, other threads:[~2018-11-12 19:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-02  3:37 [PATCH] powerpc/math-emu: Fix building with clang Joel Stanley
2018-11-02 16:54 ` Nick Desaulniers
2018-11-12 11:33   ` Joel Stanley
2018-11-12 12:43     ` Segher Boessenkool
2018-11-12 19:17     ` Nick Desaulniers
2018-11-02 17:34 ` Segher Boessenkool
2018-11-02 17:38   ` Nick Desaulniers
2018-11-02 18:44     ` Segher Boessenkool

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.