From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by sourceware.org (Postfix) with ESMTPS id B5CB43858D3C for ; Sat, 23 Dec 2023 08:26:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5CB43858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B5CB43858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703319971; cv=none; b=IpZ4i+e5DcYJRNwxYDPFdWY/7T7+x+Fz1foIJRyMTuCp0vhpJQVq6XWYBlNMcxBum5CIAqcEE4ofZMwtxmLwOCgYEq2krYwBAgN0sOdo8+K9iJr4SR0wL1GpzHWFNdLtXgxOs3cKlKf9jSwTTMp8nvnn2/hgcbnxtIqr4QuLAOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703319971; c=relaxed/simple; bh=PNjh1ChDIzPKexPrV7sZSgnsFnKJe4jhlwg/c8Gl3vM=; h=MIME-Version:From:Date:Message-ID:Subject:To; b=CPpGSDZmvYJO4NLzQr/NFVH7C+l7q7hZG0aXvEv7tAwJFOPmJKW1jJlyXZRb6s2FkAwyEHhbJ8g9avo9vTk6owad6fMteyzTYtNkKrF8+O6KXmgy3vTKTXHEA6ibMwlD8LZopg838Pc7oIQzMelCPcthYcitCvckA6XcFZbMpDA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3bb89215406so1128120b6e.1 for ; Sat, 23 Dec 2023 00:26:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703319967; x=1703924767; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hh9ues8c2BHTsukX+0T6ETTPA9TmwnAim+s8tIdhgAM=; b=S6QzQ6wu3q541ln55pGrHAdhxIHbcejtD+z4O9rZQFAG2vcLhIjOhz49MWuFiskBJG w6CVMoG8FCGjfYPU3oIFc4Uan/QchMjxUjVdpYgsP2yR7mZbgmhI13kK+ryFaIt+5AT0 qt2UN4ps7J28StK3drBW3nJoyyKEXB2tyMl3cBbDrX8jgJRpc/X/6g2Eh2VzGvsS0pOo bFIf6MKji2WmWLXQ/TxOdQCOtwBj9upvFFjnj3JuYfzw30Wq9T6WHFBj7uDhRACAgiid IQPgf49BG2Q2fhtOmRVgxkIEVOON4mk1y2hTle6V//ZFcBqIYB9dhBehfw5gBXkr/e0M 4xBQ== X-Gm-Message-State: AOJu0YyElpinfZ2FErYSMucE6oRkQzGBPMfnNXerjBxM38ebQCHiI+qw cgckJS/dFif0cYuLPo00fDP97RUKWyE= X-Google-Smtp-Source: AGHT+IGdErjJ0D8OTjSkyuEdalFjHLaO+uYVG5vsJIlaF/rHSNWpdPXAmnu+hwZWpsAWRiDwQrym6w== X-Received: by 2002:a05:6808:188e:b0:3bb:7549:8d89 with SMTP id bi14-20020a056808188e00b003bb75498d89mr3246458oib.25.1703319967487; Sat, 23 Dec 2023 00:26:07 -0800 (PST) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com. [209.85.216.47]) by smtp.gmail.com with ESMTPSA id m14-20020aa78a0e000000b006ce7e65159bsm4622836pfa.28.2023.12.23.00.26.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Dec 2023 00:26:07 -0800 (PST) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-28be52a85b9so1558344a91.1 for ; Sat, 23 Dec 2023 00:26:07 -0800 (PST) X-Received: by 2002:a17:903:238b:b0:1d3:bda3:4aa7 with SMTP id v11-20020a170903238b00b001d3bda34aa7mr1752094plh.33.1703319966742; Sat, 23 Dec 2023 00:26:06 -0800 (PST) MIME-Version: 1.0 References: <20231219013049.3165982-1-syq@gcc.gnu.org> In-Reply-To: From: YunQiang Su Date: Sat, 23 Dec 2023 16:25:55 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] MIPS: Put the ret to the end of args of reconcat [PR112759] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, ian@airs.com, pinskia@gmail.com, matoro_mailinglist_gcc-patches@matoro.tk Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jakub Jelinek =E4=BA=8E2023=E5=B9=B412=E6=9C=8819=E6=97= =A5=E5=91=A8=E4=BA=8C 16:40=E5=86=99=E9=81=93=EF=BC=9A > > On Tue, Dec 19, 2023 at 09:30:49AM +0800, YunQiang Su wrote: > > The function `reconcat` cannot append string(s) to NULL, > > as the concat process will stop at the first NULL. > > > > Let's always put the `ret` to the end, as it may be NULL. > > We keep use reconcat here, due to that reconcat can make it > > easier if we add more hardware features detecting, for example > > by hwcap. > > > > gcc/ > > > > PR target/112759 > > * config/mips/driver-native.cc (host_detect_local_cpu): > > Put the ret to the end of args of reconcat. > > --- > > gcc/config/mips/driver-native.cc | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/gcc/config/mips/driver-native.cc b/gcc/config/mips/driver-= native.cc > > index afc276f5278..9a224b3f401 100644 > > --- a/gcc/config/mips/driver-native.cc > > +++ b/gcc/config/mips/driver-native.cc > > @@ -44,6 +44,8 @@ const char * > > host_detect_local_cpu (int argc, const char **argv) > > { > > const char *cpu =3D NULL; > > + /* Don't assigne any static string to ret. If you need to do so, > > + use concat. */ > > char *ret =3D NULL; > > char buf[128]; > > FILE *f; > > @@ -90,7 +92,8 @@ host_detect_local_cpu (int argc, const char **argv) > > > > fallback_cpu: > > #if defined (__mips_nan2008) > > - ret =3D reconcat (ret, " -mnan=3D2008 ", NULL); > > + /* Put the ret to the end of list, since it maybe NULL. */ > > + ret =3D reconcat (ret, "-mnan=3D2008", ret, NULL); > > #endif > > > > #ifdef HAVE_GETAUXVAL > > @@ -104,7 +107,7 @@ fallback_cpu: > > #endif > > > > if (cpu) > > - ret =3D reconcat (ret, ret, "-m", argv[0], "=3D", cpu, NULL); > > + ret =3D reconcat (ret, "-m", argv[0], "=3D", cpu, ret, NULL); > > I think if you don't put any spaces, the above could return > -march=3Dloongson3a-mnan=3D2008 > which will not work. Thanks. > If you want to emit no spurious spaces around but emit them when needed, > one way is to put there the space when needed, so > ret =3D reconcat (ret, "-mnan=3D2008", ret ? " " : "", ret, NULL); > or > ret =3D reconcat (ret, "-m", argv[0], "=3D", cpu, ret ? " " : "", ret, NU= LL); > would do it. > > I must say I'm also surprised by determining whether to use -mnan=3D2008 = or > not by how has the host compiler been configured, shouldn't that be > querying properties of the hardware (say, perform some floating point > operation that should result in a quiet NaN and see if it has the mantiss= a > MSB set or clear)? And, do you really want to add that -mnan=3D2008 twic= e In fact, we cannot. Since the operating system env can have only one value. Currently, the OS env can be NAN-legacy, and it can be used on NAN2008 hard= ware if an extra kernel option is set. And vice versa. If we detect the hardware, user will meet some problem when linking, such a= s linking -mnan=3D2008 module with previous -mnan=3Dlegacy modules And the binaries for NaN2008, and NaN-legacy use different dynamic linkers. If we don't pass -mnan=3D2008 here, if the gcc is configured --with-nan=3D2= 008, the NaN-legacy dynamic linkers will be tried, and then failed. Maybe it needs a better fix. Let's keep it for now, and try to find a better solution. > for -march=3Dnative -mtune=3Dnative, or just for one of those (I assume > -mnan=3D2008 is an ABI option, so shouldn't be about tuning but about > -march=3D). > Thank you. Your suggestion is correct. I will skip -mtune, as a user may use it separately just for tuning. > That said, don't really know anything about MIPS, so these are just rando= m > comments. > > Jakub >