Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Homebrew overriding compiler set in Xcode projects #6406

Closed
tonyarnold opened this issue Jul 13, 2011 · 21 comments
Closed

Homebrew overriding compiler set in Xcode projects #6406

tonyarnold opened this issue Jul 13, 2011 · 21 comments

Comments

@tonyarnold
Copy link

Why does homebrew override the compiler set in Xcode projects? If there's not a good reason for this, it probably shouldn't do this by default.

For a working example, try compiling mogenerator with Xcode 4.1 or later installed — brew install mogenerator --HEAD.

@robrix
Copy link
Contributor

robrix commented Jul 13, 2011

4.0 or later, I believe.

Being able to do the equivalent of --use-clang in the formula would be a temporary workaround, but it wouldn’t really fix the underlying issue of homebrew overriding xcodebuild.

@adamv
Copy link
Contributor

adamv commented Jul 13, 2011

Xcode-based projects are problematic for Homebrew in general, especially in the face of 10.5 SDK dropping.

@robrix
Copy link
Contributor

robrix commented Jul 13, 2011

The 10.5 SDK dropping is probably an upstream issue for the projects—if they want to build on 10.7 they’ve got to deal.

@dustintitus
Copy link

You gotta be kidding me! Homebrew simply won't work with Xcode 4.x?

Why aren't you advertising this far and wide? How was I supposed to know? So now, after going through all the pain of un-installing MacPorts, and getting set up with Homebrew, now I am going to have to go back?

This is actually pretty darned outgrageous.

@robrix
Copy link
Contributor

robrix commented Aug 3, 2011

Uhhhh… I don’t think that’s what it means at all. The mogenerator formula won’t work with 4.0 or later, and while others may suffer the same fate it’s the only one I’m directly aware of. That doesn’t mean homebrew doesn’t work with Xcode 4; I’m happily using it on 10.7 with 4.1, for example. I’m just trying to resolve the issue with the mogenerator formula and seeking guidance from the homebrew devs on what seems like a strange issue with formulae that use xcodebuild.

No need for panic, I think.

@dustintitus
Copy link

I guess I misunderstood. Can anybody point me to a fix then for the "Can't find gcc 4.0.x..." issue?

It seems pretty clear that it was caused by the installation of Xcode 4.1.

@imagesafari
Copy link
Contributor

Are you sure you don't have gcc? Maybe it's just not in your path? Try:

export PATH=$PATH:'/Developer/usr/bin'

@robrix
Copy link
Contributor

robrix commented Aug 3, 2011

imagesafari: Xcode 4 does not include GCC 4. It includes LLVM-GCC but that is going to go away sooner or later; Apple is throwing all their weight behind clang.

@imagesafari
Copy link
Contributor

Hmm, that's true based on what I have (which is working fine with Homebrew as I use it anyway):

[]$ which gcc
/usr/bin/gcc
[
]$ ls -l /usr/bin/gcc
lrwxr-xr-x 1 root wheel 12 Jul 14 11:07 /usr/bin/gcc -> llvm-gcc-4.2
[~]$

@robrix
Copy link
Contributor

robrix commented Aug 3, 2011

Yes, I have the same. Some formulae look for GCC 4.0, however, which is unavailable.

This is, of course, a different issue from brew’s overriding of the compiler that Xcode targets specify when building a formula with xcodebuild.

@dustintitus
Copy link

Well, that's what brew reported last time I tried to install something, and also when I run "brew doctor".

It's gcc from LLVM:

gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

I'm just wondering, because I could understand if certain applications were looking for 4.0.x... but when "brew doctor" reports it as a problem, it seems to me that something is wrong.

@jacknagel
Copy link
Contributor

Just to clarify:

gcc 4.0.x is not included in XCode 4.x. If you have it, it is just a holdover from XCode 3.x. I believe XCode 4.1 removes gcc 4.0.x.

gcc 4.2.1 is included in XCode 4.x. However it is only accessibly as gcc-4.2, the gcc symlink points at llvm-gcc by default.

@mxcl
Copy link
Contributor

mxcl commented Sep 10, 2011

Can you describe how we are "overriding the compiler set in Xcode projects?"

All we do is set $CC in the environment. Does that effect Xcode projects? Seems a bit crazy.

If that's the problem (which is weird sounds like a bug in xcodebuild to me), then we can detect when xcodebuild is called and unset CC for the duration. We have to set CC though, untold millions of formula fail to build without it.

@mxcl
Copy link
Contributor

mxcl commented Sep 10, 2011

I've confirmed that this is the cause of the bug.

@mxcl mxcl closed this as completed in c1e3546 Sep 10, 2011
@Zearin
Copy link
Sponsor Contributor

Zearin commented Sep 10, 2011

@robrix said:

imagesafari: Xcode 4 does not include GCC 4. It includes LLVM-GCC but
that is going to go away sooner or later; Apple is throwing all their weight behind clang.


Whoa, really?!

I remember watching a video preview of XCode 4 before it was released, and a significant portion of the presentation was devoted to showing off how awesome LLVM was, how it was going to revolutionize development, perform smart/incremental/background compilation and code-completion, blah blah blah blah…

Basically, it seems to me that Apple was going to be throwing its weight behind LLVM. The video I’m referring to was before XCode 4’s release, but I didn’t think it was that old.

I admit: I’m just interested in learning about this for curiosity’s sake, and I don’t even know how to program in a language that needs a compiler. But I find the concepts of compilation fascinating, and I was actually pretty excited by the stuff Apple was claiming LLVM was capable of in that video.

Can somebody explain to me the benefits gained by switching compilers again?

@tonyarnold
Copy link
Author

@Zearin, if you have access to the WWDC videos, I believe Apple's engineers can explain it better than anyone here could. You listed a lot of the reasons behind the change in your question.

In my opinion, things aren't going to get worse by moving to LLVM properly :)

@robrix
Copy link
Contributor

robrix commented Sep 10, 2011

@Zearin, one minor point: LLVM-GCC is not the compiler they were talking about as “the future.” Clang is what Apple refers to as the “Apple LLVM Compiler,” and that’s the one they’re moving to. LLVM-GCC is a stepping stone between GCC and clang. It was always going to be temporary.

@robrix
Copy link
Contributor

robrix commented Sep 10, 2011

@mxcl Thanks dude!

@Zearin
Copy link
Sponsor Contributor

Zearin commented Sep 10, 2011

@robrix

one minor point: LLVM-GCC is not the compiler they were talking about as “the future.” Clang is what Apple refers to as the “Apple LLVM Compiler,” and that’s the one they’re moving to. LLVM-GCC is a stepping stone between GCC and clang. It was always going to be temporary.


Oohhhh!

Yeah, I think that’s it. That video is actually where I heard about this thing called “LLVM” for the first time. Before that, the only compiler I was aware of (for C/C++/ObjC anyway) was plain old vanilla GCC.

Then I noticed that there were files called llvm-gcc-x.x in somewhere under /Developer, and assumed that LLVM was something built on top of GCC.

So now I’m finally starting to realize that, although I always knew that “LLVM” means “Low Level Virtual Machine”, I thought that it was a name chosen for a specific project. If I’m reading you correctly @robrix , then what you’re saying that “LLVM” is a type of compiler, and that LLVM-GCC is just GCC’s implementation of an LLVM.

Is that correct?

@robrix
Copy link
Contributor

robrix commented Sep 11, 2011

@Zearin Close.

LLVM is an overall project that can be used to write compilers. http://llvm.org for more information. Incidentally, I think they consider the “low-level virtual machine” expansion to be deprecated :)

Apple LLVM Compiler/Clang is a specific, LLVM-based C language family (hence clang: c-language) compiler. It uses LLVM to generate machine code on the back-end, and uses its own parser and abstract syntax tree. http://clang.llvm.org for more info.

LLVM-GCC pairs GCC’s front-end (parser, etc) with an LLVM code generator back-end. Since it uses GCC’s parser, etc, it retains most of the performance/error reporting issues of GCC, but it does generate better code in many cases; it was a stepping stone developed at Apple, IIRC.

So, LLVM isn’t really a type of compiler; rather it’s a specific project whose libraries are leveraged by both LLVM-GCC and clang.

@Sharpie
Copy link
Contributor

Sharpie commented Sep 11, 2011

Incidentally, I think they consider the “low-level virtual machine” expansion to be deprecated :)

"Low-Level Virtual Machine" will always be an appropriate expansion for that project as all LLVM compilers target assembly code for a virtual machine---hence the "low level" part. As a final step, this virtualized assembly is converted into native object code.

The majority of optimizations that get compiler nerds all hot and bothered take place on this low level virtualized assembly code so "Low-Level Virtual Machine" is an apt description of the thing they are hacking on.

Sharpie pushed a commit to Sharpie/homebrew that referenced this issue Sep 19, 2011
The compiler setting in the xcodeproj is overridden by the CC setting in the environment. This is a bit insane IMO since the xcodeproj itself has detailed decisions about what tools to use.

Fixes Homebrew#6406.
martinploeger pushed a commit to martinploeger/homebrew that referenced this issue Oct 8, 2011
The compiler setting in the xcodeproj is overridden by the CC setting in the environment. This is a bit insane IMO since the xcodeproj itself has detailed decisions about what tools to use.

Fixes Homebrew#6406.
etehtsea pushed a commit to etehtsea/homebrew that referenced this issue Dec 27, 2011
The compiler setting in the xcodeproj is overridden by the CC setting in the environment. This is a bit insane IMO since the xcodeproj itself has detailed decisions about what tools to use.

Fixes Homebrew#6406.
Sharpie pushed a commit to Sharpie/homebrew that referenced this issue Sep 12, 2012
The compiler setting in the xcodeproj is overridden by the CC setting in the environment. This is a bit insane IMO since the xcodeproj itself has detailed decisions about what tools to use.

Fixes Homebrew#6406.
snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this issue Dec 17, 2012
The compiler setting in the xcodeproj is overridden by the CC setting in the environment. This is a bit insane IMO since the xcodeproj itself has detailed decisions about what tools to use.

Fixes Homebrew#6406.
@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants