Skip to content

Instantly share code, notes, and snippets.

@truatpasteurdotfr
Last active September 3, 2020 13:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save truatpasteurdotfr/d541cd279b9f7bf38ce967aa3743dfcb to your computer and use it in GitHub Desktop.
Save truatpasteurdotfr/d541cd279b9f7bf38ce967aa3743dfcb to your computer and use it in GitHub Desktop.
building bazel on CentOS-6
# install environment to build bazel
# adapted from https://github.com/bazelbuild/bazel/wiki/FAQ
# nice to see that they are using my old devtoolset-2
sudo yum -y install wget which findutils tar gzip zip unzip git zlib-devel
sudo yum -y install java-1.8.0-openjdk-devel
# one should really use the latest devtoolset-N from scl-rh
# to use newer gcc versions
# devtoolset-2-gcc.x86_64 4.8.2-15.el6 @devtools
# devtoolset-3-gcc.x86_64 4.9.2-6.2.el6 @centos-sclo-rh
# devtoolset-4-gcc.x86_64 5.3.1-6.1.el6 @centos-sclo-rh
# devtoolset-6-gcc.x86_64 6.2.1-3.1.el6 @centos-sclo-rh
sudo yum -y install centos-release-scl-rh
# use the local Pasteur repository for scl-rh too
# use one of these
sudo yum -y install devtoolset-3-gcc devtoolset-3-gcc-c++ devtoolset-3-binutils
#sudo yum -y install devtoolset-4-gcc devtoolset-4-gcc-c++ devtoolset-3-binutils
#sudo yum -y install devtoolset-3-gcc devtoolset-6-gcc-c++ devtoolset-3-binutils
# GPG key
sudo gpg --recv-key 48457EE0 ; gpg --recv-key 48457EE0
# yes twice, the 1st time, the config file are generated but not used
#gpg: directory `/root/.gnupg' created
#gpg: new configuration file `/root/.gnupg/gpg.conf' created
#gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
#gpg: keyring `/root/.gnupg/secring.gpg' created
#gpg: keyring `/root/.gnupg/pubring.gpg' created
#gpg: no keyserver known (use option --keyserver)
#gpg: keyserver receive failed: Syntax error in URI
# this does not work:
#--------------------
# wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-installer-linux-x86_64.sh
# wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-installer-linux-x86_64.sh.sig
# gpg --verify bazel-0.4.5-installer-linux-x86_64.sh.sig && sh /bazel-0.4.5-installer-linux-x86_64.sh
#
# yields:
#--------
# bazel is now installed in /usr/local
# bash completion: source /usr/local/lib/bazel/bin/bazel-complete.bash
# but the provided bazel binary is not working..
# /usr/local/bin/bazel: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/local/bin/bazel)
# CentOS-6 glibc is glibc-2.12-1.xxxx
wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-dist.zip
wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-dist.zip.sig
gpg --verify bazel-0.4.5-dist.zip.sig && unzip -d /tmp/bazel-0.4.5-dist bazel-0.4.5-dist.zip && \
/bin/rm bazel-0.4.5-dist.zip.sig bazel-0.4.5-dist.zip
# enable the new devtoolset
echo 'cd /tmp/bazel-0.4.5-dist && bash ./compile.sh && cp output/bazel /usr/local/bin' | scl enable devtoolset-3 bash
# replace devtoolset-3 by 4/5 if you are using the other versions
# cleanup
/bin/rm -rf /tmp/bazel-0.4.5-dist
# stop here if you only need bazel (to build tensorflow for instance)
# if you want to build the git version of bazel uncomment the following 2 lines.
#git clone https://github.com/bazelbuild/bazel /tmp/bazel && \
# cd /tmp/bazel && bazel build //src:bazel && cp bazel-bin/src/bazel /usr/local/bin/bazel.new
@Gwyll
Copy link

Gwyll commented Apr 19, 2017

I spent 2 hours while I figured out that bazel would compile in - and only in - /tmp. That is unfortunate because CentOS mounts /tmp with the noexec option -> caused a lot of Permission Denied error.

So before compiling do: mount /dev/device /tmp -o remount,rw
And after compiling do: mount /dev/device /tmp -o remount,rw,noexec,nosuid,nodev
Ofcourse only if your linux mounts /tmp with noexec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment