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

Aurelien Jarno <[email protected]>
Newsgroups gmane.linux.debian.ports.mips
Message-ID <[email protected]>
On Thu, Dec 26, 2013 at 12:48:44AM +0000, Aníbal Monsalve Salazar wrote:
> 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?

glibc has workarounded the clang bug, which didn't define correctly
_MIPS_SZPTR, so it's normal that your test works.

The test to do is the following:

$echo '_MIPS_SZPTR' | clang -E -  
# 1 "<stdin>"
# 1 "<stdin>" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 154 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
32

And you can see that _MIPS_SZPTR is correctly defined. So yes this bug
can be closed now.

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive: http://lists.debian.org/[email protected]
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.