public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [wwwdocs] Document -fcommon default change
@ 2019-12-05 13:14 Wilco Dijkstra
  2020-01-06 14:10 ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Wilco Dijkstra @ 2019-12-05 13:14 UTC (permalink / raw)
  To: GCC Patches; +Cc: sandra, Joseph Myers

Hi,

Add entries for the default change in changes.html and porting_to.html.
Passes the W3 validator.

Cheers,
Wilco

---

diff --git a/htdocs/gcc-10/changes.html b/htdocs/gcc-10/changes.html
index e02966460450b7aad884b2d45190b9ecd8c7a5d8..304e1e8ccd38795104156e86b92062696fa5aa8b 100644
--- a/htdocs/gcc-10/changes.html
+++ b/htdocs/gcc-10/changes.html
@@ -102,6 +102,11 @@ a work-in-progress.</p>
     <li>In C2X mode, <code>-fno-fp-int-builtin-inexact</code> is
     enabled by default.</li>
   </ul></li>
+
+  <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>
 
 <h3 id="cxx">C++</h3>
diff --git a/htdocs/gcc-10/porting_to.html b/htdocs/gcc-10/porting_to.html
index 3256e8a35d00ce1352c169a1c6df6d8f120889ee..e2c7e226a83b7720fe6ed40061cdddbc27659664 100644
--- a/htdocs/gcc-10/porting_to.html
+++ b/htdocs/gcc-10/porting_to.html
@@ -29,9 +29,25 @@ and provide solutions. Let us know if you have suggestions for improvements!
 <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="fortran">Fortran language issues</h2>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] Document -fcommon default change
  2019-12-05 13:14 [wwwdocs] Document -fcommon default change Wilco Dijkstra
@ 2020-01-06 14:10 ` Jonathan Wakely
  2020-01-06 16:25   ` Sandra Loosemore
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2020-01-06 14:10 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: GCC Patches, sandra, Joseph Myers

On 05/12/19 13:14 +0000, Wilco Dijkstra wrote:
>Hi,
>
>Add entries for the default change in changes.html and porting_to.html.
>Passes the W3 validator.
>
>Cheers,
>Wilco
>
>---
>
>diff --git a/htdocs/gcc-10/changes.html b/htdocs/gcc-10/changes.html
>index e02966460450b7aad884b2d45190b9ecd8c7a5d8..304e1e8ccd38795104156e86b92062696fa5aa8b 100644
>--- a/htdocs/gcc-10/changes.html
>+++ b/htdocs/gcc-10/changes.html
>@@ -102,6 +102,11 @@ a work-in-progress.</p>
>     <li>In C2X mode, <code>-fno-fp-int-builtin-inexact</code> is
>     enabled by default.</li>
>   </ul></li>
>+
>+  <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.

The "also" here is a bit unclear what it refers to. It seems to follow
on from the previous sentence, which suggests that the efficiencies
are somehow related to the cases that get linker errors.

How about:

GCC now defaults to <code>-fno-common</code>.  As a result, global
variable accesses are more efficient on various targets.  In C, global
variables with multiple tentative definitions will result in linker
errors.


>+  </li>
> </ul>
>
> <h3 id="cxx">C++</h3>
>diff --git a/htdocs/gcc-10/porting_to.html b/htdocs/gcc-10/porting_to.html
>index 3256e8a35d00ce1352c169a1c6df6d8f120889ee..e2c7e226a83b7720fe6ed40061cdddbc27659664 100644
>--- a/htdocs/gcc-10/porting_to.html
>+++ b/htdocs/gcc-10/porting_to.html
>@@ -29,9 +29,25 @@ and provide solutions. Let us know if you have suggestions for improvements!
> <h2 id="cpp">Preprocessor issues</h2>
> -->
>
>-<!--
> <h2 id="c">C language issues</h2>
>--->
>+
>+<h3 id="complit">Default to <code>-fno-common</code></h3>

What does "complit" mean? Would a more memorable anchor such as
"common" or "no-common" be better?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] Document -fcommon default change
  2020-01-06 14:10 ` Jonathan Wakely
@ 2020-01-06 16:25   ` Sandra Loosemore
  2020-01-07 15:15     ` Wilco Dijkstra
  0 siblings, 1 reply; 8+ messages in thread
From: Sandra Loosemore @ 2020-01-06 16:25 UTC (permalink / raw)
  To: Jonathan Wakely, Wilco Dijkstra; +Cc: GCC Patches, Joseph Myers

On 1/6/20 7:10 AM, Jonathan Wakely wrote:

> How about:
> 
> GCC now defaults to <code>-fno-common</code>.  As a result, global
> variable accesses are more efficient on various targets.  In C, global
> variables with multiple tentative definitions will result in linker
> errors.

This is better.  I'd also s/will/now/, since we're talking about the 
present behavior of GCC 10, not some future behavior.

-Sandra

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] Document -fcommon default change
  2020-01-06 16:25   ` Sandra Loosemore
