Last Comment Bug 700524 - Support building on Mac with non-Apple GCC
: Support building on Mac with non-Apple GCC
Product: Core
Classification: Components
Component: Build Config (show other bugs)
: Trunk
: All Mac OS X
-- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
: Gregory Szorc [:gps] (away until 2017-03-20)
Depends on:
Blocks: 700772
  Show dependency treegraph
Reported: 2011-11-07 17:38 PST by Gregory Szorc [:gps] (away until 2017-03-20)
Modified: 2011-11-09 10:41 PST (History)
8 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image Gregory Szorc [:gps] (away until 2017-03-20) 2011-11-07 17:38:32 PST
It appears we don't currently support building on Darwin with GCC that doesn't come from Apple (e.g. the stock GCC).

The main problem appears to be that Apple's GCC supports some flags that stock GCC doesn't (such as -arch). Unfortunately, we rely on these flags thus prohibiting compilation on stock GCC.

It appears Apple has stopped shipping actual GCC with XCode (they switched to LLVM/Clang and the transparent GCC bridge). So, we have to decide if we want to support building on Darwin with the true GCC or make the switch to Clang.

Steps to reproduce:

1) Install a non-Apple GCC. If using HomeBrew, `brew -v install --use-gcc --enable-all-languages`
2) Try to compile m-c. Define "CC=/usr/local/bin/gcc-4.6 CXX=/usr/local/bin/gcc-4.6" in your .mozconfig
3) make -C config export
/usr/local/bin/gcc-4.6 -arch x86_64 -o now.o -c      -Wall -fno-common -isysroot /Developer/SDKs/MacOSX10.7.sdk -O2 -g -fPIC  -UNDEBUG -DDEBUG_gps  -DMOZILLA_CLIENT=1 -DDEBUG=1 -DHAVE_VISIBILITY_HIDDEN_ATTRIBUTE=1 -DHAVE_VISIBILITY_PRAGMA=1 -DXP_UNIX=1 -DDARWIN=1 -DHAVE_BSD_FLOCK=1 -DHAVE_SOCKLEN_T=1 -DXP_MACOSX=1 -DHAVE_LCHOWN=1 -DHAVE_STRERROR=1  -DFORCE_PR_LOG -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM   /Users/gps/src/services-central-git/nsprpub/config/now.c
gcc-4.6: error: x86_64: No such file or directory
gcc-4.6: error: unrecognized option '-arch'
Comment 1 User image Gregory Szorc [:gps] (away until 2017-03-20) 2011-11-07 18:36:15 PST
By removing '-arch' from a few key places, I was able to unwedge the build. However, js/ is blowing up during linking of the shell:

Interestingly, it does produce libjs_static.a just fine. It seems to be missing an input library for linking.
Comment 2 User image Kyle Huey [:khuey] (Exited; not receiving bugmail, email if necessary) 2011-11-08 04:22:20 PST
I think we're going to switch to clang and this will be WONTFIX.
Comment 3 User image Rafael Ávila de Espíndola (:espindola) (not reading bugmail) 2011-11-08 05:53:53 PST
You will have a hard time getting apple's new headers to work with upstream gcc. There is a new version of objective c that is not supported upstream and blocks (which we use already on 10.7) is also not supported.
Comment 4 User image Gregory Szorc [:gps] (away until 2017-03-20) 2011-11-08 12:26:06 PST
This is unfortunate, but fair, I suppose.

I've updated the Troubleshooting section to reference this. I also took the liberty of refactoring the page, as the content was a bit stale and wasn't very easy to follow, IMO. Peer review would be appreciated.

I'm going to file a follow-up bug to have configure perform better compiler detection. IMO, we should fail fast and not get beyond configure if non-Apple GCC is being used on Darwin.

Note You need to log in before you can comment on or make changes to this bug.