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

Homebrew and Xcode 4.2 #6852

Closed
xose opened this issue Aug 6, 2011 · 50 comments
Closed

Homebrew and Xcode 4.2 #6852

xose opened this issue Aug 6, 2011 · 50 comments

Comments

@xose
Copy link
Contributor

xose commented Aug 6, 2011

The GCC 4.2 compiler will be discontinued with the Xcode 4.2 release this fall. This means that all formulae marked as 'fails_with_llvm' will no longer compile. There are currently 86 such formulae in homebrew.

Clang 3.0 will also become the default compiler on Xcode 4.2, with LLVM-GCC being downgraded to 'legacy' compiler. It's safe to assume LLVM will also be removed on a later Xcode release, so it might be interesting to consider using Clang as the default compiler for homebrew if Xcode 4.2 is installed.

@sorin-ionescu
Copy link
Contributor

There are currently 91 formulae that have fails_with_llvm. We should aim for clang first then llvm-gcc since it will most likely be removed in Xcode 4.3. Unfortunately, we will have to fix these builds ourselves since their authors use Linux, which still uses GCC; so, their response will most likely be, 'Don't know! Don't care! You fix it!'

@alassek
Copy link

alassek commented Aug 16, 2011

Is it possible to remove the XCode dependency and recommend osx-gcc-installer instead?

I've been using it exclusively and so far, so good.

@sferik
Copy link
Contributor

sferik commented Aug 16, 2011

👍 I'd love to see this as well.

@sorin-ionescu
Copy link
Contributor

@alassek. It's not possible to remove the Xcode dependency. There are desktop/mobile developers that use Homebrew, but different compiler installations should certainly be mentioned. osx-gcc-installer is flawed.

@alassek
Copy link

alassek commented Aug 16, 2011

@sorin-ionescu that's disappointing. Requiring a 3Gig download for a C compiler is intolerable.

@adamv
Copy link
Contributor

adamv commented Aug 16, 2011

Buy an Apple computer, play by Apple's rules.

@alassek
Copy link

alassek commented Aug 16, 2011

@adamv the rules are stupid. 3Gb for a C compiler is stupid. It's a consequence of OSX's lack of a decent package manager.

Developers getting annoyed is the raw fuel that powers open-source, in case you didn't know. ;-)

@adamv
Copy link
Contributor

adamv commented Aug 16, 2011

I guess if OSS had produced UI as good as OS X on Linux, we wouldn't be griping about this right now.

@sorin-ionescu
Copy link
Contributor

@adamv, while OSS has never been able to produce a decent GUI, it has certainly produced decent package managers, including great ones, like Arch Linux' Pacman. The problem is GPL; so, Apple will never touch them. The BSD community does not have a package manager worth taking.

@alassek, I would not expect Apple to ever release the compiler without Xcode. Apple is a hardware company. Whatever software they create must sell hardware, and whatever software 3rd party developers create must sell hardware. From the business point of view, it makes no sense for Apple to spend resources to help web developers create apps that can be and will be, due to low marketshare, consumed on competitors' hardware.

@alassek
Copy link

alassek commented Aug 16, 2011

@sorin-ionescu creating a decent OSX package manager would benefit everyone, Apple included. But I've already resigned myself to the reality that they're probably too myopic to care.

@sorin-ionescu
Copy link
Contributor

A few people in the Arch Linux forum were trying to port Pacman to Mac OS X. I don't know what has come of it.

Why don't you look into package managers? Then send Apple a feedback letter urging them to adopt something.

On Aug 16, 2011, at 1:35, alassekreply@reply.github.com wrote:

@sorin-ionescu creating a decent OSX package manager would benefit everyone, Apple included. But I've already resigned myself to the reality that they're probably too myopic to care.

Reply to this email directly or view it on GitHub:
#6852 (comment)

@alassek
Copy link

alassek commented Aug 16, 2011

@sorin-ionescu I wish I were more knowledgable about package management. If there's an effort underway to port Pacman I'll help out any way I can.

@storytracer
Copy link

Well, Apple released Xcode 4.2 GM yesterday, so this therotical problem has become reality. I ran into the issue after doing a clean install of Lion. Since I didn't have any previous Xcode version installed, GCC 4.2 was missing on my computer. It took me more than 4 hours to figure that out (it's really the last thing you would expect to happen) and copy the missing binaries out of the Xcode 4.1 package.

I guess more and more developers will find themselves in this very situation during the next few months and since Xcode 4.1 will not be available for download much longer, I think we need to find a solution quickly.

I tried to compile the GCC 4.2 source code from opensource.apple.com with LLVM-GCC, but of course that didn't work. I'm not a license expert, but shouldn't the binaries in the Xcode 4.1 package also be licensed under GPL? In that case we could put up a 'gcc-4.2' formula simply containing these files, couldn't we?

@thoughtpolice
Copy link
Contributor

Perhaps a better alternative is to simply make GCC (a newer version, say 4.6.1) itself a formula in mainline homebrew, and possibly let any packages that absolutely need it have it as a dependency? There are active maintainers of the Darwin port of GCC, and I myself have 4.6 installed on my machine for performance testing. Clang itself reportedly builds GCC quite capably and has been able to do so for a while, but I haven't confirmed this any time recently. (Full disclosure: I'm not yet running Lion and only have XCode 4.0.2 still.) Long term I think this is absolutely the best route if Apple is going to discontinue shipping it.

Since they're doing that (truthfully they have no reason to support it - they will never upgrade past GCC 4.2, because later version are GPLv3) there's likely not a whole lot we can do about it legitimately, that won't be a burden on users (breakage in future OS X versions, being a PITA to install) and people who want things working. I see any sort of attempts to keep GCC 4.2 alive as completely futile, and likely to cause much disturbance in the Force. Modern XCode is required in order to install certain OS X frameworks and headers properly, and they will probably not like people using a redistribution of that en masse.

I would advise making a recent GCC formula that either is keg-only, or safely sets the program suffix of GCC to something like '4.6' via --program-suffix=-4.6 in ./configure so that executable names don't clash with people who may have GCC 4.2 hanging around. Anyone who absolutely can't build without it should have it as a dependency and specifically use those compilers in the configuration step, like --use-gcc and --use-clang do now. Formula which are marked to fail with LLVM should be tested against XCode 4.2 with their latest release/unstable versions and issues reported to maintainers. That's just the way it is folks and @adamv is right - and Apple has chosen this route, so we have to deal with it. And redistributing copyrighted works ripped out of a .pkg file which will never be updated or officially Apple supported is not the way to do it.

EDIT: I'll also go ahead and mention that GCC 4.6 is in any case far ahead of GCC 4.2 in terms of performance, features and speed, so honestly it's a win in any case if you ask me. Further, this seems like a completely logical step from the Homebrew perspective IMO, because GCC is clearly no longer going to be under Apple control or distributed with the system. Thus I feel in the same vein it should be excluded from Homebrew's "package exemptions" - it has now just become an ordinary piece of software we should let people install if they need it.

@Sharpie
Copy link
Contributor

Sharpie commented Oct 5, 2011

One potentially major problem with non-Apple GCC (such as 4.6.x) is that they don't build universal binaries. On has to recompile multiple times, track the binaries down, pair them up, and stich the whole mess together using lipo.

The zeromq formula manages to pull this off, but it ain't pretty.

@storytracer
Copy link

You are absolutely right @thoughtpolice, brew shouldn't be based on a piece of legacy software, which has been out-of-date for 4 years already. LLVM should be the standard compiler from now on and GCC the exception, just like Apple defined it for OS X in general.

But this task takes time and much expertise: Testing each formula, finding compiling errors, reporting them to the project mantainers and waiting for the fixes to be released.

In the meantime people won't be able to compile these formulas or other software which isn't on brew: rvm Ruby versions, gems, python modules. Developers using Lion need a legacy solution for legacy software version anyway and only the Apple GCC version 4.2 can guarantee that everything will compile without any problems, at the moment.

Maybe someone more skilled in compiling than me, could have a look at http://www.opensource.apple.com/tarballs/gcc/gcc-5666.3.tar.gz. Compiling Apple GCC 4.2 with Clang or LLVM-GCC should be possible somehow, somehow, don't you think?

@xose
Copy link
Contributor Author

xose commented Oct 5, 2011

It could be distributed as a bottled formula (built with gcc-4.2 itself), so users of Xcode 4.2+ don't have to compile it themselves.

However, I think that making clang the default compiler should be a priority as well, otherwise we'll have the same problem when LLVM-GCC gets discontinued. Maybe create a new builds_with_clang tag similar to fails_with_llvm for formulae that have been tested to work?

@jacknagel
Copy link
Contributor

We'll probably add fails_with_clang when someone has time to write the code: #7638

@sorin-ionescu
Copy link
Contributor

Xcode 4.2 has been released.

@feoh
Copy link

feoh commented Oct 26, 2011

I just upgraded to Lion, which zorched my old Xcode, and then installed it again from the App Store. It's 4.2, and now a just about everything fails with /usr/bin/cc not found. I considered symlinking, but wonder if there will be tertiary failures as a result.

Have I shot myself in the foot? Is there any way to recover or is my homebrew doomed to failure? :) (My currently installed utilities still work, so I guess being stuck in time is tolerable, but not ideal :)

Thanks,
-Chris

@Sharpie
Copy link
Contributor

Sharpie commented Oct 26, 2011

everything fails with /usr/bin/cc not found

That sounds odd. "Installing" from the App Store just downloads an XCode installer to /Aplications---did you run that installer?

@feoh
Copy link

feoh commented Oct 26, 2011

Ah, OK I'd seen that mentioned (needing to run an additional
installer) but I got confused because the silly app store thing said
"Installed" and I also have a runnable XCode app on my system, so I
thought everything was set.

I'll try that, thanks!
-Chris

On Wed, Oct 26, 2011 at 12:20 PM, Charlie Sharpsteen
reply@reply.github.com
wrote:

everything fails with /usr/bin/cc not found

That sounds odd. "Installing" from the App Store just downloads an XCode installer to /Aplications---did you run that installer?

Reply to this email directly or view it on GitHub:
#6852 (comment)

Christopher Patti - Geek At Large | GTalk: cpatti@gmail.com | AIM:
chrisfeohpatti | P: (260) 54PATTI
"Technology challenges art, art inspires technology." - John Lasseter, Pixar

@khelben
Copy link

khelben commented Oct 29, 2011

I think I've got it fixed.

The trick is to first install Xcode 4.1 and then upgrade to Xcode 4.2.

More details can be found here: https://gist.github.com/1324955

Please let me know how this works out for you.

@feoh
Copy link

feoh commented Oct 29, 2011

Oy this was stupid user syndrome. Just in case anyone else is similarly myopic and needs exact instructions, when you 'install' Xcode from the app store (I know others have said this :) it puts an "Install Xcode.app" or similar into your /Applications folder. Until you run this it's not really installed.

Go figure.

@casualjim
Copy link
Contributor

for me the fix was to add

ENV.append "CFLAGS", "-O0"

to the formula below ENV.deparallelize and then installing with

CC=/usr/bin/cc brew install --use-gcc -v erlang

@adamv
Copy link
Contributor

adamv commented Dec 13, 2011

How are we doing on this? Are there any actionable items in here or can we close this issue?

@Sharpie
Copy link
Contributor

Sharpie commented Dec 13, 2011

How are we doing on this? Are there any actionable items in here or can we close this issue?

One thing I have found is a full build of Apple GCC 4.2.1 for Lion that supports i386 and x86_64 architectures:

http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg

Currently the GFortran formula uses this package but throws away the C compilers. It would be easy to post a full install as an apple-gcc formula on Homebrew-alt.

Then there would be an easy way for users of XCode 4.2+ to obtain a vanilla GCC installation if they absolutely need it.

@Sharpie
Copy link
Contributor

Sharpie commented Dec 18, 2011

I just added an apple-gcc42 to the duplicates folder on Homebrew-alt. Lion users who have XCode 4.2 or later and need a non-LLVM build of Apple's compilers, can install thusly:

brew install http://github.com/adamv/homebrew-alt/raw/master/duplicates/apple-gcc42.rb

The installation downloads precompiled binaries of the compilers that were dropped from XCode 4.2:

  • gcc-4.2
  • g++-4.2

The compilers were built from Apple's GCC 4.2.1-5666.3 sources and are capable of creating i386/x86_64 universal binaries.

Moving forward, it would be nice to get everything compiling cleanly under Clang as the Apple GCC is going to fade into history. However, this should provide a crutch for those who absolutely need it and we don't have to go through the effort required to maintain a source build.

@adamv @jacknagel @mxcl @MikeMcQuaid @mistydemeo

We can probably close this issue now, unless anyone has something else to add.

@igorbernstein
Copy link

How can I use this to compile formulas? it seems like Homebrew only checks /usr/bin for gcc-4.2

@MikeMcQuaid
Copy link
Member

None of the team have access to the beta so I suggest you either downgrade, write a patch or donate money for a developer license :)

@mistydemeo
Copy link
Member

@MikeMcQuaid I think he's talking about Charlie's new apple-gcc42 formula, which is meant to be used with release versions of Xcode 4.2. If Homebrew isn't checking in prefix/bin/gcc-4.2, that needs to be updated.

@MikeMcQuaid
Copy link
Member

Ah. We'll have a similar problem in Xcode 4.3 hence the confusion. Thanks @mistydemeo.

@adamv
Copy link
Contributor

adamv commented Jan 9, 2012

Is there anything actionable here in this issue? Things that need to move to a wiki page?

@igorbernstein
Copy link

I believe so...
Homebrew should check prefix/bin/gcc-4.2 when looking for a suitable gcc so that your formula can be used to compile packages

@mistydemeo
Copy link
Member

@igorbernstein See #9384.

@igorbernstein
Copy link

I stand corrected
ps. thanks for spearheading this

@Bjoern
Copy link

Bjoern commented Jan 10, 2012

I've managed to install the alternative gcc to /usr/local/bin, but how do I now make brew find it? The #9384 thing is probably not yet included in brew? --use-gcc flag is not recognized if I try brew upgrade --use-gcc. Thanks from a non-git-wizard!

@mxcl
Copy link
Contributor

mxcl commented Jan 14, 2012

Probably can close this one since Xcode 4.2 came out and things seem okay.

@Bjoern
Copy link

Bjoern commented Jan 14, 2012

Hm, not for me - but I had erased Xcode 4.1 before installing XCode 4.2. Somebody else mentioned that it works if you install 4.1 first and then 4.2, so maybe in that case it just keeps the compilers from 4.1 around?

@MikeMcQuaid
Copy link
Member

Correct. GCC isn't in 4.2 but Clang is much better so we should fall back to that instead (and probably prioritise it over llvm-gcc).

@mxcl
Copy link
Contributor

mxcl commented Jan 15, 2012

I thought llvm-gcc was the better choice since it has the same CLI as gcc?

Regarding closing this ticket, we need specific tickets for formula that break, and I expect we have them.

@MikeMcQuaid MikeMcQuaid reopened this Jan 15, 2012
@MikeMcQuaid
Copy link
Member

Reopening.

LLVM-GCC is removed as-of LLVM 3. The version included with Xcode 4.2 is based on LLVM 2336.

Clang will be remaining and the version included with Xcode 4.2 is based on LLVM 3.0svn. It also (in my limited tests, soon to be expanded) compiles more code and optimises better than LLVM-GCC does.

@evilrob666
Copy link

Sharpie's comment

brew install http://github.com/adamv/homebrew-alt/raw/master/duplicates/apple-gcc42.rb

failed for me with the almost amusing "Error: undefined method `lion?' for MacOS:Module"

furtunately it did successfully download the .pkg which, after installing, seems to have fixed the epic breakage in my homebrew.

cheers

@mistydemeo
Copy link
Member

@evilrob666 Have you brew updated?

@Sharpie
Copy link
Contributor

Sharpie commented Jan 23, 2012

@evilrob666

failed for me with the almost amusing "Error: undefined method `lion?' for MacOS:Module"

Hmm... something is wrong with your Homebrew installation if the MacOS module does not have a lion? method:

https://github.com/mxcl/homebrew/blob/master/Library/Homebrew/utils.rb#L394-396

I agree with Misty---the most likely cause is that you are somehow stuck on an ancient version of Homebrew that predates OS X 10.7.

@evilrob666
Copy link

I'm quite prepared to believe there's something screwy with my homebrew. I don't know how it could've got that way though.

(fwiw, yesterday I did brew update and brew upgrade each a few times, and neither seemed to do anything) Today I tried a brew update and got "error: Your local changes to 'Library/Formula/dirac.rb' would be overwritten by merge. Aborting.
Please, commit your changes or stash them before you can merge."

rather disturbingly;

#[Tue Jan 24 11:19:58] simurgh:/usr/local/Library/Formula:master+$ git status | wc
1211 3636 31913

(rather a lot of modified + deleted lines - none of which, as far as I know my doing (i.e. I've not consciously modified any of those) trying a few git checkout -- dirac.rb just uncovered more probs - eventually I stashed the whole thing and was able to brew update, but I don't understand how brew got itself into that state... :-/ )

after that I was able to brew update, but brew upgrade now fails with;

#[Tue Jan 24 11:22:07] simurgh:/usr/local/Library/Formula:master$ brew upgrade
Error: undefined method include?' for nil:NilClass Please report this bug: https://github.com/mxcl/homebrew/wiki/checklist-before-filing-a-new-issue /usr/local/Library/Homebrew/formula.rb:417:incanonical_name'
/usr/local/Library/Homebrew/formula.rb:449:in factory' /usr/local/Library/Contributions/examples/brew-upgrade.rb:7 /usr/local/Library/Contributions/examples/brew-upgrade.rb:7:inmap'
/usr/local/Library/Contributions/examples/brew-upgrade.rb:7
/usr/local/bin/brew:47:in require' /usr/local/bin/brew:47:inrequire?'
/usr/local/bin/brew:80

@mistydemeo
Copy link
Member

I'm not quite sure why, but this is a problem that's come up a few times. (Often enough we included it in the FAQ!) If you haven't made any local changes to Homebrew you want to keep, you can do this to remove all the extra files:

cd /usr/local
git clean -f

@jacknagel
Copy link
Contributor

Can we close this now that focus has shifted to 4.3, in #9179?

@MikeMcQuaid
Copy link
Member

Yep, definitely.

@mxcl
Copy link
Contributor

mxcl commented Feb 27, 2012

Yeah, I wish we could figure why the git history ends up in a weird state like that. Sorry Rob.

@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