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