* Sun C code compiled on OSF/1??
@ 1995-07-20 4:00 Andy C. Hsia
1995-07-20 4:00 ` Mike Iglesias
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andy C. Hsia @ 1995-07-20 4:00 UTC (permalink / raw)
I'm trying to compile C code written for Sun computer on our Alpha 3000/600
running OSF/1 2.0. At first, I got a few errors like the following:
/usr/lib/cmplrs/cc/cfe: Error: t3m..c, line 141: redeclaration of
'random'; previous declaration at line 245 in file '/usr/include/stdlib.h'
long random();
-----^
/usr/lib/cmplrs/cc/cfe: Error: t3m..c, line 141: Incompatible
function return type for this function
long random();
-----------^
/usr/lib/cmplrs/cc/cfe: Error: t3m.c, line 145: redeclaration of
'calloc'; previous declaration at line 145 in file '/usr/include/stdlib.h'
extern char *calloc();
-------------^
/usr/lib/cmplrs/cc/cfe: Error: t3m.c, line 145: Incompatible
function return type for this function
extern char *calloc();
-------------------^
So I commented out the offending lines. The code compiled with no
warnings or errors, but doesn't run properly. When run, the program
should say, "Starting analysis" and "The volume fraction is..." My
program, however, just says "Starting analysis," and doesn't go on. A 'ps
ux' shows that the program is utilizing 99% of the CPU, but no output. A
colleague successfully compiled (and run) the code on a Sun using ANSI C
(acc on Sun). I successfully compiled (and run) the code on Ultrix 4.2
(using cc -O3 t3m.c -lm).
In light of the recent incident regarding reading README files first,
etc, let me say that I have read all the documentation that came with the
code, I've tried many minor modifications to the code, and I'm not an
experienced cc user. If I had to guess, I'd say that simply commenting
out the offending lines caused the variables to be defined as the wrong
type, therefore doesn't solve my problem. My question is why doesn't the
successfully compiled program run properly and what should I look for in
fixing it? Thanks
andy
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Sun C code compiled on OSF/1??
1995-07-20 4:00 Sun C code compiled on OSF/1?? Andy C. Hsia
@ 1995-07-20 4:00 ` Mike Iglesias
1995-07-21 4:00 ` Eric Osborne
1995-07-21 4:00 ` Mark Charette
2 siblings, 0 replies; 4+ messages in thread
From: Mike Iglesias @ 1995-07-20 4:00 UTC (permalink / raw)
In article <3umh4p$amh@agate.berkeley.edu>,
Andy C. Hsia <hsiacc@prometheus.ME.Berkeley.EDU> wrote:
>In light of the recent incident regarding reading README files first,
>etc, let me say that I have read all the documentation that came with the
>code, I've tried many minor modifications to the code, and I'm not an
>experienced cc user. If I had to guess, I'd say that simply commenting
>out the offending lines caused the variables to be defined as the wrong
>type, therefore doesn't solve my problem. My question is why doesn't the
>successfully compiled program run properly and what should I look for in
>fixing it? Thanks
There are many things that can cause problems, the two most common
I've seen are assuming that a pointer or a long is the same size as
an int. Pointers and longs are 64 bits on Alphas, so trying to stuff
either of those into an int is going to cause problems (usually a
segmentation fault). Using "lint -Q" may help here; see the lint man
page for more details.
You could try running the program under dbx, and after you see it looping,
hit ^C and type "where". This will show you the calling stack so you
have an idea which routine the program is currently in.
If you can find someone who knows their way around C and dbx that would
help you find the problem.
--
Mike Iglesias Internet: iglesias@draco.acs.uci.edu
University of California, Irvine phone: (714) 824-6926
Office of Academic Computing FAX: (714) 824-2069
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Sun C code compiled on OSF/1??
1995-07-20 4:00 Sun C code compiled on OSF/1?? Andy C. Hsia
1995-07-20 4:00 ` Mike Iglesias
@ 1995-07-21 4:00 ` Eric Osborne
1995-07-21 4:00 ` Mark Charette
2 siblings, 0 replies; 4+ messages in thread
From: Eric Osborne @ 1995-07-21 4:00 UTC (permalink / raw)
In article <3umh4p$amh@agate.berkeley.edu> hsiacc@prometheus.ME.Berkeley.EDU (Andy C. Hsia) writes:
>
>I'm trying to compile C code written for Sun computer on our Alpha 3000/600
>running OSF/1 2.0. At first, I got a few errors like the following:
>
>/usr/lib/cmplrs/cc/cfe: Error: t3m..c, line 141: redeclaration of
>'random'; previous declaration at line 245 in file '/usr/include/stdlib.h'
> long random();
> -----^
>/usr/lib/cmplrs/cc/cfe: Error: t3m..c, line 141: Incompatible
>function return type for this function
> long random();
> -----------^
>/usr/lib/cmplrs/cc/cfe: Error: t3m.c, line 145: redeclaration of
>'calloc'; previous declaration at line 145 in file '/usr/include/stdlib.h'
> extern char *calloc();
> -------------^
>/usr/lib/cmplrs/cc/cfe: Error: t3m.c, line 145: Incompatible
>function return type for this function
> extern char *calloc();
> -------------------^
>
These types of errors are common, in my experience, when porting code from
Sun machines. The Digital compilers enforce much tighter syntax checking than
at least some Sun compilers.
>
>So I commented out the offending lines. The code compiled with no
This is the correct thing to do. When you say you commented them out, I assume
you commented them in YOUR code, but not in the system header files. Commenting
them out in the header files would be very, very bad :-) .
>warnings or errors, but doesn't run properly. When run, the program
>should say, "Starting analysis" and "The volume fraction is..." My
>program, however, just says "Starting analysis," and doesn't go on. A 'ps
>ux' shows that the program is utilizing 99% of the CPU, but no output. A
>colleague successfully compiled (and run) the code on a Sun using ANSI C
>(acc on Sun). I successfully compiled (and run) the code on Ultrix 4.2
>(using cc -O3 t3m.c -lm).
>
The first thing to check for is word size dependencies that are breaking
on the 64 bit Alpha architecture. You can use the 'lint -Q' command to find
and identify many/most of these. Word size dependencies, especially the
notion that you can put the contents of a pointer into an int, or that an
int and a long are the same size, are the single most common cause of errors
when porting code to Alpha machine. The C language definition essentially
states only that sizeof(short) <= sizeof(int) <= sizeof(long). Unfortunately,
most current architectures use 32 bits for the size of an int, long, and
pointer. That's been the case for so long that a lot of code takes it for
granted. Such code is broken, but since it will compile and run on about
everything except Alpha, most people immediately assume that something is
wrong with the Alpha system or compilers.
Word ordering and alignment errors are the other big bugaboo. Since you were
able to compile and run on Ultrix 4.2, the byte order issue probably isn't
getting you here.
If you're running on one of the newer versions of Digital UNIX, you should
be able to compile your code with the -g option, then run it. When it goes
into the heavy CPU usage mode, you can use dbx to attach the process and
determine where the code is spending it's time. You can also run the program
from inside dbx.
In terms of general advice, that's about all I can offer without seeing the
code in question. You might also check Digital's Web page -
http://www.digital.com - somewhere in there is a reference to a PostScript
file which contains a very nice guide on porting SunOS applications to
Digital UNIX (I think the guide actually still says DEC OSF/1).
Hope this helps.
Eric Osborne, who has ported a couple of million line of code to Alpha.
--
Eric D. Osborne (614) 292-8018 |The Ohio State University
edo@cis.ohio-state.edu |Department of Computer and Information Science
MIME Accepted |2015 Neil Ave. Columbus OH USA 43210
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Sun C code compiled on OSF/1??
1995-07-20 4:00 Sun C code compiled on OSF/1?? Andy C. Hsia
1995-07-20 4:00 ` Mike Iglesias
1995-07-21 4:00 ` Eric Osborne
@ 1995-07-21 4:00 ` Mark Charette
2 siblings, 0 replies; 4+ messages in thread
From: Mark Charette @ 1995-07-21 4:00 UTC (permalink / raw)
Andy C. Hsia (hsiacc@prometheus.ME.Berkeley.EDU) wrote:
: I'm trying to compile C code written for Sun computer on our Alpha 3000/600
: running OSF/1 2.0. At first, I got a few errors like the following:
: /usr/lib/cmplrs/cc/cfe: Error: t3m..c, line 141: redeclaration of
: 'random'; previous declaration at line 245 in file '/usr/include/stdlib.h'
: long random();
: -----^
...
: So I commented out the offending lines. The code compiled with no
: warnings or errors, but doesn't run properly. When run, the program
: should say, "Starting analysis" and "The volume fraction is..." My
: program, however, just says "Starting analysis," and doesn't go on. A 'ps
: ux' shows that the program is utilizing 99% of the CPU, but no output. A
Chances are that commenting out the offending lines (such as long random();)
haven't caused any errors, since the correct prototype is in the system
include files (the reason you were getting the errors). However, fixing the
problem of longs and pointers being 8 bytes (64 bits) in length now rears its
head.
Try cc -migrate and check and correct any warnings
Use lint -Q and correct any pointer/integer mismatches
grep for long & make sure that the variables REALLY should be long, not an int.
Make sure every long & pointer passed as arguments are accepted as long &
pointer.
Put protoypes in for all your codes.
There's more but this should get you pointed in the right direction.
--
Mark Charette charette@mika.com
MIKA Systems, Inc
17197 N. Laurel Park Dr Suite 115
Livonia, MI 48152
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1995-07-21 4:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-07-20 4:00 Sun C code compiled on OSF/1?? Andy C. Hsia
1995-07-20 4:00 ` Mike Iglesias
1995-07-21 4:00 ` Eric Osborne
1995-07-21 4:00 ` Mark Charette
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox