Bug#601645: /usr/bin/clang: compilation fails on MIPS due to missing _MIPS_SZPTR macro

Mark Heily mark at heily.com
Thu Oct 28 02:32:01 UTC 2010

Package: clang
Version: 2.7-3
Severity: normal
File: /usr/bin/clang

clang is unable to compile a trivial program on MIPS due to a glibc 
dependency on GCC-specific macros. Here is a command that demonstrates the 

$ echo '#include <stdlib.h>' | clang -x c -
clang: warning: unknown platform, assuming -mfloat-abi=soft
In file included from <stdin>:1:
In file included from /usr/include/stdlib.h:320:
In file included from /usr/include/sys/types.h:31:
/usr/include/bits/types.h:128:3: error: #error

The problem is that glibc expects the macro _MIPS_SZPTR to be defined by the 
compiler. Clang does not appear to define this macro. Glibc uses _MIPS_SZPTR 
to set the value of __WORDSIZE, so you can workaround the compilation issue 
like this:

     printf "#define _MIPS_SZPTR 32\n#include <stdlib.h>\n" | clang -x c -

The Linux kernel sources mention several other MIPS-related macros that are 
specific to GCC and may not be implemented by other compilers [1].

[1] http://www.kneuro.net/cgi-bin/lxr/http/source/include/asm-mips/sgidefs.h#L35

More information about the Pkg-llvm-team mailing list