Solvedlinuxbrew core glibc: Requires GCC 4.7 or later

Is it currently supported to install glibc on rather old systems without root access?

I am working with an old Linux (SLC 6.8 where gcc verson is 4.4.7 and glibc is 2.12) without root privileges (so I can't use the glibc bottle with /home/linuxbrew/.linuxbrew/). I tried for a fresh installation of Linuxbrew by the official installation script, which created ~/.linuxbrew. Then brew install hello failed due to a problem in building glibc. The error message said that the compiler is too old:

==> Installing hello dependency: glibc
==> Downloading https://ftp.gnu.org/gnu/glibc/glibc-2.23.tar.gz
Already downloaded: /localstore/theorie/tueda/build/linuxbrew/Cache/glibc-2.23.tar.gz
==> ../configure --disable-debug --disable-dependency-tracking --disable-silent-rules --prefix=/user/tueda/.linuxbrew/Cellar/glibc/2.23 --enable-obsolete-rpc --without-selinux --with-binutils=/user/tueda/.linuxbrew/opt/binutils/bin --with-headers=/user/tueda/.linuxbrew/opt/linux-headers/include
Last 15 lines from /localstore/theorie/tueda/build/linuxbrew/Logs/glibc/01.configure:
checking version of gmake... 3.81, ok
checking for gnumsgfmt... no
checking for gmsgfmt... no
checking for msgfmt... msgfmt
checking version of msgfmt... 0.17, ok
checking for makeinfo... no
checking for sed... sed
checking version of sed... 4.2.1, ok
checking for gawk... gawk
checking version of gawk... 3.1.7, ok
checking if gcc-4.4 -B/user/tueda/.linuxbrew/opt/binutils/bin/ is sufficient to build libc... no
checking for nm... nm
configure: error: 
*** These critical programs are missing or too old: compiler
*** Check the INSTALL file for required versions.

READ THIS: https://github.com/Linuxbrew/brew/blob/master/docs/Troubleshooting.md#troubleshooting
Please do not report this issue to Homebrew/brew or Homebrew/core, which support macOS only.

These open issues may also help:
glibc install failed because etc/ld.so.conf not found https://github.com/Linuxbrew/homebrew-core/issues/3361

Actually, in config.log I found that the configure script checks if gcc >= 4.7:

configure:4820: checking if gcc-4.4 -B/user/tueda/.linuxbrew/opt/binutils/bin/ is sufficient to build libc
configure:4840: gcc-4.4 -B/user/tueda/.linuxbrew/opt/binutils/bin/ -c -g -O2  conftest.c >&5
conftest.c:20:2: error: #error insufficient compiler
configure:4840: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Library"
| #define PACKAGE_TARNAME "glibc"
| #define PACKAGE_VERSION "(see version.h)"
| #define PACKAGE_STRING "GNU C Library (see version.h)"
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/"
| #define PACKAGE_URL "http://www.gnu.org/software/glibc/"
| #define PKGVERSION "(GNU libc) "
| #define REPORT_BUGS_TO "<http://www.gnu.org/software/libc/bugs.html>"
| #define LINK_OBSOLETE_RPC 1
| #define HAVE_LIBIDN 1
| #define USE_MULTIARCH 1
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
| #if !defined __GNUC__ || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
| #error insufficient compiler
| #endif
|   ;
|   return 0;
| }
configure:4847: result: no

The check seems to be introduced (firstly for gcc 4.6) by https://sourceware.org/ml/libc-alpha/2014-11/msg00322.html.

It was working when Linuxbrew version of glibc was 2.19. Today I tried for updating a formula, which triggered to upgrade glibc, messing up the system and that's why I'm trying for a fresh installation.

As background: I would like to have rather new gcc for C++11/14 features and rather new glibc for Tensorflow.

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

Please always follow these steps:

  • Confirmed this is a problem with brew installing one, specific formula and not every time you run brew? If it's a general brew problem please file this issue at https://github.com/Linuxbrew/brew/issues/new.
  • If you have a macOS system and can replicate the problem on macOS with Homebrew, please report the issue to Homebrew/core and follow their issue template from your macOS system. If you are unsure, please report the issue to Linuxbrew.
    -- I don't have macOS systems and presumably it is not reproducible on macOS.
  • Ran brew update and retried your prior step?
  • Ran brew doctor, fixed all issues and retried your prior step?
    -- It says that git on the system is old, but brew install git fails due to the same problem of glibc. I believe the git version is not related to the issue.
  • Ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
    -- The log is: https://gist.github.com/anonymous/b896bc1a3c65a7f5cee9f3f84fb8dec8
  • If brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

To help us debug your issue please explain:

  • What you were trying to do (and why)
  • What happened (include command output)
  • What you expected to happen
  • Step-by-step reproduction instructions (by running brew install commands)

Formula additions or changes

To get formulae added or changed in Linuxbrew please file a Pull Request.
To get formulae added or changed that is a dependency of a formula in Linuxbrew/homebrew-core submit a Pull Request to https://github.com/Linuxbrew/homebrew-core/compare
To get formulae added or changed that is not a dependency of a formula in Linuxbrew/homebrew-core submit a Pull Request to https://github.com/Linuxbrew/homebrew-extra/compare
We will close issues requesting formulae changes.

34 Answers

✔️Accepted Answer

OK. I found a way to circumvent the build error: installing glibc 2.20 -> gcc 5.3 -> glibc 2.23:

brew install --only-dependencies glibc
brew install --ignore-dependencies https://raw.githubusercontent.com/Linuxbrew/homebrew-core/6fb5dfd50895416bea3d00628b8d3b41fa1f4f32/Formula/glibc.rb  # 2.20
brew install --ignore-dependencies xz gmp mpfr libmpc isl gcc
brew upgrade glibc

where only glibc is installed from the source and the others are installed from the bottles.

Though it would be very nice if Linuxbrew can handle these tricky building steps, if there is no way to improve it, maybe you can close this issue.

Other Answers:

If you have sudo access, you can install Linuxbrew on CentOS 6 using...

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

If you do not have sudo access, you can build gcc 5.3 from source, and use that to compile glibc.

export HOMEBREW_NO_AUTO_UPDATE=1
HOMEBREW_BUILD_FROM_SOURCE=1 brew install gcc --without-glibc
brew test gcc
brew install glibc
brew test glibc
brew remove gcc
brew install gcc
brew test gcc

Reinstalling gcc may not be strictly necessary. brew postinstall gcc may be sufficient, but I think it's probably best to install the gcc bottle once glibc is installed, to ensure that gcc is not somehow using the host's old glibc.

That's the best workaround that I have for now. Other possibilities would be to create a versioned formula glibc@2.19. Install glibc@2.19 then the bottled gcc 5.3 then upgrade glibc to 2.23. The disadvantage of this path is that you have to compile GLIBC twice. The advantage is that you never have to compile GCC, which takes a while.

Another possible fix would be to create a portable-gcc formula that can run on any system (CentOS 5 or newer). See https://github.com/homebrew/homebrew-portable

More Issues: