Linuxbrew / legacy-linuxbrew

:skull: This repository is defunct, because it has been split into https://github.com/Linuxbrew/brew and https://github.com/Linuxbrew/homebrew-core
http://linuxbrew.sh
Other
2.23k stars 296 forks source link

Unable to bootstrap gcc #137

Closed oneillkza closed 10 years ago

oneillkza commented 10 years ago

I'm trying to install linuxbrew on a machine running CentOS 6.5, which means that it has extremely outdated packages, such that linuxbrew does not want to use the system-installed gcc. I have no systems rights on the machine, so cannot upgrade these myself.

The suggested solution by linuxbrew is:

To install this formula, you may need to:
  brew install gcc

However, when I run brew install gcc, the following happens:

==> Installing dependencies for gcc: gmp, mpfr, libmpc, pkg-config, isl, 
==> Installing gcc dependency: gmp
Error: gmp cannot be built with any available compilers.
 To install this formula, you may need to:
  brew install gcc
sjackman commented 10 years ago

This might be resolved by 3353c346f08738b1891730e7647b1aebd6e40c70. Can you run brew update and try again?

sjackman commented 10 years ago

Are you using HOMEBREW_CC or --cc?

sjackman commented 10 years ago

Try

prefix=~/.linuxbrew
ln -s /usr/bin/gcc44 $prefix/bin/gcc-4.4
ln -s /usr/bin/g++44 $prefix/bin/g++-4.4
ln -s /usr/bin/gfortran44 $prefix/bin/gfortran-4.4
export HOMEBREW_CC=gcc-4.4
brew install hello && brew test -v hello; brew remove hello

See here: https://github.com/Homebrew/linuxbrew/wiki/Standalone-Installation#use-a-compiler-other-than-gcc

oneillkza commented 10 years ago

Definitely not the update -- I downloaded and updated about half an hour ago, and when I re-ran update now it said it was already up to date.

Running your hello code (using the steps avoe), I get:

Error: The Homebrew GCC was not installed.
You must:
  brew install gcc
Error: No such keg: /home/koneill/.linuxbrew/Cellar/hello
oneillkza commented 10 years ago

Ah hang on, those symlinks don't look right.

oneillkza commented 10 years ago

Yeah, it looks like there's no gcc44 in/usr/bin

Symlinking to /usr/bin/gcc etc seems to work. Will this cause issues in future, though?

ln -s /usr/bin/gcc gcc-4.4 $prefix/bin/gcc-4.4
oneillkza commented 10 years ago

Yep that worked completely -- I was able to bootstrap gcc 4.9.

I guess shared.rb will need a little more tweaking to account for this particular case.

sjackman commented 10 years ago

Can you report the output of the following?

ls -l /usr/bin/cc* /usr/bin/gcc*
cc --version
gcc --version
oneillkza commented 10 years ago
[koneill@klesack01-centos Aly_meetings]$ ls -l /usr/bin/cc* /usr/bin/gcc*
lrwxrwxrwx. 1 root root      3 Jan 29  2014 /usr/bin/cc -> gcc
-rwxr-xr-x  1 root root  50216 Sep 23  2011 /usr/bin/ccache-swig
-rwxr-xr-x  2 root root 268224 Nov 21  2013 /usr/bin/gcc
[koneill@klesack01-centos Aly_meetings]$ cc --version
cc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[koneill@klesack01-centos Aly_meetings]$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
oneillkza commented 10 years ago

Basically there is only a gcc executable, and no version-specific executable name.

sjackman commented 10 years ago

That's fine.

prefix=~/.linuxbrew
ln -s /usr/bin/gcc $prefix/bin/gcc-4.4
ln -s /usr/bin/g++ $prefix/bin/g++-4.4
ln -s /usr/bin/gfortran $prefix/bin/gfortran-4.4
export HOMEBREW_CC=gcc-4.4
brew install hello && brew test -v hello; brew remove hello
oneillkza commented 10 years ago

Yes, that's what I did. I'm busy testing the complete procedure as listed at https://github.com/Homebrew/linuxbrew/wiki/Standalone-Installation

It's running fairly smoothly so far. I think my problem was that I jumped straight to trying to compile gcc without completing the other steps. I'll post again to close if this is sorted.

oneillkza commented 10 years ago

Yeah, I just needed to go back to the TL;DR steps and run through them (after correctly symlinking gcc and g++) . So basically this issue is resolved, although as I said before it may be a good idea to include this as a case in shared.rb (basically a modification on this : https://github.com/Homebrew/linuxbrew/commit/3353c346f08738b1891730e7647b1aebd6e40c70)

Now, if I can just figure out how to get Mendeley in a cask and using the up-to-date linuxbrew libraries, I'll become very, very happy.

sjackman commented 10 years ago

brew cask install https://raw.githubusercontent.com/sjackman/homebrew-cask/mendeley/Casks/mendeley.rb

sjackman commented 10 years ago

See caskroom/homebrew-cask#6349

oneillkza commented 10 years ago
[koneill@klesack01-centos lib]$ brew cask install https://raw.githubusercontent.com/sjackman/homebrew-cask/mendeley/Casks/mendeley.rb
Error: No available formula for brew-cask 
[koneill@klesack01-centos lib]$ brew install brew-cask
Error: No available formula for brew-cask 

I think the cask functionality hasn't been ported over? I did run brew update first.

sjackman commented 10 years ago

Sorry, I misunderstood. brew cask is not available for Linuxbrew. Sorry to get your hopes up.

matope commented 10 years ago

Hi, I hit this problem and it has been solved by your snippet. https://github.com/Homebrew/linuxbrew/issues/137#issuecomment-57025676

Below snippet doesn't solve as /usr/bin/{gcc44,g++44,gfortran44} not found in my system. https://github.com/Homebrew/linuxbrew/wiki/Standalone-Installation#use-a-compiler-other-than-gcc

sjackman commented 10 years ago

Try this instead:

ln -s `which gcc` ~/.linuxbrew/bin/gcc-`gcc -dumpversion |cut -d. -f1,2`
ln -s `which g++` ~/.linuxbrew/bin/g++-`g++ -dumpversion |cut -d. -f1,2`
ln -s `which gfortran` ~/.linuxbrew/bin/gfortran-`gfortran -dumpversion |cut -d. -f1,2`
matope commented 10 years ago

Thanks! It goes well in my CentOS 6.5.

matope commented 9 years ago

@sjackman Don't you include this trick into the omnibus installer? (https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install) I originally wanted to make such a patch, but I couldn't find where the source code is.

sjackman commented 9 years ago

Yes, that's a good idea, but I think I'll instead put it somewhere in the Ruby code, probably where it looks for the default compiler, so as to support installs via a simple git clone.

The code for install is in the branch go.

matope commented 9 years ago

That sounds better way. So, I'm looking forwrad to the implementation as I'm not good at Ruby:)

tseemann commented 9 years ago

I just got burnt with this exact same issue when I decided to start from scratch after screwing up my existing Linuxbrew install. However I did not have to do this bootstrap the first time around? Has something changed since Feb 2015?

sjackman commented 9 years ago

It changed at some point, but I'm not sure when. Sorry I couldn't be more helpful.

wenerme commented 9 years ago

After ls, I can install hello, but test not good

# brew -v test hello
Homebrew 0.9.5
Error: cannot load such file -- minitest/unit
Please report this bug:
    https://github.com/Homebrew/linuxbrew/blob/master/share/doc/homebrew/Troubleshooting.md#troubleshooting
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/share/ruby/test/unit/assertions.rb:1:in `<top (required)>'
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/wener/.linuxbrew/Library/Homebrew/formula_assertions.rb:7:in `rescue in <module:Assertions>'
/home/wener/.linuxbrew/Library/Homebrew/formula_assertions.rb:4:in `<module:Assertions>'
/home/wener/.linuxbrew/Library/Homebrew/formula_assertions.rb:2:in `<module:Homebrew>'
/home/wener/.linuxbrew/Library/Homebrew/formula_assertions.rb:1:in `<top (required)>'
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/wener/.linuxbrew/Library/Homebrew/cmd/test.rb:2:in `<top (required)>'
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/wener/.linuxbrew/Library/brew.rb:58:in `require?'
/home/wener/.linuxbrew/Library/brew.rb:122:in `<main>'
sjackman commented 9 years ago

Please report ruby --version. This minitest issue has come up before. See #314

wenerme commented 9 years ago
ruby --version
ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
tseemann commented 9 years ago

@wenerme I got the same problem. As #314 says, just use the Brew version of ruby: brew install ruby.

wenerme commented 9 years ago

Thanks @tseemann , the test pass now

tomek-he-him commented 9 years ago

https://github.com/Homebrew/linuxbrew/issues/137#issuecomment-57353932 fails for me with gcc 5.1brew doesn’t seem to recognize the gcc-5.1 symlink as gcc:

$ brew install gcc
==> Installing dependencies for gcc: gmp, mpfr, libmpc, isl
==> Installing gcc dependency: gmp
Error: gmp cannot be built with any available compilers.
To install this formula, you may need to:
  brew install gcc

Here’s what seems to do the job – but I can’t help feeling it’s a hack:

$ ln -s $(which gcc) ~/.linuxbrew/bin/gcc-4.4
$ ln -s $(which g++) ~/.linuxbrew/bin/g++-4.4
$ brew install gcc g++

It needs time to compile – I’ll let you know as soon as I know the results.

tomek-he-him commented 9 years ago

Hmm, that’s a nope:

==> Installing gcc
# …
==> make bootstrap
Makefile:20663: recipe for target 'stage3-bubble' failed
make[1]: *** [stage3-bubble] Error 2
make[1]: Leaving directory '/tmp/gcc20150620-26406-gm4c73/gcc-5.1.0/build'
Makefile:20726: recipe for target 'bootstrap' failed
make: *** [bootstrap] Error 2

READ THIS:
# …
DoomHammer commented 9 years ago

Try perhaps ln -s $(which gcc) ~/.linuxbrew/bin/gcc-5 and ln -s $(which g++) ~/.linuxbrew/bin/g++-5

paulhybryant commented 9 years ago

My gcc installation also failed at Make bootstrap but for different reason.

gist logs here https://gist.github.com/anonymous/c7ac66274508a6525b8d

In short the error seems to be that it cannot find the shared library libisl.so.13 However, I can see isl installed with brew and it is available at ~/.linuxbrew/lib/

paulhybryant commented 9 years ago

OK I think my case is different from the above. The problem with my issue is ldconfig

ldconfig would report the following error:

ldconfig: Warning: ignoring configuration file that cannot be opened: $HOME/.linuxbrew/Cellar/glibc/2.19/etc/ld.so.conf: No such file or directory

I see that ld.so.cache symlinked to ld.so.cache in the same folder, but there is no ld.so.conf file. Is this a bug?

sjackman commented 9 years ago

Linuxbrew does not use ld.so.conf. It uses rpath instead. Using ld.so.conf makes a lot of sense though, I think. In any case, it's not necessary, and you can ignore the ldconfig warning.

sjackman commented 9 years ago

https://gist.githubusercontent.com/anonymous/c7ac66274508a6525b8d/raw/02.make

make[3]: Leaving directory `/tmp/gcc20150622-5108-1qwsx8g/gcc-5.1.0/build/gcc'
mkdir -p -- x86_64-unknown-linux-gnu/libgcc
Checking multilib configuration for libgcc...
Configuring stage 2 in x86_64-unknown-linux-gnu/libgcc
…
checking for suffix of object files... configure: error: in `/tmp/gcc20150622-5108-1qwsx8g/gcc-5.1.0/build/x86_64-unknown-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage2-target-libgcc] Error 1

Can you gist the appropriate config.log? There's more than one. The one with the most recent time stamp.

diegocaro commented 9 years ago

+1, I cant compile gcc (5.1). It seems to be related with a zlib dependency (not installed by default in most linux distros, but already installed in os x). I tried installing zlib, but it fails after the bootstrap stage.

sjackman commented 9 years ago

@diegocaro Try brew install homebrew/dupes/zlib gcc

kim612 commented 9 years ago

In my case (CentOS 5.11 with gcc44),

prefix=~/.linuxbrew
ln -s /usr/bin/gcc44 $prefix/bin/gcc-4.4
ln -s /usr/bin/g++44 $prefix/bin/g++-4.4
ln -s /usr/bin/gfortran44 $prefix/bin/gfortran-4.4
export HOMEBREW_CC=gcc-4.4
brew install hello

Error: Homebrew GCC requested, but formula gcc44 not found!

unset HOMEBREW_CC
brew install hello 
(no error)
sjackman commented 9 years ago

Can you try

brew install hello --cc=gcc-4.4

and also

brew tap homebrew/versions
HOMEBREW_CC=gcc-4.4 brew install hello
jorgebg commented 9 years ago

This worked for me (CentOS):

brew install gcc --cc=gcc 
dakl commented 9 years ago

To get symlinking to work I've had to

prefix=~/.linuxbrew
ln -s /usr/bin/gcc $prefix/bin/gcc-4.4
ln -s /usr/bin/g++ $prefix/bin/g++-4.4
ln -s /usr/bin/gfortran $prefix/bin/gfortran-4.4
export HOMEBREW_CC=gcc-4.4
brew tap homebrew/versions
brew install hello && brew test -v hello; brew remove hello

brew tap homebrew/versions seems to be needed in there. The I don't have to use --cc=gcc at all it seems like.

Scapadiver commented 8 years ago

@jorgebg's solution worked for me also - centos

sjackman commented 8 years ago

@jorgebg wrote…

brew install gcc --cc=gcc

And it doesn't work without --cc=gcc? That's odd. Thanks for the feedback.

prologic commented 8 years ago

Disregard last comment (deleted) -- If you have modified changes in the git tree you'll cause problems with bew :)

prologic commented 8 years ago

Actually I'm having a lot of trouble getting Homebrewed linux gcc bootstrapped.

  1. sudo yum groupinstall 'Development Tools'
  2. brew install gcc --cc=gcc
$ brew install gcc --cc=gcc
==> Installing dependencies for gcc: mpfr, libmpc, isl
==> Installing gcc dependency: mpfr
Error: /home/prologic/.linuxbrew/opt/xz not present or broken
Please reinstall xz. Sorry :(

Okay so let's install xz first:

$ brew install xz --cc=gcc
==> Downloading https://fossies.org/linux/misc/xz-5.2.2.tar.gz
Already downloaded: /home/prologic/.cache/Homebrew/xz-5.2.2.tar.gz
==> ./configure --disable-silent-rules --prefix=/home/prologic/.linuxbrew/Cellar/xz/5.2.2
==> make install
Error: No such file or directory - (unreachable)/

I've also tried and have in place @dakl's snippet which doesn't seem to help because tapping homebrew/versions yields:

$ brew tap homebrew/versions
==> Tapping homebrew/versions
fatal: Could not change back to '(unreachable)/': No such file or directory
Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-versions /home/prologic/.linuxbrew/Library/Taps/homebrew/homebrew-versions --depth=1
sjackman commented 8 years ago

That's a strange error message Error: No such file or directory - (unreachable)/. I've not seen that before. Does brew install hello work?

prologic commented 8 years ago

Nope :/

sjackman commented 8 years ago

Moved this discussion to #608.