[comp.os.minix] C compiler problems

KJBSF%SLACVM.BITNET@wiscvm.wisc.edu (07/20/87)

Date: 20 July 1987, 11:13:53 PST
From: Kevin J. Burnett          x3330                KJBSF    at SLACVM
To:   INFO-MINIX at UDEL.EDU
Subject: C compiler problems

I seem to be having problems with the minix C compiler...
'cpp' through 'opt' seem to work fine, but it gets to 'cg' things don't
work too well. 'cg' complains of something like "Bad word size" and stops.

Does anybody know what the problem could be?

dick@hcx1.SSD.HARRIS.COM (07/22/87)

  I ran into the same problem.  I solved it by removing some of the
changes to cc.  Specifically, 

67,69d67
< /* object sizes */
< char *V_FLAG = "-Vs2.2w2.2i2.2l4.2f4.2d8.2p2.2";
< 

254d253
< 				append(call1, V_FLAG);
274d272
< 			append(call, V_FLAG);

This -V flag is apparently very important to /lib/cem (at least in the
distributed version).   The same patch file also introduces a -L flag
for cem which cause it to print an annoying diagnostic, but otherwise
working and producing identical code.

Perhaps someone with documentation on the compilers could enlighten us
on the meaning of these flags.

-------------------------
Dick Reynolds (hcx1!dick)
Manager, OS Development
Harris Computer Systems 
Fort Lauderdale, Florida

schmitz@uiucdcsb.cs.uiuc.edu (07/22/87)

I had exactly the same problem.  In the original 1.1 compiler driver an
argument was sent which defined various word sizes to the cg.  To see how
to fix this, run the 1.1 driver in verbose mode to see the flags passed to
cg, then modify the 1.2 driver to also pass those flags.  It's a very 
simple fix, but if anyone has trouble, I'll send the details.


+=============================================================================+
|	Michael Schmitz University of Illinois	 Dept. of CS (217) 333-6680   |
|									      |
|       arpa		schmitz@b.cs.uiuc.edu                    	      |
|       csnet		schmitz@uiuc.csnet				      |
|       usenet		ihnp4!uiucdcs!schmitz				      |
+=============================================================================+

KJBSF%SLACVM.BITNET@wiscvm.wisc.edu (07/24/87)

Date: 24 July 1987, 08:41:37 PST
From: Kevin J. Burnett          x3330                KJBSF    at SLACVM
To:   INFO-MINIX at UDEL.EDU
Subject: Re: C compiler problems

In-Reply-To: INFO-MINIX AT UDEL.EDU -- 07/23/87 20:55

The '>' lines are schmitz@b.cs.uiuc.edu:
>I had exactly the same problem.  In the original 1.1 compiler driver an
>argument was sent which defined various word sizes to the cg.  To see how
>to fix this, run the 1.1 driver in verbose mode to see the flags passed to
>cg, then modify the 1.2 driver to also pass those flags.  It's a very
>simple fix, but if anyone has trouble, I'll send the details.
Thanks for the response, but I am running 1.1, not 1.2... I haven't been
able to get a 1.2 running because the C compiler don't work...
---
Kevin J. Burnett
KJBSF%SLACVM.BITNET@Forsythe.Stanford.EDU
Santa Clara University '88

erikb@cs.vu.nl (Erik Baalbergen) (08/14/87)

A few words about the C compiler problems reported recently in this newsgroup.
Note: version 1.2 of the compiler is not yet, but soon will be available.
Andy will post an announcement when it is ready.
This article also contains lists of options available to both 1.1 and 1.2 cc.

> From: john@moncol.UUCP (John Ruschmeyer)
> 1) What does the undocumented -O flag do?
As John already indicated, cc passes the additional argument "-p4" to
cg, which causes cg, the actual code generator, to have a better look at
the intermediate code, in order to produce better code. This option does
not have any effect on the code produced by the 1.1 compiler, but only slows
down cg.

> 2) .. 'cc' does not pass a copy of the -Tdir argument along to 'asld'...
This is a bug in 1.1 cc, fixed in 1.2 cc.

> From: KJBSF%SLACVM.BITNET@wiscvm.wisc.edu (Kevin J. Burnett)
> ... 'cg' complains of something like "Bad word size" and stops.
and
> From: dick@hcxl.SSD.HARRIS.COM
> ... Perhaps someone [] could enlighten us on the meaning of these flags.
The problem is that cc, after applying the diffs as they occured in the 1.2
diff listing, no longer passes the -V... option to cem, which is not desired.
1.2 cc does not cooperate with the 1.1 cem, because the 1.1 cem still needs
-V..., which is an indication to use the word and pointer sizes as indicated
by "-Vs2.2w2.2i2.2l4.2f4.2d8.2p2.2." The reason for cem having the -V option
is that cem originally is a cross-compiler, able to produce intermediate
code for various target machines with various sizes for shorts, words, longs,
floats, etc. The 1.1 cem uses default sizes (used when no -V is specified)
which differ from the ones needed for Minix.  The 1.2 cem (in which many
other bugs reported in this newsgroup have been fixed!) uses the Minix
sizes as default target sizes, so there is no longer need for the -V option.
The 1.2 cc does not hand the -V option to your 1.1 cem which causes cem
to produce code for a 4-byte word machine, which code the Minix cg cannot
handle. The solution to this inconvenience is already given by
Dick Reynolds: just remove some of the changes in cc, related to V_FLAG.

> From: dick@hcxl.SSD.HARRIS.COM
> ... -L flag for cem
The annoying diagnostics also results from the incompatibility between
1.2 cc and 1.1 cem. The "-L" is passed to cem to prevent cem from producing
some means of profiling code.

> [various complaints about large and slow code produced by the compiler]
The 1.2 compiler produces better code. The code generated by 1.2 cg is
faster and smaller than that produced by 1.1 cg,
due to the fact that local variables can now be placed in registers.

> From: news@santra.UUCP (news)
> Subject: Bug in cc => fix for diff
> ...  Minix cc
> gets confused of the comparison to '\377' and produces code
> to compare *16-bit* memory area against this pattern and newer
> succeeds.  This is probably a bug in cc ?
Yes. Cem distinguishes between signed and unsigned characters, but takes
'signed' as default. 1.1 cem, however, sees '\377' as unsigned.
Consider the following interesting program
	main()
	{
		char p = '\377';

		printf("%d %d\n", p, '\377');
	}
Compiled with the 1.1 compiler, this produces a program that prints
	-1 255
which is obviously wrong. The output should be (and 1.2 does!)
	-1 -1

So the fix for diff is needed only for compiling under 1.1, not for other
compilers.


###################### options for 1.1 cc ########################
option		passed to(how)	meaning
-Dx		cpp		same as -Dx=
-Dx=y		cpp		define macro x with replacement y
-F		-		don't run cpp and cem simultaneously, use
				file for intermediate code
-Idir		cpp		append dir to list of directories to
				search for #include files
-LIB		opt(-L)		produce a library module
-L		-		erroneously causes -v to be activated
-O		cg(-p4)		try to do some optimizations; in practice
				this options has no effect on the resulting
				code, but causes cg to produce code very slowly
-R		cem		warnings for non-Kernighan-and-Ritchie code
-S		-		compile up to .s file
-Tdir		cem		use dir for storing temporary files
-Ux		cpp		undefine (predefined) macro x
-c		-		suppress linking (same effect as -S)
-lx		asld		use library /usr/lib/libx.a
-o prog		asld		put executable ("a.out") file in prog
-p		cem		produce calls to procentry and procexit upon
				entering and exiting a procedure. Both routines
				are supposed to accept the procedure's name
				as a string. This option is used in ACK for
				profiling services, but in Minix, the programmer
				has to supply these routines himself
-v		-		print what's going on
-w		cem		suppress warnings

Other options, including -i, are passed to asld. However, 1.1 asld does not
support separate I/D. The 1.2 asld does.
The use of options -O, -L and -p with 1.1 cc is not recommended. 
1.1 cc invokes cem  with the following options: 

-L	do not produce any EM line and file trace instructions (fil/lin)
-Vs2.2w2.2i2.2l4.2f4.2d8.2p2.2
	produce code for an environment with the following characteristics
			size	alignment
	short		2	2
	word/integer	2	2
	long		4	2
	float		4	2
	double		4	2
	pointer		2	2

	The float and double indications are misleading since floating
	point is not supported. Cem, however, is almost able to handle floating
	point; only no libraries are available.

###################### options for 1.2 cc ########################
option		passed to(how)	meaning
-Dx		cpp		same as -Dx=
-Dx=y		cpp		define macro x with replacement y
-F		-		don't run cpp and cem simultaneously, use
				a file for intermediate code
-Idir		cpp		append dir to list of directories to
				search for #include files
-LIB		opt(-L)		produce a library module
-O		cg(-p4)		try to do some optimizations during code
				generation
-R		cem		warnings for non-Kernighan-and-Ritchie code
-S		-		compile up to .s file
-Tdir		also: cem,asld	use dir for storing temporary and all
				intermediate code files
-Ux		cpp		undefine (predefined) macro x
-c		-		suppress linking (same effect as -S)
-i		asld		produce a separate I/D program
-lx		asld		use library /usr/lib/libx.a
-o prog		asld		put executable ("a.out") file in prog
-p		cem		produce calls to procentry and procexit upon
				entering and exiting a procedure. Both routines
				are supposed to accept the procedure's name
				as a string. This option is used in ACK for
				profiling services, but in Minix, the programmer
				has to supply these routines himself.
-v		-		print what's going on
-w		cem		suppress warnings

Other options are passed to, but not interpreted by asld.
1.2 cc invokes cem using the "-L" flag to indicate cem not to produce line
and file trace code. The trace facility is useful in ACK but not in Minix.
Other options (e.g. -V...) to 1.2 cem proper are ignored, while a warning
is given. 1.2 cem accepts a -N options indicating that code generation
takes place in a somewhat different form, which generally is not accepted
by the rest of the compiler pipeline. The use of -N is not recommended.

---------------------------------------
Erik H. Baalbergen     <erikb@cs.vu.nl>
Dept. of Mathematics & Computer Science
Vrije Universiteit (tel +31 20 5488080)
P.O. Box 7161 Amsterdam The Netherlands
---------------------------------------