From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id D51323858C30 for ; Wed, 30 Aug 2023 10:01:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D51323858C30 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=loongson.cn Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbI16-00063B-42 for gcc-patches@gcc.gnu.org; Wed, 30 Aug 2023 06:01:43 -0400 Received: from loongson.cn (unknown [192.168.100.1]) by gateway (Coremail) with SMTP id _____8Cx2ep8E+9kdw8dAA--.54242S3; Wed, 30 Aug 2023 18:01:32 +0800 (CST) Received: from 3a5000 (unknown [192.168.100.1]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxicx7E+9k3ClnAA--.26765S2; Wed, 30 Aug 2023 18:01:32 +0800 (CST) Date: Wed, 30 Aug 2023 18:01:33 +0800 From: Yujie Yang To: Xi Ruoyao Cc: Yujie Yang , gcc-patches@gcc.gnu.org, xuchenghua@loongson.cn, chenglulu@loongson.cn, panchenghui@loongson.cn Subject: Re: [PATCH v2 3/4] LoongArch: add new configure option --with-strict-align-lib Message-ID: <3ylosgbv2ludnzu4yck3bjeozeik4sg24ur5irlhcigvea7pn2@t7y25ilweon3> References: <20230830015808.19870-1-yangyujie@loongson.cn> <20230830015808.19870-4-yangyujie@loongson.cn> <7e29b15bb6096c240c3ffd27a16f7350a7742f97.camel@xry111.site> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7e29b15bb6096c240c3ffd27a16f7350a7742f97.camel@xry111.site> X-CM-TRANSID:AQAAf8Bxicx7E+9k3ClnAA--.26765S2 Authentication-Results: localhost.locald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sIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UAMa8UUUUU= Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangyujie@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,BODY_8BITS,KAM_DMARC_STATUS,SPF_FAIL,SPF_HELO_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Aug 30, 2023 at 04:22:13PM +0800, Xi Ruoyao wrote: > On Wed, 2023-08-30 at 14:51 +0800, Yujie Yang wrote: > > > > LoongArch processors may not support memory accesses without natural > > > > alignments.  Building libraries with -mstrict-align may help with > > > > toolchain binary compatiblity and performance on these implementations > > > > (e.g. Loongson 2K1000LA). > > > > > > > > No significant performance degredation is observed on current mainstream > > > > LoongArch processors when the option is enabled. > > > > > > > > gcc/ChangeLog: > > > > > > > >         * config.gcc: use -mstrict-align for building libraries > > > >         if --with-strict-align-lib is given. > > > > > > Isn't this equivalent to --with-default-multilib=mno-strict-align now? > > > > > > And I still believe the easiest way for 2K1000LA is adding -march=la264 > > > support so the user can simply configure with --with-arch=la264. > > > > Not exactly -- Options given in --with-multilib-default= will not be applied > > to multilib variants that have build options specified in --with-multilib-list, > > but --with-strict-align-lib is always effective. > > > > e.g. for the following configuration: > > > >   --with-multilib-default=mstrict-align > >   --with-multilib-list=lp64d/la464,lp64s > > > > The library build options would be: > > > >   base/lp64d variant: -mabi=lp64d -march=la464 (no -mstrict-align appended) > >   base/lp64s variant: -mabi=lp64s -march=abi-default -mstrict-align > > > > Sure, you can do it with --with-arch=la264. It's just a convenient > > switch that we can use for building generic toolchains. > > If you want a generic toolchain, it should default to -mstrict-align as > well. Or it will still do unexpected thing for cases like: > > struct foo { char x; int y; } __attribute__ ((packed)); > > int get (struct foo *foo) { return foo->y; } > > So it should be --with-strict-align (it should make the *compiler* > default to -mstrict-align). But them it seems --with-arch=la264 is just > easier... By "generic" I mean: when you enable "-march=la264"/"-march=la464" and link statically, you get a binary that's good for running on LA264/LA464 cores, respectively. It's more of a cross-toolchain case.