Opened 12 years ago

Closed 6 years ago

#37206 closed defect (fixed)

pcc: does it actually work on today's machines/OS?

Reported by: akimd (Akim Demaille) Owned by: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc: cooljeanius (Eric Gallager), MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Port: pcc

Description

Hi,

I'm running 10.8.2 on an i7, and I can't compile the simplest C program using pcc. It looks very much like the ASM syntax it uses is not the one accepted by the asm it actually runs.

$ cat /tmp/foo.c
int
main()
{
  return 0;
}
$ pcc /tmp/foo.c
/tmp/ctm.nHsLTr:5:suffix or operands invalid for `push'
/tmp/ctm.nHsLTr:12:suffix or operands invalid for `pop'
/tmp/ctm.nHsLTr:22:unknown section type: non_lazy_symbol_pointers
/tmp/ctm.nHsLTr:22:Rest of line ignored. 1st junk character valued 32 ( ).
$ pcc -v
pcc 1.0.0.RELEASE 20110221 for i386-apple-darwin12.2.1, root@erebus.local
no input files
$ pcc -h
ld: warning: directory not found for option '-L/opt/local/lib/pcc/i386-apple-darwin12.2.1/1.0.0.RELEASE/lib/'
ld: file not found: /opt/local/lib/pcc/i386-apple-darwin12.2.1/1.0.0.RELEASE/lib/crt1.o

The last lines seem to show that there is also something weird in the installation. There is no /opt/local/lib/pcc at all.

Sorry if I missed something :(

Change History (12)

comment:1 Changed 12 years ago by akimd (Akim Demaille)

I should have shown this:

$ pcc -v /tmp/foo.c
pcc 1.0.0.RELEASE 20110221 for i386-apple-darwin12.2.1, root@erebus.local
/opt/local/libexec/cpp -v -D__PCC__=1 -D__PCC_MINOR__=0 -D__PCC_MINORMINOR__=0 -D__GNUC__=4 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -D__GNUC_STDC_INLINE__=1 -D__VERSION__="pcc 1.0.0.RELEASE 20110221 for i386-apple-darwin12.2.1, root@erebus.local" -D__SCHAR_MAX__=127 -D__SHRT_MAX__=32767 -D__INT_MAX__=0x7fffffff -D__LONG_MAX__=0x7fffffff -D__LONG_LONG_MAX__=0x7fffffffffffffffLL -D__REGISTER_PREFIX__= -D__USER_LABEL_PREFIX__= -D__Darwin__ -D__APPLE__ -D__STDC_ISO_10646__=200009L -D__WCHAR_TYPE__=int -D__SIZEOF_WCHAR_T__=4 -D__WCHAR_MAX__=2147483647 -D__WINT_TYPE__=unsigned int -D__SIZE_TYPE__=unsigned long -D__PTRDIFF_TYPE__=long int -D__SIZEOF_WINT_T__=4 -D__i386__ -D__LITTLE_ENDIAN__ -S /opt/local/include/pcc/ -S /usr/include/ -S /opt/local/lib/pcc/i386-apple-darwin12.2.1/1.0.0.RELEASE/include/ /tmp/foo.c /tmp/ctm.4d2kGy 
cpp: pcc 1.0.0.RELEASE 20110221 for i386-apple-darwin12.2.1, root@erebus.local
/opt/local/libexec/ccom -k /tmp/ctm.4d2kGy /tmp/ctm.LyUE7D 
as -v -o /tmp/ctm.vtuyHS /tmp/ctm.LyUE7D 
Apple Inc version cctools-836, GNU assembler version 1.38
/tmp/ctm.LyUE7D:5:suffix or operands invalid for `push'
/tmp/ctm.LyUE7D:12:suffix or operands invalid for `pop'
/tmp/ctm.LyUE7D:22:unknown section type: non_lazy_symbol_pointers
/tmp/ctm.LyUE7D:22:Rest of line ignored. 1st junk character valued 32 ( ).

comment:2 Changed 12 years ago by Veence (Vincent)

Salut Akim :)

The standard ‘as’ used by pcc (and various gcc) is outdated. It corresponds to gcc-4.2, latest version published under the GPL v2. You won’t get any AVX instructions out of it, for example. Maybe pcc uses a syntax adapted to more recent versions of gas? Is there a -s option to see the actual ASM output file?

Bonne journée ! Vincent

comment:3 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: mww@… openmaintainer@… removed
Owner: changed from macports-tickets@… to mww@…

comment:4 Changed 12 years ago by jmroot (Joshua Root)

Sounds like the kind of errors you get trying to run x86_64 asm through an i386 assembler (or perhaps vice versa?).

comment:5 Changed 12 years ago by akimd (Akim Demaille)

@vince: Bonjour !

@jmr: yes, I do agree, the problem is with the assembly language. I am not knowledgeable in assembly language, yet I expected (i) pcc to generate i386 assembly (it's documented to support it, but not x86_64), and (ii) a x86_64 assembler to support i386 assembly language. So I expected this to work.

FWIW

$ less foo.s
        .text
        .align 4
        .globl _main
_main:
        pushl %ebp
        movl %esp,%ebp
        subl $8,%esp
        subl $16,%esp
L11:
        call Lmain$pb
Lmain$pb:
        popl %eax

        movl %eax,-4(%ebp)
L13:
        movl $0,-8(%ebp)
        jmp L12
L12:
        movl -8(%ebp),%eax
        leave
        ret
        .section __IMPORT,__pointers,non_lazy_symbol_pointers
        .ident "PCC: pcc 1.0.0.RELEASE (darwin)"
$ as foo.s
foo.s:5:suffix or operands invalid for `push'
foo.s:12:suffix or operands invalid for `pop'
foo.s:22:unknown section type: non_lazy_symbol_pointers
foo.s:22:Rest of line ignored. 1st junk character valued 32 ( ).

Same result with both as (/usr/bin and /opt/local/bin). I could not find a MacPort package for gas.

comment:6 Changed 12 years ago by Veence (Vincent)

Akim,

There is no gas package because GNU binutils will not work on MacOS out of the box, and nobody has been able to figure out the patches needed to get gas producing Mach-O correct binaries.

Try llvm-mc instead, given that llvm-mc might use a syntax slightly different from GAS.

Bonne chance ! Vincent

comment:7 Changed 12 years ago by akimd (Akim Demaille)

Thanks Vince, but I couldn't have llvm-mc do something useful. Thanks to you, I found llvm's as though, and it does not work any better (well, in a way it does: there are less errors ;).

$ llvm-as-mp-3.2 foo.s
/opt/local/libexec/llvm-3.2/bin/llvm-as: foo.s:1:2: error: expected top-level entity
        .text
        ^

Is there really any use for pcc in the MacPorts? It does not seem to work. On the other hand, it's a pity that there is no available port for tcc, which seems more maintained.

comment:8 in reply to:  6 Changed 10 years ago by cooljeanius (Eric Gallager)

Replying to vince@…:

Akim,

There is no gas package because GNU binutils will not work on MacOS out of the box, and nobody has been able to figure out the patches needed to get gas producing Mach-O correct binaries.

Actually there is a port for GNU binutils, but it does not install the gas part of it it though. I have tried some things to get it to work, but have not quite figured it out yet. Also the binutils port has other issues, specifically:

Replying to akim.demaille@…:

On the other hand, it's a pity that there is no available port for tcc, which seems more maintained.

I opened #38196 for that.

comment:9 Changed 10 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:10 Changed 8 years ago by mf2k (Frank Schima)

Owner: mww@… deleted
Status: newassigned

See #53012.

comment:11 Changed 6 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Cc: MarcusCalhoun-Lopez added

comment:12 Changed 6 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Owner: set to MarcusCalhoun-Lopez
Resolution: fixed
Status: assignedclosed

In f61adec180a50a9f9998561405b69d9a628e7f19/macports-ports (master):

pcc/pcc-libs: update version 1.0.0->1.1.0 & new port

Fixes #37206

Note: See TracTickets for help on using tickets.