From patchwork Mon Aug 14 03:57:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yujie X-Patchwork-Id: 135120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2505670vqi; Sun, 13 Aug 2023 21:01:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFALXv3H/+l4TWDwCkFEZH0HE+k2AJlzgKQ2EE1Wlvnww6iIx/VWiLJBqcamW0NcuETznDL X-Received: by 2002:a05:6402:151a:b0:523:3754:a4e1 with SMTP id f26-20020a056402151a00b005233754a4e1mr6623061edw.22.1691985663474; Sun, 13 Aug 2023 21:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691985663; cv=none; d=google.com; s=arc-20160816; b=QrrFuI/8QIVf5kFbjmKZByKfC7haFPLZB1VnWyuNQZIK//Ot7+itdocRfXl65YH1fI VQNyph/j3H+5aSoEaekOjHFs62kGcXA4wVn/UvWJbgzWsTbY2rZccqHqPtuDqEauX4tG XYKrcndPC5tJq8vI39xWIdphEDpuNJ4HCpeqlAjHmZXOhtkBhmG7pbwruOtpEzHxbmoO RCYnXSUh1cDoxc/mtqsllizXhQkcBmZpIoqnpAJQnHNbnDglXapi9b6FGyYmb254N59k Jnl4gCEJj/gF3V1Mo/9PdviHyOezR1z8rbe6F9lRwCOwWt72efoi12jSAC2SguEU1Y8/ Cazw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dmarc-filter :delivered-to; bh=oPgB0cBlBMf2ua43jkHZVlagJt+dXoXzzuL2FafN28Q=; fh=IxMqdJj3G+v5QmZpidO3uwMg7Jqu8kY37TcqbgmfO1o=; b=tV4/Y+9Sc8M3j9PdOtxSK/ulFJ1eKJ4SP5xHKrMyzex9Z6BnwqrDykQ+mbhuKbh970 DCTgwvT+69Ky61zmxjX5M4CzDxjUMjriVHPv+d3bn0dmHV6w7xumVlXFNEaULF7e08nc Y4LM9K93YMpkqunKkTfX+zPdBXD/iCAAhcBYVMOnM1LxdaUp28QIVlj3UETM2USkHGG3 fZFfnWQ8WVm5pyHkM8aUZNmafzE/ZDaLly0c2MRqwFi5hsf2oXQtx8HQR3SniFo5evbI vdvqOJ0GUKKVugwuJURehS7xBD9VKvWZjbuHvWIODrS3AaGgq3cXXpaMRoVbrsHfnxdB E+IA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k6-20020aa7c386000000b00522775c014esi7127349edq.475.2023.08.13.21.01.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Aug 2023 21:01:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E34703882074 for ; Mon, 14 Aug 2023 03:59:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id A51033858C3A for ; Mon, 14 Aug 2023 03:57:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A51033858C3A 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 1qVOi1-0004wj-HR for gcc-patches@gcc.gnu.org; Sun, 13 Aug 2023 23:57:40 -0400 Received: from loongson.cn (unknown [192.168.100.1]) by gateway (Coremail) with SMTP id _____8CxLOslptlk9uUXAA--.44108S3; Mon, 14 Aug 2023 11:57:26 +0800 (CST) Received: from localhost.localdomain (unknown [192.168.100.1]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxTs8jptlkPVFZAA--.25099S2; Mon, 14 Aug 2023 11:57:23 +0800 (CST) From: Yang Yujie To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, xuchenghua@loongson.cn, panchenghui@loongson.cn, chenglulu@loongson.cn, Yang Yujie Subject: [PATCH v1 1/6] LoongArch: a symmetric multilib subdir layout Date: Mon, 14 Aug 2023 11:57:02 +0800 Message-Id: <20230814035707.11272-1-yangyujie@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxTs8jptlkPVFZAA--.25099S2 X-CM-SenderInfo: 51dqw5pxmlvqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxZFyfGFy3tFykZw17tw1DJwc_yoW7Gryrpr W7u3W5AFs5XFn3Gws3A3yfX3WrGFZ5Gry7ZFy3K3y7CrsxGwnFvF4kt347WF1DCrs5AFWa gwnYga43uFs8CacCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv 67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j8sqAUUUUU= 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=-15.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_FAIL, SPF_HELO_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774175558749498344 X-GMAIL-MSGID: 1774175558749498344 Multilib in gcc is asymmetric. i.e. a "default" / "toplevel" library variant is always built and installed, and: * it is installed directly under the gcc libdir (with no suffix); * it is selected / searched / linked against when the gcc driver does not receive any option from MULTILIB_OPTIONS. Meanwhile, multilib options from MULTILIB_OPTIONS may add suffixes (--print-multi-lib) to this base directory and find compatible library variants there. However, for LoongArch, we do not want such a "toplevel" library installation since the default ABI may change. We expect all multilib variants of libraries to be installed to their designated ABI-specific subdirs (e.g. base/lp64d) of the GCC libdir, so that the default ABI can be configured arbitrarily (with --with-abi) while the gcc libdir layout stays consistent. This could be helpful for the distribution packaging of GCC libraries. This patch achieves this by overriding ${with_multisubdir} of the "toplevel" library and disabling the duplicate "multilib" variant (which exists because LA's driver always generates a normalized "-mabi=" option from self_spec even if it is not given on the command line, causing the semantics of "toplevel" library to be duplicate with a non-toplevel one). Other architectures stay unaffected as long as they do not override ${with_multisubdir} in config-ml.in. ChangeLog: * config-ml.in: add loongarch support. Allow overriding toplevel multisubdir. libgcc/ChangeLog: * config/loongarch/t-loongarch: make symlinks of toplevel libgcc.a under gcc/ for passing regression tests. --- config-ml.in | 39 ++++++++++++++++++++++++++++- libgcc/config/loongarch/t-loongarch | 16 ++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/config-ml.in b/config-ml.in index 68854a4f16c..914cafb4b50 100644 --- a/config-ml.in +++ b/config-ml.in @@ -383,6 +383,18 @@ mips*-*-*) done fi ;; +loongarch*-*-*) + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + `${CC-gcc} --print-multi-directory`) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + + with_multisubdir=`${CC-gcc} --print-multi-directory` + ;; msp430-*-*) if [ x$enable_no_exceptions = xno ] then @@ -509,7 +521,7 @@ multi-do: compiler="$(CC)"; \ for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \ dir=`echo $$i | sed -e 's/;.*$$//'`; \ - if [ "$${dir}" = "." ]; then \ + if [ "$${dir}" = "." ] || [ "/$${dir}" = "$(MULTISUBDIR)" ]; then \ true; \ else \ if [ -d ../$${dir}/$${lib} ]; then \ @@ -595,6 +607,12 @@ if [ -z "${with_multisubdir}" ]; then ml_subdir= ml_builddotdot= : # ml_srcdotdot= # already set +elif [ "${ml_toplevel_p}" = yes ]; then + : # When ml_* is set by ${host}. + ml_subdir="/${with_multisubdir}" + ml_builddotdot= + ml_builddotdot_link=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/ + : # ml_srcdotdot= # already set else ml_subdir="/${with_multisubdir}" # The '[^/][^/]*' appears that way to work around a SunOS sed bug. @@ -654,6 +672,25 @@ mv Makefile.tem ${Makefile} if [ "${ml_toplevel_p}" = yes ]; then +# If multisubdir is set on the top level, create a symbolic link +# to cope with in-tree regression tests (see dejagnu: libgloss.exp). + +if [ -n "${with_multisubdir}" ]; then + if [ "${ml_verbose}" = --verbose ]; then + echo "Creating multilib link (${with_multisubdir}) for the default library." + echo "pwd: `${PWDCMD-pwd}`" + fi + + ml_origdir=`${PWDCMD-pwd}` + ml_libdir=`echo "$ml_origdir" | sed -e 's,^.*/,,'` + # cd to top-level-build-dir/${with_target_subdir} + cd .. + + mkdir -p "${with_multisubdir}" + ln -sf "${ml_builddotdot_link}${ml_libdir}" "${with_multisubdir}/" + cd "${ml_origdir}" +fi + # We must freshly configure each subdirectory. This bit of code is # actually partially stolen from the main configure script. FIXME. diff --git a/libgcc/config/loongarch/t-loongarch b/libgcc/config/loongarch/t-loongarch index 2a7dbf6ca83..791a8c52f24 100644 --- a/libgcc/config/loongarch/t-loongarch +++ b/libgcc/config/loongarch/t-loongarch @@ -5,3 +5,19 @@ softfp_int_modes := si di softfp_extensions := softfp_truncations := softfp_exclude_libgcc2 := n + +# Since we employ a symmetric multilib layout, i.e. the default lib +# always gets installed to its ${multisubdir} (see config-ml.in), +# we need to copy it (again) into the GCC directory +# (without the multilib suffix) in order to keep some regression +# tests working (libstdc++), because "too many things knows +# about the layout of the build tree" for now (libgcc/Makefile.in). + +# If we are on the top level (default library), +# copy libgcc into gcc build directory. +ifneq ($(MULTIDO),true) +all: install-default-lib +.PHONY: install-default-lib +install-default-lib: libgcc.a + -$(LN_S) .$(MULTISUBDIR)/libgcc.a $(gcc_objdir)/libgcc.a +endif