Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 1 | # The following variables will likely need to be modified, depending on where |
| 2 | # and how you built LLVM & Clang. They can be overridden in a command-line |
| 3 | # invocation of make, like: |
| 4 | # |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 5 | # make LLVM_SRC_PATH=<path> LIBCXX_INSTALL_PATH=<path> CLANG_PATH=<path> \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 6 | # PNACL_BIN_PATH=<path> ... |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 7 | # |
| 8 | |
| 9 | # LLVM_SRC_PATH is the path to the root of the checked out source code. This |
| 10 | # directory should contain the configure script, the include/ and lib/ |
| 11 | # directories of LLVM, Clang in tools/clang/, etc. |
| 12 | # Alternatively, if you're building vs. a binary download of LLVM, then |
| 13 | # LLVM_SRC_PATH can point to the main untarred directory. |
| 14 | LLVM_SRC_PATH ?= ../llvm |
| 15 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 16 | # The x86-32-specific sandboxed translator directory. |
| 17 | # It holds sandboxed versions of libraries and binaries. |
| 18 | SB_LLVM_PATH ?= $(shell readlink -e \ |
| 19 | ../../out/sandboxed_translators_work/translator-i686/llvm-sb/Release) |
| 20 | |
| 21 | # NACL_ROOT is the root of the native client repository. |
| 22 | NACL_ROOT ?= $(shell python -c "import sys; sys.path.insert(0, 'pydir'); \ |
| 23 | import utils; print utils.FindBaseNaCl()") |
| 24 | |
Jan Voung | 8e32fed | 2015-06-17 10:16:23 -0700 | [diff] [blame^] | 25 | # TOOLCHAIN_ROOT is the location of NaCl/PNaCl toolchains and other |
| 26 | # tools like qemu. |
| 27 | TOOLCHAIN_ROOT ?= $(shell readlink -e $(NACL_ROOT)/toolchain/linux_x86) |
| 28 | |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 29 | # PNACL_TOOLCHAIN_ROOT is the location of the PNaCl toolchain. |
| 30 | # This is used as the default root for finding binutils, libcxx, etc. |
Jan Voung | 8e32fed | 2015-06-17 10:16:23 -0700 | [diff] [blame^] | 31 | PNACL_TOOLCHAIN_ROOT ?= $(shell readlink -e $(TOOLCHAIN_ROOT)/pnacl_newlib_raw) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 32 | |
| 33 | # The location of PNaCl tools (e.g., binutils objdump, pnacl-clang++, etc.). |
| 34 | PNACL_BIN_PATH ?= $(shell readlink -e $(PNACL_TOOLCHAIN_ROOT)/bin) |
Karl Schimpf | 8fcefc3 | 2014-09-15 12:56:50 -0700 | [diff] [blame] | 35 | |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 36 | # Hack to auto-detect autoconf versus cmake build of LLVM. If the LLVM tools |
Jim Stichnoth | e5b58fb | 2015-06-01 15:17:20 -0700 | [diff] [blame] | 37 | # were dynamically linked with something like libLLVM-3.7svn.so, it is an |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 38 | # autoconf build, otherwise it is a cmake build. AUTOCONF is set to 0 for |
| 39 | # cmake, nonzero for autoconf. |
| 40 | AUTOCONF ?= $(shell ldd $(PNACL_BIN_PATH)/opt | grep -c libLLVM-) |
| 41 | |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 42 | # CLANG_PATH is the location of the clang compiler to use for building |
| 43 | # the host binaries. |
Karl Schimpf | 8fcefc3 | 2014-09-15 12:56:50 -0700 | [diff] [blame] | 44 | CLANG_PATH ?= $(shell readlink -e \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 45 | $(NACL_ROOT)/../third_party/llvm-build/Release+Asserts/bin) |
Karl Schimpf | 8fcefc3 | 2014-09-15 12:56:50 -0700 | [diff] [blame] | 46 | |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 47 | # LIBCXX_INSTALL_PATH is the directory where libc++ is located. It should |
| 48 | # contain header files and corresponding libraries. This is used for |
| 49 | # building the host binaries in conjuction with clang. |
| 50 | LIBCXX_INSTALL_PATH ?= $(PNACL_TOOLCHAIN_ROOT) |
Karl Schimpf | 9d92854 | 2015-04-16 15:08:05 -0700 | [diff] [blame] | 51 | STDLIB_FLAGS := -stdlib=libc++ -I$(LIBCXX_INSTALL_PATH)/include/c++/v1 |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 52 | |
Jan Voung | 4c127ba | 2014-09-19 13:11:36 -0700 | [diff] [blame] | 53 | HOST_ARCH ?= x86_64 |
Jan Voung | 839c4ce | 2014-07-28 15:19:43 -0700 | [diff] [blame] | 54 | ifeq ($(HOST_ARCH),x86_64) |
Jim Stichnoth | 6c6adf1 | 2015-04-07 14:22:25 -0700 | [diff] [blame] | 55 | HOST_FLAGS = -m64 |
Jan Voung | 839c4ce | 2014-07-28 15:19:43 -0700 | [diff] [blame] | 56 | else |
| 57 | ifeq ($(HOST_ARCH),x86) |
Jim Stichnoth | 6c6adf1 | 2015-04-07 14:22:25 -0700 | [diff] [blame] | 58 | HOST_FLAGS = -m32 |
Jan Voung | 839c4ce | 2014-07-28 15:19:43 -0700 | [diff] [blame] | 59 | endif |
| 60 | endif |
| 61 | |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 62 | ifdef DEBUG |
| 63 | OBJDIR = build/Debug |
| 64 | OPTLEVEL = -O0 |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 65 | LINKOPTLEVEL = -O0 |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 66 | else |
| 67 | OBJDIR = build/Release |
Jim Stichnoth | a49e9d9 | 2014-12-07 14:25:34 -0800 | [diff] [blame] | 68 | OPTLEVEL = -O2 -ffunction-sections -fdata-sections |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 69 | LINKOPTLEVEL = -O2 |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 70 | endif |
| 71 | |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 72 | # The list of CXX defines that are dependent on build parameters. |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 73 | BASE_CXX_DEFINES = |
Jim Stichnoth | fa4efea | 2015-01-27 05:06:03 -0800 | [diff] [blame] | 74 | CXX_EXTRA = |
| 75 | LD_EXTRA = |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 76 | |
| 77 | ifdef MINIMAL |
Jim Stichnoth | e3c02c2 | 2014-12-05 14:16:07 -0800 | [diff] [blame] | 78 | NOASSERT = 1 |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 79 | OBJDIR := $(OBJDIR)+Min |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 80 | BASE_CXX_DEFINES += -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \ |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 81 | -DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_DISABLE_IR_GEN=0 \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 82 | -DALLOW_MINIMAL_BUILD=1 |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 83 | else |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 84 | BASE_CXX_DEFINES += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \ |
Karl Schimpf | df80eb8 | 2015-02-09 14:20:22 -0800 | [diff] [blame] | 85 | -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_DISABLE_IR_GEN=1 \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 86 | -DALLOW_MINIMAL_BUILD=0 |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 87 | endif |
| 88 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 89 | SB_CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=1 |
| 90 | CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=0 |
| 91 | |
Jim Stichnoth | 9c234e2 | 2014-10-01 09:28:21 -0700 | [diff] [blame] | 92 | ifdef NOASSERT |
| 93 | ASSERTIONS = -DNDEBUG |
| 94 | else |
| 95 | ASSERTIONS = |
| 96 | OBJDIR := $(OBJDIR)+Asserts |
| 97 | endif |
| 98 | |
Jim Stichnoth | fa4efea | 2015-01-27 05:06:03 -0800 | [diff] [blame] | 99 | ifdef TSAN |
| 100 | OBJDIR := $(OBJDIR)+TSan |
| 101 | CXX_EXTRA += -fsanitize=thread |
| 102 | LD_EXTRA += -fsanitize=thread |
| 103 | endif |
| 104 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 105 | SB_OBJDIR := $(OBJDIR)+Sandboxed |
| 106 | |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 107 | $(info -----------------------------------------------) |
| 108 | $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH)) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 109 | $(info Using SB_LLVM_PATH = $(SB_LLVM_PATH)) |
| 110 | $(info Using NACL_ROOT = $(NACL_ROOT)) |
Jan Voung | 8e32fed | 2015-06-17 10:16:23 -0700 | [diff] [blame^] | 111 | $(info Using TOOLCHAIN_ROOT = $(TOOLCHAIN_ROOT)) |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 112 | $(info Using PNACL_TOOLCHAIN_ROOT = $(PNACL_TOOLCHAIN_ROOT)) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 113 | $(info Using PNACL_BIN_PATH = $(PNACL_BIN_PATH)) |
Karl Schimpf | 8fcefc3 | 2014-09-15 12:56:50 -0700 | [diff] [blame] | 114 | $(info Using CLANG_PATH = $(CLANG_PATH)) |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 115 | $(info Using LIBCXX_INSTALL_PATH = $(LIBCXX_INSTALL_PATH)) |
Jan Voung | 839c4ce | 2014-07-28 15:19:43 -0700 | [diff] [blame] | 116 | $(info Using HOST_ARCH = $(HOST_ARCH)) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 117 | $(info -----------------------------------------------) |
| 118 | |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 119 | LLVM_CXXFLAGS := `$(PNACL_BIN_PATH)/llvm-config --cxxflags` |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 120 | SB_LLVM_CXXFLAGS := $(LLVM_CXXFLAGS) |
| 121 | |
| 122 | # Listing specific libraries that are needed for pnacl-sz |
| 123 | # and the unittests, since we build "tools-only" for the |
| 124 | # sandboxed_translators (which doesn't include every library |
| 125 | # listed by llvm-config). |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 126 | |
| 127 | LLVM_LIBS_LIST := -lLLVMIRReader -lLLVMBitReader -lLLVMNaClBitTestUtils \ |
| 128 | -lLLVMNaClBitReader -lLLVMNaClBitAnalysis -lLLVMNaClBitWriter \ |
| 129 | -lLLVMAsmParser -lLLVMNaClAnalysis -lLLVMCore -lLLVMSupport |
| 130 | |
| 131 | ifeq ($(AUTOCONF), 0) |
| 132 | # LLVM cmake build |
| 133 | LLVM_LIBS := $(LLVM_LIBS_LIST) |
| 134 | # For the cmake build, the gtest libs end up in the same place as the LLVM |
| 135 | # libs, so no "-L..." arg is needed. |
| 136 | GTEST_LIB_PATH ?= |
| 137 | CLANG_FORMAT_PATH ?= $(PNACL_BIN_PATH) |
| 138 | else |
| 139 | # LLVM autoconf build |
Jim Stichnoth | e5b58fb | 2015-06-01 15:17:20 -0700 | [diff] [blame] | 140 | LLVM_LIBS := -lLLVM-3.7svn |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 141 | GTEST_LIB_PATH ?= -L../../out/llvm_x86_64_linux_work/Release+Asserts/lib |
| 142 | CLANG_FORMAT_PATH ?= ../../out/llvm_x86_64_linux_work/Release+Asserts/bin |
| 143 | endif |
| 144 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 145 | LLVM_LDFLAGS := $(LLVM_LIBS) \ |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 146 | `$(PNACL_BIN_PATH)/llvm-config --ldflags` \ |
| 147 | `$(PNACL_BIN_PATH)/llvm-config --system-libs` |
| 148 | SB_LLVM_LDFLAGS := $(LLVM_LIBS_LIST) \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 149 | -L$(SB_LLVM_PATH)/lib |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 150 | |
Jim Stichnoth | 5e06f9f | 2014-09-17 08:41:21 -0700 | [diff] [blame] | 151 | CCACHE := `command -v ccache` |
| 152 | CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 153 | SB_CXX := CCACHE_CPP2=yes $(CCACHE) $(PNACL_BIN_PATH)/pnacl-clang++ |
| 154 | SB_TRANSLATE := $(PNACL_BIN_PATH)/pnacl-translate |
Jan Voung | 839c4ce | 2014-07-28 15:19:43 -0700 | [diff] [blame] | 155 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 156 | BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -Werror -fno-rtti \ |
| 157 | -fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g -pedantic \ |
| 158 | -Wno-error=unused-parameter $(CXX_EXTRA) |
| 159 | |
| 160 | CXXFLAGS := $(LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(CXX_DEFINES) $(HOST_FLAGS) \ |
Jim Stichnoth | 6c6adf1 | 2015-04-07 14:22:25 -0700 | [diff] [blame] | 161 | $(STDLIB_FLAGS) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 162 | SB_CXXFLAGS := $(SB_LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(SB_CXX_DEFINES) |
| 163 | |
Jim Stichnoth | fa4efea | 2015-01-27 05:06:03 -0800 | [diff] [blame] | 164 | LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib -Wl,--gc-sections \ |
Jim Stichnoth | 6c6adf1 | 2015-04-07 14:22:25 -0700 | [diff] [blame] | 165 | $(LD_EXTRA) $(STDLIB_FLAGS) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 166 | # Not specifying -Wl,--gc-sections but instead doing bitcode linking GC w/ LTO. |
| 167 | SB_LDFLAGS := $(LINKOPTLEVEL) $(LD_EXTRA) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 168 | |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 169 | SRCS = \ |
John Porto | aff4ccf | 2015-06-10 16:35:06 -0700 | [diff] [blame] | 170 | IceAssembler.cpp \ |
| 171 | IceAssemblerX8632.cpp \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 172 | IceBrowserCompileServer.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 173 | IceCfg.cpp \ |
| 174 | IceCfgNode.cpp \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 175 | IceClFlags.cpp \ |
| 176 | IceCompiler.cpp \ |
| 177 | IceCompileServer.cpp \ |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 178 | IceELFObjectWriter.cpp \ |
| 179 | IceELFSection.cpp \ |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 180 | IceFixups.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 181 | IceGlobalContext.cpp \ |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 182 | IceGlobalInits.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 183 | IceInst.cpp \ |
Jan Voung | b2d5084 | 2015-05-12 09:53:50 -0700 | [diff] [blame] | 184 | IceInstARM32.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 185 | IceInstX8632.cpp \ |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 186 | IceIntrinsics.cpp \ |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 187 | IceLiveness.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 188 | IceOperand.cpp \ |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 189 | IceRegAlloc.cpp \ |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 190 | IceRNG.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 191 | IceTargetLowering.cpp \ |
Jan Voung | b36ad9b | 2015-04-21 17:01:49 -0700 | [diff] [blame] | 192 | IceTargetLoweringARM32.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 193 | IceTargetLoweringX8632.cpp \ |
Jim Stichnoth | 6da4cef | 2015-06-11 13:26:33 -0700 | [diff] [blame] | 194 | IceTargetLoweringMIPS32.cpp \ |
Jim Stichnoth | bbca754 | 2015-02-11 16:08:31 -0800 | [diff] [blame] | 195 | IceThreading.cpp \ |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 196 | IceTimerTree.cpp \ |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 197 | IceTranslator.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 198 | IceTypes.cpp \ |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 199 | main.cpp \ |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 200 | PNaClTranslator.cpp |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 201 | |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 202 | ifndef MINIMAL |
Karl Schimpf | 4019f08 | 2014-12-15 13:45:00 -0800 | [diff] [blame] | 203 | SRCS += IceConverter.cpp \ |
| 204 | IceTypeConverter.cpp |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 205 | endif |
| 206 | |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 207 | OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS)) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 208 | SB_OBJS=$(patsubst %.cpp, $(SB_OBJDIR)/%.o, $(SRCS)) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 209 | |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 210 | UNITTEST_SRCS = \ |
Karl Schimpf | 2e7daef | 2015-01-09 13:04:13 -0800 | [diff] [blame] | 211 | BitcodeMunge.cpp \ |
| 212 | IceELFSectionTest.cpp \ |
| 213 | IceParseInstsTest.cpp |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 214 | |
| 215 | UNITTEST_OBJS = $(patsubst %.cpp, $(OBJDIR)/unittest/%.o, $(UNITTEST_SRCS)) |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 216 | UNITTEST_LIB_OBJS = $(filter-out $(OBJDIR)/main.o,$(OBJS)) |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 217 | |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 218 | # Keep all the first target so it's the default. |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 219 | all: $(OBJDIR)/pnacl-sz make_symlink runtime |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 220 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 221 | ifdef TSAN |
| 222 | sb: |
| 223 | @echo "Skipping pnacl-sz.*.nexe: TSAN isn't supported under NaCl." |
| 224 | else |
| 225 | sb: $(SB_OBJDIR)/pnacl-sz.x86-32.nexe |
| 226 | endif |
| 227 | |
Karl Schimpf | 6af6336 | 2014-10-29 14:55:00 -0700 | [diff] [blame] | 228 | # Creates symbolic link so that testing is easier. Also runs |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 229 | # pnacl-sz to verify that the defines flags have valid values, |
Karl Schimpf | 6af6336 | 2014-10-29 14:55:00 -0700 | [diff] [blame] | 230 | # as well as describe the corresponding build attributes. |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 231 | make_symlink: $(OBJDIR)/pnacl-sz |
| 232 | rm -rf pnacl-sz |
| 233 | ln -s $(OBJDIR)/pnacl-sz |
Karl Schimpf | 6af6336 | 2014-10-29 14:55:00 -0700 | [diff] [blame] | 234 | @echo "Build Attributes:" |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 235 | @$(OBJDIR)/pnacl-sz --build-atts |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 236 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 237 | .PHONY: all make_symlink runtime bloat sb |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 238 | |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 239 | $(OBJDIR)/pnacl-sz: $(OBJS) |
Jim Stichnoth | 3324642 | 2014-11-24 14:36:23 -0800 | [diff] [blame] | 240 | $(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \ |
Karl Schimpf | 8fcefc3 | 2014-09-15 12:56:50 -0700 | [diff] [blame] | 241 | -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 242 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 243 | $(SB_OBJDIR)/pnacl-sz.x86-32.nexe: $(SB_OBJS) |
| 244 | $(eval PNACL_SZ_BASE := $(patsubst %.nexe, %, $@)) |
| 245 | $(SB_CXX) $(SB_LDFLAGS) -o $(PNACL_SZ_BASE).nonfinal.pexe $^ \ |
| 246 | $(SB_LLVM_LDFLAGS) |
| 247 | $(SB_TRANSLATE) -arch x86-32 $(PNACL_SZ_BASE).nonfinal.pexe -o $@ \ |
| 248 | --allow-llvm-bitcode-input |
| 249 | |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 250 | # TODO(stichnot): Be more precise than "*.h" here and elsewhere. |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 251 | $(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 252 | $(CXX) -c $(CXXFLAGS) $< -o $@ |
| 253 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 254 | $(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp src/*.h src/*.def |
| 255 | $(SB_CXX) -c $(SB_CXXFLAGS) $< -o $@ |
| 256 | |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 257 | $(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS) |
Jim Stichnoth | e7e9b02 | 2015-04-21 15:05:22 -0700 | [diff] [blame] | 258 | $(CXX) $(GTEST_LIB_PATH) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \ |
| 259 | -lgtest -lgtest_main -ldl \ |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 260 | -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) |
| 261 | |
Jim Stichnoth | 6e861d5 | 2015-02-03 14:35:51 -0800 | [diff] [blame] | 262 | $(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp \ |
| 263 | unittest/*.h src/*.h src/*.def |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 264 | $(CXX) -c $(CXXFLAGS) \ |
| 265 | -Isrc/ \ |
| 266 | -I$(LLVM_SRC_PATH)/utils/unittest/googletest/include \ |
Karl Schimpf | cbb1d3d | 2015-06-08 09:25:15 -0700 | [diff] [blame] | 267 | -I$(LLVM_SRC_PATH) \ |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 268 | -DGTEST_HAS_RTTI=0 -DGTEST_USE_OWN_TR1_TUPLE \ |
| 269 | $< -o $@ |
| 270 | |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 271 | $(OBJS): | $(OBJDIR) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 272 | $(SB_OBJS): | $(SB_OBJDIR) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 273 | |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 274 | $(UNITTEST_OBJS): | $(OBJDIR)/unittest |
| 275 | |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 276 | $(OBJDIR): |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 277 | @mkdir -p $@ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 278 | $(SB_OBJDIR): |
| 279 | @mkdir -p $@ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 280 | |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 281 | $(OBJDIR)/unittest: $(OBJDIR) |
| 282 | @mkdir -p $@ |
| 283 | |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 284 | RT_SRC := runtime/szrt.c runtime/szrt_ll.ll runtime/szrt_profiler.c |
Jan Voung | 050deaa | 2015-06-12 15:12:05 -0700 | [diff] [blame] | 285 | RT_OBJ := build/runtime/szrt_native_x8632.o build/runtime/szrt_sb_x8632.o \ |
| 286 | build/runtime/szrt_native_arm32.o build/runtime/szrt_sb_arm32.o |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 287 | |
| 288 | runtime: $(RT_OBJ) |
| 289 | |
| 290 | # Use runtime.is.built so that build-runtime.py is invoked only once |
| 291 | # even in a parallel build. |
| 292 | .INTERMEDIATE: runtime.is.built |
| 293 | $(RT_OBJ): runtime.is.built |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 294 | runtime.is.built: $(RT_SRC) pydir/build-runtime.py |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 295 | @echo ================ Building Subzero runtime ================ |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 296 | ./pydir/build-runtime.py -v --pnacl-root $(PNACL_TOOLCHAIN_ROOT) |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 297 | |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 298 | check-lit: $(OBJDIR)/pnacl-sz make_symlink |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 299 | PNACL_BIN_PATH=$(PNACL_BIN_PATH) \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 300 | $(LLVM_SRC_PATH)/utils/lit/lit.py -sv tests_lit |
Jim Stichnoth | ac9c943 | 2014-08-26 14:07:13 -0700 | [diff] [blame] | 301 | |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 302 | ifdef MINIMAL |
Jim Stichnoth | c925822 | 2015-03-13 11:59:49 -0700 | [diff] [blame] | 303 | check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime |
| 304 | @echo "Crosstests disabled, minimal build" |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 305 | else |
Jim Stichnoth | c925822 | 2015-03-13 11:59:49 -0700 | [diff] [blame] | 306 | check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime |
Jim Stichnoth | dc7c597 | 2015-03-10 11:17:15 -0700 | [diff] [blame] | 307 | # Do all native/sse2 tests, but only test_vector_ops for native/sse4.1. |
| 308 | # For (slow) sandboxed tests, limit to Om1/sse4.1. |
| 309 | ./pydir/crosstest_generator.py -v --lit \ |
Jan Voung | 8e32fed | 2015-06-17 10:16:23 -0700 | [diff] [blame^] | 310 | --toolchain-root $(TOOLCHAIN_ROOT) \ |
| 311 | -i x8632,native,sse2 -i x8632,native,sse4.1,test_vector_ops \ |
| 312 | -i x8632,sandbox,sse4.1,Om1 \ |
| 313 | -i arm32,native,neon,Om1,simple_loop |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 314 | PNACL_BIN_PATH=$(PNACL_BIN_PATH) \ |
Jim Stichnoth | dc7c597 | 2015-03-10 11:17:15 -0700 | [diff] [blame] | 315 | $(LLVM_SRC_PATH)/utils/lit/lit.py -sv crosstest/Output |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 316 | endif |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 317 | |
Jim Stichnoth | c925822 | 2015-03-13 11:59:49 -0700 | [diff] [blame] | 318 | check-unit: $(OBJDIR)/run_unittests |
| 319 | $(OBJDIR)/run_unittests |
| 320 | |
| 321 | check: check-lit check-unit check-xtest |
| 322 | |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 323 | FORMAT_BLACKLIST = |
| 324 | # Add one of the following lines for each source file to ignore. |
| 325 | FORMAT_BLACKLIST += ! -name IceParseInstsTest.cpp |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 326 | format: |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 327 | $(CLANG_FORMAT_PATH)/clang-format -style=LLVM -i \ |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 328 | `find . -regex '.*\.\(c\|h\|cpp\)' $(FORMAT_BLACKLIST)` |
Jim Stichnoth | 240e0f8 | 2014-07-09 16:53:40 -0700 | [diff] [blame] | 329 | |
Jim Stichnoth | 240e0f8 | 2014-07-09 16:53:40 -0700 | [diff] [blame] | 330 | format-diff: |
Jim Stichnoth | 206833c | 2014-08-07 10:58:05 -0700 | [diff] [blame] | 331 | git diff -U0 `git merge-base HEAD master` | \ |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 332 | PATH=$(PNACL_BIN_PATH):$(PATH) \ |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 333 | $(LLVM_SRC_PATH)/../clang/tools/clang-format/clang-format-diff.py \ |
| 334 | -p1 -style=LLVM -i |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 335 | |
Jim Stichnoth | 307e326 | 2015-02-12 16:10:37 -0800 | [diff] [blame] | 336 | bloat: make_symlink |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 337 | nm -C -S -l pnacl-sz | \ |
| 338 | bloat/bloat.py --nm-output=/dev/stdin syms > build/pnacl-sz.bloat.json |
| 339 | @echo See Subzero size breakdown in bloat/pnacl-sz.bloat.html |
Jim Stichnoth | 307e326 | 2015-02-12 16:10:37 -0800 | [diff] [blame] | 340 | |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 341 | clean: |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 342 | rm -rf pnacl-sz *.o $(OBJDIR) $(SB_OBJDIR) build/pnacl-sz.bloat.json |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 343 | |
| 344 | clean-all: clean |
| 345 | rm -rf build/ |