This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR85678: Change default to -fno-common
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: Martin Liška <mliska at suse dot cz>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 29 Nov 2019 14:43:18 +0000
- Subject: Re: [PATCH] PR85678: Change default to -fno-common
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3uC2SKnzUyb6LJ3QOhlegifgaMPyxOU/ehT+bnl03kA=; b=VlDqLOotVj4fekVKsGYub8wcNZE1m+cRdeSwLcSxhsFBFwcZJEodsUrgPl1117x600KWwmw09pnF+Z+KDdepYJ9sqtRDDSIhDSOp9gNqyyaYOFx/lG10HgvWk/y1AbSOy3LyI0hM6JnK7bleACwV9hiLrWSLoNmYJ/0Qii2F1NE8W80ZxpJ3obVZBH4NYcYR80P+3RXr7Gs2dm+pfVBZoN/eGlcb1f3bPs1AjGSRXqg+k3um+wjRuq30yRGeY6O73e3JzQI4VmZC85pgMZCqlXZnLm8n0LGrTIS9ontC3h6p50iLsfMhdrWkydBE2joXj4EdiG1EHc+Pn7KBBRqYog==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F4Vmujo0Xjwvk9avC6lyl/N4lZpREx5eqFvbxrd5D2pY6yM17WWlqtubqXrEzqtGG2PhngVyRF09eQEiM5fBBejJFRarExUJXN75dDBHA3E7K4KEn8FB3oWizpS7vkzc6Vqi5n83IHMag80Dl0oeRSgHae1MUHubkePy7ofT6ZFVh8s8lrINtpU8fZ0iG1EqVkGpsoIW8/kci+oK8yoaQAVaExnSVNiSRX2g1+m0AsIRoLMBIRlPlZ6wTg5ED4JIAZAVuPchJV2YBbhw8aUXcfebf0T+eGzfnpYdIWG8jlm80STxIJ+wsegFrEjOghPyVKwgicFaFwoXCi76+XbAWw==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco dot Dijkstra at arm dot com;
- References: <VI1PR0801MB212795B138C5027E46F83C4983650@VI1PR0801MB2127.eurprd08.prod.outlook.com>,<2600d107-dc05-95b0-8864-5a9c4d7bb85e@suse.cz>
Hi Martin,
> I've noticed quite significant package failures caused by the revision.
How significant? Is it mostly the common mistake of forgetting extern?
> Would you please consider documenting this change in porting_to.html
> (and in changes.html) for GCC 10 release?
Sure, I already had a patch for changes.html - I've added an initial porting_to
as well:
[wwwdocs] Document -fcommon default change
Add an entry for the default change. Passes the W3 validator.
--
diff --git a/htdocs/gcc-10/changes.html b/htdocs/gcc-10/changes.html
index f0f0d312171a54afede176f06ce76f9c8abaebc4..980e4e591781d04aa888ba5988981006bd30dd1f 100644
--- a/htdocs/gcc-10/changes.html
+++ b/htdocs/gcc-10/changes.html
@@ -47,6 +47,13 @@ a work-in-progress.</p>
<!-- .................................................................. -->
<h2 id="general">General Improvements</h2>
+<p>The following GCC command line options have been introduced or improved.</p>
+<ul>
+ <li>GCC now defaults to <code>-fno-common</code>. In C, global variables with
+ multiple tentative definitions will result in linker errors.
+ Global variable accesses are also more efficient on various targets.
+ </li>
+</ul>
<p>The following built-in functions have been introduced.</p>
<ul>
diff --git a/htdocs/gcc-10/porting_to.html b/htdocs/gcc-10/porting_to.html
new file mode 100644
index 0000000000000000000000000000000000000000..2e652f6aa4bd3259a316af0c72ab7eb96bab53b7
--- /dev/null
+++ b/htdocs/gcc-10/porting_to.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Porting to GCC 10</title>
+<link rel="stylesheet" type="text/css" href="https://gcc.gnu.org/gcc.css" />
+</head>
+
+<body>
+<h1>Porting to GCC 10</h1>
+
+<p>
+The GCC 10 release series differs from previous GCC releases in
+<a href="changes.html">a number of ways</a>. Some of these are a result
+of bug fixing, and some old behaviors have been intentionally changed
+to support new standards, or relaxed in standards-conforming ways to
+facilitate compilation or run-time performance.
+</p>
+
+<p>
+Some of these changes are user visible and can cause grief when
+porting to GCC 10. This document is an effort to identify common issues
+and provide solutions. Let us know if you have suggestions for improvements!
+</p>
+
+
+<!--
+<h2 id="cpp">Preprocessor issues</h2>
+-->
+
+<h2 id="c">C language issues</h2>
+
+<h3 id="complit">Default to <code>-fno-common</code></h3>
+
+<p>
+ A common mistake in C is omitting <code>extern</code> when declaring a global
+ variable in a header file. If the header is included by several files it
+ results in multiple definitions of the same variable. In previous GCC
+ versions this error is ignored. GCC 10 defaults to <code>-fno-common</code>,
+ which means a linker error will now be reported.
+ To fix this, use <code>extern</code> in header files when declaring global
+ variables, and ensure each global is defined in exactly one C file.
+ As a workaround, legacy C code can be compiled with <code>-fcommon</code>.
+</p>
+ <pre><code>
+ int x; // tentative definition - avoid in header files
+
+ extern int y; // correct declaration in a header file
+ </code></pre>
+
+<!--
+<h2 id="cxx">C++ language issues</h2>
+-->
+
+<!--
+<h2 id="fortran">Fortran language issues</h2>
+-->
+
+<!--
+<h2 id="links">Links</h2>
+-->
+
+</body>
+</html>