This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] [i386] PR 81850 Don't ignore -mabi=sysv on Cygwin/MinGW
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Daniel Santos <daniel dot santos at pobox dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <hubicka at ucw dot cz>, Andreas Schwab <schwab at suse dot de>
- Date: Wed, 23 Aug 2017 08:12:57 +0200
- Subject: Re: [PATCH] [i386] PR 81850 Don't ignore -mabi=sysv on Cygwin/MinGW
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4YXt2Oynx=bGumyFjaVDhL=QNboqVQdR1DCwA+YWPP9XQ@mail.gmail.com> <20170822194753.5405-1-daniel.santos@pobox.com> <CAFULd4ZwB0kL_Yn25TtM3=YLfO3LW19s6ynPTeiXqV0kCnTkLg@mail.gmail.com> <3c4f395c-132f-1c2b-ef5a-04da60c9c050@pobox.com>
On Wed, Aug 23, 2017 at 7:23 AM, Daniel Santos <daniel.santos@pobox.com> wrote:
> On 08/22/2017 03:00 PM, Uros Bizjak wrote:
>> On Tue, Aug 22, 2017 at 9:47 PM, Daniel Santos <daniel.santos@pobox.com> wrote:
>>>> Please add UNKNOWN_ABI to the enum and initialize -mabi in i386.opt to
>>>> UNKNOWN_ABI.
>>> It would seem to me that UNSPECIFIED_ABI would be a better value name.
>>>
>>> Also, I don't really understand what opts_set and opts are, except that I had
>>> guessed opts_set is what the user asked for (or didn't ask for) and opts is
>>> what we're going to actually use. Am I close?
>> Yes. opts_set is a flag that user specified an option at the command line.
>>
>> However, I fail to see what is the problem. If nothing was specified,
>> then opts->x_ix86_abi is set to DEFAULT_ABI.
>
> That is not what is happening. If -mabi=sysv is specified, then the
> test (!opts_set->x_ix86_abi) is true since the value of SYSV_ABI is
> zero. When that is evaluated as true, then the abi is set to
> DEFAULT_ABI, which on Windows is MS_ABI, thus ignoring the command line
> option.
Let's use the following patch:
--cut here--
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 3c82ae64f4f2..f8590f663285 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -5682,7 +5682,7 @@ ix86_option_override_internal (bool main_args_p,
? PMODE_DI : PMODE_SI;
if (!opts_set->x_ix86_abi)
- opts->x_ix86_abi = DEFAULT_ABI;
+ printf ("Using default ABI\n"), opts->x_ix86_abi = DEFAULT_ABI;
/* For targets using ms ABI enable ms-extensions, if not
explicit turned off. For non-ms ABI we turn off this
--cut here--
$ ./cc1 -O2 -quiet hello.c
Using default ABI
$ ./cc1 -O2 -mabi=sysv -quiet hello.c
$
$ ./cc1 -O2 -mabi=sysv -quiet hello.c
$
Again, opts_set is set to true when the option is specified on the
command line, it has nothing to do with the value of the option.
> I'm guessing that if we don't specify an Init() option then it will
> default to zero? We just need a valid way to differentiate when
> -mabi=sysv has been passed from when nothing has been passed.
Yes, it defaults to zero, but since we live in c++ world nowadays, we
can't initialize enum with integer zero...
Uros.