public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: u-xsnf@aetey.se
To: Richard Henderson <rth@redhat.com>
Cc: libffi-discuss@sourceware.org
Subject: Re: showstopper bug on x86 (Re: libffi does not follow proper ABI on ia32)
Date: Tue, 06 Jan 2015 10:21:00 -0000	[thread overview]
Message-ID: <20150106102102.GF14316@example.net> (raw)
In-Reply-To: <54AB036B.4030104@redhat.com>

Hello Richard,

On Mon, Jan 05, 2015 at 01:34:35PM -0800, Richard Henderson wrote:
> On 01/03/2015 02:14 AM, u-xsnf@aetey.se wrote:
> > Is it hard to make libffi implementation compatible with cdecl?
> > The calling conventions is exactly what the library is competent about. 
> 
> I guess it wasn't that hard.
> 
> See https://github.com/atgreen/libffi/pull/165

Thanks a lot.

I wonder which version of pcc you were testing with, the comments
about the pcc behaviour indicate that the version used was either
too old or its install was broken (pcc used to ship redundant and
in practice harmful startup files, not actually being a part of the compiler).

To avoid misunderstanding let me list the positive points:

"Apparently, PCC doesn't support the fastcall calling convention.
Nor does it issue a warning or error for the attribute that it
does not understand."

pcc complains/warns about unsupported attributes:

$ cat a.c
__attribute__((fastcall)) int fastc(int i) {
  return i;
}
$ pcc -c a.c
a.c:1: warning: unsupported attribute `fastcall'
$ pcc --version
pcc 1.2.0.DEVEL 20141228 for i486-pc-linux-gnu

This is the current version of pcc, mostly the same as the newly released
pcc-1.1.0 (2014-12-10) with the reservation that I did not test the latter.

"Note that it also, apparently, doesn't support shared libraries. Test
cases linked against the pcc-built shared library segfault inside ld.so
before reaching main."

This is quite doubtless the result of using the broken startup files
regrettably used to be included in the pcc-libs package.
Shared libraries do work, in fact this very MUA is running shared
libraries compiled with pcc.

Now to the point:

I tested to apply
 https://github.com/rth7680/libffi/commit/3fa5d70cbb18b39a5e44f1c7984dedf73446bf6c

and it now passes the majority of the tests (2119) !

306 of the still failing tests try to test FASTCALL and THISCALL which
is not expected to pass. At least some of the remaining 210 ones quite
probably depend on a bug in pcc which was independently discovered this
week and fixed ("Float complex struct return were not dealt with as it
should in the PIC case.").

Moreover, at about the same time pcc seems to have got support for fastcall (!)

(Nevertheless I would argue that avoiding hardcoded reliance on fastcall
in libffi on x86 is good, placing less constraints on the compilers to
be used with it)

I am going to make the next round with the newest pcc and see how many
test failures remain.

Thanks again,
Rune

  reply	other threads:[~2015-01-06 10:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22 19:36 libffi does not follow proper ABI on ia32 (?) u-xsnf
2014-12-24 13:58 ` showstopper bug on x86 (Re: libffi does not follow proper ABI on ia32) u-xsnf
2014-12-24 16:31   ` Richard Henderson
2014-12-24 21:35     ` u-xsnf
2014-12-31 16:12     ` Richard Henderson
2015-01-02 18:57       ` u-xsnf
2015-01-02 22:20         ` Richard Henderson
2015-01-03 10:15           ` u-xsnf
2015-01-03 10:36             ` u-xsnf
2015-01-05 21:34             ` Richard Henderson
2015-01-06 10:21               ` u-xsnf [this message]
2015-01-06 12:46                 ` libffi vs pcc (was: showstopper bug on x86 / " u-xsnf
2015-01-06 16:20                 ` showstopper bug on x86 (Re: " Richard Henderson
2015-01-06 16:52                   ` u-xsnf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150106102102.GF14316@example.net \
    --to=u-xsnf@aetey.se \
    --cc=libffi-discuss@sourceware.org \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).