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

Aníbal Monsalve Salazar anibal at debian.org
Thu Dec 26 00:35:16 UTC 2013


On Mon, Jun 06, 2011 at 08:36:26PM +0200, Aurelien Jarno wrote:
> clone 601645 -1
> reopen -1
> reassign -1 clang 2.9-1
> thanks
> 
> Hi,
> 
> On Wed, Oct 27, 2010 at 10:32:01PM -0400, Mark Heily wrote:
>> 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 failure:
>> 
>> $ 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].
> 
> This bug has been workaround in eglibc 2.13-5 by using another way to
> define __WORDSIZE on clang.
> 
> That said after discussing with upstream, it clearly appears to be a
> clang issue. _MIPS_SZPTR has been defined by SGI and must be present
> in all compilers targeting MIPS. Some more details are given in 
> "MIPSpro(TM) Compiling and Performance Tuning Guide" (SGI's document 
> #007-2360-008).
> 
> I am therefore cloning and reassigning this bug to clang. I'll keep the
> workaround in eglibc until the problem is solved on the clang side.

Hello Aurelien,

I just closed #599984.

http://bugs.debian.org/599984

And #629441 was blocking the fix for #599984.

http://bugs.debian.org/629441

I tried your one-line clang command on mips and mipsel.

The mips result is below.

  $ uname -a
  Linux choco 3.10-3-r5k-ip32 #1 Debian 3.10.11-1 (2013-09-10) mips64 GNU/Linux

  $ echo '#include <stdlib.h>' | clang -x c -
  /usr/bin/ld: /tmp/--6Ek165.o: warning: linking abicalls files with non-abicalls files
  /usr/bin/../lib/gcc/mips-linux-gnu/4.8/../../../mips-linux-gnu/crt1.o: In function `__start':
  (.text+0x18): undefined reference to `main'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

And the mipsel result is below.

  $ uname -a
  Linux eladi 2.6.36-trunk-loongson-2f #1 Thu Oct 28 17:32:42 UTC 2010 mips64 GNU/Linux

  $ echo '#include <stdlib.h>' | clang -x c -
  /usr/bin/ld: /tmp/--klojkk.o: warning: linking abicalls files with non-abicalls files
  /usr/bin/../lib/gcc/mipsel-linux-gnu/4.8/../../../mipsel-linux-gnu/crt1.o: In function `__start':
  (.text+0x18): undefined reference to `main'
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

Should I close #629441?

Regards,

Aníbal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-llvm-team/attachments/20131226/1b1d6e1d/attachment.sig>


More information about the Pkg-llvm-team mailing list