@ 2020-01-07 15:15     ` Wilco Dijkstra
  2020-01-11 10:27       ` Gerald Pfeifer
  2020-02-06 20:07       ` [wwwdocs] Mention common attribute in gcc-10/porting_to.html Jakub Jelinek
  0 siblings, 2 replies; 8+ messages in thread
From: Wilco Dijkstra @ 2020-01-07 15:15 UTC (permalink / raw)
  To: Sandra Loosemore, Jonathan Wakely; +Cc: GCC Patches, Joseph Myers

Hi,

>On 1/6/20 7:10 AM, Jonathan Wakely wrote:
>> GCC now defaults to <code>-fno-common</code>.  As a result, global
>> variable accesses are more efficient on various targets.  In C, global
>> variables with multiple tentative definitions will result in linker
>> errors.
>
> This is better.  I'd also s/will/now/, since we're talking about the 
> present behavior of GCC 10, not some future behavior.

Thanks for the suggestions, I've reworded it as:

GCC now defaults to <code>-fno-common</code>.  As a result, global
variable accesses are more efficient on various targets.  In C, global
variables with multiple tentative definitions now result in linker errors.
With <code>-fcommon</code> such definitions are silently merged during
linking.

Also changed the anchor name (I think it was a copy/paste from another entry).
Here the updated version:


diff --git a/htdocs/gcc-10/changes.html b/htdocs/gcc-10/changes.html
index d6108269e977df2af29bd5c9149cc2136654ce05..45af7fa333cfff2155ff0346fe36855aa6ff940a 100644
--- a/htdocs/gcc-10/changes.html
+++ b/htdocs/gcc-10/changes.html
@@ -140,6 +140,13 @@ a work-in-progress.</p>
     <li>In C2X mode, <code>-fno-fp-int-builtin-inexact</code> is
     enabled by default.</li>
   </ul></li>
+
+  <li>GCC now defaults to <code>-fno-common</code>.  As a result, global
+      variable accesses are more efficient on various targets.  In C, global
+      variables with multiple tentative definitions now result in linker errors.
+      With <code>-fcommon</code> such definitions are silently merged during
+      linking.
+  </li>
 </ul>
 
 <h3 id="cxx">C++</h3>
diff --git a/htdocs/gcc-10/porting_to.html b/htdocs/gcc-10/porting_to.html
index 3256e8a35d00ce1352c169a1c6df6d8f120889ee..7d45a962d014fecece9bd52a13ca1799153672fe 100644
--- a/htdocs/gcc-10/porting_to.html
+++ b/htdocs/gcc-10/porting_to.html
@@ -29,9 +29,25 @@ and provide solutions. Let us know if you have suggestions for improvements!
 <h2 id="cpp">Preprocessor issues</h2>
 -->
 
-<!--
 <h2 id="c">C language issues</h2>
--->
+
+<h3 id="common">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="fortran">Fortran language issues</h2>
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] Document -fcommon default change
  2020-01-07 15:15     ` Wilco Dijkstra
@ 2020-01-11 10:27       ` Gerald Pfeifer
  2020-02-06 20:07       ` [wwwdocs] Mention common attribute in gcc-10/porting_to.html Jakub Jelinek
  1 sibling, 0 replies; 8+ messages in thread
From: Gerald Pfeifer @ 2020-01-11 10:27 UTC (permalink / raw)
  To: Wilco Dijkstra
  Cc: Sandra Loosemore, Jonathan Wakely, GCC Patches, Joseph Myers

On Tue, 7 Jan 2020, Wilco Dijkstra wrote:
> Thanks for the suggestions, I've reworded it as:

> +  <li>GCC now defaults to <code>-fno-common</code>.  As a result, global
> +      variable accesses are more efficient on various targets.  In C, global
> +      variables with multiple tentative definitions now result in linker errors.
> +      With <code>-fcommon</code> such definitions are silently merged during
> +      linking.
> +  </li>

Thank you, this patchset is okay (also the other parts).


(Ideally reformat for a bit smaller width since right now the patch
format, which is wider by a few columns, induces line wraps in an 80
column view, but that is optional.)

Thank you,
Gerald

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [wwwdocs] Mention common attribute in gcc-10/porting_to.html
  2020-01-07 15:15     ` Wilco Dijkstra
  2020-01-11 10:27       ` Gerald Pfeifer
@ 2020-02-06 20:07       ` Jakub Jelinek
  2020-02-06 22:18         ` Gerald Pfeifer
  1 sibling, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2020-02-06 20:07 UTC (permalink / raw)
  To: Gerald Pfeifer, Wilco Dijkstra
  Cc: Sandra Loosemore, Jonathan Wakely, GCC Patches, Joseph Myers

Hi!

On Tue, Jan 07, 2020 at 03:15:05PM +0000, Wilco Dijkstra wrote:
> --- a/htdocs/gcc-10/porting_to.html
> +++ b/htdocs/gcc-10/porting_to.html
> @@ -29,9 +29,25 @@ and provide solutions. Let us know if you have suggestions for improvements!
>  <h2 id="cpp">Preprocessor issues</h2>
>  -->
>  
> -<!--
>  <h2 id="c">C language issues</h2>
> --->
> +
> +<h3 id="common">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="fortran">Fortran language issues</h2>

IMHO we should mention also the common attribute, in some cases the common
behavior is intentional decision and there is no problem supporting it,
just the code should mark it explicitly.

Ok for wwwdocs?

diff --git a/htdocs/gcc-10/porting_to.html b/htdocs/gcc-10/porting_to.html
index 980d3af1..c5d7eb82 100644
--- a/htdocs/gcc-10/porting_to.html
+++ b/htdocs/gcc-10/porting_to.html
@@ -41,7 +41,12 @@ and provide solutions. Let us know if you have suggestions for improvements!
   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>.
+  If tentative definitions of particular variable or variables need to be
+  placed in a common block, <code>__attribute__((__common__))</code> can be
+  used to force that behavior for those even in code compiled without
+  <code>-fcommon</code>.
+  As a workaround, legacy C code where all tentative definitions should
+  be placed into a common block can be compiled with <code>-fcommon</code>.
 </p>
   <pre><code>
       int x;  // tentative definition - avoid in header files


	Jakub

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] Mention common attribute in gcc-10/porting_to.html
  2020-02-06 20:07       ` [wwwdocs] Mention common attribute in gcc-10/porting_to.html Jakub Jelinek
@ 2020-02-06 22:18         ` Gerald Pfeifer
  2020-02-07  1:34           ` Sandra Loosemore
  0 siblings, 1 reply; 8+ messages in thread
From: Gerald Pfeifer @ 2020-02-06 22:18 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Wilco Dijkstra, Sandra Loosemore, Jonathan Wakely, gcc-patches,
	Joseph Myers

On Thu, 6 Feb 2020, Jakub Jelinek wrote:
> +  If tentative definitions of particular variable or variables need to be

I believe that would be "a particular variable", but best to simplify
to "of particular variables".

> +  placed in a common block, <code>__attribute__((__common__))</code> can be
> +  used to force that behavior for those even in code compiled without
> +  <code>-fcommon</code>.

Here I'd omit "for those".

This makes sense to me and reads well; okay from my side. :)

Gerald

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] Mention common attribute in gcc-10/porting_to.html
  2020-02-06 22:18         ` Gerald Pfeifer
@ 2020-02-07  1:34           ` Sandra Loosemore
  0 siblings, 0 replies; 8+ messages in thread
From: Sandra Loosemore @ 2020-02-07  1:34 UTC (permalink / raw)
  To: Gerald Pfeifer, Jakub Jelinek
  Cc: Wilco Dijkstra, Jonathan Wakely, gcc-patches, Joseph Myers

On 2/6/20 3:18 PM, Gerald Pfeifer wrote:
> On Thu, 6 Feb 2020, Jakub Jelinek wrote:
>> +  If tentative definitions of particular variable or variables need to be
> 
> I believe that would be "a particular variable", but best to simplify
> to "of particular variables".
> 
>> +  placed in a common block, <code>__attribute__((__common__))</code> can be
>> +  used to force that behavior for those even in code compiled without
>> +  <code>-fcommon</code>.
> 
> Here I'd omit "for those".
> 
> This makes sense to me and reads well; okay from my side. :)

Looks good to me with those changes.

-Sandra

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-02-07  1:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05 13:14 [wwwdocs] Document -fcommon default change Wilco Dijkstra
2020-01-06 14:10 ` Jonathan Wakely
2020-01-06 16:25   ` Sandra Loosemore
2020-01-07 15:15     ` Wilco Dijkstra
2020-01-11 10:27       ` Gerald Pfeifer
2020-02-06 20:07       ` [wwwdocs] Mention common attribute in gcc-10/porting_to.html Jakub Jelinek
2020-02-06 22:18         ` Gerald Pfeifer
2020-02-07  1:34           ` Sandra Loosemore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).