unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Ken Raeburn <raeburn@raeburn.org>
To: guile-devel <guile-devel@gnu.org>
Subject: Re: more compilation failures: -DSCM_DEBUG_TYPING_STRICTNESS=2
Date: Wed, 18 Nov 2009 00:52:03 -0500	[thread overview]
Message-ID: <F27E32FE-563A-4160-A273-9DBA04B5E87F@raeburn.org> (raw)
In-Reply-To: <m3zl8ubssg.fsf@pobox.com>

Picking up this thread again...

I've run some basic tests, and it looks like setting  
SCM_DEBUG_TYPING_STRICTNESS to 0 (which causes SCM to be defined as an  
integer type) also fails, though not quite as messily as setting it to  
2.

On Sep 16, 2009, at 15:20, Andy Wingo wrote:
> I don't see it as such a big problem to play "fast and loose" with
> types, honestly... one day we'll have native compilation, and it's all
> just words there.

(Sorry, as a former compiler guy, I find my "portability" buttons  
being pushed here....)

Words with what representation?  Take a look at SCM2PTR and  
PTR2SCM ... for the old Cray systems.  As the comment above the  
definition indicates, the machine has an unusual pointer  
representation.  Still compliant with the C spec, as far as I know;  
just not what you'd expect from most machines.

We've got code using SCM2PTR and PTR2SCM in some places.  We've got  
code simply casting values in other places.  Unless the uses are  
carefully matched up to do the corresponding conversions in both  
directions, we're practically guaranteeing that the code will never be  
portable to the old Cray.  Even without that, I'm skeptical whether a  
Cray port of BDW-GC would be able to process our SCM objects there,  
since apparently our SCM objects are represented rather differently  
from native pointers.

We also cast function pointer types in places.  Pointers are not  
required to all have the same representation, nor to be passed or  
returned in function calls the same way.  There are also ABIs where  
pointers are passed around one way, and integers another way.  Take  
the address of a function with one kind of argument, and call it  
through a pointer to a function type with a different argument, and  
the calling sequence may not match how the function attempts to access  
its arguments.

Among modern general-purpose computers, the behavior's going to be  
pretty consistent -- to some people, "modern general-purpose computer"  
means x86 only, *maybe* one or possibly two other architectures,  
definitely a flat address space and uniform pointer representations  
the size of some standard integer type -- but try porting to older  
systems or some embedded processors, and some of the assumptions start  
to fail.  Do we even have a good idea what the assumptions we're  
making, beyond the basic requirements for a compliant C  
implementation, are?

I know it's tempting to ignore older systems and only worry about  
modern ones, but what of the people who might want to use Guile in  
other packages?  If we limit Guile's portability, we're also forcing  
that limitation on any such other packages.  One of my nagging  
concerns, which I have avoided investigating thus far, is whether  
Guile (and the BDW-GC library) will support all the platforms that  
Emacs does.  Do they support s390, sh3, or vax systems?  How about AIX  
4.2?  All of those are listed in the configure script for Emacs.  If  
someone revives the VMS port of Emacs, will they be able to port Guile  
and libgc (and libunistring and ...)?

The advantage of the STRICTNESS=2 code is that it forces additional  
discipline; simple casts can't paper over all the conversions.  It may  
seem like an annoyance to treat "SCM" and "void *" and "int" as  
requiring explicit conversions, but if someday someone tries porting  
to a platform like the old Cray, C code written with the assumption  
that "it's all just words (and we know what the representations look  
like)" may cause them no end of headaches.  Such an assumption *is*  
valid when we start looking at code generation for specific  
architectures.  But despite any cracks about C being a "high level  
assembly language", it *is* more abstract and such assumptions don't  
hold true for C in the general case.

If all we were discussing was whether the "guile" program should be  
available on older platforms, that would be one thing.  But we're  
talking about the extension library we want to promote for widespread  
use, in GNU programs and presumably elsewhere.  Should we really tell  
people, "you have to choose between portability to these old or  
uncommon platforms, and being able to use this extension library"?   
Especially if they're already supporting old platforms and not yet  
supporting Guile?

In my not-so-humble opinion, the onus should be on us to keep the  
Guile library as portable as possible (and push implementors of the  
libraries that libguile depends on in the same direction), and leave  
it to the application writers to decide what they want to do in terms  
of supporting old or unusual platforms, rather than having us impose  
limitations on them.

</soapbox>

I still don't have any specific proposal to make STRICTNESS!=1 work  
throughout our code, but I do expect it would be somewhat intrusive in  
places.  (For example, some macros that do "interesting" things with  
the values they're passed, I'd probably want to change to inline  
functions, at least when BUILDING_LIBGUILE under gcc, so we can do  
type checking of the supplied values, and then add conversion calls or  
casts or whatever as necessary.  The static initialization macros  
would almost certainly need changes.)  So unless I've swayed some of  
the maintainers, I'm not going to spend much more time on it.

In fact, if the general opinion is "screw the unusual platforms, let's  
hard-code the default STRICTNESS=1 case and get rid of the rest so  
people like Ken stop trying to play with it", I'm also willing to do  
the coding for that, too.  But as I've indicated, I do think it's the  
wrong direction....

Ken




  reply	other threads:[~2009-11-18  5:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-01  6:23 more compilation failures: -DSCM_DEBUG_TYPING_STRICTNESS=2 Ken Raeburn
2009-09-01  6:26 ` Ken Raeburn
2009-09-16 19:20   ` Andy Wingo
2009-11-18  5:52     ` Ken Raeburn [this message]
2009-11-18  9:37       ` Ludovic Courtès
2009-11-18 20:40         ` Ken Raeburn
2009-11-18 21:18           ` Andy Wingo
2009-11-18 23:09           ` Ludovic Courtès
2009-09-01 19:47 ` Ludovic Courtès
2009-09-01 22:29   ` Ken Raeburn
2009-09-02  8:08     ` Ludovic Courtès
2009-09-02 18:17       ` Ken Raeburn
2009-09-03 11:48         ` Ludovic Courtès
2009-09-08 23:37       ` Neil Jerram
2009-09-09  1:41         ` Ken Raeburn
  -- strict thread matches above, loose matches on Subject: below --
2009-09-01  4:52 Ken Raeburn

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=F27E32FE-563A-4160-A273-9DBA04B5E87F@raeburn.org \
    --to=raeburn@raeburn.org \
    --cc=guile-devel@gnu.org \
    /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).