PCC on IRIX
#1
PCC on IRIX
I've added pre-eliminary support for PCC on IRIX using the latest CVS versions. it is however, nonfunctional and I'm not sure why. In any case, I wanted to document how easy it was to add it.

pcc, if your arch is supported, requires patching in configure/configure.ac, and a file in os/<osname>/ccconfig.h that contains definitions for things: 

https://github.com/IanHarvey/pcc/blob/ma...ccconfig.h

For now, I can't get MIPSPro to work with it. But I did get it working using GCC 4.8.5, just don't use Bison, it broke on me. Many times. IRIX yacc or byacc should work. 

It builds valid MIPSIV executables:

% file /usr/local/bin/pcc

/usr/local/bin/pcc:    ELF N32 MSB mips-4 dynamic executable MIPS - version 1

However, the compiler itself does not like IRIX's headers:

% /usr/local/bin/pcc -o gettext gettext.c
/usr/include//internal/string_core.h, line 61: Syntax error
/usr/include//internal/string_core.h, line 61: invalid function definition

for example, or:

/usr/local/bin/pcc -c util.c -std=c99
#error This header file is to be used only for c99 mode compilations
error: /usr/local/libexec/cpp terminated with status 1

Additionally, compiling hw.c didn't work... (hello world)

Code:
root@murasaki /tmp % /usr/local/bin/pcc -c hw.c
ld32: FATAL   11 : Object file format error (/tmp/ctm.a42098): unrecognizable format
error: as terminated with status 2
root@murasaki /tmp % /usr/local/bin/pcc -S hw.c
root@murasaki /tmp % ls
hw.c  hw.s
root@murasaki /tmp % more hw.s
        .section .mdebug.abi32
        .previous
        .file "hw.c"
        .text
        .p2align 2
        .align 2
        .globl main
        .ent main
main:
        .frame $fp,16,$ra
        .set noreorder
        .cpload $25     # pseudo-op to load GOT ptr into $25
        .set reorder
        subu $sp,$sp,16
        sw $ra,4($sp)
        sw $fp,($sp)
        move $fp,$sp
        subu $sp,$sp,8
L249:
L253:
        la $a0,L257     # load constant address to reg
        subu $sp,$sp,16 # call (args, result in v0) to scon/sname
        jal printf
        nop
        addiu $sp,$sp,16
        sw $v0,-4($fp)          # store (u)int/(u)long
        nop
        move $v0,$zero  # load 0 to reg
        sw $v0,-8($fp)          # store (u)int/(u)long
        nop
        j L251          # goto label
        nop
        nop
L251:
        lw $v0,-8($fp)  # load (u)int/(u)long to reg
        nop
        addiu $sp,$fp,16
        lw $ra,-12($sp)
        lw $fp,-16($sp)
        jr $ra
        nop
        .section .rodata
        .p2align 0
L257:
        .ascii "Hello World!\0"

My guess, without being an ASM expert, is that it either is not producing correct 32-bit MIPS code for our OS (which is possible, as it may have been designed for embedded MIPS), it's not using valid ASM for the IRIX as. If I feed it into the GCC as:
Code:
root@murasaki /tmp % file a.out
a.out:          ELF N32 MSB mips-4 relocatable MIPS - version 1
root@murasaki /tmp % ./a.out
./a.out: Permission denied.
root@murasaki /tmp % chmod +x a.out
root@murasaki /tmp % ./a.out
./a.out: Exec format error. Binary file not executable.

I suspect that even if that is correct for our dialect of MIPS, we have ABI issues. PCC is a simple compiler, but I'm a novice to stuff like this. 

I've mentioned to Anders Magnusson and the PCC lists to see if I can drum any interest up. It's worth nothing it only uses soft floats for MIPS, however. It'd be nice to get hard float support. 

Clearly, this took me less than 20 mins to port and get this far, so hopefully we can get even further?

Edit: pcc-libs compiles without a hitch - patch the configure and it works.


Attached Files
.tar ccconfig.tar Size: 2 KB  Downloads: 178

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
(This post was last modified: 06-16-2021, 03:44 AM by Raion.)
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
06-16-2021, 03:15 AM


Messages In This Thread
PCC on IRIX - by Raion - 06-16-2021, 03:15 AM
RE: PCC on IRIX - by jpstewart - 06-17-2021, 07:12 PM
RE: PCC on IRIX - by Raion - 06-17-2021, 07:16 PM
RE: PCC on IRIX - by Raion - 06-21-2021, 02:06 AM
RE: PCC on IRIX - by Raion - 07-09-2021, 12:13 AM
RE: PCC on IRIX - by Raion - 07-19-2021, 03:17 PM
RE: PCC on IRIX - by Raion - 07-19-2021, 11:39 PM
RE: PCC on IRIX - by jpstewart - 07-20-2021, 01:15 AM
RE: PCC on IRIX - by Raion - 07-20-2021, 01:20 AM
RE: PCC on IRIX - by jpstewart - 07-20-2021, 03:30 PM
RE: PCC on IRIX - by Raion - 07-20-2021, 03:36 PM
RE: PCC on IRIX - by Raion - 09-12-2021, 09:31 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)