diff mbox series

Add a bootstrap-native build config

Message ID 20240730164042.4106759-1-ak@linux.intel.com
State New
Headers show
Series Add a bootstrap-native build config | expand

Commit Message

Andi Kleen July 30, 2024, 4:40 p.m. UTC
From: Andi Kleen <ak@gcc.gnu.org>

... that uses -march=native -mtune=native to build a compiler optimized
for the host.

config/ChangeLog:

	* bootstrap-native.mk: New file.

gcc/ChangeLog:

	* doc/install.texi: Document bootstrap-native.
---
 config/bootstrap-native.mk | 1 +
 gcc/doc/install.texi       | 6 ++++++
 2 files changed, 7 insertions(+)
 create mode 100644 config/bootstrap-native.mk

Comments

Sam James July 30, 2024, 5:48 p.m. UTC | #1
Andi Kleen <ak@linux.intel.com> writes:

> From: Andi Kleen <ak@gcc.gnu.org>
>
> ... that uses -march=native -mtune=native to build a compiler optimized
> for the host.
>

I like the idea and I'll probably use this. (I can't approve it though.)

> config/ChangeLog:
>
> 	* bootstrap-native.mk: New file.
>
> gcc/ChangeLog:
>
> 	* doc/install.texi: Document bootstrap-native.
> ---
>  config/bootstrap-native.mk | 1 +
>  gcc/doc/install.texi       | 6 ++++++
>  2 files changed, 7 insertions(+)
>  create mode 100644 config/bootstrap-native.mk
>
> diff --git a/config/bootstrap-native.mk b/config/bootstrap-native.mk
> new file mode 100644
> index 000000000000..a4a3d8594089
> --- /dev/null
> +++ b/config/bootstrap-native.mk
> @@ -0,0 +1 @@
> +BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)

I was under the impression that -mtune=native is useless with
-march=native. Is that wrong?

> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index 4973f195daf9..29827c5106f8 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -3052,6 +3052,12 @@ Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
>  @itemx @samp{bootstrap-Og}
>  Analogous to @code{bootstrap-O1}.
>  
> +@item @samp{bootstrap-native}
> +@itemx @samp{bootstrap-native}
> +Optimize the compiler code for the build host, if supported by the
> +architecture. Note this only affects the compiler, not the targeted
> +code. If you want the later use @samp{--with-cpu}.

later -> latter

> +
>  @item @samp{bootstrap-lto}
>  Enables Link-Time Optimization for host tools during bootstrapping.
>  @samp{BUILD_CONFIG=bootstrap-lto} is equivalent to adding
Andi Kleen July 30, 2024, 6:38 p.m. UTC | #2
> > +BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)
> 
> I was under the impression that -mtune=native is useless with
> -march=native. Is that wrong?

On x86 it's right, but not sure about other architectures. I suppose
it doesn't hurt.

-Andi
Gerald Pfeifer Aug. 10, 2024, 10:21 a.m. UTC | #3
On Tue, 30 Jul 2024, Andi Kleen wrote:
> config/ChangeLog:
> 
> 	* bootstrap-native.mk: New file.
> 
> gcc/ChangeLog:
> 
> 	* doc/install.texi: Document bootstrap-native.

This makes sense to me, and the documentation is fine (with "latter" 
instead of "later"); I cannot approve the code patch, though.

Gerald
Andi Kleen Aug. 12, 2024, 4:17 p.m. UTC | #4
Andi Kleen <ak@linux.intel.com> writes:

I wanted to ping this patch:

https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658729.html


> From: Andi Kleen <ak@gcc.gnu.org>
>
> ... that uses -march=native -mtune=native to build a compiler optimized
> for the host.
>
> config/ChangeLog:
>
> 	* bootstrap-native.mk: New file.
>
> gcc/ChangeLog:
>
> 	* doc/install.texi: Document bootstrap-native.
> ---
>  config/bootstrap-native.mk | 1 +
>  gcc/doc/install.texi       | 6 ++++++
>  2 files changed, 7 insertions(+)
>  create mode 100644 config/bootstrap-native.mk
>
> diff --git a/config/bootstrap-native.mk b/config/bootstrap-native.mk
> new file mode 100644
> index 000000000000..a4a3d8594089
> --- /dev/null
> +++ b/config/bootstrap-native.mk
> @@ -0,0 +1 @@
> +BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)
> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index 4973f195daf9..29827c5106f8 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -3052,6 +3052,12 @@ Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
>  @itemx @samp{bootstrap-Og}
>  Analogous to @code{bootstrap-O1}.
>  
> +@item @samp{bootstrap-native}
> +@itemx @samp{bootstrap-native}
> +Optimize the compiler code for the build host, if supported by the
> +architecture. Note this only affects the compiler, not the targeted
> +code. If you want the later use @samp{--with-cpu}.
> +
>  @item @samp{bootstrap-lto}
>  Enables Link-Time Optimization for host tools during bootstrapping.
>  @samp{BUILD_CONFIG=bootstrap-lto} is equivalent to adding
Andi Kleen Aug. 25, 2024, 5:15 p.m. UTC | #5
Andi Kleen <ak@linux.intel.com> writes:

