Skip to content

Instantly share code, notes, and snippets.

@cmd-ntrf
Last active January 3, 2017 16:50
Show Gist options
  • Save cmd-ntrf/6be2902990989fe2349762050c4134f4 to your computer and use it in GitHub Desktop.
Save cmd-ntrf/6be2902990989fe2349762050c4134f4 to your computer and use it in GitHub Desktop.
module purge -f
module load compilers/gcc/4.8.5 compilers/java/1.8 apps/buildtools

cd /tmp
wget https://github.com/bazelbuild/bazel/archive/0.4.3.tar.gz
tar xvf 0.4.3.tar.gz
mv {bazel-,}0.4.3

cd 0.4.3

# Path
cp tools/cpp/CROSSTOOL.tpl{,.orig}
for tool in gcc cpp gcov ar ld dwp nm objdump objcopy strip; do
  sed -i "s;/usr/bin/$tool;$(which $tool);g" tools/cpp/CROSSTOOL.tpl
done

GCC_PREFIX=$(dirname $(dirname $(which gcc)))
sed -i "\;linker_flag: \"-B/usr/bin/\";a \
\ \ linker_flag: \"-Wl,-rpath=$GCC_PREFIX/lib64\"" tools/cpp/CROSSTOOL.tpl
sed -i "\;linker_flag: \"-B/usr/bin/\";a \
\ \ linker_flag: \"-Wl,-rpath=$GCC_PREFIX/lib\"" tools/cpp/CROSSTOOL.tpl

# Include directory
for path in $(find $GCC_PREFIX -name include\*); do
  sed -i "\;cxx_builtin_include_directory: \"/usr/local/include\"; a \
  \ \ cxx_builtin_include_directory: \"$path\"" tools/cpp/CROSSTOOL.tpl
done 

# Replace "-B/usr/bin"
TOOLS_PREFIX=$(dirname $(which ar))
sed -i "s;-B/usr/bin;-B$TOOLS_PREFIX;g" tools/cpp/CROSSTOOL tools/cpp/cc_configure.bzl 

export TEST_TMPDIR=/tmp/bazel

export MALLOC_ARENA_MAX=4
cp /software6/apps/bazel/0.3.2_gcc/output/bazel .
./bazel build //src:bazel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment