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

Aníbal Monsalve Salazar <[email protected]>
Newsgroups gmane.linux.debian.ports.mips
Message-ID <[email protected]>
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
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (GNU/Linux)

iQIcBAEBCgAGBQJSu3nDAAoJEHxWrP6UeJfY5NoP/AtgEwJNxoHvLBKGYkWwraEI
PJQa8cfL9z1+SOEMXcgO58MVsLLQB4/MYUNKUL2SLt2NlefAMeItVJFFIjIRX3AF
1YDkJ7FjwVyMrHLSf4iOfwBMk4ywj8W4zpTMOlKpGvDxxj123rA+6fq4QJKLAzRw
+sHwZg45KnbnzkLH1SUotbjBLFppBzyG8gaN38tdukrEGB7y9u1AXzb/IOLbSZdY
kOuADHfFMe8IAuAhEEcDTjr35XJ6TGVDY3oWwzCA9NzE07nGfihtvg4KimOo3m+0
3ne+F6M/r+mejrbp9UQaoZmGhGeVXyguTVNgAq2Jbln+Qw1ovuaILUo8DI3Xuive
pjBNWe6RtCDivj6nNfqcQ5IlqMwI3zO0sjc3Jy0MwLkjGoumhb84o9LNGDpID9Si
QbUsiqPMyvlkBsrpP3Qb8CqsQv8yLTAfDh5BWJW+6dOd9vhvyiLlR+JibLlo/iec
HxEx6wmaXQOhZoV9lEuAumEg+prV3DABowIigQXRx6dbnlcDAA0JWpEN1NH+kIvq
xYLpCnBRQiEzNe5/A7bBJHBoQ2i/9NvRrKRzXYSW41OQB63AG2jUHrD+xPtRyFXb
2oryim2FInKvoqQR7KgB+P+QWTHaPwNvYDclBvRZPvEG2LozCi+q+Xqw6R072Sbi
gPa3S/ty2lNC5nR447Zj
=ddZg
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.