From patchwork Fri May 20 19:13:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 54256 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 078B5383088B for ; Fri, 20 May 2022 19:14:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 078B5383088B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653074044; bh=0pivlVPIp1fdj7HWKrI0Q6jZGAy5xhSb9/H1ZcJZhZc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=b5zcRX/FMsVhVh79yMlSGOjdho/9dU4JLoAC/ChVF766ARWJdjW+qJxh0LNos7urv asjiZa5WJH7bNpNnUTiFGLzTqulWZRPz7dzavgL4XB/nWHEF+iN2Vs7OLk9CLFupTT gNeXb/NCg3mIp0NNtqABXrNoX3p/2RJskPOazL5w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 301E63856DEA for ; Fri, 20 May 2022 19:13:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 301E63856DEA Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7E2261170CB; Fri, 20 May 2022 15:13:33 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MrkcZGuVpS6I; Fri, 20 May 2022 15:13:33 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id E19DB116615; Fri, 20 May 2022 15:13:32 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 24KJDMiV424811 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 May 2022 16:13:23 -0300 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Support multilib-aware target lib flags self-specs overriding Organization: Free thinker, does not speak for AdaCore Date: Fri, 20 May 2022 16:13:22 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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 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: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch introduces -multiflags, short for multilib TFLAGS, as an option that does nothing by default, but that can be added to TFLAGS and mapped to useful options by driver self-specs. I realize -m is reserved for machine-specific flags, which this option sort-of isn't, but its intended use is indeed to stand for machine-specific flags, so it's kind of ok. But that's just my official excuse, the reason I couldn't help picking it up is that it is a portmanteau of multi[lib] and TFLAGS. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * common.opt (multiflags): New. * doc/invoke.texi: Document it. * gcc.cc (driver_self_specs): Discard it. * opts.cc (common_handle_option): Ignore it in the driver. --- gcc/common.opt | 4 ++++ gcc/doc/invoke.texi | 30 +++++++++++++++++++++++++++++- gcc/gcc.cc | 6 +++++- gcc/opts.cc | 4 ++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 8a0dafc522d12..73b69ba3118e4 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1786,6 +1786,10 @@ fif-conversion2 Common Var(flag_if_conversion2) Optimization Perform conversion of conditional jumps to conditional execution. +multiflags +Common Driver +Building block for specs-based multilib-aware TFLAGS. + fstack-reuse= Common Joined RejectNegative Enum(stack_reuse_level) Var(flag_stack_reuse) Init(SR_ALL) Optimization -fstack-reuse=[all|named_vars|none] Set stack reuse level for local variables. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 98a543ae06fda..0bd8d7b129612 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -727,7 +727,7 @@ Objective-C and Objective-C++ Dialects}. -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol -fstats -fstack-usage -ftime-report -ftime-report-details @gol -fvar-tracking-assignments-toggle -gtoggle @gol --print-file-name=@var{library} -print-libgcc-file-name @gol +-multiflags -print-file-name=@var{library} -print-libgcc-file-name @gol -print-multi-directory -print-multi-lib -print-multi-os-directory @gol -print-prog-name=@var{program} -print-search-dirs -Q @gol -print-sysroot -print-sysroot-headers-suffix @gol @@ -18870,6 +18870,34 @@ For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10}, eleventh invocation. For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations. +@item -multiflags +@opindex multiflags +This option enables multilib-aware @code{TFLAGS} to be used to build +target libraries with options different from those the compiler is +configured to use by default, through the use of specs (@xref{Spec +Files}) set up by compiler internals, by the target, or by builders at +configure time. + +Like @code{TFLAGS}, this allows the target libraries to be built for +portable baseline environments, while the compiler defaults to more +demanding ones. That's useful because users can easily override the +defaults the compiler is configured to use to build their own programs, +if the defaults are not ideal for their target environment, whereas +rebuilding the runtime libraries is usually not as easy or desirable. + +Unlike @code{TFLAGS}, the use of specs enables different flags to be +selected for different multilibs. The way to accomplish that is to +build with @samp{make TFLAGS=-multiflags}, after configuring +@samp{--with-specs=%@{multiflags:...@}}. + +This option is discarded by the driver once it's done processing driver +self spec. + +It is also useful to check that @code{TFLAGS} are being used to build +all target libraries, by configuring a non-bootstrap compiler +@samp{--with-specs='%@{!multiflags:%emissing TFLAGS@}'} and building the +compiler and target libraries. + @item -print-file-name=@var{library} @opindex print-file-name Print the full absolute name of the library file @var{library} that diff --git a/gcc/gcc.cc b/gcc/gcc.cc index 299e09c4f545f..fd9523c48f1e9 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -1347,7 +1347,11 @@ static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS; static const char *const driver_self_specs[] = { "%{fdump-final-insns:-fdump-final-insns=.} %report_bug = value; break; + case OPT_multiflags: + gcc_checking_assert (lang_mask == CL_DRIVER); + break; + default: /* If the flag was handled in a standard way, assume the lack of processing here is intentional. */