diff mbox

[RFC] Introduce configure flag --with-stage1-cflags.

Message ID b3c3fe8c-b8c6-ea19-df59-f2613dbf92e6@suse.cz
State New
Headers show

Commit Message

Martin Liška May 26, 2017, 1 p.m. UTC
On 05/26/2017 01:55 PM, Richard Biener wrote:
> On Fri, May 26, 2017 at 1:51 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Fri, May 26, 2017 at 01:46:47PM +0200, Richard Biener wrote:
>>> On Thu, May 25, 2017 at 11:23 AM, Martin Liška <mliska@suse.cz> wrote:
>>>> Hello.
>>>>
>>>> After a discussion with Richi, using adding "-O2" to STAGE1 cflags with a recent
>>>> enough compiler can significantly speed up bootstrap. Thus I'm suggesting to
>>>> introduce --with-stage1-cflags where one can provide such options.
>>>
>>> I don't think this is necessary -- you can always override with STAGE1_CFLAGS.
>>>
>>>> Apart from that, maybe it would be handy to automatically enable "-O2" when
>>>> one has a recent compiler? Do we have an example where we detect host compiler
>>>> and it's version?
>>>
>>> Don't know about version but configury already detects that we use GCC, so that
>>> knowledge should be readily available.
>>
>> Well, it certainly shouldn't be -O2 by default for any system GCC, more
>> something like if it is major of the configured configure minus 1 or newer
>> (or minus 2?), then use -O2, otherwise default to -O0 as before.
> 
> I'd still default to -O0 on release branches regardless of version and then
> for development we can probably simply use "any GCC" when people have
> the chance to override.

Ok, sending new patch that does that on experimental branches for ${CC} --version
being a GCC newer than 4.9.

Martin

> 
> At least for me host GCC 4.8 works quite well with -O2.
> 
> Richard.
> 
>>         Jakub

Comments

Martin Liška May 26, 2017, 1:11 p.m. UTC | #1
On 05/26/2017 03:00 PM, Martin Liška wrote:
> Ok, sending new patch that does that on experimental branches for ${CC} --version
> being a GCC newer than 4.9.

s/4.9/4.8/
Martin Liška June 19, 2017, 10:51 a.m. UTC | #2
PING^1

Richi are you fine with the suggested change? I basically followed your advises :)

Martin

On 05/26/2017 03:00 PM, Martin Liška wrote:
> On 05/26/2017 01:55 PM, Richard Biener wrote:
>> On Fri, May 26, 2017 at 1:51 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>>> On Fri, May 26, 2017 at 01:46:47PM +0200, Richard Biener wrote:
>>>> On Thu, May 25, 2017 at 11:23 AM, Martin Liška <mliska@suse.cz> wrote:
>>>>> Hello.
>>>>>
>>>>> After a discussion with Richi, using adding "-O2" to STAGE1 cflags with a recent
>>>>> enough compiler can significantly speed up bootstrap. Thus I'm suggesting to
>>>>> introduce --with-stage1-cflags where one can provide such options.
>>>>
>>>> I don't think this is necessary -- you can always override with STAGE1_CFLAGS.
>>>>
>>>>> Apart from that, maybe it would be handy to automatically enable "-O2" when
>>>>> one has a recent compiler? Do we have an example where we detect host compiler
>>>>> and it's version?
>>>>
>>>> Don't know about version but configury already detects that we use GCC, so that
>>>> knowledge should be readily available.
>>>
>>> Well, it certainly shouldn't be -O2 by default for any system GCC, more
>>> something like if it is major of the configured configure minus 1 or newer
>>> (or minus 2?), then use -O2, otherwise default to -O0 as before.
>>
>> I'd still default to -O0 on release branches regardless of version and then
>> for development we can probably simply use "any GCC" when people have
>> the chance to override.
> 
> Ok, sending new patch that does that on experimental branches for ${CC} --version
> being a GCC newer than 4.9.
> 
> Martin
> 
>>
>> At least for me host GCC 4.8 works quite well with -O2.
>>
>> Richard.
>>
>>>         Jakub
>
Richard Biener June 19, 2017, 12:30 p.m. UTC | #3
On Mon, Jun 19, 2017 at 12:51 PM, Martin Liška <mliska@suse.cz> wrote:
> PING^1
>
> Richi are you fine with the suggested change? I basically followed your advises :)

Well, I am but as Eric disagrees I think we need input from other
people on this.
I'm comfortably setting STAGE1_CFLAGS here.

Richard.

> Martin
>
> On 05/26/2017 03:00 PM, Martin Liška wrote:
>> On 05/26/2017 01:55 PM, Richard Biener wrote:
>>> On Fri, May 26, 2017 at 1:51 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>>>> On Fri, May 26, 2017 at 01:46:47PM +0200, Richard Biener wrote:
>>>>> On Thu, May 25, 2017 at 11:23 AM, Martin Liška <mliska@suse.cz> wrote:
>>>>>> Hello.
>>>>>>
>>>>>> After a discussion with Richi, using adding "-O2" to STAGE1 cflags with a recent
>>>>>> enough compiler can significantly speed up bootstrap. Thus I'm suggesting to
>>>>>> introduce --with-stage1-cflags where one can provide such options.
>>>>>
>>>>> I don't think this is necessary -- you can always override with STAGE1_CFLAGS.
>>>>>
>>>>>> Apart from that, maybe it would be handy to automatically enable "-O2" when
>>>>>> one has a recent compiler? Do we have an example where we detect host compiler
>>>>>> and it's version?
>>>>>
>>>>> Don't know about version but configury already detects that we use GCC, so that
>>>>> knowledge should be readily available.
>>>>
>>>> Well, it certainly shouldn't be -O2 by default for any system GCC, more
>>>> something like if it is major of the configured configure minus 1 or newer
>>>> (or minus 2?), then use -O2, otherwise default to -O0 as before.
>>>
>>> I'd still default to -O0 on release branches regardless of version and then
>>> for development we can probably simply use "any GCC" when people have
>>> the chance to override.
>>
>> Ok, sending new patch that does that on experimental branches for ${CC} --version
>> being a GCC newer than 4.9.
>>
>> Martin
>>
>>>
>>> At least for me host GCC 4.8 works quite well with -O2.
>>>
>>> Richard.
>>>
>>>>         Jakub
>>
>
Martin Liška July 31, 2017, 7:47 a.m. UTC | #4
I would like to ping this. Input from other people will be appreciated ;)

Thanks,
Martin

On 06/19/2017 02:30 PM, Richard Biener wrote:
> On Mon, Jun 19, 2017 at 12:51 PM, Martin Liška <mliska@suse.cz> wrote:
>> PING^1
>>
>> Richi are you fine with the suggested change? I basically followed your advises :)
> 
> Well, I am but as Eric disagrees I think we need input from other
> people on this.
> I'm comfortably setting STAGE1_CFLAGS here.
> 
> Richard.
> 
>> Martin
>>
>> On 05/26/2017 03:00 PM, Martin Liška wrote:
>>> On 05/26/2017 01:55 PM, Richard Biener wrote:
>>>> On Fri, May 26, 2017 at 1:51 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>>>>> On Fri, May 26, 2017 at 01:46:47PM +0200, Richard Biener wrote:
>>>>>> On Thu, May 25, 2017 at 11:23 AM, Martin Liška <mliska@suse.cz> wrote:
>>>>>>> Hello.
>>>>>>>
>>>>>>> After a discussion with Richi, using adding "-O2" to STAGE1 cflags with a recent
>>>>>>> enough compiler can significantly speed up bootstrap. Thus I'm suggesting to
>>>>>>> introduce --with-stage1-cflags where one can provide such options.
>>>>>>
>>>>>> I don't think this is necessary -- you can always override with STAGE1_CFLAGS.
>>>>>>
>>>>>>> Apart from that, maybe it would be handy to automatically enable "-O2" when
>>>>>>> one has a recent compiler? Do we have an example where we detect host compiler
>>>>>>> and it's version?
>>>>>>
>>>>>> Don't know about version but configury already detects that we use GCC, so that
>>>>>> knowledge should be readily available.
>>>>>
>>>>> Well, it certainly shouldn't be -O2 by default for any system GCC, more
>>>>> something like if it is major of the configured configure minus 1 or newer
>>>>> (or minus 2?), then use -O2, otherwise default to -O0 as before.
>>>>
>>>> I'd still default to -O0 on release branches regardless of version and then
>>>> for development we can probably simply use "any GCC" when people have
>>>> the chance to override.
>>>
>>> Ok, sending new patch that does that on experimental branches for ${CC} --version
>>> being a GCC newer than 4.9.
>>>
>>> Martin
>>>
>>>>
>>>> At least for me host GCC 4.8 works quite well with -O2.
>>>>
>>>> Richard.
>>>>
>>>>>         Jakub
>>>
>>
Jeff Law Aug. 25, 2017, 7:51 p.m. UTC | #5
On 07/31/2017 01:47 AM, Martin Liška wrote:
> I would like to ping this. Input from other people will be appreciated ;)
I think the thing to keep in mind here is that IIUC this only affects
things when we've configured using the --with-stage1-cflags option.

So questions about is -O1 more stable than -O2, should we restrict -O2
to newer compilers, etc are really more about the defaults we set.

My understanding is the patch is just adding the capability and does not
change the default.  Assuming that's the case, then I'm comfortable
acking the raw infrastructure.

jeff
Richard Biener Aug. 28, 2017, 12:24 p.m. UTC | #6
On Fri, Aug 25, 2017 at 9:51 PM, Jeff Law <law@redhat.com> wrote:
> On 07/31/2017 01:47 AM, Martin Liška wrote:
>> I would like to ping this. Input from other people will be appreciated ;)
> I think the thing to keep in mind here is that IIUC this only affects
> things when we've configured using the --with-stage1-cflags option.
>
> So questions about is -O1 more stable than -O2, should we restrict -O2
> to newer compilers, etc are really more about the defaults we set.
>
> My understanding is the patch is just adding the capability and does not
> change the default.  Assuming that's the case, then I'm comfortable
> acking the raw infrastructure.

OTOH you can simply set STAGE1_CFLAGS so the value of this
as a configure option is somewhat questionable.

> jeff
Martin Liška Aug. 30, 2017, 10:45 a.m. UTC | #7
On 08/28/2017 02:24 PM, Richard Biener wrote:
> On Fri, Aug 25, 2017 at 9:51 PM, Jeff Law <law@redhat.com> wrote:
>> On 07/31/2017 01:47 AM, Martin Liška wrote:
>>> I would like to ping this. Input from other people will be appreciated ;)
>> I think the thing to keep in mind here is that IIUC this only affects
>> things when we've configured using the --with-stage1-cflags option.
>>
>> So questions about is -O1 more stable than -O2, should we restrict -O2
>> to newer compilers, etc are really more about the defaults we set.
>>
>> My understanding is the patch is just adding the capability and does not
>> change the default.  Assuming that's the case, then I'm comfortable
>> acking the raw infrastructure.
> 
> OTOH you can simply set STAGE1_CFLAGS so the value of this
> as a configure option is somewhat questionable.

Yes, STAGE1_CFLAGS is a working solution. I'm not planning to install the patch.

Martin

> 
>> jeff
diff mbox

Patch

From 56acea8345eaa0961f12bfc2383c14676054665d Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 26 May 2017 14:58:39 +0200
Subject: [PATCH] Add -O2 to stage1_cflags for experimental branch.

ChangeLog:

2017-05-26  Martin Liska  <mliska@suse.cz>

	* configure.ac: Add -O2 to stage1_cflags for experimental branch.
	* configure: Regenerate.
---
 configure    | 23 +++++++++++++++++++++++
 configure.ac | 21 +++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/configure b/configure
index 82aa619fad1..079bad6bf34 100755
--- a/configure
+++ b/configure
@@ -7080,6 +7080,24 @@  fi
 $as_echo "$BUILD_CONFIG" >&6; }
 
 
+# Detect if compiler is GCC >= 4.8.x
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CC is recent compiler" >&5
+$as_echo_n "checking CC is recent compiler... " >&6; }
+cc_is_recent_gcc=
+version_output=`${CC} -v 2>&1 | grep 'gcc version'`
+
+if test "x${version_output}" != x; then
+  version=`echo ${version_output} | sed 's/gcc version \([^ ]*\).*/\\1/'`
+  major=`echo ${version} | cut -d. -f1`
+  minor=`echo ${version} | cut -d. -f2`
+
+  if test "${major}" -ge 5 || ( test "${major}" -eq 4 && test "${minor}" -ge 8 ); then
+    cc_is_recent_gcc=yes
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cc_is_recent_gcc" >&5
+$as_echo "$cc_is_recent_gcc" >&6; }
+
 # Use same top-level configure hooks in libgcc/libstdc++/libvtv.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-vtable-verify" >&5
 $as_echo_n "checking for --enable-vtable-verify... " >&6; }
@@ -14655,6 +14673,11 @@  if test -d ${srcdir}/gcc && test x"`cat $srcdir/gcc/DEV-PHASE`" = xexperimental;
   "")
       stage2_werror_flag="--enable-werror-always" ;;
   esac
+
+  if test "$cc_is_recent_gcc" = "yes"; then
+    stage1_cflags="$stage1_cflags -O2"
+
+  fi
 fi
 
 
diff --git a/configure.ac b/configure.ac
index 78d2d593106..d312e2e8347 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2667,6 +2667,22 @@  fi
 AC_MSG_RESULT($BUILD_CONFIG)
 AC_SUBST(BUILD_CONFIG)
 
+# Detect if compiler is GCC >= 4.8.x
+AC_MSG_CHECKING(CC is recent compiler)
+cc_is_recent_gcc=
+version_output=`${CC} -v 2>&1 | grep 'gcc version'`
+
+if test "x${version_output}" != x; then
+  version=`echo ${version_output} | sed 's/gcc version \([[^ ]]*\).*/\\1/'`
+  major=`echo ${version} | cut -d. -f1`
+  minor=`echo ${version} | cut -d. -f2`
+
+  if test "${major}" -ge 5 || ( test "${major}" -eq 4 && test "${minor}" -ge 8 ); then
+    cc_is_recent_gcc=yes
+  fi
+fi
+AC_MSG_RESULT($cc_is_recent_gcc)
+
 # Use same top-level configure hooks in libgcc/libstdc++/libvtv.
 AC_MSG_CHECKING([for --enable-vtable-verify])
 AC_ARG_ENABLE(vtable-verify,
@@ -3521,6 +3537,11 @@  if test -d ${srcdir}/gcc && test x"`cat $srcdir/gcc/DEV-PHASE`" = xexperimental;
   "")
       stage2_werror_flag="--enable-werror-always" ;;
   esac
+
+  if test "$cc_is_recent_gcc" = "yes"; then
+    stage1_cflags="$stage1_cflags -O2"
+    AC_SUBST(stage1_cflags)
+  fi
 fi
 
 AC_SUBST(stage2_werror_flag)
-- 
2.12.2