9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: forsyth@plan9.cs.york.ac.uk forsyth@plan9.cs.york.ac.uk
Subject: kc cross-compiler bug on PC
Date: Tue, 23 Jan 1996 18:50:51 -0500	[thread overview]
Message-ID: <19960123235051.TFyWtv-racV4j3jT2ydNSqhCjz33xZqD243lQJxMrKU@z> (raw)

given the following program as p.c:

------
typedef struct Point Point;
typedef struct Rectangle Rectangle;
struct	Point
{
	int	x;
	int	y;
};

struct Rectangle
{
	Point min;
	Point max;
};
#define	Pt(x, y)		((Point){(x), (y)})
#define	Rect(x1, y1, x2, y2)	((Rectangle){Pt(x1, y1), Pt(x2, y2)})
#define	Rpt(p1, p2)		((Rectangle){(p1), (p2)})
void
main(int argc, char **argv)
{
	Rectangle r;

	r = Rect(0, 0, 1152, 900);
	print("%d %d %d %d\n", r.min.x, r.min.y, r.max.x, r.max.y);
}
------

on a 486, compile with kc/kl and interpret with ki:

pc% kc t.c
pc% kc p.c
p.c:23 function args not checked: print
pc% kl p.k -lc
pc% ki k.out
ki
:r
900 0 0 0
exits(main)
stopped at #3250 _exits+c

wrong.

now, on a 68020 [probably any non-PC, including a sparc!], do the same:

68k% kc p.c
p.c:23 function args not checked: print
68k% kl p.k -lc
68k% ki k.out
ki
:r
0 0 1152 900
exits(main)
stopped at #3250 _exits+c

right!

if you compare the -S output of kc on both machines, the difference
is obvious.

this bug prevents the correct cross-compilation for a Sparc from a PC
of the sparc kernel, graphics programs, and anything else that uses
the (MUMBLE){a,b,c} extension to expressions.
those two architectures deserve each other, i admit.

the following change to kc seems to fix that one, but i don't know my way round kc
well enough to make guarantees about the fix, or about any related problems:

vortex% diff old /sys/src/cmd/kc/cgen.c
880c880
< 			nod4.xoffset = t->offset;
---
> 			nod4.vconst = t->offset;






                 reply	other threads:[~1996-01-23 23:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=19960123235051.TFyWtv-racV4j3jT2ydNSqhCjz33xZqD243lQJxMrKU@z \
    --to=forsyth@plan9.cs.york.ac.uk \
    /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 NNTP newsgroup(s).