public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove pointless -fPIC warning on Windows platforms
@ 2015-08-14 22:43 Paolo Bonzini
  2015-08-15 16:19 ` Mike Stump
  2015-08-29 15:45 ` Kai Tietz
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2015-08-14 22:43 UTC (permalink / raw)
  To: gcc-patches

There are plenty of targets that do not require -fPIC because they always
generate position independent code, but none of them feels the need to
complain with the user about an unnecessary but perfectly valid option,
on each and every .c->.o rule, and without a way to disable it.

Adding insult to injury, the warning is also wrong in 3 cases out of four.
For 32-bit, warning may make a small amount of sense because there is
simply no such thing as PIC code (Windows just uses a "preferred base
address" for DLLs); but then the text is wrong.

For 64-bit, -fpic does not warn, but "all code is position independent"
would apply just as well!

As a summary, googling for the warning text finds exactly two categories
of people: those that are annoyed by the message because they want to
use -Werror (this includes me), and those that suggest replacing -fPIC
with -fpic.  Just zap it.

Paolo

	* config/i386/cygming.h (SUBTARGET_OVERRIDE_OPTIONS): Do
	not warn.

diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index fda59fb..71506ec 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -198,20 +198,7 @@ along with GCC; see the file COPYING3.  If not see
 #undef  SUBTARGET_OVERRIDE_OPTIONS
 #define SUBTARGET_OVERRIDE_OPTIONS					\
 do {									\
-  if (TARGET_64BIT && flag_pic != 1)					\
-    {									\
-      if (flag_pic > 1)							\
-        warning (0,							\
-	         "-fPIC ignored for target (all code is position independent)"\
-                 );                         				\
-      flag_pic = 1;							\
-    }									\
-  else if (!TARGET_64BIT && flag_pic)					\
-    {									\
-      warning (0, "-f%s ignored for target (all code is position independent)",\
-	       (flag_pic > 1) ? "PIC" : "pic");				\
-      flag_pic = 0;							\
-    }									\
+  flag_pic = TARGET_64BIT ? 1 : 0;                                      \
 } while (0)
 
 /* Define this macro if references to a symbol must be treated

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

* Re: [PATCH] Remove pointless -fPIC warning on Windows platforms
  2015-08-14 22:43 [PATCH] Remove pointless -fPIC warning on Windows platforms Paolo Bonzini
@ 2015-08-15 16:19 ` Mike Stump
  2015-08-29 15:45 ` Kai Tietz
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Stump @ 2015-08-15 16:19 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches

On Aug 14, 2015, at 3:24 PM, Paolo Bonzini <bonzini@gnu.org> wrote:
> There are plenty of targets that do not require -fPIC because they always
> generate position independent code, but none of them feels the need to
> complain with the user about an unnecessary but perfectly valid option,
> on each and every .c->.o rule, and without a way to disable it.

:-)  I think darwin had, or has that same bug.  I kinda like the notion that -fPIC is ignored on such a platform, not complained about.

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

* Re: [PATCH] Remove pointless -fPIC warning on Windows platforms
  2015-08-14 22:43 [PATCH] Remove pointless -fPIC warning on Windows platforms Paolo Bonzini
  2015-08-15 16:19 ` Mike Stump
@ 2015-08-29 15:45 ` Kai Tietz
  1 sibling, 0 replies; 3+ messages in thread
From: Kai Tietz @ 2015-08-29 15:45 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: GCC Patches

Hi Pedro,

2015-08-15 0:24 GMT+02:00 Paolo Bonzini <bonzini@gnu.org>:
> There are plenty of targets that do not require -fPIC because they always
> generate position independent code, but none of them feels the need to
> complain with the user about an unnecessary but perfectly valid option,
> on each and every .c->.o rule, and without a way to disable it.
>
> Adding insult to injury, the warning is also wrong in 3 cases out of four.
> For 32-bit, warning may make a small amount of sense because there is
> simply no such thing as PIC code (Windows just uses a "preferred base
> address" for DLLs); but then the text is wrong.
>
> For 64-bit, -fpic does not warn, but "all code is position independent"
> would apply just as well!

Agreed.

> As a summary, googling for the warning text finds exactly two categories
> of people: those that are annoyed by the message because they want to
> use -Werror (this includes me), and those that suggest replacing -fPIC
> with -fpic.  Just zap it.
>
> Paolo

Patch is ok.  Please apply.

Thanks,
Kai

>         * config/i386/cygming.h (SUBTARGET_OVERRIDE_OPTIONS): Do
>         not warn.
>
> diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
> index fda59fb..71506ec 100644
> --- a/gcc/config/i386/cygming.h
> +++ b/gcc/config/i386/cygming.h
> @@ -198,20 +198,7 @@ along with GCC; see the file COPYING3.  If not see
>  #undef  SUBTARGET_OVERRIDE_OPTIONS
>  #define SUBTARGET_OVERRIDE_OPTIONS                                     \
>  do {                                                                   \
> -  if (TARGET_64BIT && flag_pic != 1)                                   \
> -    {                                                                  \
> -      if (flag_pic > 1)                                                        \
> -        warning (0,                                                    \
> -                "-fPIC ignored for target (all code is position independent)"\
> -                 );                                                    \
> -      flag_pic = 1;                                                    \
> -    }                                                                  \
> -  else if (!TARGET_64BIT && flag_pic)                                  \
> -    {                                                                  \
> -      warning (0, "-f%s ignored for target (all code is position independent)",\
> -              (flag_pic > 1) ? "PIC" : "pic");                         \
> -      flag_pic = 0;                                                    \
> -    }                                                                  \
> +  flag_pic = TARGET_64BIT ? 1 : 0;                                      \
>  } while (0)
>
>  /* Define this macro if references to a symbol must be treated

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

end of thread, other threads:[~2015-08-29 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-14 22:43 [PATCH] Remove pointless -fPIC warning on Windows platforms Paolo Bonzini
2015-08-15 16:19 ` Mike Stump
2015-08-29 15:45 ` Kai Tietz

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).