PING^2 for the patch.

(not sure if there is any maintainer to cc here, this is generic build infrastructure)

> Andi Kleen <ak@linux.intel.com> writes:
>
> I wanted to ping this patch:
>
> https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658729.html
>
>
>> From: Andi Kleen <ak@gcc.gnu.org>
>>
>> ... that uses -march=native -mtune=native to build a compiler optimized
>> for the host.
>>
>> config/ChangeLog:
>>
>> 	* bootstrap-native.mk: New file.
>>
>> gcc/ChangeLog:
>>
>> 	* doc/install.texi: Document bootstrap-native.
>> ---
>>  config/bootstrap-native.mk | 1 +
>>  gcc/doc/install.texi       | 6 ++++++
>>  2 files changed, 7 insertions(+)
>>  create mode 100644 config/bootstrap-native.mk
>>
>> diff --git a/config/bootstrap-native.mk b/config/bootstrap-native.mk
>> new file mode 100644
>> index 000000000000..a4a3d8594089
>> --- /dev/null
>> +++ b/config/bootstrap-native.mk
>> @@ -0,0 +1 @@
>> +BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)
>> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
>> index 4973f195daf9..29827c5106f8 100644
>> --- a/gcc/doc/install.texi
>> +++ b/gcc/doc/install.texi
>> @@ -3052,6 +3052,12 @@ Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
>>  @itemx @samp{bootstrap-Og}
>>  Analogous to @code{bootstrap-O1}.
>>  
>> +@item @samp{bootstrap-native}
>> +@itemx @samp{bootstrap-native}
>> +Optimize the compiler code for the build host, if supported by the
>> +architecture. Note this only affects the compiler, not the targeted
>> +code. If you want the later use @samp{--with-cpu}.
>> +
>>  @item @samp{bootstrap-lto}
>>  Enables Link-Time Optimization for host tools during bootstrapping.
>>  @samp{BUILD_CONFIG=bootstrap-lto} is equivalent to adding
Andi Kleen Sept. 2, 2024, 11:22 p.m. UTC | #6
Andi Kleen <ak@linux.intel.com> writes:

Ping^3

> Andi Kleen <ak@linux.intel.com> writes:
>
> PING^2 for the patch.
>
> (not sure if there is any maintainer to cc here, this is generic build infrastructure)
>
>> Andi Kleen <ak@linux.intel.com> writes:
>>
>> I wanted to ping this patch:
>>
>> https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658729.html
>>
>>
>>> From: Andi Kleen <ak@gcc.gnu.org>
>>>
>>> ... that uses -march=native -mtune=native to build a compiler optimized
>>> for the host.
>>>
>>> config/ChangeLog:
>>>
>>> 	* bootstrap-native.mk: New file.
>>>
>>> gcc/ChangeLog:
>>>
>>> 	* doc/install.texi: Document bootstrap-native.
>>> ---
>>>  config/bootstrap-native.mk | 1 +
>>>  gcc/doc/install.texi       | 6 ++++++
>>>  2 files changed, 7 insertions(+)
>>>  create mode 100644 config/bootstrap-native.mk
>>>
>>> diff --git a/config/bootstrap-native.mk b/config/bootstrap-native.mk
>>> new file mode 100644
>>> index 000000000000..a4a3d8594089
>>> --- /dev/null
>>> +++ b/config/bootstrap-native.mk
>>> @@ -0,0 +1 @@
>>> +BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)
>>> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
>>> index 4973f195daf9..29827c5106f8 100644
>>> --- a/gcc/doc/install.texi
>>> +++ b/gcc/doc/install.texi
>>> @@ -3052,6 +3052,12 @@ Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
>>>  @itemx @samp{bootstrap-Og}
>>>  Analogous to @code{bootstrap-O1}.
>>>  
>>> +@item @samp{bootstrap-native}
>>> +@itemx @samp{bootstrap-native}
>>> +Optimize the compiler code for the build host, if supported by the
>>> +architecture. Note this only affects the compiler, not the targeted
>>> +code. If you want the later use @samp{--with-cpu}.
>>> +
>>>  @item @samp{bootstrap-lto}
>>>  Enables Link-Time Optimization for host tools during bootstrapping.
>>>  @samp{BUILD_CONFIG=bootstrap-lto} is equivalent to adding
Andi Kleen Sept. 9, 2024, 5:04 p.m. UTC | #7
Andi Kleen <ak@linux.intel.com> writes:

Ping^4

Could someone please approve this (nearly trivial) patch?

Thanks,
-Andi

> Andi Kleen <ak@linux.intel.com> writes:
>
> Ping^3
>
>> Andi Kleen <ak@linux.intel.com> writes:
>>
>> PING^2 for the patch.
>>
>> (not sure if there is any maintainer to cc here, this is generic build infrastructure)
>>
>>> Andi Kleen <ak@linux.intel.com> writes:
>>>
>>> I wanted to ping this patch:
>>>
>>> https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658729.html
>>>
>>>
>>>> From: Andi Kleen <ak@gcc.gnu.org>
>>>>
>>>> ... that uses -march=native -mtune=native to build a compiler optimized
>>>> for the host.
>>>>
>>>> config/ChangeLog:
>>>>
>>>> 	* bootstrap-native.mk: New file.
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>> 	* doc/install.texi: Document bootstrap-native.
>>>> ---
>>>>  config/bootstrap-native.mk | 1 +
>>>>  gcc/doc/install.texi       | 6 ++++++
>>>>  2 files changed, 7 insertions(+)
>>>>  create mode 100644 config/bootstrap-native.mk
>>>>
>>>> diff --git a/config/bootstrap-native.mk b/config/bootstrap-native.mk
>>>> new file mode 100644
>>>> index 000000000000..a4a3d8594089
>>>> --- /dev/null
>>>> +++ b/config/bootstrap-native.mk
>>>> @@ -0,0 +1 @@
>>>> +BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)
>>>> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
>>>> index 4973f195daf9..29827c5106f8 100644
>>>> --- a/gcc/doc/install.texi
>>>> +++ b/gcc/doc/install.texi
>>>> @@ -3052,6 +3052,12 @@ Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
>>>>  @itemx @samp{bootstrap-Og}
>>>>  Analogous to @code{bootstrap-O1}.
>>>>  
>>>> +@item @samp{bootstrap-native}
>>>> +@itemx @samp{bootstrap-native}
>>>> +Optimize the compiler code for the build host, if supported by the
>>>> +architecture. Note this only affects the compiler, not the targeted
>>>> +code. If you want the later use @samp{--with-cpu}.
>>>> +
>>>>  @item @samp{bootstrap-lto}
>>>>  Enables Link-Time Optimization for host tools during bootstrapping.
>>>>  @samp{BUILD_CONFIG=bootstrap-lto} is equivalent to adding
Ramana Radhakrishnan Sept. 10, 2024, 3:29 a.m. UTC | #8
> On 9 Sep 2024, at 10:34 PM, Andi Kleen <ak@linux.intel.com> wrote:
> 
> External email: Use caution opening links or attachments
> 
> 
> Andi Kleen <ak@linux.intel.com> writes:
> 
> Ping^4
> 
> Could someone please approve this (nearly trivial) patch?
> 
> Thanks,
> -Andi
> 
>> Andi Kleen <ak@linux.intel.com> writes:
>> 
>> Ping^3
>> 
>>> Andi Kleen <ak@linux.intel.com> writes:
>>> 
>>> PING^2 for the patch.
>>> 
>>> (not sure if there is any maintainer to cc here, this is generic build infrastructure)
>>> 
>>>> Andi Kleen <ak@linux.intel.com> writes:
>>>> 
>>>> I wanted to ping this patch:
>>>> 
>>>> https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658729.html
>>>> 
>>>> 
>>>>> From: Andi Kleen <ak@gcc.gnu.org>
>>>>> 
>>>>> ... that uses -march=native -mtune=native to build a compiler optimized
>>>>> for the host.
>>>>> 
>>>>> config/ChangeLog:
>>>>> 
>>>>>   * bootstrap-native.mk: New file.
>>>>> 
>>>>> gcc/ChangeLog:
>>>>> 
>>>>>   * doc/install.texi: Document bootstrap-native.
>>>>> ---
>>>>> config/bootstrap-native.mk | 1 +
>>>>> gcc/doc/install.texi       | 6 ++++++
>>>>> 2 files changed, 7 insertions(+)
>>>>> create mode 100644 config/bootstrap-native.mk
>>>>> 
>>>>> diff --git a/config/bootstrap-native.mk b/config/bootstrap-native.mk
>>>>> new file mode 100644
>>>>> index 000000000000..a4a3d8594089
>>>>> --- /dev/null
>>>>> +++ b/config/bootstrap-native.mk
>>>>> @@ -0,0 +1 @@
>>>>> +BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)

Does every port have a -march=native + -mtune=native that behaves the same way as what is expected here ? 

>>>>> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
>>>>> index 4973f195daf9..29827c5106f8 100644
>>>>> --- a/gcc/doc/install.texi
>>>>> +++ b/gcc/doc/install.texi
>>>>> @@ -3052,6 +3052,12 @@ Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
>>>>> @itemx @samp{bootstrap-Og}
>>>>> Analogous to @code{bootstrap-O1}.
>>>>> 
>>>>> +@item @samp{bootstrap-native}
>>>>> +@itemx @samp{bootstrap-native}
>>>>> +Optimize the compiler code for the build host, if supported by the
>>>>> +architecture. Note this only affects the compiler, not the targeted
>>>>> +code. If you want the later use @samp{--with-cpu}.
>>>>> +

 The defaults suitable for a port can be different , for instance on AArch32 additional options to specify float abi and floating point units might be required.
 I would suggest rewriting this to something like .  “If you want the later , choose options suitable to the target you are looking for.  For e.g. @samp{--with-cpu} would be a good starting point.” 


>>>>> @item @samp{bootstrap-lto}
>>>>> Enables Link-Time Optimization for host tools during bootstrapping.
>>>>> @samp{BUILD_CONFIG=bootstrap-lto} is equivalent to adding
Andi Kleen Sept. 10, 2024, 1:52 p.m. UTC | #9
On Tue, Sep 10, 2024 at 03:29:08AM +0000, Ramana Radhakrishnan wrote:
> >>>>> diff --git a/config/bootstrap-native.mk b/config/bootstrap-native.mk
> >>>>> new file mode 100644
> >>>>> index 000000000000..a4a3d8594089
> >>>>> --- /dev/null
> >>>>> +++ b/config/bootstrap-native.mk
> >>>>> @@ -0,0 +1 @@
> >>>>> +BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)
> 
> Does every port have a -march=native + -mtune=native that behaves the same way as what is expected here ? 

Not all of them do, but it's getting somewhat common with popular ones.

> 
> >>>>> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> >>>>> index 4973f195daf9..29827c5106f8 100644
> >>>>> --- a/gcc/doc/install.texi
> >>>>> +++ b/gcc/doc/install.texi
> >>>>> @@ -3052,6 +3052,12 @@ Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
> >>>>> @itemx @samp{bootstrap-Og}
> >>>>> Analogous to @code{bootstrap-O1}.
> >>>>> 
> >>>>> +@item @samp{bootstrap-native}
> >>>>> +@itemx @samp{bootstrap-native}
> >>>>> +Optimize the compiler code for the build host, if supported by the
> >>>>> +architecture. Note this only affects the compiler, not the targeted
> >>>>> +code. If you want the later use @samp{--with-cpu}.
> >>>>> +
> 
>  The defaults suitable for a port can be different , for instance on AArch32 additional options to specify float abi and floating point units might be required.
>  I would suggest rewriting this to something like .  “If you want the later , choose options suitable to the target you are looking for.  For e.g. @samp{--with-cpu} would be a good starting point.” 

Ok.

-Andi
diff mbox series

Patch

diff --git a/config/bootstrap-native.mk b/config/bootstrap-native.mk
new file mode 100644
index 000000000000..a4a3d8594089
--- /dev/null
+++ b/config/bootstrap-native.mk
@@ -0,0 +1 @@ 
+BOOT_CFLAGS := -march=native -mtune=native $(BOOT_CFLAGS)
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 4973f195daf9..29827c5106f8 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -3052,6 +3052,12 @@  Removes any @option{-O}-started option from @code{BOOT_CFLAGS}, and adds
 @itemx @samp{bootstrap-Og}
 Analogous to @code{bootstrap-O1}.
 
+@item @samp{bootstrap-native}
+@itemx @samp{bootstrap-native}
+Optimize the compiler code for the build host, if supported by the
+architecture. Note this only affects the compiler, not the targeted
+code. If you want the later use @samp{--with-cpu}.
+
 @item @samp{bootstrap-lto}
 Enables Link-Time Optimization for host tools during bootstrapping.
 @samp{BUILD_CONFIG=bootstrap-lto} is equivalent to adding