summaryrefslogtreecommitdiff
path: root/taskcluster/scripts/misc/build-cctools.sh
blob: 3eea0929d7b3115cf35d9190a16eec73b4dacc9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
set -x -e -v

# This script is for building cctools (Apple's binutils) for Linux using
# crosstool-ng (https://github.com/diorcety/crosstool-ng).

WORKSPACE=$HOME/workspace
UPLOAD_DIR=$WORKSPACE/artifacts

# Repository info
: CROSSTOOL_NG_REPOSITORY    ${CROSSTOOL_NG_REPOSITORY:=https://github.com/diorcety/crosstool-ng}
: CROSSTOOL_NG_REV           ${CROSSTOOL_NG_REV:=master}

# hacky
ln -s `which gcc` ~/bin/x86_64-linux-gnu-gcc
export PATH=$PATH:~/bin

# Set some crosstools-ng directories
CT_TOP_DIR=$WORKSPACE/crosstool-ng-build
CT_PREFIX_DIR=$WORKSPACE/cctools
CT_SRC_DIR=$CT_TOP_DIR/src
CT_TARBALLS_DIR=$CT_TOP_DIR
CT_WORK_DIR=$CT_SRC_DIR
CT_LIB_DIR=$WORKSPACE/crosstool-ng
CT_BUILD_DIR=$CT_TOP_DIR/build
CT_LLVM_DIR=$WORKSPACE/clang
CT_BUILDTOOLS_PREFIX_DIR=$CT_PREFIX_DIR

# Create our directories
rm -rf $CT_TOP_DIR
mkdir $CT_TOP_DIR
rm -rf $CT_PREFIX_DIR
mkdir $CT_PREFIX_DIR
mkdir -p $CT_SRC_DIR

# Clone the crosstool-ng repo
tc-vcs checkout $CT_LIB_DIR $CROSSTOOL_NG_REPOSITORY $CROSSTOOL_NG_REPOSITORY $CROSSTOOL_NG_REV

# Fetch clang from tooltool
cd $WORKSPACE
wget -O tooltool.py https://raw.githubusercontent.com/mozilla/build-tooltool/master/tooltool.py
chmod +x tooltool.py
: TOOLTOOL_CACHE                ${TOOLTOOL_CACHE:=/home/worker/tooltool-cache}
export TOOLTOOL_CACHE

wget ${GECKO_HEAD_REPOSITORY}/raw-file/${GECKO_HEAD_REV}/browser/config/tooltool-manifests/linux64/clang.manifest

python tooltool.py -v --manifest=clang.manifest fetch

# Copy clang into the crosstools-ng srcdir
cp -Rp $CT_LLVM_DIR $CT_SRC_DIR

# Configure crosstools-ng
sed=sed
CT_CONNECT_TIMEOUT=5
CT_BINUTILS_VERSION=809
CT_PATCH_ORDER=bundled
CT_BUILD=x86_64-linux-gnu
CT_HOST=x86_64-linux-gnu
CT_TARGET=x86_64-apple-darwin10
CT_LLVM_FULLNAME=clang

cd $CT_TOP_DIR

# gets a bit too verbose here
set +x

. $CT_LIB_DIR/scripts/functions
. $CT_LIB_DIR/scripts/build/binutils/cctools.sh

# Build cctools
do_binutils_get
do_binutils_extract
do_binutils_for_host

set -x

strip $CT_PREFIX_DIR/bin/*

# Put a tarball in the artifacts dir
mkdir -p $UPLOAD_DIR
tar czf $UPLOAD_DIR/cctools.tar.gz -C $WORKSPACE `basename $CT_PREFIX_DIR`