2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
8 # Script for building just llc and reducing its memory footprint
13 readonly MAKE_OPTS="-j12 VERBOSE=1"
17 readonly CXXFLAGS=-m32
21 readonly PNACL_ROOT="$(pwd)/pnacl"
22 readonly TC_BUILD="${PNACL_ROOT}/build"
23 readonly TC_BUILD_LLVM="${TC_BUILD}/llc"
25 readonly TC_SRC="${PNACL_ROOT}/src"
26 readonly TC_SRC_UPSTREAM="${TC_SRC}/upstream"
27 readonly TC_SRC_LLVM="${TC_SRC_UPSTREAM}/llvm"
29 readonly LLVM_EXTRA_OPTIONS="--enable-optimized"
31 readonly CROSS_TARGET_ARM=arm-none-linux-gnueabi
35 if [ -d "${TC_SRC_LLVM}" ]; then
36 rm -f "${TC_SRC_LLVM}"/tools/clang
42 local srcdir="${TC_SRC_LLVM}"
43 local objdir="${TC_BUILD_LLVM}"
49 # Some components like ARMDisassembler may time out when built with -O3.
50 # If we ever start using MSVC, we may also need to tone down the opt level
51 # (see the settings in the CMake file for those components).
52 local llvm_extra_opts=${LLVM_EXTRA_OPTIONS}
55 # The --with-binutils-include is to allow llvm to build the gold plugin
56 env -i PATH=/usr/bin/:/bin \
57 MAKE_OPTS=${MAKE_OPTS} \
61 CXXFLAGS="${CXXFLAGS}" \
62 LDFLAGS="${LDFLAGS}" \
66 --enable-targets=x86,x86_64,arm \
67 --target=${CROSS_TARGET_ARM} \
74 local srcdir="${TC_SRC_LLVM}"
75 local objdir="${TC_BUILD_LLVM}"
81 env -i PATH=/usr/bin/:/bin \
82 MAKE_OPTS="${MAKE_OPTS}" \
88 CXXFLAGS="${CXXFLAGS}" \
89 LDFLAGS="${LDFLAGS}" \
90 make ${MAKE_OPTS} tools-only
96 # This just works on linux and assumes release builds...
97 # TODO(pnacl-team): Make this path configurable.
98 cp ${TC_BUILD_LLVM}/Release+Asserts/bin/llc \
99 toolchain/linux_x86/pnacl_newlib/host_x86_32/bin/llc
105 ${TC_BUILD_LLVM}/Release+Asserts/bin/llc \
107 -mtriple=i686-none-nacl-gnu \
110 -tail-merge-threshold=50 \
113 -metadata-text ${pexe}.meta
116 # to use tc malloc, get it from here and configure it like so:
117 # https://code.google.com/p/gperftools/
118 # CXXFLAGS=-m32 LDFLAGS=-m32 CFLAGS=-m32 ./configure
119 llc-run-x8632-heapprofile() {
120 export LD_PRELOAD="${TCMALLOC_SO}"
121 export HEAPPROFILE="$1.heapprofile"