diff mbox

Remove pointless -fPIC warning on Windows platforms

Message ID 1439591077-2642-1-git-send-email-bonzini@gnu.org
State New
Headers show

Commit Message

Paolo Bonzini Aug. 14, 2015, 10:24 p.m. UTC
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.

Comments

Mike Stump Aug. 15, 2015, 3:43 p.m. UTC | #1
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.
Kai Tietz Aug. 29, 2015, 3:26 p.m. UTC | #2
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
diff mbox

Patch

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