Re: GMP test fails with -flto

2019-07-01 Thread Richard Biener
On Mon, Jul 1, 2019 at 5:27 PM Vincent Lefevre  wrote:
>
> On 2019-07-01 16:59:06 +0200, Marc Glisse wrote:
> > On Mon, 1 Jul 2019, Vincent Lefevre wrote:
> > > I suggest another solution:
> > >
> > > First try like now. If the format is unknown, check whether the
> > > object file contains the string ".gnu.lto" (which should mean
> > > that GCC was used with LTO), and in this case, try again with
> > > "-fno-lto" as the patch was doing.
> >
> > We also have problems with clang's version of LTO. IIRC using emscripten to
> > compile GMP has a similar issue.
>
> With clang 7 and above, "ThinLTO" appears in the object file.

-fno-lto also works with clang?

When not cross-compiling the configure test could also be executable
doing the matching itself.  Breaks for cross which is likely why you've
done it as it is now?  For cross-compiling building a shared object
might work though, it should no longer contain only LTO bytecode
but also the data.

Richard.

> --
> Vincent Lefèvre  - Web: 
> 100% accessible validated (X)HTML - Blog: 
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: GMP test fails with -flto

2019-07-01 Thread Torbjörn Granlund
Vincent Lefevre  writes:

  Yes, with LTO, the object file does not contain the structure as is.
  Thus the detection from "od -b conftest.$OBJEXT" does not work.

That could be solved by generating a final executable, right?

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: GMP test fails with -flto

2019-07-01 Thread Vincent Lefevre
On 2019-07-01 16:59:06 +0200, Marc Glisse wrote:
> On Mon, 1 Jul 2019, Vincent Lefevre wrote:
> > I suggest another solution:
> > 
> > First try like now. If the format is unknown, check whether the
> > object file contains the string ".gnu.lto" (which should mean
> > that GCC was used with LTO), and in this case, try again with
> > "-fno-lto" as the patch was doing.
> 
> We also have problems with clang's version of LTO. IIRC using emscripten to
> compile GMP has a similar issue.

With clang 7 and above, "ThinLTO" appears in the object file.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: GMP test fails with -flto

2019-07-01 Thread Vincent Lefevre
On 2019-07-01 16:36:23 +0200, Torbjorn Granlund wrote:
> Vincent Lefevre  writes:
> 
>   I suggest another solution:
> 
>   First try like now. If the format is unknown, check whether the
>   object file contains the string ".gnu.lto" (which should mean
>   that GCC was used with LTO), and in this case, try again with
>   "-fno-lto" as the patch was doing.
> 
> That might work, but it is a bit more complex that ideally.  I believe
> some grep commands do not cope well with binaries.

Alternatively or additionally, use strings + grep (strings is part
of POSIX and first appeared in Issue 4; however it is not listed
in the GNU Coding Standards).

Otherwise "od -b" with awk, possibly in the same awk script as the
detection itself.

> I have forgotten why lto hurts the GMP_C_DOUBLE_FORMAT test.  (That's
> the problematic test, right?)

Yes, with LTO, the object file does not contain the structure as is.
Thus the detection from "od -b conftest.$OBJEXT" does not work.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: GMP test fails with -flto

2019-07-01 Thread Marc Glisse

On Mon, 1 Jul 2019, Vincent Lefevre wrote:


On 2019-07-01 13:44:04 +0200, Marc Glisse wrote:

On Mon, 1 Jul 2019, Martin Liška wrote:

> On 6/24/19 8:57 PM, Marc Glisse wrote:
> > On Mon, 24 Jun 2019, Martin Liška wrote:
> > 
> > > Using -flto one can see a test failure:
> > 
> > This is well known, see the archives for details. It is a combination of 2 issues:

> > - (thin) LTO prevents configure from guessing the floating point format
> > - a bug in the generic GMP code (fixed in master IIRC)
> > 
> 
> Hi.
> 
> I've got a patch for the wrong configure of floating point format.


That's going to break every non-gcc compiler, isn't it?


I suggest another solution:

First try like now. If the format is unknown, check whether the
object file contains the string ".gnu.lto" (which should mean
that GCC was used with LTO), and in this case, try again with
"-fno-lto" as the patch was doing.


We also have problems with clang's version of LTO. IIRC using emscripten 
to compile GMP has a similar issue.


--
Marc Glisse
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: GMP test fails with -flto

2019-07-01 Thread Torbjörn Granlund
Vincent Lefevre  writes:

  I suggest another solution:

  First try like now. If the format is unknown, check whether the
  object file contains the string ".gnu.lto" (which should mean
  that GCC was used with LTO), and in this case, try again with
  "-fno-lto" as the patch was doing.

That might work, but it is a bit more complex that ideally.  I believe
some grep commands do not cope well with binaries.

I have forgotten why lto hurts the GMP_C_DOUBLE_FORMAT test.  (That's
the problematic test, right?)

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: GMP test fails with -flto

2019-07-01 Thread Vincent Lefevre
On 2019-07-01 13:44:04 +0200, Marc Glisse wrote:
> On Mon, 1 Jul 2019, Martin Liška wrote:
> 
> > On 6/24/19 8:57 PM, Marc Glisse wrote:
> > > On Mon, 24 Jun 2019, Martin Liška wrote:
> > > 
> > > > Using -flto one can see a test failure:
> > > 
> > > This is well known, see the archives for details. It is a combination of 
> > > 2 issues:
> > > - (thin) LTO prevents configure from guessing the floating point format
> > > - a bug in the generic GMP code (fixed in master IIRC)
> > > 
> > 
> > Hi.
> > 
> > I've got a patch for the wrong configure of floating point format.
> 
> That's going to break every non-gcc compiler, isn't it?

I suggest another solution:

First try like now. If the format is unknown, check whether the
object file contains the string ".gnu.lto" (which should mean
that GCC was used with LTO), and in this case, try again with
"-fno-lto" as the patch was doing.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: GMP test fails with -flto

2019-07-01 Thread Marc Glisse

On Mon, 1 Jul 2019, Martin Liška wrote:


On 6/24/19 8:57 PM, Marc Glisse wrote:

On Mon, 24 Jun 2019, Martin Liška wrote:


Using -flto one can see a test failure:


This is well known, see the archives for details. It is a combination of 2 
issues:
- (thin) LTO prevents configure from guessing the floating point format
- a bug in the generic GMP code (fixed in master IIRC)



Hi.

I've got a patch for the wrong configure of floating point format.


That's going to break every non-gcc compiler, isn't it?

--
Marc Glisse
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: GMP test fails with -flto

2019-07-01 Thread Martin Liška
On 6/24/19 8:57 PM, Marc Glisse wrote:
> On Mon, 24 Jun 2019, Martin Liška wrote:
> 
>> Using -flto one can see a test failure:
> 
> This is well known, see the archives for details. It is a combination of 2 
> issues:
> - (thin) LTO prevents configure from guessing the floating point format
> - a bug in the generic GMP code (fixed in master IIRC)
> 

Hi.

I've got a patch for the wrong configure of floating point format.

Can you please Mark upstream it?
Thanks,
Martin
diff --git a/acinclude.m4 b/acinclude.m4
index 3c3ecf5..9c2675e 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -3308,7 +3308,7 @@ struct foo foo = {
   { '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' },
 };]
 EOF
-gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >_FD_CC 2>&1"
+gmp_compile="$CC $CFLAGS $CPPFLAGS -fno-lto -c conftest.c >_FD_CC 2>&1"
 if AC_TRY_EVAL(gmp_compile); then
 cat >conftest.awk <<\EOF
 [
diff --git a/configure b/configure
index 12ddffd..a7890ed 100755
--- a/configure
+++ b/configure
@@ -24563,7 +24563,7 @@ struct foo foo = {
   { '\376', '\334', '\272', '\230', '\166', '\124', '\062', '\020' },
 };
 EOF
-gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&5 2>&1"
+gmp_compile="$CC $CFLAGS $CPPFLAGS -fno-lto -c conftest.c >&5 2>&1"
 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$gmp_compile\""; } >&5
   (eval $gmp_compile) 2>&5
   ac_status=$?
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs