On C extensions, portability, and alternative compilers

43 points by lemon


jprotopopov

(I am the author of kefir compiler). Thank you for bringing up the issue. The __attribute__ issue of <sys/cdefs.h> is perhaps the most "offending", at least in my experience, because it breaks epoll (and anything packed, in general), constructors, symbol visibility. I ended up bundling the following monkey-patch header with kefir. This is not ideal, but perhaps the sanest thing to do. It actually enabled me to remove bulk of custom patches from the external test suite.

Another failure mode I encountered are buggy fallbacks. Certain projects try to detect the compiler and adjust accordingly, but due to lack of testing on alternative compilers, the fallback code ends up buggy or unmaintained properly. As a compiler author, this is much more frustrating than abrupt failure with "unsupported compiler" error message, because I end up debugging weird miscompilations caused by e.g. some integer typedef width mismatch between the program and some pre-compiled library it uses.