From patchwork Mon Oct 14 23:18:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 1997130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=keithp.com header.i=@keithp.com header.a=rsa-sha256 header.s=mail header.b=lbQm7ftc; dkim=fail reason="signature verification failed" (2048-bit key) header.d=keithp.com header.i=@keithp.com header.a=rsa-sha256 header.s=mail header.b=lR6mIn1j; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSD8f4nfjz1xsc for ; Tue, 15 Oct 2024 10:34:26 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D8FD13858414 for ; Mon, 14 Oct 2024 23:34:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id 160B73858414 for ; Mon, 14 Oct 2024 23:33:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 160B73858414 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=keithp.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=keithp.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 160B73858414 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=63.227.221.253 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728948844; cv=none; b=iXglCFQzfJd+JmqhVtut8bCeX9bVkaLDIqfGsZa8wpqluYPvGLJvQPDAmcFsoamy0YvfFFS/fwrtS+xcJtSx7/qolfN6OnnEFnS68FUO8XkWZLiTmudkUQGwm/5Jq7xN9TTFIJfhLmgwvrPLOwk+iZ30a5fXK+ofm8n6M8Li3D8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728948844; c=relaxed/simple; bh=T8mpv0aWwGV9LdqKWdCvRax0HDNm0cu077ogUcr2kh0=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=NqsyyNhhtKd093E8gQebnmE0At9dMMqlvb+e6kpUKWhEh77BkESCEUGISJU/na0y2LP0HeBzlkUYdN6gcRGM/mJchaD5XXJKItT3Jz+p8Pdf7yJxy06micy8P/l+ho9c4nVr6E+pYHle6wiZUECiFhhY8HZ+lpFr9rZ0aU1cg5E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1728948837; bh=T8mpv0aWwGV9LdqKWdCvRax0HDNm0cu077ogUcr2kh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lbQm7ftcvv70szUaGD4AtAbEWak0OXJIJmSzrcUzu/XBP2Id7tQOO6U64YNSmqGCk 3raSh6uHGdRl8ADx8XS+6WAeCajKpofbrPuQdzWg2hl0+TAcdcMnhb66SVh08g0zRo hxWIit8cP58v1lDEFD+sJHk+vqnSqXNQ5lCARU80wzuLtT1kUWPdbl3rLScFtuPsvA vGWdspupQdCcnH8NdKDevsUvy9maZzw1So58D44EBnPPZHOm//CLzqJEd//1jDkL8n /fywxHwaz45S33MuxYr1xKFqn1VVaw6BNzw+4XUYvHIzsIlHHv3IgnKyyhV6Hd1oVu bhEFUiUA/iqVg== Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 2D9AE3F20561 for ; Mon, 14 Oct 2024 16:33:57 -0700 (PDT) X-Virus-Scanned: Debian amavis at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavis, port 10024) with LMTP id ujyP241R8jmR; Mon, 14 Oct 2024 16:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1728948834; bh=T8mpv0aWwGV9LdqKWdCvRax0HDNm0cu077ogUcr2kh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lR6mIn1jq1xqaNdl8+jHDFck4fyQZZZI1JHQ9fSLThV/ryOQ7DU3uKy/wP8dkHDFj K9WzDFCMbEEFH7XI4wv1PLzAuVm+Js67rbO4n2KYBnIVrPwRjq0yTu/I1qXsFsUo5d sI/kaPCrVntzigOkuKbMfqiZ27ekY3AZCbkmdL/p39hfeIdUhls3TP6D4nc4sDqdBA izYVg69YuhPhNuudyQfWtxxQOGSDsXjYX0k3x7dKtStKVwagq+fIklMvtAUjhjASq1 tS0S6AFbo6rfhJa3VS9UqJWRD+RO2tSljPc2PClczqEKqhd+d1iOuXn0N8dC+uuQye RcCcFP/tJ4YBw== Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id D07C53F20817; Mon, 14 Oct 2024 16:33:54 -0700 (PDT) Received: by keithp.com (Postfix, from userid 1000) id 86A931E60238; Tue, 15 Oct 2024 01:33:54 +0200 (CEST) From: Keith Packard To: gcc-patches@gcc.gnu.org Cc: Keith Packard Subject: [PATCH 1/2] libgcc: Use -Os/-Oz from CC or CFLAGS Date: Mon, 14 Oct 2024 16:18:34 -0700 Message-ID: <20241014233350.1625639-2-keithp@keithp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241014233350.1625639-1-keithp@keithp.com> References: <20241014233350.1625639-1-keithp@keithp.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_BODY, SPF_HELO_NONE, SPF_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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Override other optimization settings with any -Os or -Oz found in CC or CFLAGS. libgcc/ChangeLog: * Makefile.in: Use -Os or -Oz from CC or CFLAGS Signed-off-by: Keith Packard --- libgcc/Makefile.in | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index ffc45f21267..25710636938 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -294,16 +294,20 @@ override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS)) # CFLAGS first is not perfect; normally setting CFLAGS should override any # options in LIBGCC2_CFLAGS. But LIBGCC2_CFLAGS may contain -g0, and CFLAGS # will usually contain -g, so for the moment CFLAGS goes first. We must -# include CFLAGS - that's where multilib options live. +# include CFLAGS - that's where multilib options live. If CC or CFLAGS +# specify -Os or -Oz, we want that to override our local options as that +# could be a multilib flag. INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \ - $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@ + $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@ \ + $(filter -Os -Oz,$(CC) $(CFLAGS)) # Options to use when compiling crtbegin/end. CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \ -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \ -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \ - $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY) + $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY) \ + $(filter -Os -Oz,$(CC) $(CFLAGS)) # Extra flags to use when compiling crt{begin,end}.o. CRTSTUFF_T_CFLAGS = From patchwork Mon Oct 14 23:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 1997131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=keithp.com header.i=@keithp.com header.a=rsa-sha256 header.s=mail header.b=E7r5sFSi; dkim=fail reason="signature verification failed" (2048-bit key) header.d=keithp.com header.i=@keithp.com header.a=rsa-sha256 header.s=mail header.b=kXqOx3QN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XSD8f6Py3z1xvy for ; Tue, 15 Oct 2024 10:34:26 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EABF3385AC3D for ; Mon, 14 Oct 2024 23:34:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id C60E83858433 for ; Mon, 14 Oct 2024 23:33:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C60E83858433 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=keithp.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=keithp.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C60E83858433 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=63.227.221.253 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728948844; cv=none; b=aj4CLhDC9kziDxBLdKkl666T5P8bfFn8+TAyT2GTt8djbLmQdbuKZF/K9VZupFW3l97A4xaGckr+BBzfRvaqm3ssmAadxAcdFmyVg3jerB5w3NBe0NNEi2SeKPVIJb72QyJoeLHD5fRfeh1EwaP8v2ym4CS5K8cVGRg7Uo4aSuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728948844; c=relaxed/simple; bh=5ZbupcjL/fDMxpulhayJ+h9khy2EGBT7KO0RaZJFBOg=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=mr2aaX4Btn6RltorAqVr6yQ5tzg/y7DBbqv4gE46SROXebEs2O03Mk7mSFBVSj4BpyS7CRvEr28s2oLZ7K9feZs4ctBo9v7epoLM7h54AgdXz0egOY5uD4AE9MalyhrJsWFWCCMcQEIqL6ZuB9OGokEc5cU6fc/XOoUTzh+yKHM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1728948838; bh=5ZbupcjL/fDMxpulhayJ+h9khy2EGBT7KO0RaZJFBOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E7r5sFSi2AXYmDQyHNuRt6TXqO28N7viN65dsjCzUy5DctTY19iklyMAvJnMe7eLn jajY5EhBrHAKg2BP0IMCkKnbnq4+jLOb1A4qY2kjGAn9FyLDHBSk2zioJkNZchKEay Ss0nJ34BJSrHeLfrPr/BrGEN2iJr47K86cOeIR/MQF88wdY/RD3vXRwwuGLOoKckxr RBfEk3hH/uRcLFgEBXVFFnetdV5LG5GmWP1B2kphxoP3ZEO91BW/WppVIndmcmXmXm Q20FRgFmvtrXtnqy/aJNG/XG9EeDgZGgqZCG+z/Ik66q7rMCxVgOc1btuE8G6BssUh 70FW4QKmcmz4Q== Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 0191B3F20817 for ; Mon, 14 Oct 2024 16:33:58 -0700 (PDT) X-Virus-Scanned: Debian amavis at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavis, port 10024) with LMTP id ZaslRq7MIsFU; Mon, 14 Oct 2024 16:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1728948834; bh=5ZbupcjL/fDMxpulhayJ+h9khy2EGBT7KO0RaZJFBOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kXqOx3QN8tTWz9n5QBl5uNHC02ShTGT9IH6pOfo9slRcns21gFYsvKYOfxfS7rBM5 P1TrreS94IGoIamw39HPS7y0Xh89WV/VuUL7pgWq94koHNc/+or5CuMBDsx87F11wp +D/Hu+Zyv7TmuBdLiw5FQT5SqWeFbeaNO459mYTg5p6jfpMfmix43Z6iKXcNC3qNf2 ZUibh0cmEet0pozLeI0DBPV7nyR+6w0lTQJlWo6QbH2co4ipuGzPx04IyfquFLzhGR 14u84XmfkDNWqV68KO+zosh4HsyuyR5r50tIdcHnXSSL7+CRLR1xvsNFj2yZOaeRNj O9lBUlZ7hMM7Q== Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id CE47F3F20620; Mon, 14 Oct 2024 16:33:54 -0700 (PDT) Received: by keithp.com (Postfix, from userid 1000) id 898E91E6023C; Tue, 15 Oct 2024 01:33:54 +0200 (CEST) From: Keith Packard To: gcc-patches@gcc.gnu.org Cc: Keith Packard Subject: [PATCH 2/2] gcc: Add --enable-multilib-space option Date: Mon, 14 Oct 2024 16:18:35 -0700 Message-ID: <20241014233350.1625639-3-keithp@keithp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241014233350.1625639-1-keithp@keithp.com> References: <20241014233350.1625639-1-keithp@keithp.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_BODY, SPF_HELO_NONE, SPF_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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This option adds a per-multilib variant that specifies -Os instead of the default. With this, all multilib libraries will be built with -Os as well as -O2; the appropriate one selected automatically at link time based upon the optimization level selected. This could be done in the target configuration, but adding it globally allows it to be used with any existing target. gcc/ChangeLog: * Makefile.in: Expand multilib set when --enable-multilib-space * configure.ac: Support --enable-multilib-space option * configure: Regenerate Signed-off-by: Keith Packard --- gcc/Makefile.in | 16 ++++++++++++++-- gcc/configure | 13 +++++++++++++ gcc/configure.ac | 7 +++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index b7735908de7..56df632dc94 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2304,6 +2304,18 @@ libgcc.mvars: config.status Makefile specs xgcc$(exeext) mv tmp-libgcc.mvars libgcc.mvars +ifeq (@enable_multilib_space@,yes) +MULTILIB_OPTIONS += Os +MULTILIB_DIRNAMES += space +MULTILIB_MATCHES += Os=Oz + +MULTILIB_REQUIRED_SPACE = $(if $(MULTILIB_REQUIRED),Os $(foreach REQ, $(MULTILIB_REQUIRED), $(REQ) $(REQ)/Os),) +MULTILIB_EXCEPTIONS_SPACE = $(foreach EXC, $(MULTILIB_EXCEPTIONS), $(EXC) $(EXC)/Os) +else +MULTILIB_REQUIRED_SPACE = $(MULTILIB_REQUIRED) +MULTILIB_EXCEPTIONS_SPACE = $(MULTILIB_EXCEPTIONS) +endif + # Use the genmultilib shell script to generate the information the gcc # driver program needs to select the library directory based on the # switches. @@ -2315,11 +2327,11 @@ s-mlib: $(srcdir)/genmultilib Makefile "$(MULTILIB_OPTIONS)" \ "$(MULTILIB_DIRNAMES)" \ "$(MULTILIB_MATCHES)" \ - "$(MULTILIB_EXCEPTIONS)" \ + "$(MULTILIB_EXCEPTIONS_SPACE)" \ "$(MULTILIB_EXTRA_OPTS)" \ "$(MULTILIB_EXCLUSIONS)" \ "$(MULTILIB_OSDIRNAMES)" \ - "$(MULTILIB_REQUIRED)" \ + "$(MULTILIB_REQUIRED_SPACE)" \ "$(if $(MULTILIB_OSDIRNAMES),,$(MULTIARCH_DIRNAME))" \ "$(MULTILIB_REUSE)" \ "@enable_multilib@" \ diff --git a/gcc/configure b/gcc/configure index 5acc42c1e4d..2a12a7cd224 100755 --- a/gcc/configure +++ b/gcc/configure @@ -856,6 +856,7 @@ DEFAULT_MATCHPD_PARTITIONS with_float with_cpu enable_multiarch +enable_multilib_space enable_multilib coverage_flags valgrind_command @@ -977,6 +978,7 @@ enable_coverage enable_gather_detailed_mem_stats enable_valgrind_annotations enable_multilib +enable_multilib_space enable_multiarch with_stack_clash_protection_guard_size with_matchpd_partitions @@ -1718,6 +1720,7 @@ Optional Features: --enable-valgrind-annotations enable valgrind runtime interaction --enable-multilib enable library support for multiple ABIs + --enable-multilib-space enable extra -Os variant for every multilib ABI --enable-multiarch enable support for multiarch paths --enable-__cxa_atexit enable __cxa_atexit for C++ --enable-decimal-float={no,yes,bid,dpd} @@ -7834,6 +7837,16 @@ fi +# Determine whether or not -Os multilibs are enabled. +# Check whether --enable-multilib-space was given. +if test "${enable_multilib_space+set}" = set; then : + enableval=$enable_multilib_space; +else + enable_multilib_space=yes +fi + + + # Determine whether or not multiarch is enabled. # Check whether --enable-multiarch was given. if test "${enable_multiarch+set}" = set; then : diff --git a/gcc/configure.ac b/gcc/configure.ac index 23f4884eff9..84faf3a7645 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -848,6 +848,13 @@ AC_ARG_ENABLE(multilib, [], [enable_multilib=yes]) AC_SUBST(enable_multilib) +# Determine whether or not -Os multilibs are enabled. +AC_ARG_ENABLE(multilib-space, +[AS_HELP_STRING([--enable-multilib-space], + [enable extra -Os variant for every multilib ABI])], +[], [enable_multilib_space=yes]) +AC_SUBST(enable_multilib_space) + # Determine whether or not multiarch is enabled. AC_ARG_ENABLE(multiarch, [AS_HELP_STRING([--enable-multiarch],