Skip to content

Commit 2fe5fd2

Browse files
author
Jason Mobarak
committed
Attempt to use ccache, stage correct llvm packages
1 parent e56f084 commit 2fe5fd2

File tree

11 files changed

+113
-31
lines changed

11 files changed

+113
-31
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ branches:
1010
services:
1111
- docker
1212

13+
cache:
14+
directories:
15+
- output/ccache
16+
1317
matrix:
1418
include:
1519
- env:

Dockerfile renamed to Dockerfile.base

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ RUN apt-get update \
2323
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
2424
&& echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" \
2525
>/etc/apt/sources.list.d/llvm40.list \
26+
&& echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main" \
27+
>/etc/apt/sources.list.d/llvm60.list \
2628
&& apt-get update \
2729
&& apt-get upgrade -y \
2830
&& apt-get install -y libcurl4-openssl-dev \
2931
build-essential \
3032
bison \
3133
flex \
3234
ninja-build \
33-
llvm-4.0 \
34-
llvm-4.0-dev \
35-
clang-4.0 \
3635
git \
3736
m4 \
3837
gperf \
@@ -45,6 +44,7 @@ RUN apt-get update \
4544
libtinfo-dev \
4645
python \
4746
python-dev \
47+
ccache \
4848
binutils-multiarch-dev \
4949
g++-4.8-arm-linux-gnueabihf \
5050
gcc-4.8-arm-linux-gnueabihf \
@@ -66,10 +66,9 @@ RUN apt-get update \
6666
&& tar -xzf cmake-3.10.1.tar.gz \
6767
&& cd cmake-3.10.1 \
6868
&& ./configure \
69-
&& make -j4 \
70-
&& make install \
69+
&& make -j8 \
70+
&& make -j8 install \
7171
&& cd .. && rm -rf cmake-* \
72-
&& apt-get clean \
73-
&& rm -rf /var/lib/apt/lists/*
72+
&& apt-get clean
7473

7574
# EOF

Dockerfile.obfuscator

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (C) 2017-2018 Swift Navigation Inc.
2+
# Contact: Swift Navigation <dev@swiftnav.com>
3+
#
4+
# This source is subject to the license found in the file 'LICENSE' which must
5+
# be be distributed together with this source. All other rights reserved.
6+
#
7+
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
8+
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
9+
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
10+
11+
ARG DOCKER_NAMETAG
12+
FROM $DOCKER_NAMETAG
13+
14+
RUN apt-get install -y llvm-4.0 llvm-4.0-dev clang-4.0 libclang-4.0-dev

Dockerfile.vanilla

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (C) 2017-2018 Swift Navigation Inc.
2+
# Contact: Swift Navigation <dev@swiftnav.com>
3+
#
4+
# This source is subject to the license found in the file 'LICENSE' which must
5+
# be be distributed together with this source. All other rights reserved.
6+
#
7+
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
8+
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
9+
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
10+
11+
ARG DOCKER_NAMETAG
12+
FROM $DOCKER_NAMETAG
13+
14+
RUN apt-get install -y llvm-6.0 llvm-6.0-dev clang-6.0 libclang-6.0-dev

base.bash

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,16 @@ fi
5656

5757
docker build \
5858
--force-rm --no-cache \
59-
-f Dockerfile -t "$DOCKER_NAMETAG" .
59+
-f Dockerfile.base -t "$DOCKER_NAMETAG" .
6060

61-
if [[ -n "${DOCKER_USER:-}" ]] && [[ -n "${DOCKER_PASS:-}" ]]; then
62-
echo "$DOCKER_PASS" | docker login --username="$DOCKER_USER" --password-stdin
63-
docker push "$DOCKER_NAMETAG"
64-
else
65-
echo "WARNING: not pushing new image to Docker Hub..." >&2
66-
fi
61+
docker build \
62+
--force-rm --no-cache \
63+
--build-arg "DOCKER_NAMETAG=$DOCKER_NAMETAG" \
64+
-f Dockerfile.vanilla -t "$DOCKER_NAMETAG-vanilla" .
65+
66+
docker build \
67+
--force-rm --no-cache \
68+
--build-arg "DOCKER_NAMETAG=$DOCKER_NAMETAG" \
69+
-f Dockerfile.obfuscator -t "$DOCKER_NAMETAG-obfuscator" .
70+
71+
./push.bash

build.bash

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ IFS=$'\n\t'
1616
DOCKER_NAMETAG=$(cat docker_nametag)
1717

1818
mkdir -p output/opt
19+
mkdir -p output/ccache
1920

2021
VERBOSE=
2122
NO_TTY=
@@ -48,7 +49,9 @@ if [[ -z "${VARIANT:-}" ]]; then
4849
exit 1
4950
fi
5051

51-
set -x
52+
CXX_FLAGS="-L/toolchain/x86/x86_64-buildroot-linux-gnu/sysroot/lib \
53+
-L/toolchain/x86/x86_64-buildroot-linux-gnu/sysroot/usr/lib \
54+
-I/toolchain/x86/lib/gcc/x86_64-buildroot-linux-gnu/6.4.0/plugin/include"
5255

5356
if [[ "$VARIANT" == "obfuscator" ]]; then
5457
LLVM_REPO="https://github.com/obfuscator-llvm/obfuscator.git"
@@ -67,14 +70,17 @@ else
6770
CPP_WRAPPER_DEFINE="-DCMAKE_CXX_COMPILER=/toolchain/x86/bin/x86_64-linux-g++"
6871
PATCH_COMMAND="true"
6972
COMPILE_CPP_WRAPPER="true"
73+
CXX_FLAGS+=" -I/work/$VARIANT-llvm/tools/clang/include"
74+
CXX_FLAGS+=" -I/work/build/tools/clang/include"
7075
fi
7176

7277
CMAKE_COMMAND="\
7378
cmake -G Ninja \
7479
/work/$VARIANT-llvm \
7580
-DCMAKE_INSTALL_PREFIX=/opt/llvm-$VARIANT \
7681
-DLLVM_TARGETS_TO_BUILD=$ARCH \
77-
-DCMAKE_CXX_FLAGS='-DENDIAN_LITTLE=1 -L/toolchain/x86/x86_64-buildroot-linux-gnu/sysroot/lib -L/toolchain/x86/x86_64-buildroot-linux-gnu/sysroot/usr/lib -I/toolchain/x86/lib/gcc/x86_64-buildroot-linux-gnu/6.4.0/plugin/include' \
82+
-DCMAKE_CXX_FLAGS='-DENDIAN_LITTLE=1 $CXX_FLAGS' \
83+
-DLLVM_CCACHE_BUILD=ON \
7884
$CPP_WRAPPER_DEFINE \
7985
-DCMAKE_C_COMPILER=/toolchain/x86/bin/x86_64-linux-gcc \
8086
-DCMAKE_BUILD_TYPE=Release \
@@ -88,11 +94,14 @@ else
8894
INTERACTIVE=()
8995
fi
9096

97+
# -v $VARIANT-llvm-ccache:/work/ccache \
98+
9199
# shellcheck disable=SC2068
92100
docker run ${INTERACTIVE[@]:-} --rm \
93101
-v "$PWD/output/opt:/opt" \
94102
-v "$PWD/patches:/patches" \
95103
-v "$PWD:/this_dir" \
104+
-v "$PWD/output/ccache:/work/ccache" \
96105
-v $VARIANT-llvm:/work/$VARIANT-llvm \
97106
-v $VARIANT-llvm-build:/work/build \
98107
-e VARIANT=$VARIANT -e ARCH=$ARCH \
@@ -105,7 +114,8 @@ docker run ${INTERACTIVE[@]:-} --rm \
105114
-e CLANG_TOOLS_EXTRA_REPO=$CLANG_TOOLS_EXTRA_REPO \
106115
-e PATCH_COMMAND=$PATCH_COMMAND \
107116
-e COMPILE_CPP_WRAPPER=$COMPILE_CPP_WRAPPER \
108-
"$DOCKER_NAMETAG" \
117+
-e CCACHE_DIR=/work/ccache \
118+
"$DOCKER_NAMETAG-$VARIANT" \
109119
/bin/bash -c "/this_dir/do_clang_build.bash"
110120

111121
./stage_sysroot.bash $NO_TTY "--variant=$VARIANT"

do_clang_build.bash

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/usr/bin/env bash
22

3+
# Copyright (C) 2018 Swift Navigation Inc.
4+
# Contact: Swift Navigation <dev@swiftnav.com>
5+
#
6+
# This source is subject to the license found in the file 'LICENSE' which must
7+
# be be distributed together with this source. All other rights reserved.
8+
#
9+
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10+
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
11+
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12+
313
set -euo pipefail
414
IFS=$'\n\t'
515

@@ -9,14 +19,15 @@ die_non_empty()
919
die_not_defined()
1020
{ echo "*** ERROR: variable $1 must be defined (can be empty)" >&2; exit 1; }
1121

12-
[[ -n "${VARIANT}" ]] || die_not_defined
22+
[[ -n "${VARIANT:-}" ]] || die_non_empty
1323

1424
[[ "${VARIANT}" == "obfuscator" ]] || [[ "${VARIANT}" == "vanilla" ]] || \
1525
{ echo "*** ERROR: invalid variant (must be one of 'vanilla', or 'obfuscator')" >&2; exit 1; }
1626

17-
[[ -n "${LLVM_REPO}" ]] || die_non_empty LLVM_REPO
18-
[[ -n "${LLVM_BRANCH}" ]] || die_non_empty LLVM_BRANCH
19-
[[ -n "${CMAKE_COMMAND}" ]] || die_non_empty CMAKE_COMMAND
27+
[[ -n "${LLVM_REPO:-}" ]] || die_non_empty LLVM_REPO
28+
[[ -n "${LLVM_BRANCH:-}" ]] || die_non_empty LLVM_BRANCH
29+
[[ -n "${CMAKE_COMMAND:-}" ]] || die_non_empty CMAKE_COMMAND
30+
[[ -n "${CCACHE_DIR:-}" ]] || die_non_empty CCACHE_DIR
2031

2132
[[ -n "${CLANG_REPO+x}" ]] || die_not_defined CLANG_REPO
2233
[[ -n "${CLANG_TOOLS_EXTRA_REPO+x}" ]] || die_not_defined CLANG_TOOLS_EXTRA_REPO
@@ -49,6 +60,9 @@ if [ -n "${CLANG_TOOLS_EXTRA_REPO:-}" ]; then \
4960
fi
5061
fi
5162

63+
export CCACHE_DIR=$CCACHE_DIR
64+
echo "CCACHE_DIR: $CCACHE_DIR"
65+
5266
eval "$COMPILE_CPP_WRAPPER"
5367

5468
cd "/work/$VARIANT-llvm"
@@ -58,10 +72,5 @@ cd /work/build
5872

5973
eval "$CMAKE_COMMAND"
6074

61-
if [[ -n "$VERBOSE" ]]; then
62-
ninja -v
63-
ninja -v install
64-
else
65-
ninja
66-
ninja install
67-
fi
75+
eval ninja "$VERBOSE"
76+
eval ninja "$VERBOSE" install

docker_nametag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
swiftnav/arm-llvm-obf:4.0-ubuntu1604-2018.06.08
1+
swiftnav/arm-llvm-obf:2018.06.10

push.bash

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (C) 2017 Swift Navigation Inc.
4+
# Contact: Swift Navigation <dev@swiftnav.com>
5+
#
6+
# This source is subject to the license found in the file 'LICENSE' which must
7+
# be be distributed together with this source. All other rights reserved.
8+
#
9+
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10+
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
11+
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12+
13+
set -euo pipefail
14+
IFS=$'\n\t'
15+
16+
[[ -z "${DEBUG:-}" ]] || set -x
17+
18+
DOCKER_NAMETAG=$(cat docker_nametag)
19+
20+
if [[ -n "${DOCKER_USER:-}" ]] && [[ -n "${DOCKER_PASS:-}" ]]; then
21+
echo "$DOCKER_PASS" | docker login --username="$DOCKER_USER" --password-stdin
22+
docker push "$DOCKER_NAMETAG"
23+
docker push "$DOCKER_NAMETAG-vanilla"
24+
docker push "$DOCKER_NAMETAG-obfuscator"
25+
else
26+
echo "WARNING: not pushing new image to Docker Hub..." >&2
27+
fi

run_build_shell.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ docker run -i -t --rm \
3939
-v "$PWD:/this_dir" \
4040
-v $VARIANT-llvm:/work/$VARIANT-llvm \
4141
-v $VARIANT-llvm-build:/work/build \
42-
"$DOCKER_NAMETAG" \
42+
"$DOCKER_NAMETAG-$VARIANT" \
4343
/bin/bash -c "export PATH=/opt/llvm-$VARIANT/bin:/opt/llvm-$VARIANT/wrappers/bin:\$PATH; \
4444
cp -v /this_dir/cpp_wrapper.c /work/cpp_wrapper.c \
4545
&& gcc -std=c99 -O3 -Wall /work/cpp_wrapper.c -o /bin/cpp_wrapper; \

0 commit comments

Comments
 (0)