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 Thu, Dec 26, 2013 at 11:35:16AM +1100, Aníbal Monsalve Salazar wrote:
> 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

Fixed typo in Cc list.
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (GNU/Linux)

iQIcBAEBCgAGBQJSu3zrAAoJEHxWrP6UeJfYAqgQAMTM28ibbevue5XnZ/YYVotW
YNvdhF1baxHpLJhFlNGqiAPWSUw/XL8uwcsjsycRL8lYYhgcw4G9t3YvFYi/OMrL
ybYQyMxcBjePVA6R3vsKzpLd97JOF3Rs4a0DSviu/Xqqg9tEXgKUkajcdUST0ouE
FhU5uZeCfK8nq2bGs6/893OpT/7AwpWWi2sWGUUMqBbpphhoe/OdsHB59q7fIUjp
mOsf/7JyTHW6JJd5t+AKF1DrCYxImOVNdgT2h0asGu3YxSf7A9QAvc63NJKy9UNf
kFX6B0qe9fXp/m4Qgdb+LtSGs99iNzo7Shdg+6tvPrsz9l2DKpHWZ64JDfFQsElS
qmzCZ4d6iMNx4enZj3XYkqKjLBOjIuqk6DoCg7VARf+wSNwAGxUu6Tura+zonInv
CYsaYZz5BElpn5yc9C3Vyr41GzfXfrMpuhLKxEW+S9385UPSn2zZ1HHhhsLe2Jdj
glagyOHJ7PCpWkOWXq8f6uBXRcH3Y0UBci723rbiW1+yglqEHa9sx1xhh15g2U9p
DVVq85GIPXPrwliyaJSNwWbalA4UvFNU4WYsH+MShnAntXiL2h06PVCsZsD3gKyh
Aci/Zt9EQI/SvlefZghYwBSVf1gisrvLEG/jUg+kWjnteUaoUA2d0c4zDgOGJInH
ivK/hRE2tYhFDQNpkg6Z
=UG8Y
-----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.