[MacPorts] #66302: gcc12 universal variant has no effect

MacPorts noreply at macports.org
Tue Nov 22 13:08:38 UTC 2022


#66302: gcc12 universal variant has no effect
----------------------------+------------------------------------
  Reporter:  JanWielemaker  |      Owner:  (none)
      Type:  defect         |     Status:  new
  Priority:  Normal         |  Milestone:
 Component:  ports          |    Version:  2.8.0
Resolution:                 |   Keywords:  universal arm64 x68_64
      Port:  gcc12          |
----------------------------+------------------------------------

Comment (by kencu):

 Replying to [comment:6 JanWielemaker]:
 > Replying to [comment:4 kencu]:
 > > the gcc10-bootstrap port is as close to a real cross compiler as we
 have for this, but still has a number of faults, and is not really a
 cross-compiler.
 >
 > Thanks.  Is this simply a X86_64 gcc, i.e., running as x86_64 under
 Rosetta and producing x86_64 binaries?   Even the same as I would get if I
 copy a gcc installation from an Intel Mac to the M1?

 No, it closer to what you want. It is two compilers combined together:

 {{{
 $ file ./opt/local/libexec/gcc10-bootstrap/bin/gcc
 ./opt/local/libexec/gcc10-bootstrap/bin/gcc: Mach-O universal binary with
 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
 ./opt/local/libexec/gcc10-bootstrap/bin/gcc (for architecture x86_64):
 Mach-O 64-bit executable x86_64
 ./opt/local/libexec/gcc10-bootstrap/bin/gcc (for architecture arm64):
 Mach-O 64-bit executable arm64

 $ file ./opt/local/libexec/gcc10-bootstrap/bin/x86_64-apple-darwin20-gcc
 ./opt/local/libexec/gcc10-bootstrap/bin/x86_64-apple-darwin20-gcc: Mach-O
 64-bit executable x86_64

 $ file ./opt/local/libexec/gcc10-bootstrap/bin/aarch64-apple-darwin20-gcc
 ./opt/local/libexec/gcc10-bootstrap/bin/aarch64-apple-darwin20-gcc: Mach-O
 64-bit executable arm64

 $ file ./opt/local/libexec/gcc10-bootstrap/lib/libstdc++.6.dylib
 ./opt/local/libexec/gcc10-bootstrap/lib/libstdc++.6.dylib: Mach-O
 universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically
 linked shared library x86_64] [arm64]
 ./opt/local/libexec/gcc10-bootstrap/lib/libstdc++.6.dylib (for
 architecture x86_64):    Mach-O 64-bit dynamically linked shared library
 x86_64
 ./opt/local/libexec/gcc10-bootstrap/lib/libstdc++.6.dylib (for
 architecture arm64):     Mach-O 64-bit dynamically linked shared library
 arm64
 }}}

 and you can use it somewhat clumsily with the muniversal portgroup to make
 fat binary:
 {{{
 $ port notes gcc10-bootstrap
 --->  gcc10-bootstrap has the following notes:
   To use this bootstrap version of gcc instead of the default compiler,
 add the following lines to the Portfile:

   depends_lib-append      port:gcc10-bootstrap

   configure.cc            ${prefix}/libexec/gcc10-bootstrap/bin/gcc
   configure.cxx           ${prefix}/libexec/gcc10-bootstrap/bin/g++

   If you would like to build universal port with this compiler, you must
 use per target compiler. The easy way is using muniversal PG:

   PortGroup               muniversal 1.0

   if {${universal_possible} && [variant_isset universal]} {
       configure.cc        {}
       configure.cxx       {}

       foreach arch ${universal_archs_supported} {
           lappend merger_configure_env(${arch})  "CC=arch -arch ${arch}
 ${prefix}/libexec/gcc10-bootstrap/bin/gcc"
           lappend merger_configure_env(${arch})  "CXX=arch -arch ${arch}
 ${prefix}/libexec/gcc10-bootstrap/bin/g++"
       }
   } else {
       configure.cc        ${prefix}/libexec/gcc10-bootstrap/bin/gcc
       configure.cxx       ${prefix}/libexec/gcc10-bootstrap/bin/g++
   }
 }}}

 but the arm64 compiler is an arm64 and the x86_64 compiler is an x86_64
 binary, so it will only work to build a fat binary on an arm64 mac.

 That could be fixed, as above, so the whole compiler is written in one
 arch but can output two different arches, but even so, it is very clumsy
 to use, so I haven't bothered pushing this idea until somebody updates
 driverdriver.c to make it work right.

 If someone wanted to push ahead on that idea it would be a bit convoluted
 to sort out the arch naming, so we'd probably need to add a "host" or
 "build" variant into the port to make it work. Just too messy, so I"m not
 doing it.

 But for TODAY, it most likely CAN build a fat binary on an M1 Mac.

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


More information about the macports-tickets mailing list