Isaac Dunham
2012-10-14 04:44:23 UTC
Rich Felker and I recently took a look at why musl[1] was segfaulting when built with pcc. There were a few issues, which he's worked around for the time being:
1. PCC's support for __attribute__(visibility("hidden")) is buggy.
The workaround [2] is suboptimal, although it runs.
2. With gcc, arrays decay to pointers when used as arguments to inline asm. PCC is incompatible on this point. See [3] for an example.
3. Minor issue 1: -fPIC usually defines __PIC__, which pcc doesn't do.
This can be circumvented via -D__PIC__
4. Minor issue 2: pcc-libs is built without -fPIC; on some Linux systems/libcs (musl being one; I think any system with PaX may be affected as well), this can break linking with shared libraries. Additionally,
/configure doesn't honor CFLAGS. The workaround is
make CFLAGS="-fPIC" (or similar) when building pcc-libs.
Also, would it be possible for PCC to handle -march=* or at least -march=i*86 (=ld -melf_i386)? The current lack of handling means that the makefiles need some manual adjustment.
Thanks,
Isaac Dunham <***@lavabit.com>
[1] http://musl-libc.org
[2] http://git.musl-libc.org/cgit/musl/commit/?id=e23d358fd6254d88c85750a23cd1234855c3292c
and
http://git.musl-libc.org/cgit/musl/commit/?id=36be5284c2a79406778ac489928c6deb05857329
[3] http://git.musl-libc.org/cgit/musl/commit/?id=185a97707429aacfa1e8db62fc9fdb2188539d86
1. PCC's support for __attribute__(visibility("hidden")) is buggy.
The workaround [2] is suboptimal, although it runs.
2. With gcc, arrays decay to pointers when used as arguments to inline asm. PCC is incompatible on this point. See [3] for an example.
3. Minor issue 1: -fPIC usually defines __PIC__, which pcc doesn't do.
This can be circumvented via -D__PIC__
4. Minor issue 2: pcc-libs is built without -fPIC; on some Linux systems/libcs (musl being one; I think any system with PaX may be affected as well), this can break linking with shared libraries. Additionally,
/configure doesn't honor CFLAGS. The workaround is
make CFLAGS="-fPIC" (or similar) when building pcc-libs.
Also, would it be possible for PCC to handle -march=* or at least -march=i*86 (=ld -melf_i386)? The current lack of handling means that the makefiles need some manual adjustment.
Thanks,
Isaac Dunham <***@lavabit.com>
[1] http://musl-libc.org
[2] http://git.musl-libc.org/cgit/musl/commit/?id=e23d358fd6254d88c85750a23cd1234855c3292c
and
http://git.musl-libc.org/cgit/musl/commit/?id=36be5284c2a79406778ac489928c6deb05857329
[3] http://git.musl-libc.org/cgit/musl/commit/?id=185a97707429aacfa1e8db62fc9fdb2188539d86