From patchwork Fri Nov 17 19:12:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 839134 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467208-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="nwPj+D+i"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydnrQ50H4z9rxj for ; Sat, 18 Nov 2017 06:15:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=r5l znsvM/2VfT/O7ZhBMxMfYQVWc46CVNGNHQHuUkT2IbI5utshMKB34UQ3tCmX4tWh akfSb45NGPj2/u1DtigyaXWSDJ9sF+9H1G3IFXxe5izFK8enz+6KaN25v1bDYUKH jVU690GejYNpJbYvcXiSHNDG0ZcuVMtGlcgCDJuk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=l6i21DyGl oiVCEQdkIUULjI1qdo=; b=nwPj+D+invsF/HKyvfrYtQEOx5MPQ7sJR2W0XSM3z 9rU28+03xcxF7hnPfSjwwKIRVZePKyxn3az3+MUrIKw63CgTkggTOaSBLrJZhAmx WsV958Za4biDdwfskkVqm9T6i/E2qg3lPSKq1dsIOX42Bthi47YR54KUTejS3/EJ vY= Received: (qmail 49217 invoked by alias); 17 Nov 2017 19:12:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 48935 invoked by uid 89); 17 Nov 2017 19:12:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=wine, dating X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0058.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Nov 2017 19:12:26 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by DB6PR0801MB2054.eurprd08.prod.outlook.com (10.168.86.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Fri, 17 Nov 2017 19:12:19 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::9cdc:27e2:bc30:67f7]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::9cdc:27e2:bc30:67f7%17]) with mapi id 15.20.0218.011; Fri, 17 Nov 2017 19:12:19 +0000 From: Wilco Dijkstra To: GCC Patches CC: nd Subject: [RFC][PATCH] Change default to -fcommon Date: Fri, 17 Nov 2017 19:12:19 +0000 Message-ID: x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB2054; 6:ay255Wge5I4HfeoG3VgZhb15Nb4Uau0v4ugT4ce6eQbkeypYn2qLXsmVAKWqxzypkSq/q+NcYEmMQncVaj5pQDMDUcNiaXSy3DSMt8Jfedy5UJqQ0ShOmD/JMSq2vm/wiefZ5/pfZ/ZIQ7HiXvHvhRHUTQMmaoWdgzmE/aryN4+d//YWA7uKUJdvOJZl0PRJxTYKp5DtvV/ohwcOVEnK2MGpR+WQ76WkamKxQ+n5Z8zMBh807jiDF4a1NP9uhnKfsS4dSFx/PcYGaeJT/p4gLbWuMAT3JwwLzQzC3nBapXWrfxao/3val9AcmwvUqgXb511BmHbgcSV+dxdGs0VGK20Y7v8Q+ZP/UzmuoranH8A=; 5:vg8tSVV2nPFI9hxIuVTuQ9/4rs/njXm31lVB3Gm7VZUtnHpTVOckNQRQwIMbqtAiYhIIyf/q9ub/KQ9bk6JT9NW8rHiSRM+elIHqEStOgY7I31mw3rnamLqNsJnFKGYO9tgvVhgG5SyWdv8gE6y2JZSfHmVqgIaZD+l4cw++1oE=; 24:ibemfn84LCgiGqKDOL9nsCUdBVRBSZfTuF3DCDDwxP41XFKX30BmJMfXm3FqSyItt7rCRkn2T3jFPb5Vtp/Q/hzWDhs8tf5LWvszLmZk3NI=; 7:y4TQi143NJtfKYNanjxYvDF1By4lOXadY+w46/N5uhPFXilqvqJylE7uWcVbZkJRl5WDyssFGXKRhZKPHJPtJdjU2o0t1Zet7BFj+objaIUouwxYxsbsYjG49houcT9nmlyzmogECA9mlGpd7cCz6pVUZTkBfm4U0F7utMQoJrYuE5Px60x4YTwUkvnChzKth9keO5jWG0I9Dh+T+/yVZRvi5/Ncmfgl/C+U8FBcrbteaj678X8Sz+pYS0jUPN/P x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 76448d97-c86e-4afe-b5a9-08d52def1ff7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603258); SRVR:DB6PR0801MB2054; x-ms-traffictypediagnostic: DB6PR0801MB2054: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(3231022)(6055026)(6041248)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB6PR0801MB2054; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB6PR0801MB2054; x-forefront-prvs: 049486C505 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(39860400002)(199003)(377424004)(189002)(2900100001)(66066001)(106356001)(8676002)(3280700002)(81156014)(81166006)(6116002)(102836003)(3846002)(189998001)(105586002)(4001150100001)(68736007)(97736004)(3660700001)(5250100002)(7696004)(99286004)(101416001)(54356999)(50986999)(6506006)(6916009)(86362001)(575784001)(5660300001)(33656002)(316002)(14454004)(72206003)(25786009)(9686003)(2906002)(8936002)(4326008)(55016002)(53936002)(7736002)(305945005)(74316002)(478600001)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB2054; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76448d97-c86e-4afe-b5a9-08d52def1ff7 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Nov 2017 19:12:19.8773 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2054 GCC currently defaults to -fcommon. This is an optional C feature dating back to early C implementations. On many targets this means global variable accesses having an unnecessary codesize and performance penalty in C code (the same source generates better code when built as C++). Given there isn't a lot of software that really requires this (mostly it's accidentally forgetting to use 'extern' in a header), it is about time to change the default. What do people think? I presume someone with access to distro source code and a fast build machine could try and see how many packages fail to get an idea how feasible it is. We could keep defaulting to -fcommon with -std=c89 if necessary. 2017-11-17 Wilco Dijkstra * common.opt (fcommon): Change init to 1. * doc/invoke.texi (-fcommon): Update documentation. diff --git a/gcc/common.opt b/gcc/common.opt index 59940c64356964f8f9b9d842ad3f1a1c02548bab..575472aee7572601b6276944679c0a55171e39b2 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1110,7 +1110,7 @@ Common Report Var(flag_combine_stack_adjustments) Optimization Looks for opportunities to reduce stack adjustments and stack references. fcommon -Common Report Var(flag_no_common,0) +Common Report Var(flag_no_common,0) Init(1) Do not put uninitialized globals in the common section. fcompare-debug diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 7ea9f765717d1ace59276406777a6055d6ed6b59..b618e648dbd9ab4a16ec856aea7a6660caad3e9a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -12494,8 +12494,8 @@ useful for building programs to run under WINE@. code that is not binary compatible with code generated without that switch. Use it to conform to a non-default application binary interface. -@item -fno-common -@opindex fno-common +@item -fcommon +@opindex fcommon @cindex tentative definitions In C code, this option controls the placement of global variables defined without an initializer, known as @dfn{tentative definitions} @@ -12506,15 +12506,14 @@ Unix C compilers have traditionally allocated storage for uninitialized global variables in a common block. This allows the linker to resolve all tentative definitions of the same variable in different compilation units to the same object, or to a non-tentative -definition. -This is the behavior specified by @option{-fcommon}, and is the default for -GCC on most targets. +definition. This is the behavior specified by @option{-fcommon}. On the other hand, this behavior is not required by ISO -C, and on some targets may carry a speed or code size penalty on +C, and on several targets implies a speed and code size penalty on variable references. -The @option{-fno-common} option specifies that the compiler should instead -place uninitialized global variables in the data section of the object file. +The @option{-fno-common} option is the default. It specifies that the +compiler should instead place uninitialized global variables in the data +section of the object file. This inhibits the merging of tentative definitions by the linker so you get a multiple-definition error if the same variable is defined in more than one compilation unit.