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 | |
Karl Schimpf | 6f9ba11 | 2015-06-22 13:20:23 -0700 | [diff] [blame] | 89 | ifdef TEXTUAL_BITCODE |
| 90 | BASE_CXX_DEFINES += -DINPUT_IS_TEXTUAL_BITCODE=1 |
| 91 | OBJDIR := $(OBJDIR)+Tbc |
Karl Schimpf | 6f9ba11 | 2015-06-22 13:20:23 -0700 | [diff] [blame] | 92 | else |
| 93 | BASE_CXX_DEFINES += -DINPUT_IS_TEXTUAL_BITCODE=0 |
Karl Schimpf | 6f9ba11 | 2015-06-22 13:20:23 -0700 | [diff] [blame] | 94 | endif |
| 95 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 96 | SB_CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=1 |
| 97 | CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=0 |
| 98 | |
Jim Stichnoth | 9c234e2 | 2014-10-01 09:28:21 -0700 | [diff] [blame] | 99 | ifdef NOASSERT |
| 100 | ASSERTIONS = -DNDEBUG |
| 101 | else |
| 102 | ASSERTIONS = |
| 103 | OBJDIR := $(OBJDIR)+Asserts |
| 104 | endif |
| 105 | |
Jim Stichnoth | fa4efea | 2015-01-27 05:06:03 -0800 | [diff] [blame] | 106 | ifdef TSAN |
| 107 | OBJDIR := $(OBJDIR)+TSan |
| 108 | CXX_EXTRA += -fsanitize=thread |
| 109 | LD_EXTRA += -fsanitize=thread |
| 110 | endif |
| 111 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 112 | SB_OBJDIR := $(OBJDIR)+Sandboxed |
| 113 | |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 114 | $(info -----------------------------------------------) |
| 115 | $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH)) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 116 | $(info Using SB_LLVM_PATH = $(SB_LLVM_PATH)) |
| 117 | $(info Using NACL_ROOT = $(NACL_ROOT)) |
Jan Voung | 8e32fed | 2015-06-17 10:16:23 -0700 | [diff] [blame] | 118 | $(info Using TOOLCHAIN_ROOT = $(TOOLCHAIN_ROOT)) |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 119 | $(info Using PNACL_TOOLCHAIN_ROOT = $(PNACL_TOOLCHAIN_ROOT)) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 120 | $(info Using PNACL_BIN_PATH = $(PNACL_BIN_PATH)) |
Karl Schimpf | 8fcefc3 | 2014-09-15 12:56:50 -0700 | [diff] [blame] | 121 | $(info Using CLANG_PATH = $(CLANG_PATH)) |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 122 | $(info Using LIBCXX_INSTALL_PATH = $(LIBCXX_INSTALL_PATH)) |
Jan Voung | 839c4ce | 2014-07-28 15:19:43 -0700 | [diff] [blame] | 123 | $(info Using HOST_ARCH = $(HOST_ARCH)) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 124 | $(info -----------------------------------------------) |
| 125 | |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 126 | LLVM_CXXFLAGS := `$(PNACL_BIN_PATH)/llvm-config --cxxflags` |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 127 | SB_LLVM_CXXFLAGS := $(LLVM_CXXFLAGS) |
| 128 | |
| 129 | # Listing specific libraries that are needed for pnacl-sz |
| 130 | # and the unittests, since we build "tools-only" for the |
| 131 | # sandboxed_translators (which doesn't include every library |
| 132 | # listed by llvm-config). |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 133 | |
| 134 | LLVM_LIBS_LIST := -lLLVMIRReader -lLLVMBitReader -lLLVMNaClBitTestUtils \ |
| 135 | -lLLVMNaClBitReader -lLLVMNaClBitAnalysis -lLLVMNaClBitWriter \ |
| 136 | -lLLVMAsmParser -lLLVMNaClAnalysis -lLLVMCore -lLLVMSupport |
| 137 | |
| 138 | ifeq ($(AUTOCONF), 0) |
| 139 | # LLVM cmake build |
Karl Schimpf | 28f3f73 | 2015-06-24 09:32:40 -0700 | [diff] [blame] | 140 | LLVM_LIBS := $(LLVM_LIBS_LIST) |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 141 | # For the cmake build, the gtest libs end up in the same place as the LLVM |
| 142 | # libs, so no "-L..." arg is needed. |
| 143 | GTEST_LIB_PATH ?= |
| 144 | CLANG_FORMAT_PATH ?= $(PNACL_BIN_PATH) |
| 145 | else |
| 146 | # LLVM autoconf build |
Jim Stichnoth | e5b58fb | 2015-06-01 15:17:20 -0700 | [diff] [blame] | 147 | LLVM_LIBS := -lLLVM-3.7svn |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 148 | GTEST_LIB_PATH ?= -L../../out/llvm_x86_64_linux_work/Release+Asserts/lib |
| 149 | CLANG_FORMAT_PATH ?= ../../out/llvm_x86_64_linux_work/Release+Asserts/bin |
| 150 | endif |
| 151 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 152 | LLVM_LDFLAGS := $(LLVM_LIBS) \ |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 153 | `$(PNACL_BIN_PATH)/llvm-config --ldflags` \ |
| 154 | `$(PNACL_BIN_PATH)/llvm-config --system-libs` |
| 155 | SB_LLVM_LDFLAGS := $(LLVM_LIBS_LIST) \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 156 | -L$(SB_LLVM_PATH)/lib |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 157 | |
Jim Stichnoth | 5e06f9f | 2014-09-17 08:41:21 -0700 | [diff] [blame] | 158 | CCACHE := `command -v ccache` |
| 159 | CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 160 | SB_CXX := CCACHE_CPP2=yes $(CCACHE) $(PNACL_BIN_PATH)/pnacl-clang++ |
| 161 | SB_TRANSLATE := $(PNACL_BIN_PATH)/pnacl-translate |
Jan Voung | 839c4ce | 2014-07-28 15:19:43 -0700 | [diff] [blame] | 162 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 163 | BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -Werror -fno-rtti \ |
| 164 | -fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g -pedantic \ |
Jim Stichnoth | 98da966 | 2015-06-27 06:38:08 -0700 | [diff] [blame] | 165 | $(CXX_EXTRA) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 166 | |
| 167 | CXXFLAGS := $(LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(CXX_DEFINES) $(HOST_FLAGS) \ |
Jim Stichnoth | 6c6adf1 | 2015-04-07 14:22:25 -0700 | [diff] [blame] | 168 | $(STDLIB_FLAGS) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 169 | SB_CXXFLAGS := $(SB_LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(SB_CXX_DEFINES) |
| 170 | |
Jim Stichnoth | fa4efea | 2015-01-27 05:06:03 -0800 | [diff] [blame] | 171 | LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib -Wl,--gc-sections \ |
Jim Stichnoth | 6c6adf1 | 2015-04-07 14:22:25 -0700 | [diff] [blame] | 172 | $(LD_EXTRA) $(STDLIB_FLAGS) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 173 | # Not specifying -Wl,--gc-sections but instead doing bitcode linking GC w/ LTO. |
| 174 | SB_LDFLAGS := $(LINKOPTLEVEL) $(LD_EXTRA) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 175 | |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 176 | SRCS = \ |
John Porto | aff4ccf | 2015-06-10 16:35:06 -0700 | [diff] [blame] | 177 | IceAssembler.cpp \ |
John Porto | d58f01c | 2015-06-23 15:55:17 -0700 | [diff] [blame] | 178 | IceAssemblerX8664.cpp \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 179 | IceBrowserCompileServer.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 180 | IceCfg.cpp \ |
| 181 | IceCfgNode.cpp \ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 182 | IceClFlags.cpp \ |
| 183 | IceCompiler.cpp \ |
| 184 | IceCompileServer.cpp \ |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 185 | IceELFObjectWriter.cpp \ |
| 186 | IceELFSection.cpp \ |
Jan Voung | ec27073 | 2015-01-12 17:00:22 -0800 | [diff] [blame] | 187 | IceFixups.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 188 | IceGlobalContext.cpp \ |
Karl Schimpf | e3f64d0 | 2014-10-07 10:38:22 -0700 | [diff] [blame] | 189 | IceGlobalInits.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 190 | IceInst.cpp \ |
Jan Voung | b2d5084 | 2015-05-12 09:53:50 -0700 | [diff] [blame] | 191 | IceInstARM32.cpp \ |
Reed Kotler | d00d48d | 2015-07-08 09:49:07 -0700 | [diff] [blame] | 192 | IceInstMIPS32.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 193 | IceInstX8632.cpp \ |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 194 | IceIntrinsics.cpp \ |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 195 | IceLiveness.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 196 | IceOperand.cpp \ |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 197 | IceRegAlloc.cpp \ |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 198 | IceRNG.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 199 | IceTargetLowering.cpp \ |
Jan Voung | b36ad9b | 2015-04-21 17:01:49 -0700 | [diff] [blame] | 200 | IceTargetLoweringARM32.cpp \ |
Jim Stichnoth | 6da4cef | 2015-06-11 13:26:33 -0700 | [diff] [blame] | 201 | IceTargetLoweringMIPS32.cpp \ |
John Porto | 7e93c62 | 2015-06-23 10:58:57 -0700 | [diff] [blame] | 202 | IceTargetLoweringX8632.cpp \ |
John Porto | d58f01c | 2015-06-23 15:55:17 -0700 | [diff] [blame] | 203 | IceTargetLoweringX8664.cpp \ |
Jim Stichnoth | bbca754 | 2015-02-11 16:08:31 -0800 | [diff] [blame] | 204 | IceThreading.cpp \ |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 205 | IceTimerTree.cpp \ |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 206 | IceTranslator.cpp \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 207 | IceTypes.cpp \ |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 208 | main.cpp \ |
Karl Schimpf | 8d7abae | 2014-07-07 14:50:30 -0700 | [diff] [blame] | 209 | PNaClTranslator.cpp |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 210 | |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 211 | ifndef MINIMAL |
Karl Schimpf | 4019f08 | 2014-12-15 13:45:00 -0800 | [diff] [blame] | 212 | SRCS += IceConverter.cpp \ |
| 213 | IceTypeConverter.cpp |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 214 | endif |
| 215 | |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 216 | OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS)) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 217 | SB_OBJS=$(patsubst %.cpp, $(SB_OBJDIR)/%.o, $(SRCS)) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 218 | |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 219 | UNITTEST_SRCS = \ |
Karl Schimpf | 2e7daef | 2015-01-09 13:04:13 -0800 | [diff] [blame] | 220 | BitcodeMunge.cpp \ |
John Porto | f746f3d | 2015-07-11 08:29:20 -0700 | [diff] [blame] | 221 | IceAssemblerX8632Test.cpp \ |
Karl Schimpf | 2e7daef | 2015-01-09 13:04:13 -0800 | [diff] [blame] | 222 | IceELFSectionTest.cpp \ |
| 223 | IceParseInstsTest.cpp |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 224 | |
| 225 | UNITTEST_OBJS = $(patsubst %.cpp, $(OBJDIR)/unittest/%.o, $(UNITTEST_SRCS)) |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 226 | UNITTEST_LIB_OBJS = $(filter-out $(OBJDIR)/main.o,$(OBJS)) |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 227 | |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 228 | # Keep all the first target so it's the default. |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 229 | all: $(OBJDIR)/pnacl-sz make_symlink runtime |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 230 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 231 | ifdef TSAN |
| 232 | sb: |
| 233 | @echo "Skipping pnacl-sz.*.nexe: TSAN isn't supported under NaCl." |
| 234 | else |
| 235 | sb: $(SB_OBJDIR)/pnacl-sz.x86-32.nexe |
| 236 | endif |
| 237 | |
Karl Schimpf | 6f9ba11 | 2015-06-22 13:20:23 -0700 | [diff] [blame] | 238 | # SHOW_BUILD_ATTS is an executable that is run to show what build |
| 239 | # attributes were used to build pnacl-sz. |
| 240 | ifdef TEXTUAL_BITCODE |
| 241 | SHOW_BUILD_ATTS = echo "Can't show build attributes when TEXTUAL_BITCODE=1" |
| 242 | else |
| 243 | SHOW_BUILD_ATTS = $(OBJDIR)/pnacl-sz --build-atts |
| 244 | endif |
| 245 | |
Karl Schimpf | 6af6336 | 2014-10-29 14:55:00 -0700 | [diff] [blame] | 246 | # Creates symbolic link so that testing is easier. Also runs |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 247 | # pnacl-sz to verify that the defines flags have valid values, |
Karl Schimpf | 6af6336 | 2014-10-29 14:55:00 -0700 | [diff] [blame] | 248 | # as well as describe the corresponding build attributes. |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 249 | make_symlink: $(OBJDIR)/pnacl-sz |
| 250 | rm -rf pnacl-sz |
| 251 | ln -s $(OBJDIR)/pnacl-sz |
Karl Schimpf | 6af6336 | 2014-10-29 14:55:00 -0700 | [diff] [blame] | 252 | @echo "Build Attributes:" |
Karl Schimpf | 6f9ba11 | 2015-06-22 13:20:23 -0700 | [diff] [blame] | 253 | @$(SHOW_BUILD_ATTS) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 254 | |
Andrew Scull | a509e1d | 2015-06-29 11:07:08 -0700 | [diff] [blame] | 255 | .PHONY: all make_symlink runtime bloat sb docs |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 256 | |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 257 | $(OBJDIR)/pnacl-sz: $(OBJS) |
Jim Stichnoth | 3324642 | 2014-11-24 14:36:23 -0800 | [diff] [blame] | 258 | $(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \ |
Karl Schimpf | 8fcefc3 | 2014-09-15 12:56:50 -0700 | [diff] [blame] | 259 | -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 260 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 261 | $(SB_OBJDIR)/pnacl-sz.x86-32.nexe: $(SB_OBJS) |
| 262 | $(eval PNACL_SZ_BASE := $(patsubst %.nexe, %, $@)) |
| 263 | $(SB_CXX) $(SB_LDFLAGS) -o $(PNACL_SZ_BASE).nonfinal.pexe $^ \ |
| 264 | $(SB_LLVM_LDFLAGS) |
| 265 | $(SB_TRANSLATE) -arch x86-32 $(PNACL_SZ_BASE).nonfinal.pexe -o $@ \ |
| 266 | --allow-llvm-bitcode-input |
| 267 | |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 268 | # TODO(stichnot): Be more precise than "*.h" here and elsewhere. |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 269 | $(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 270 | $(CXX) -c $(CXXFLAGS) $< -o $@ |
| 271 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 272 | $(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp src/*.h src/*.def |
| 273 | $(SB_CXX) -c $(SB_CXXFLAGS) $< -o $@ |
| 274 | |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 275 | $(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS) |
Jim Stichnoth | e7e9b02 | 2015-04-21 15:05:22 -0700 | [diff] [blame] | 276 | $(CXX) $(GTEST_LIB_PATH) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \ |
| 277 | -lgtest -lgtest_main -ldl \ |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 278 | -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) |
| 279 | |
Jim Stichnoth | 6e861d5 | 2015-02-03 14:35:51 -0800 | [diff] [blame] | 280 | $(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp \ |
| 281 | unittest/*.h src/*.h src/*.def |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 282 | $(CXX) -c $(CXXFLAGS) \ |
| 283 | -Isrc/ \ |
| 284 | -I$(LLVM_SRC_PATH)/utils/unittest/googletest/include \ |
Karl Schimpf | cbb1d3d | 2015-06-08 09:25:15 -0700 | [diff] [blame] | 285 | -I$(LLVM_SRC_PATH) \ |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 286 | -DGTEST_HAS_RTTI=0 -DGTEST_USE_OWN_TR1_TUPLE \ |
| 287 | $< -o $@ |
| 288 | |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 289 | $(OBJS): | $(OBJDIR) |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 290 | $(SB_OBJS): | $(SB_OBJDIR) |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 291 | |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 292 | $(UNITTEST_OBJS): | $(OBJDIR)/unittest |
| 293 | |
Jim Stichnoth | fddef24 | 2014-09-26 18:53:41 -0700 | [diff] [blame] | 294 | $(OBJDIR): |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 295 | @mkdir -p $@ |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 296 | $(SB_OBJDIR): |
| 297 | @mkdir -p $@ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 298 | |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 299 | $(OBJDIR)/unittest: $(OBJDIR) |
| 300 | @mkdir -p $@ |
| 301 | |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 302 | 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] | 303 | RT_OBJ := build/runtime/szrt_native_x8632.o build/runtime/szrt_sb_x8632.o \ |
| 304 | build/runtime/szrt_native_arm32.o build/runtime/szrt_sb_arm32.o |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 305 | |
| 306 | runtime: $(RT_OBJ) |
| 307 | |
| 308 | # Use runtime.is.built so that build-runtime.py is invoked only once |
| 309 | # even in a parallel build. |
| 310 | .INTERMEDIATE: runtime.is.built |
| 311 | $(RT_OBJ): runtime.is.built |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 312 | runtime.is.built: $(RT_SRC) pydir/build-runtime.py |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 313 | @echo ================ Building Subzero runtime ================ |
Jan Voung | 68a0633 | 2015-03-05 14:33:38 -0800 | [diff] [blame] | 314 | ./pydir/build-runtime.py -v --pnacl-root $(PNACL_TOOLCHAIN_ROOT) |
Jim Stichnoth | 9738a9e | 2015-02-23 16:39:06 -0800 | [diff] [blame] | 315 | |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 316 | check-lit: $(OBJDIR)/pnacl-sz make_symlink |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 317 | PNACL_BIN_PATH=$(PNACL_BIN_PATH) \ |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 318 | $(LLVM_SRC_PATH)/utils/lit/lit.py -sv tests_lit |
Jim Stichnoth | ac9c943 | 2014-08-26 14:07:13 -0700 | [diff] [blame] | 319 | |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 320 | ifdef MINIMAL |
Jim Stichnoth | c925822 | 2015-03-13 11:59:49 -0700 | [diff] [blame] | 321 | check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime |
| 322 | @echo "Crosstests disabled, minimal build" |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 323 | else |
Jim Stichnoth | c925822 | 2015-03-13 11:59:49 -0700 | [diff] [blame] | 324 | check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime |
Jim Stichnoth | dc7c597 | 2015-03-10 11:17:15 -0700 | [diff] [blame] | 325 | # Do all native/sse2 tests, but only test_vector_ops for native/sse4.1. |
| 326 | # For (slow) sandboxed tests, limit to Om1/sse4.1. |
| 327 | ./pydir/crosstest_generator.py -v --lit \ |
Jan Voung | 8e32fed | 2015-06-17 10:16:23 -0700 | [diff] [blame] | 328 | --toolchain-root $(TOOLCHAIN_ROOT) \ |
| 329 | -i x8632,native,sse2 -i x8632,native,sse4.1,test_vector_ops \ |
| 330 | -i x8632,sandbox,sse4.1,Om1 \ |
Jan Voung | f645d85 | 2015-07-09 10:35:09 -0700 | [diff] [blame] | 331 | -i arm32,native,neon,Om1,simple_loop \ |
Jan Voung | 112b6e8 | 2015-07-13 11:36:53 -0700 | [diff] [blame] | 332 | -i arm32,native,neon,Om1,mem_intrin \ |
| 333 | -i arm32,native,neon,Om1,test_stacksave \ |
| 334 | -i arm32,native,neon,Om1,test_strengthreduce |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 335 | PNACL_BIN_PATH=$(PNACL_BIN_PATH) \ |
Jim Stichnoth | dc7c597 | 2015-03-10 11:17:15 -0700 | [diff] [blame] | 336 | $(LLVM_SRC_PATH)/utils/lit/lit.py -sv crosstest/Output |
Karl Schimpf | ab06df3 | 2014-10-29 14:58:25 -0700 | [diff] [blame] | 337 | endif |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 338 | |
Jim Stichnoth | c925822 | 2015-03-13 11:59:49 -0700 | [diff] [blame] | 339 | check-unit: $(OBJDIR)/run_unittests |
| 340 | $(OBJDIR)/run_unittests |
| 341 | |
| 342 | check: check-lit check-unit check-xtest |
| 343 | |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 344 | FORMAT_BLACKLIST = |
| 345 | # Add one of the following lines for each source file to ignore. |
| 346 | FORMAT_BLACKLIST += ! -name IceParseInstsTest.cpp |
Karl Schimpf | 74cd883 | 2015-06-23 11:05:01 -0700 | [diff] [blame] | 347 | FORMAT_BLACKLIST += ! -name IceParseTypesTest.cpp |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 348 | format: |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 349 | $(CLANG_FORMAT_PATH)/clang-format -style=LLVM -i \ |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 350 | `find . -regex '.*\.\(c\|h\|cpp\)' $(FORMAT_BLACKLIST)` |
Jim Stichnoth | 240e0f8 | 2014-07-09 16:53:40 -0700 | [diff] [blame] | 351 | |
Jim Stichnoth | 240e0f8 | 2014-07-09 16:53:40 -0700 | [diff] [blame] | 352 | format-diff: |
Jim Stichnoth | 206833c | 2014-08-07 10:58:05 -0700 | [diff] [blame] | 353 | git diff -U0 `git merge-base HEAD master` | \ |
Jim Stichnoth | 0a9e126 | 2015-04-21 09:59:21 -0700 | [diff] [blame] | 354 | PATH=$(PNACL_BIN_PATH):$(PATH) \ |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 355 | $(LLVM_SRC_PATH)/../clang/tools/clang-format/clang-format-diff.py \ |
| 356 | -p1 -style=LLVM -i |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 357 | |
Jim Stichnoth | 307e326 | 2015-02-12 16:10:37 -0800 | [diff] [blame] | 358 | bloat: make_symlink |
Jim Stichnoth | fa0cfa5 | 2015-02-26 09:42:36 -0800 | [diff] [blame] | 359 | nm -C -S -l pnacl-sz | \ |
| 360 | bloat/bloat.py --nm-output=/dev/stdin syms > build/pnacl-sz.bloat.json |
| 361 | @echo See Subzero size breakdown in bloat/pnacl-sz.bloat.html |
Jim Stichnoth | 307e326 | 2015-02-12 16:10:37 -0800 | [diff] [blame] | 362 | |
Andrew Scull | a509e1d | 2015-06-29 11:07:08 -0700 | [diff] [blame] | 363 | docs: |
| 364 | doxygen Doxyfile |
| 365 | @echo See file://`pwd`/docs/html/index.html |
| 366 | |
Derek Schuff | bc64313 | 2014-05-22 16:39:25 -0700 | [diff] [blame] | 367 | clean: |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 368 | 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] | 369 | |
| 370 | clean-all: clean |
Andrew Scull | a509e1d | 2015-06-29 11:07:08 -0700 | [diff] [blame] | 371 | rm -rf build/ docs/ |