Skip to content

Commit e14670a

Browse files
Merge pull request #47 from trailofbits/build_improve
* Ninja instead of Makefiles for Linux on LLVM * Enable ccache on LLVM [more work to do on this one to use cache on rebuilds] * New supported LLVM targets: ARMv7 and NVPTX
2 parents 45755bf + adb0358 commit e14670a

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ARG LLVM_VERSION
1111
ENV DEBIAN_FRONTEND=noninteractive
1212

1313
RUN apt-get update && \
14-
apt-get install -qqy python2.7 python3 python3-pip build-essential \
14+
apt-get install -qqy ninja-build python2.7 python3 python3-pip build-essential ccache \
1515
liblzma-dev clang libssl-dev && \
1616
rm -rf /var/lib/apt/lists/*
1717

@@ -32,32 +32,34 @@ RUN ./pkgman.py \
3232
rm -rf build && mkdir build && \
3333
rm -rf sources && mkdir sources
3434

35-
RUN ./pkgman.py \
35+
RUN mkdir -p /cache && ./pkgman.py \
3636
--c_compiler=/usr/bin/clang \
3737
--cxx_compiler=/usr/bin/clang++ \
3838
--llvm_version=${LLVM_VERSION} \
3939
--verbose \
40+
--use_ccache \
4041
--exclude_libcxx \
4142
"--additional_paths=${BOOTSTRAP}/cmake/bin" \
4243
"--repository_path=${LIBRARIES}" \
4344
"--packages=llvm" && \
4445
rm -rf build && mkdir build && \
45-
rm -rf sources && mkdir sources
46+
rm -rf sources && mkdir sources && rm -rf /cache
4647

4748
FROM base as cxx-common-build
4849

4950
WORKDIR /cxx-common
5051
ARG BOOTSTRAP
5152
ARG LIBRARIES
5253

53-
RUN ./pkgman.py \
54+
RUN mkdir -p /cache && ./pkgman.py \
5455
--cxx_compiler="${LIBRARIES}/llvm/bin/clang++" \
5556
--c_compiler="${LIBRARIES}/llvm/bin/clang" \
57+
--use_ccache \
5658
--verbose \
5759
"--additional_paths=${BOOTSTRAP}/cmake/bin:${LIBRARIES}/llvm/bin" \
5860
"--repository_path=${LIBRARIES}" \
5961
"--packages=cmake,capstone,google,xed,capnproto" && \
6062
rm -rf build && mkdir build && \
61-
rm -rf sources && mkdir sources
63+
rm -rf sources && mkdir sources && rm -rf /cache
6264

6365
ENTRYPOINT ["/bin/bash"]

pkgman.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def main():
3434
arg_parser.add_argument("--c_compiler", type=str, help="The C compiler to use.")
3535
arg_parser.add_argument("--exclude_libcxx", help="Exclude libc++ from the build", action='store_true')
3636
arg_parser.add_argument("--use_no_ssl_requests", help="Use the requests library to download files, and do so without SSL verification. If behind a firewall/proxy, this can help", action='store_true')
37+
arg_parser.add_argument("--use_ccache", help="Enable ccache build for LLVM", action='store_true')
3738

3839
default_repository_path = ""
3940
if get_platform_type() == "windows":
@@ -95,6 +96,8 @@ def main():
9596
properties["verbose"] = args.verbose
9697
properties["debug"] = args.debug
9798

99+
properties["ccache"] = args.use_ccache
100+
98101
# Make sure that file downloading will work.
99102
if args.use_no_ssl_requests:
100103
properties["use_requests_for_downloading"] = True

pkgman/installers/common.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def common_installer_llvm(properties):
575575

576576
arch_list = "'X86"
577577
if sys.platform != "win32":
578-
arch_list += ";AArch64;Sparc"
578+
arch_list += ";AArch64;Sparc;NVPTX;ARM"
579579
arch_list += "'"
580580

581581
cppstd = "11"
@@ -586,6 +586,15 @@ def common_installer_llvm(properties):
586586
"-DLLVM_ENABLE_RTTI=ON", "-DLLVM_INCLUDE_EXAMPLES=OFF",
587587
"-DLLVM_INCLUDE_TESTS=OFF"]
588588

589+
if properties["ccache"]:
590+
print(" i Enabling ccache on /cache ... ")
591+
# some versions of LLVM use CCACHE_MAX_SIZE, others use CCACHE_SIZE
592+
cmake_command.extend(
593+
["-DLLVM_CCACHE_BUILD=ON",
594+
"-DLLVM_CCACHE_SIZE=10G",
595+
"-DLLVM_CCACHE_DIR=/cache",
596+
"-DLLVM_CCACHE_MAXSIZE=10G"])
597+
589598
if use_libcxx:
590599
if int(properties["llvm_version"]) < 371:
591600
cmake_command += ["-DLIBCXX_ENABLE_SHARED=NO"]

pkgman/installers/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def get_cmake_generator(use_clang=True):
5959
parameters = ["-G", "Visual Studio 15 2017 Win64"]
6060
if use_clang:
6161
parameters += ["-T", "LLVM-vs2014"]
62+
elif sys.platform.startswith("linux"):
63+
# do ninja-build on linux for faster builds
64+
parameters = ["-G", "Ninja"]
6265

6366
return parameters
6467

travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ linux_initialize() {
3939
fi
4040

4141
printf " > Installing the required packages...\n"
42-
sudo apt-get install -qqy python2.7 build-essential python3 python3-pip clang
42+
sudo apt-get install -qqy python2.7 build-essential python3 python3-pip clang ninja-build
4343
if [ $? -ne 0 ] ; then
4444
printf " x Could not install the required dependencies\n"
4545
return 1

0 commit comments

Comments
 (0)