From patchwork Thu Feb 22 10:20:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 204669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp157761dyb; Thu, 22 Feb 2024 02:23:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXtytlhs3DPFScOk4JAeti8Ctg8EDKau/R2FG3nA7YyL/0TsTqfmNVi2CTjB91NP0Q0WMqIXzwYbWPigRvWRsLYD3aC8Q== X-Google-Smtp-Source: AGHT+IEXE+VPAvyXa+FGW9+rRb+uhaOQ1mKnEAW+Lrt5FlCVc8mLT0IUzigNY0xGJClNcwdg6h0U X-Received: by 2002:a5b:112:0:b0:dcd:30f9:eb6d with SMTP id 18-20020a5b0112000000b00dcd30f9eb6dmr1941912ybx.57.1708597415609; Thu, 22 Feb 2024 02:23:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708597415; cv=pass; d=google.com; s=arc-20160816; b=FoG26NAngTqhNOh24Vz1s+3HN2EtxB1pRRF/gYlEdNQMCg6+rENP7PMTB45w62d4jX gScCPof6asqM+abcG2oGVN9I/FHskROfcDxv/bFZgd3mztsZwdjYg1K4WJiQ2qbouF4f YUcUamLYK6WbsjKIVviWKSjfoOWWXX6dJJIT91c7jCRF3fdj6LMbLabhu0D3RAadQhbT Yu65bikEQJ2quL1pI273jItbBMvY91wQcA2mx7eHG9vu7qRNEWV69Uz6qNtQ7Zssky6Q 5d804KDkNM+hQd7AXNs6/OZIk5ctJ0nnwmWeLbhDzYJUYtVv9XqHopOER6bUDo27B4YW +rNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=WKp+kDBYP7Bt2Egovjxt+oAOYCgi4NI+QzyAVLcz3XM=; fh=oUCfM/eMlWtMCtZZKY1bglzxCo7b3kw9D5LTFFWuz38=; b=APjHYivab34pxHauVuuXpdHJ4NJUWoV40pvg04tPrm7vKX7dz1FwEnWjGjQYY78ZzU gAkArkbWJxZin4ELdJ4LZSIoSWjVger31INcg10JH6J9XVU4YAZAAMRWiwBhbaFsqstm iYBnCAlXNiIA6bik0KlDpGxqlXRiV8ipET+VgzRCm5wfwuNSN++vmthvL0ZfCPcnZXyA xquX/QmVG895uFDMAYllu5ha0IF2oUvz22wcGpnz/DaLVGtIH8m7Pow09STI24shUVkY ljq6ZU1TtdC5D3OhkUMdKfPCtCwivtp+rk+jT3et/uHrs8D695eVoCrLoLhK29b8OtY+ 2kNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=hFbdTwKM; arc=pass (i=1); 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"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v17-20020ac87291000000b0042e58c34078si3104qto.255.2024.02.22.02.23.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 02:23:35 -0800 (PST) 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; dkim=pass header.i=@xry111.site header.s=default header.b=hFbdTwKM; arc=pass (i=1); 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"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F2861385841C for ; Thu, 22 Feb 2024 10:23:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 3C71B3858414 for ; Thu, 22 Feb 2024 10:22:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C71B3858414 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3C71B3858414 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.208.246.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708597368; cv=none; b=eYH3M5DNugFqKQwYKY5592QzPji6388BpBSanNZVhzKbyh+UZX0helIbli3/SSjFf834gcMiFCGJsAdSpqvpyzC8QOG5eEhvnshyUwSWPPHKcf5idTAXv78L9QnCCYkFp3S5v0f4UbCFsN+Vb+AZbxq+bDA/unKGiZTiFCFS/7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708597368; c=relaxed/simple; bh=7v3h7Qna+EWiJlwTuhgQzdWvrZK2yrT4MICpR3hqROM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qVXtznXzhqvxoSwm/+FVEY3Up88wELYWyb0k5fw8BGTS/GFi/o0R40cTvbBtmACaArLlPJ06jfrqlbmfoGoda56BhZ8YIy4wZqKzwaWyiaEN9nuCpWIRw1PjMnYbqvXJ+eqs0tiZvqpsv5GQAefoO054WWZx0XoqLdGA+3OZwsA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1708597364; bh=7v3h7Qna+EWiJlwTuhgQzdWvrZK2yrT4MICpR3hqROM=; h=From:To:Cc:Subject:Date:From; b=hFbdTwKMQAqGdTHnOQnTltNG72qcfW9K0fJj/sa3AK3Z+tLkw6EukjcPrwRfyhUKZ AKMn7VvRs8awLPOgTvn8ph9oXNfX42nFPJp0HwT4Yjzq/uP0W9OkVNTXWqlmfFUGox J19+IPex4sl52AGrYRp444Flx+HJo7A+fCUE2Nrg= Received: from stargazer.. (unknown [IPv6:240e:358:1112:4600:dc73:854d:832e:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id F16E4671CF; Thu, 22 Feb 2024 05:22:38 -0500 (EST) From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: chenglulu , i@xen0n.name, xuchenghua@loongson.cn, Xi Ruoyao Subject: [GCC 13 PATCH] LoongArch: Don't default to -mno-explicit-relocs if -mno-relax Date: Thu, 22 Feb 2024 18:20:25 +0800 Message-ID: <20240222102121.180635-1-xry111@xry111.site> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, SPF_HELO_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791594243897884720 X-GMAIL-MSGID: 1791594243897884720 To improve Binutils compatibility we've had to backported relaxation support. But if a user just updates to GCC 13.3 and sticks with Binutils 2.41, there is no reason to use -mno-explicit-relocs as the default because we are turning off relaxation for Binutils 2.41 (it lacks conditional branch relaxation support) anyway. So like GCC 14, make the default of -m[no-]explicit-relocs depend on -m[no-]relax instead of HAVE_AS_MRELAX_OPTION. Also update the doc to reflect the behavior change. gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in (TARGET_EXPLICIT_RELOCS): Init to M_OPTION_NOT_SEEN. * config/loongarch/loongarch.opt: Regenerate. * config/loongarch/loongarch.cc (loongarch_option_override_internal): Set the default of TARGET_EXPLICIT_RELOCS to HAVE_AS_EXPLICIT_RELOCS && !loongarch_mrelax. * doc/invoke.texi (-m[no-]explicit-relocs): Update for LoongArch. --- Ok for releases/gcc-13? gcc/config/loongarch/genopts/loongarch.opt.in | 2 +- gcc/config/loongarch/loongarch.cc | 4 ++++ gcc/config/loongarch/loongarch.opt | 2 +- gcc/doc/invoke.texi | 11 +++++------ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in index da6fedd153e..76acd35d39c 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -155,7 +155,7 @@ Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init -mmax-inline-memcpy-size=SIZE Set the max size of memcpy to inline, default is 1024. mexplicit-relocs -Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS & !HAVE_AS_MRELAX_OPTION) +Target Var(TARGET_EXPLICIT_RELOCS) Init(M_OPTION_NOT_SEEN) Use %reloc() assembly operators. ; The code model option names for -mcmodel. diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 768e2427285..e78b81cd8fc 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -6222,6 +6222,10 @@ loongarch_option_override_internal (struct gcc_options *opts) gcc_unreachable (); } + if (TARGET_EXPLICIT_RELOCS == M_OPTION_NOT_SEEN) + TARGET_EXPLICIT_RELOCS = (HAVE_AS_EXPLICIT_RELOCS + && !loongarch_mrelax); + /* Validate the guard size. */ int guard_size = param_stack_clash_protection_guard_size; diff --git a/gcc/config/loongarch/loongarch.opt b/gcc/config/loongarch/loongarch.opt index 59b1e06d3f2..e61fbaed2c1 100644 --- a/gcc/config/loongarch/loongarch.opt +++ b/gcc/config/loongarch/loongarch.opt @@ -162,7 +162,7 @@ Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init -mmax-inline-memcpy-size=SIZE Set the max size of memcpy to inline, default is 1024. mexplicit-relocs -Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS & !HAVE_AS_MRELAX_OPTION) +Target Var(TARGET_EXPLICIT_RELOCS) Init(M_OPTION_NOT_SEEN) Use %reloc() assembly operators. ; The code model option names for -mcmodel. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 99657fb44d8..792ce283bb9 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -25830,12 +25830,11 @@ The default code model is @code{normal}. @itemx -mno-explicit-relocs Use or do not use assembler relocation operators when dealing with symbolic addresses. The alternative is to use assembler macros instead, which may -limit optimization. The default value for the option is determined during -GCC build-time by detecting corresponding assembler support: -@code{-mexplicit-relocs} if said support is present, -@code{-mno-explicit-relocs} otherwise. This option is mostly useful for -debugging, or interoperation with assemblers different from the build-time -one. +limit instruction scheduling but allow linker relaxation. The default +value for the option is determined with the assembler capability detected +during GCC build-time and the setting of @code{-mrelax}: +@code{-mexplicit-relocs} if the assembler supports relocation operators +but @code{-mrelax} is not enabled, @code{-mno-explicit-relocs} otherwise. @opindex mdirect-extern-access @item -mdirect-extern-access