Skip to content

Instantly share code, notes, and snippets.

@djvanderlaan
Created January 17, 2015 18:56
Show Gist options
  • Save djvanderlaan/1e9beb75d2d595824efc to your computer and use it in GitHub Desktop.
Save djvanderlaan/1e9beb75d2d595824efc to your computer and use it in GitHub Desktop.
Vagrant setup for testing R packages with clang and UBSAN
#!/usr/bin/env bash
apt-get update
# Install packages needed to build R
apt-get install -y vim g++ gfortran make libreadline-dev
apt-get install -y clang-3.4 lldb-3.4 llvm-3.4-runtime
# ====== Set locale ======
# The image doesn't set LC_TIME, LC_NUMERIC etc, which causes warnings when
# starting R
echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale
# ====== Install TeXLive ======
# This will result in a more compact install than installing the needed Ubuntu
# packages which results in >1GB download.
cd /tmp
# Download and extract texlive
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xzf install-tl-unx.tar.gz
# Run installer; install basic scheme
pattern="install-tl"
for _dir in *"${pattern}"*; do
[ -d "${_dir}" ] && dir="${_dir}" && break
done
cd "${dir}"
echo "selected_scheme scheme-basic" > texlive.profile
./install-tl -profile texlive.profile
# Add texlive to the path
export PATH=/usr/local/texlive/2014/bin/x86_64-linux:$PATH
echo "export PATH=\$PATH:/usr/local/texlive/2014/bin/x86_64-linux" > /etc/profile.d/texlive.sh
chmod +x /etc/profile.d/texlive.sh
# Install some additional packages needed to build packages
tlmgr install inconsolata upquote times helvetic ec courier fancyvrb
# ====== Build and install R ======
cd /tmp
# Download the R source
wget http://cran.rstudio.com/src/base/R-3/R-3.1.2.tar.gz
tar -xzf R-3.1.2.tar.gz
cd R-3.1.2
# Create a config.site; this sets up clang as the compiler for R
echo "#! /bin/sh" > config.site
echo "CC=\"clang -std=gnu99 -fsanitize=undefined\"" >> config.site
echo "CFLAGS=\"-fno-omit-frame-pointer -O2 -Wall -pedantic -mtune=native\"" >> config.site
echo "CXX=\"clang++ -fsanitize=undefined -fno-sanitize=function -fno-omit-frame-pointer\"" >> config.site
# Configure and build R
./configure --with-x=no
make
make install
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu-14.04"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.network :forwarded_port, host: 4567, guest: 80
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment