Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

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

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by mouse07410):

 Any update on this issue? It's been over 5 years, and the problem remains.

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:12>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by raimue):

 These AVX instructions are not emitted by gcc; the example code uses
 intrinsics. gcc does not validate that, it just passes it through to the
 assembler like it always does for inline assembler code.

 I do not know or check whether gcc on macOS would emit AVX code from C
 code (keyword: auto-vectorization).

 If we want to support this, we need to modify the gcc ports in MacPorts to
 use the LLVM assembler. The simplest option seems to be to use `--with-
 as=/usr/bin/as` (maybe the same for the other target tools that are now
 provided by cctools?).

 But this can only be done on macOS and Xcode version combinations that
 already use the LLVM assembler by default and not the old cctools. You
 need to find out which these are. Older versions should continue to use
 cctools, as that is still newer than what is provided in `/usr/bin`.

 Then test this setup and report back.

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:13>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by kencu):

 gcc on macOS uses the ancient apple gcc assembler from about 1852. It is
 version 1.32, and hasn't been updated in years. The build of gcc-as in
 binutils is disabled as it is not apple-happy. I would love it if somebody
 would update that to something fresh.

 However, gcc accepts {{{-Wa,-q}}} which causes it to use {{{clang}}} as
 the compiler. So you can add that to the cflags and cxxflags on a gcc
 build, and if {{{clang}}} calls to some newish version of clang, you're
 good to go.

 There is a flag to spec the clang you want to sent the asm to, I believe.
 I just haven't found it / tested it / bothered to look for it.

 When I want to build new asm with old gcc version (e.g. building
 TenFourFox for Intel on 10.6.8 using gcc-4.8 with modern libvpx
 instructions), I just add the mentioned flag and {{{port select}}} a
 newish clang.

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:14>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by raimue):

 MacPorts forces gcc to use `${prefix}/bin/as` instead, which comes from
 cctools.

 `/usr/bin/as` is already be the LLVM assembler on my system. There is no
 need to use `as -q` as far as I can see.

 {{{
 $ sw_vers -productVersion
 10.12.6
 $ xcodebuild -version
 Xcode 9.2
 Build version 9C40b
 $ /usr/bin/as -v |& head -1
 Apple LLVM version 9.0.0 (clang-900.0.39.2)
 }}}

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:15>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by kencu):

 mmmmm. look at the same result on my system, however:
 {{{
 $ which as
 /opt/local/bin/as
 $ as -version
 Apple Inc version cctools-895, GNU assembler version 1.38
 }}}

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:16>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by raimue):

 Of course `/opt/local/bin/as` will always be cctools; it is provided by
 the MacPorts port. I was talking about `/usr/bin/as`, which is provided by
 the Xcode toolchain.

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:17>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by kencu):

 Oh, OK, you had noted `${prefix}/bin/as`
 [https://trac.macports.org/ticket/37846#comment:15 above].

 Turns out `/usr/bin/as` is even worse on older systems, as it is just an
 even older version of cctools, although may well provide the exact same
 assembler:
 {{{
 $ /usr/bin/as -version
 Apple Inc version cctools-809~2, GNU assembler version 1.38
 }}}

 Good to know there are different ways of doing things.

 You have me thinking now. I'd like to somehow prove that `-Wa,-q` actually
 calls through to `clang` instead of `/usr/bin/as` or `${prefix}/bin/as`
 just so I know for sure what I'm saying is actually fully correct. I'll
 see if I can figure out how to do that. -- K

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:18>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by raimue):

 On older systems, `/usr/bin/as` is an old cctools. That's why we started
 using `${prefix}/bin/as` from the cctools port instead, to get the
 benefits of the newer version.

 That's what I meant [comment:13 above]: we should only use `--with-
 as=/usr/bin/as` on newer systems on which `/usr/bin/as` is the newer LLVM
 assembler. On older systems leave everything as it is.

 Your theory on `-Wa,-q` is easy to prove:
 {{{
 $ /opt/local/bin/as -q
 /opt/local/bin/as: assembler (/opt/local/bin/clang) not installed
 }}}

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:19>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by kencu):

 Good! So on some vintage of OS, `-Wa,-q` is the proper way to go if you
 want gcc to use a current assembler. That is what I thought, as that is
 what worked for me.

 Now we just need to figure out where the cutoff might be. Likely 10.6.8, I
 would bet.

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:20>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by kencu):

 See also:

 [ticket:36389]
 [ticket:51642]
 [ticket:54166]

 and

 [https://stackoverflow.com/questions/37855898/macports-gcc-compiler-wa-q
 -and-opt-local-bin-clang-not-installed]

 and

 [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80782]

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:21>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by kencu):

 The guts of this behaviour is controlled by cctools `as` `driver.c`.

 For practical purposes, `/usr/bin/as` sends you to `/usr/bin/clang` for
 assember work on 10.10 or later, which on my system matched up to Xcode 7.
 On 10.9 and below, it appears you get the standard GNU assember 1.38
 unless you send the `-q` flag, or have set the `AS_INTEGRATED_ASSEMBER`
 environment variable.

 On older systems, if you have set `AS_INTEGRATED_ASSEMBER`, or if you have
 set the `-q` flag with `-Wa,-q`, then cctools `as` passes off the assembly
 to `clang` in the same directory as `as` is.

 At this moment, you can't set a more specific name for `clang`, and you
 can't specify a full path to `clang`. It's just going to look for `clang`,
 next to `as`, wherever the running copy of `as` is.

 So for a MacPorts install of cctools, `/opt/local/bin/as` which is the
 first one on the path usually will look for `/opt/local/bin/clang`.
 `/usr/bin/as` will look for `/usr/bin/clang`.

 To make the MacPorts cctools `as` work to use `clang` as the assembler,
 there needs to be an `/opt/local/bin/clang` and the only way to get that
 is to `sudo port select` a clang manually, at present.

 So on systems 10.9 or older, you need to select a clang, and then use
 `-Wa,-q` to make it work.

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:22>
MacPorts <https://www.macports.org/>
Ports system for macOS
Reply | Threaded
Open this post in threaded view
|

Re: [MacPorts] #37846: cctools as does not support AVX, consider using llvm

MacPorts
In reply to this post by MacPorts
#37846: cctools as does not support AVX, consider using llvm
--------------------------+--------------------------------
  Reporter:  wd11@…       |      Owner:  macports-tickets@…
      Type:  defect       |     Status:  assigned
  Priority:  Normal       |  Milestone:
 Component:  ports        |    Version:  2.1.2
Resolution:               |   Keywords:
      Port:  cctools gcc  |
--------------------------+--------------------------------

Comment (by mouse07410):

 Should {{{AS_INTEGRATED_ASSEMBLER}}} env var be set to 1? Will the current
 Macports cctools {{{as}}} respect/use it?

--
Ticket URL: <https://trac.macports.org/ticket/37846#comment:23>
MacPorts <https://www.macports.org/>
Ports system for macOS