public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: L A Walsh <gcc@tlinx.org>, gcc-help <gcc-help@gcc.gnu.org>,
	unlvsur unlvsur <unlvsur@live.com>
Subject: Re: how to get -march=native's value?
Date: Mon, 27 Sep 2021 15:26:32 -0500	[thread overview]
Message-ID: <20210927202632.GB8185@gate.crashing.org> (raw)
In-Reply-To: <CAH6eHdQbVr6G26eqEeRyNkzHdEo3obixRt5SLAfzpsQGjw2MZg@mail.gmail.com>

On Mon, Sep 27, 2021 at 07:25:58PM +0100, Jonathan Wakely wrote:
> On Mon, 27 Sept 2021 at 19:16, L A Walsh <gcc@tlinx.org> wrote:
> > On 2021/09/27 10:13, Segher Boessenkool wrote:
> > > On Mon, Sep 27, 2021 at 02:55:28PM +0200, Vincent Lefevre wrote:
> > >> On 2021-09-17 12:53:25 -0500, Segher Boessenkool wrote:
> > >>
> > >>> For x86 -march=something is the same as -march=native, _if_ the compiler
> > >>> knows about your CPU.
> > >>>
> > ----
> > I have a question, as someone reading this conversation ....
> >
> > If one is using cross-compilation -- as it sounded like the original
> > author might be doing, what could the compiler know about the target
> > machine?
> 
> Only what you tell it.
> 
> > Is there some sort of "profile-this-cpu-for-pertinent-options" binary
> > or compiler-option that one should(or could) run on the target
> > machine in order that the correct compiler switches be set?
> >
> > Otherwise, it would seem that -march=native would only be useful for
> > the (probably majority of) cases where one is compiling for their own
> > machine (?).
> 
> Yes, -march=native is for native compilation, not cross compilation.
> The clue is in the name :-)

And in fact you get something like

$ x86_64-linux-gcc-12.0.0 -Wall -W -O2 -S at.c -march=native
cc1: error: bad value ('native') for '-march=' switch
cc1: note: valid arguments to '-march=' switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client rocketlake icelake-server cascadelake tigerlake cooperlake sapphirerapids alderlake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm x86-64 x86-64-v2 x86-64-v3 x86-64-v4 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 znver3 btver1 btver2

when you try.  Not the friendliest error message perhaps, but it is a
pretty silly thing to try as well :-)  (This has been the same since at
least 5.4.1 (but the note is newer)).


Segher

  reply	other threads:[~2021-09-27 20:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07  7:02 unlvsur unlvsur
2021-09-07  7:56 ` Jonathan Wakely
2021-09-17  2:46   ` NightStrike
2021-09-17  8:29     ` Xi Ruoyao
2021-09-17 10:26       ` Jonathan Wakely
2021-09-17 10:38         ` Jonathan Wakely
2021-09-17 17:53         ` Segher Boessenkool
2021-09-27 12:55           ` Vincent Lefevre
2021-09-27 17:13             ` Segher Boessenkool
2021-09-27 18:14               ` L A Walsh
2021-09-27 18:25                 ` Jonathan Wakely
2021-09-27 20:26                   ` Segher Boessenkool [this message]
2021-09-27 20:30                     ` NightStrike
2021-09-27 18:26                 ` Florian Weimer
2021-09-07  7:59 ` Hongtao Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210927202632.GB8185@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=gcc-help@gcc.gnu.org \
    --cc=gcc@tlinx.org \
    --cc=jwakely.gcc@gmail.com \
    --cc=unlvsur@live.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).