gcc, as, AVX, binutils and MacOS X 10.7

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

gcc, as, AVX, binutils and MacOS X 10.7

vincent habchi-2
Hi there,

I haven’t been much presently lately, but I was taken away by my work and also pondering on various bugs I encountered lately, especially with the Atlas port. I am now sure something is definitely rotten in OS 10.7 kingdom.

The starting point is Atlas not being compiled properly by clang. The source compiles fine, but the resulting library crashes on various calls. Then, there are sparse bugs related to ar(1) or ranlib(1) that prevents gcc46, atlas with standard ar or even qt4.8 beta to build properly. At this point, I am deeply convinced that this is caused by clang miscompilations: either we are plagued by clang producing weirds object files, or the tools themselves (MacOS 10.7 has been built with clang/llvm, AFAIK) are buggy. Unfortunately, I am more inclined towards the latter possibility, since the ar bugs manifests itself during the libgfortran archiving, where clang plays no role. I have filed various radars apropos, but while they have been acknowledged, no patch has been released yet. My opinion is that Apple has moved far too fast to clang for obvious political reasons, resulting in a flawed OS.

Then there is another knot: the ‘as’ assembler, bundled with OS 10.7, and used by our various gcc, is antiquated: GNU assembler version 1.38 (output of as -v – this is probably the last GPL v.2 version). This means no Sandy bridge AVX support (unknown instructions), so no possibility to compile or assemble code with gcc -mavx switch on: that’s a waste of power, and means inferior performance on floating point code (at best); with Ivy bridge processor looming, the gap will increase if we find no quick fix to this.

Trying to build the gas included in libtools fails: the configure script reports an unknown configuration and won’t build the assembler. The llvm toolchain won’t help us, since it is based on a wholly different structure, and won’t accept GNU assembler files as input, so our last hope is to try using ‘yasm’ with gcc: did anybody already test this?

We can’t count on Apple helping us, since they are forbidden to touch every GPL v.3 tool. Besides, clang support for AVX instructions is currently broken.

So folks, question is: how can we get out of this trap?

Cheers,
Vincent
_______________________________________________
macports-dev mailing list
[hidden email]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev
Reply | Threaded
Open this post in threaded view
|

Re: gcc, as, AVX, binutils and MacOS X 10.7

Ryan Schmidt-24

On Oct 2, 2011, at 04:17, vincent habchi wrote:

> I haven’t been much presently lately, but I was taken away by my work and also pondering on various bugs I encountered lately, especially with the Atlas port. I am now sure something is definitely rotten in OS 10.7 kingdom.
>
> The starting point is Atlas not being compiled properly by clang. The source compiles fine, but the resulting library crashes on various calls. Then, there are sparse bugs related to ar(1) or ranlib(1) that prevents gcc46, atlas with standard ar or even qt4.8 beta to build properly. At this point, I am deeply convinced that this is caused by clang miscompilations: either we are plagued by clang producing weirds object files, or the tools themselves (MacOS 10.7 has been built with clang/llvm, AFAIK) are buggy. Unfortunately, I am more inclined towards the latter possibility, since the ar bugs manifests itself during the libgfortran archiving, where clang plays no role. I have filed various radars apropos, but while they have been acknowledged, no patch has been released yet. My opinion is that Apple has moved far too fast to clang for obvious political reasons, resulting in a flawed OS.
>
> Then there is another knot: the ‘as’ assembler, bundled with OS 10.7, and used by our various gcc, is antiquated: GNU assembler version 1.38 (output of as -v – this is probably the last GPL v.2 version). This means no Sandy bridge AVX support (unknown instructions), so no possibility to compile or assemble code with gcc -mavx switch on: that’s a waste of power, and means inferior performance on floating point code (at best); with Ivy bridge processor looming, the gap will increase if we find no quick fix to this.
>
> Trying to build the gas included in libtools fails: the configure script reports an unknown configuration and won’t build the assembler. The llvm toolchain won’t help us, since it is based on a wholly different structure, and won’t accept GNU assembler files as input, so our last hope is to try using ‘yasm’ with gcc: did anybody already test this?
>
> We can’t count on Apple helping us, since they are forbidden to touch every GPL v.3 tool. Besides, clang support for AVX instructions is currently broken.
>
> So folks, question is: how can we get out of this trap?

I don't know. I would talk with the developers of atlas and get them to support the version of clang and llvm-gcc-4.2 in Lion's Xcode, since that's what's out there.



_______________________________________________
macports-dev mailing list
[hidden email]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev
Reply | Threaded
Open this post in threaded view
|

Re: gcc, as, AVX, binutils and MacOS X 10.7

Andrea D'Amore-4
In reply to this post by vincent habchi-2
On Sun, Oct 2, 2011 at 11:17, vincent habchi <[hidden email]> wrote:
> We can’t count on Apple helping us, since they are forbidden to touch every GPL v.3 tool.

Why is this?

--
Andrea
_______________________________________________
macports-dev mailing list
[hidden email]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev
Reply | Threaded
Open this post in threaded view
|

Re: gcc, as, AVX, binutils and MacOS X 10.7

Joshua Root-8
On 2011-10-3 01:50 , Andrea D'Amore wrote:
> On Sun, Oct 2, 2011 at 11:17, vincent habchi <[hidden email]> wrote:
>> We can’t count on Apple helping us, since they are forbidden to touch every GPL v.3 tool.
>
> Why is this?

There's been no official statement from Apple, but it's probably to do
with the patent clauses in GPLv3.

- Josh
_______________________________________________
macports-dev mailing list
[hidden email]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev
Reply | Threaded
Open this post in threaded view
|

Re: gcc, as, AVX, binutils and MacOS X 10.7

vincent habchi-2
In reply to this post by vincent habchi-2
Le 2 oct. 2011 à 16:47, Andrea D'Amore <[hidden email]> a écrit :

> On Sun, Oct 2, 2011 at 11:17, vincent habchi <[hidden email]> wrote:
>> We can’t count on Apple helping us, since they are forbidden to touch every GPL v.3 tool.
>
> Why is this?

Apple politics. When GPL v3 went out, I was involved with the NetBSD project, and there was also a lot of discussions about it, up to the point of thinking about abandoning Gcc altogether. I switched to MacOS before the case was settled down. The GPL v3 is less permissive and much more obscure, legally, than the v.2.

Apple did not hesitate for a long time: they decided to quit using all GPLv3, that’s why you never got a GCC newer than 4.2; accidentally, sometime later I reported a bug about being unable to compile GCC, and I was told engineering couldn't help me because they were forbidden to use or even download GPLv3 tools.

I don’t think Jobs’ departure will alter this course…

Vincent
_______________________________________________
macports-dev mailing list
[hidden email]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev
Reply | Threaded
Open this post in threaded view
|

Re: gcc, as, AVX, binutils and MacOS X 10.7

vincent habchi-2
Ok, finally I figured out a way to compile AVX instructions. But it is somewhat crooked. The old ‘as’ assembler in /usr/bin/as must be discarded and replaced by this script, that uses the clang assembler:

#!/bin/sh
HAS_INPUT_FILE=0
ARGS=$@
while [ $# -ne 0 ]; do
        ARG=$1
        # Skip options
        if [ $ARG == "-arch" ] || [ $ARG == "-o" ]; then
                # Skip next token
                shift
                shift
                continue
        fi

        if [ `echo $ARG | head -c1` == "-" ]; then
                shift
                continue
        fi

        HAS_INPUT_FILE=1
        break
done

if [ $HAS_INPUT_FILE -eq 1 ]; then
        clang -c -x assembler $ARGS
else
        clang -c -x assembler $ARGS -
fi

Obviously, since this is a shell script, the assembly phase is slowed down. But it seems to work, at least it compiles AVX assembly properly (gcc-mp-4.5 avx.s works, and I have even recompiled gcc45 with the script as assembler).

Well, I have filed a RADAR asking Apple to give us an assembler that supports AVX. We’ll see.

Cheers
Vincent
_______________________________________________
macports-dev mailing list
[hidden email]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev
Reply | Threaded
Open this post in threaded view
|

Re: gcc, as, AVX, binutils and MacOS X 10.7

Jordan K. Hubbard

On Oct 3, 2011, at 12:50 PM, vincent habchi wrote:

Well, I have filed a RADAR asking Apple to give us an assembler that supports AVX. We’ll see.

Not the craziest idea I've ever heard, no. :-)   Do you happen to have the radar # handy?   Thanks!

- Jordan


_______________________________________________
macports-dev mailing list
[hidden email]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev
Reply | Threaded
Open this post in threaded view
|

Re: gcc, as, AVX, binutils and MacOS X 10.7

Vincenzo Innocente
In reply to this post by vincent habchi-2
I tried the "as" wrapper with
gcc version 4.7.0 20110926 (experimental) (GCC)
and got a
error: invalid instruction mnemonic 'vcvttss2siq'
        vcvttss2siq %xmm0, %rax

so it seems that clang is not complete (or gcc mnemonic not fully conformant)

vincenzo


_______________________________________________
macports-dev mailing list
[hidden email]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev