From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 334D73858C2C for ; Mon, 27 Sep 2021 20:30:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 334D73858C2C Received: by mail-ed1-x52a.google.com with SMTP id s17so55567395edd.8 for ; Mon, 27 Sep 2021 13:30:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2UtnTSMmWZBj80SjvRyP75tXceZadDSOO4nZMpbxkC0=; b=yWc57UtCLuv3jAZTY2ZUappuG5O4tJ2NExOzDFp20t253GAOQMphB7qmXfNeIm/IzV ryWr2Dra28Iq/y9EjXCESgREFcHqGrtFFkSftYRCFdcxc33yiTicu3Ha05fMsyBoSZSY RSVGK/2nw493BVEOFxMaUP4pmFvcqjGOte8m3QbwtB13C9TwjZ1OKB4Kyhdxa0F3kEbx 779D6nWPvDY+TqaW3u9Len7ffyGcf18EbcRYRnYNMmMSXhzV0pLIbyIsWhb+J6vIEwYy ZcXIfrpfbDc4mqPoHn9BrjIF0lKLpelMWRdCHB3dvm9XPhtg6ZiaVsk3+37FkiCrgrdj u7vw== X-Gm-Message-State: AOAM530ecNtPZpqZvszK1HnbE+HM6R33RxWaCdipghV5sk72S8scries 8y3jfu7d8A86Eoen/AK1FK++1wPZOMY8MqZuJ6x18NGjvtY= X-Google-Smtp-Source: ABdhPJxehwX0SJEzCxK2Mnvc8ftRrHDlvddsBr6SelQWvQb9Bm6N/lrfx1fPLc5H+SrwPSS4ytvcDbAap+H81ZOeVQc= X-Received: by 2002:a05:6402:64e:: with SMTP id u14mr2703511edx.184.1632774652194; Mon, 27 Sep 2021 13:30:52 -0700 (PDT) MIME-Version: 1.0 References: <5b4a11b1a9a3945256d298cd355991dcffa1d806.camel@mengyan1223.wang> <20210917175325.GS1583@gate.crashing.org> <20210927125528.GA3789484@cventin.lip.ens-lyon.fr> <20210927171344.GA8185@gate.crashing.org> <61520A1E.9050900@tlinx.org> <20210927202632.GB8185@gate.crashing.org> In-Reply-To: <20210927202632.GB8185@gate.crashing.org> From: NightStrike Date: Mon, 27 Sep 2021 16:30:38 -0400 Message-ID: Subject: Re: how to get -march=native's value? To: Segher Boessenkool Cc: Jonathan Wakely , gcc-help , unlvsur unlvsur Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Sep 2021 20:30:54 -0000 On Mon, Sep 27, 2021 at 4:28 PM Segher Boessenkool wrote: > > On Mon, Sep 27, 2021 at 07:25:58PM +0100, Jonathan Wakely wrote: > > On Mon, 27 Sept 2021 at 19:16, L A Walsh 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=3Dsomething is the same as -march=3Dnative, _if_ t= he 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=3Dnative would only be useful fo= r > > > the (probably majority of) cases where one is compiling for their own > > > machine (?). > > > > Yes, -march=3Dnative 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=3Dnative > cc1: error: bad value ('native') for '-march=3D' switch > cc1: note: valid arguments to '-march=3D' switch are: nocona core2 nehale= m 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 bo= nnell 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 a= thlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 znver= 3 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)). There are cases where that's a reasonable thing to do, for instance when running a mingw-w64 cross compiler on cygwin. Anytime the host computer can run a target binary, then native makes sense. There is probably a Linux / Wine use case, too.