[MacPorts] #48857: gcc ports: support compiling multiple archs (universal) using the Apple GCC driver
#48857: gcc ports: support compiling multiple archs (universal) using the Apple GCC driver ---------------------------------+------------------------------------- Reporter: frederic.devernay@… | Owner: macports-tickets@… Type: enhancement | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.3.3 Keywords: | Port: gcc46 gcc47 gcc48 gcc49 ---------------------------------+------------------------------------- Apple's gcc, llvm-gcc and clang have a nice feature, which is taht multiple archs can be specified on the same command-line (e.g. "-arch i386 -arch x86_64"). GNU's gcc, as installed by the gcc ports in MacPorts, doesn't have this feature, and thus most ports (actuall all non-muniversal ports) cannot be built universal using gcc. With the following enhancements, *all* ports could be built universal using a modern GNU gcc (with proper OpenMP support etc.) Actually, what apple did was to write a simple wrapper that calls gcc twice, and then lipo to merge the two objects. That driver can be compiled with modern gcc versions, and works very well. It's a single C file, called driverdriver.c, and can be found at: http://www.opensource.apple.com/source/gcc/gcc-5666.3/driverdriver.c?txt John Bower manage to modify and build that driver for GNU GCC, as installed by macports: http://thecoderslife.blogspot.fr/2015/07/building-with-gcc-46-and- xcode-4.html That blog article is about gcc 4.6, but I tested it with GCC 4.8 (built with +universal) and it works very well. I now have to binaries (gcc-mp and g++-mp) that behave exactly like Apple's GCC. His source code can be found at: https://github.com/jhnbwrs/macportsGCCfixup He added also building and installing configurations for Xcode, but we don't really need these (although that would be a bonus). The main improvement would be the driver. -- Ticket URL: <https://trac.macports.org/ticket/48857> MacPorts <https://www.macports.org/> Ports system for OS X
#48857: gcc ports: support compiling multiple archs (universal) using the Apple GCC driver --------------------------------------+------------------- Reporter: frederic.devernay@… | Owner: mww@… Type: enhancement | Status: new Priority: Normal | Milestone: Component: ports | Version: Resolution: | Keywords: Port: gcc46 gcc47 gcc48 gcc49 | --------------------------------------+------------------- Changes (by mf2k@…): * cc: mww (removed) * owner: macports-tickets@… => mww@… * version: 2.3.3 => Comment: Trac requires complete email addresses. -- Ticket URL: <https://trac.macports.org/ticket/48857#comment:1> MacPorts <https://www.macports.org/> Ports system for OS X
#48857: gcc ports: support compiling multiple archs (universal) using the Apple GCC driver -------------------------------------------------+------------------------- Reporter: frederic.devernay@… | Owner: mww@… Type: enhancement | Status: new Priority: Normal | Milestone: Component: ports | Version: Resolution: | Keywords: Port: gcc43 gcc44 gcc45 gcc46 gcc47 | gcc48 gcc49 gcc5 gcc6 | -------------------------------------------------+------------------------- Changes (by ryandesign@…): * cc: ryandesign@… (added) * port: gcc46 gcc47 gcc48 gcc49 => gcc43 gcc44 gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 gcc6 Comment: Although I could not find a prior MacPorts ticket for this, the idea has been mentioned many times before. And although I would welcome this feature, it's unclear how to use John's contributions to provide it. It seems to be organized as a separate project, rather than a set of patches that could be applied to the existing gcc source code. It also seems as though John's instructions rely on the user moving or renaming the compilers installed by the MacPorts gcc ports. At least some of his information is also out of date. One of the problems mentioned in the blog post is the lack of support for the `-arch` flag in gcc 4.6. Support for the `-arch` flag was added in gcc 4.7. It's not MacPorts' job to extend other people's projects. If this feature is desired, John or you or someone should work with the developers of gcc to incorporate it into the gcc sources. That way, every Mac user, not just those who get their copy of gcc from MacPorts, would benefit. He also mentions a way to get Xcode to recognize MacPorts compilers. This too has been previously brought to MacPorts' attention. I would welcome this as well, not just for the benefit of users wishing to use gcc in Xcode for their own projects, but for MacPorts itself; we have some ports that use Xcode to build, but that require either a newer or older version of clang than Xcode provides; there is currently no way to build these projects because there is no way to tell Xcode to use a MacPorts clang compiler. -- Ticket URL: <https://trac.macports.org/ticket/48857#comment:2> MacPorts <https://www.macports.org/> Ports system for OS X
#48857: gcc ports: support compiling multiple archs (universal) using the Apple GCC driver -------------------------------------------------+------------------------- Reporter: frederic.devernay@… | Owner: mww@… Type: enhancement | Status: new Priority: Normal | Milestone: Component: ports | Version: Resolution: | Keywords: Port: gcc43 gcc44 gcc45 gcc46 gcc47 | gcc48 gcc49 gcc5 gcc6 | -------------------------------------------------+------------------------- Comment (by frederic.devernay@…): Basically, it's just a *single* C file (driverdriver.c) that - runs the standard gcc-mp-4.8 (or whichever version it was compiled for) for each arch - runs lipo to make a fat object It's as simple as that. John added many things to the project (such as Xcode templates), but only driverdriver.c (which is from Apple) is useful for macports. John made very few modifications to driverdriver.c Since it's a single file, it could be compiled and installed by every gcc port, it could be named gcc-mp-driver-4.8 or whatever, and it could be used by macport when using gcc, instead of gcc-mp-4.8. I'm using it everyday to build universal Qt programs compiled with gcc- mp-4.8 (to get OpenMP support) and it works like a charm. This would solve many issues with universal ports... Concerning integration into GCC: Apple did that a long time ago, and it never was incorporated in the gcc sources. The GCC guys are very picky, and I am pretty sure they won't integrate anything that depends on external binaries (namely lipo), or that are specific to a few arch's. -- Ticket URL: <https://trac.macports.org/ticket/48857#comment:3> MacPorts <https://www.macports.org/> Ports system for OS X
participants (1)
-
MacPorts