NeXT Computers Forum Index NeXT Computers
www.NeXTComputers.org
 
Log in to check your private messagesLog in to check your private messages

Log inLog in  RegisterRegister


Profile  Search  Memberlist  FAQ  Usergroups
pcc (portable compiler)

 
Post new topic   Reply to topic    NeXT Computers Forum Index -> Porting New Software
View previous topic :: View next topic  
Author Message
neozeed



Joined: 15 Apr 2006
Posts: 716
Location: Hong Kong

PostPosted: Wed Jun 18, 2008 2:13 pm    Post subject: pcc (portable compiler) Reply with quote

I've had some minor/major sucess with this package!

The good news is that I've managed to hand walk thru bulding a hello world!

The bad news is that I have a bit more work to do, but I don't think it's impossible.

Anyways with pcc-0.99 they say it's basically C99 compliant!

Here is an example of it failing to build something:

Code:
bash-2.01# cc/pcc -S  -v j.c
pcc 0.9.9 for i386-pc-nextstep, root@albinonext Wed Jun 18 14:44:36 GMT-0600 200
8
/usr/local/libexec/pcc-cpp -v -D__PCC__=0 -D__PCC_MINOR__=9 -D__PCC_MINORMINOR__
=9 -D__NEXT__ -I/usr/local/include/pcc -D__i386__ -D__LITTLE_ENDIAN__ -S /usr/in
clude/ j.c /tmp/ctm.009979
cpp: pcc 0.9.9 for i386-pc-nextstep, root@albinonext Wed Jun 18 14:44:36 GMT-060
0 2008
/usr/local/libexec/pcc-ccom -v /tmp/ctm.009979 j.s
ccom: pcc 0.9.9 for i386-pc-nextstep, root@albinonext Wed Jun 18 14:44:36 GMT-06
00 2008
bash-2.01# cc/pcc -S j.c
bash-2.01# cat j.s
        .text
        .align 4
        .globl main
main:
        pushl %ebp
        movl %esp,%ebp
.L11:
.L13:
.L12:
        leave
        ret
bash-2.01# /lib/i386/as -arch i386 -o j.o j.s
bash-2.01# ld -arch i386 -o j -NEXTSTEP-deployment-target 3.2 -lcrt0.o -L/lib/i
386 -L/lib/i386 j.o -lsys_s
ld: Undefined symbols:
_main


Now the fix is pretty easy... it's missing the _'s from main. Here is something more complix:



Code:
        .section .rodata
.L15:
        .ascii "hi\n\0"
        .text
        .align 4
        .globl main
main:
        pushl %ebp
        movl %esp,%ebp
.L11:
.L13:
        pushl $.L15
        call printf
        addl $4, %esp
.L12:
        leave
        ret



adding some comma's and _'s gives us this:



Code:
        .section, .rodata
.L15:
        .ascii "hi\n\0"
        .text
        .align 4
        .globl _main
_main:
        pushl %ebp
        movl %esp,%ebp
.L11:
.L13:
        pushl $.L15
        call _printf
        addl $4, %esp
.L12:
        leave
        ret


And finally:

Code:
bash-2.01# /lib/i386/as -arch i386 -o j.o j.s
bash-2.01# ld -arch i386 -o j -NEXTSTEP-deployment-target 3.2 -lcrt0.o -L/lib/i386 -L/lib/i386 j.o -lsys_s
bash-2.01# ./j
hi
bash-2.01#


I know there is more to do, but I've hand walked it thru a hello world!
And for the other archs, pcc supports:

hppa m16c nova powerpc vax
arm i386 mips pdp10 sparc64

So this could be a "good thing" for either the sparc/hppa NeXTSTEP as I recall that only the gcc 2.5.8 was about all that ran.
_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
cubist



Joined: 20 Sep 2007
Posts: 247
Location: Cambridge, MA

PostPosted: Wed Jun 18, 2008 9:10 pm    Post subject: Re: pcc (portable compiler) Reply with quote

neozeed wrote:

I know there is more to do, but I've hand walked it thru a hello world!

Reading the builds, it looks like it uses the original 'as', 'ld' and libraries, is that correct? No calling convention problems on x86?
Back to top
View user's profile Send private message
neozeed



Joined: 15 Apr 2006
Posts: 716
Location: Hong Kong

PostPosted: Wed Jun 18, 2008 9:21 pm    Post subject: Re: pcc (portable compiler) Reply with quote

cubist wrote:
neozeed wrote:

I know there is more to do, but I've hand walked it thru a hello world!

Reading the builds, it looks like it uses the original 'as', 'ld' and libraries, is that correct? No calling convention problems on x86?


Yeah I've actually never built a next compatable binutils... I've tried a few times, and it never works.. I suspect I need the binutils from next/apple to get something to work... I should look again to rhapsody or even darwin for those....

But yes I was able to call printf from main.

It does have some really good viable hopes.
_________________
# include <wittycomment.h>
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    NeXT Computers Forum Index -> Porting New Software All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2017 phpBB Group