blob: 5f2686ba8f7788db34b49715bed3689905a65640 [file] [log] [blame]
Derek Schuffbc643132014-05-22 16:39:25 -07001# 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 Stichnoth0a9e1262015-04-21 09:59:21 -07005# make LLVM_SRC_PATH=<path> LIBCXX_INSTALL_PATH=<path> CLANG_PATH=<path> \
Jan Voung44c3a802015-03-27 16:29:08 -07006# PNACL_BIN_PATH=<path> ...
Derek Schuffbc643132014-05-22 16:39:25 -07007#
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.
14LLVM_SRC_PATH ?= ../llvm
15
Jan Voung44c3a802015-03-27 16:29:08 -070016# The x86-32-specific sandboxed translator directory.
17# It holds sandboxed versions of libraries and binaries.
18SB_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.
22NACL_ROOT ?= $(shell python -c "import sys; sys.path.insert(0, 'pydir'); \
23 import utils; print utils.FindBaseNaCl()")
24
Jan Voung8e32fed2015-06-17 10:16:23 -070025# TOOLCHAIN_ROOT is the location of NaCl/PNaCl toolchains and other
26# tools like qemu.
27TOOLCHAIN_ROOT ?= $(shell readlink -e $(NACL_ROOT)/toolchain/linux_x86)
28
Jan Voung68a06332015-03-05 14:33:38 -080029# PNACL_TOOLCHAIN_ROOT is the location of the PNaCl toolchain.
30# This is used as the default root for finding binutils, libcxx, etc.
Jan Voung8e32fed2015-06-17 10:16:23 -070031PNACL_TOOLCHAIN_ROOT ?= $(shell readlink -e $(TOOLCHAIN_ROOT)/pnacl_newlib_raw)
Jan Voung44c3a802015-03-27 16:29:08 -070032
33# The location of PNaCl tools (e.g., binutils objdump, pnacl-clang++, etc.).
34PNACL_BIN_PATH ?= $(shell readlink -e $(PNACL_TOOLCHAIN_ROOT)/bin)
Karl Schimpf8fcefc32014-09-15 12:56:50 -070035
Jim Stichnoth0a9e1262015-04-21 09:59:21 -070036# Hack to auto-detect autoconf versus cmake build of LLVM. If the LLVM tools
Jim Stichnothe5b58fb2015-06-01 15:17:20 -070037# were dynamically linked with something like libLLVM-3.7svn.so, it is an
Jim Stichnoth0a9e1262015-04-21 09:59:21 -070038# autoconf build, otherwise it is a cmake build. AUTOCONF is set to 0 for
39# cmake, nonzero for autoconf.
40AUTOCONF ?= $(shell ldd $(PNACL_BIN_PATH)/opt | grep -c libLLVM-)
41
Jan Voung68a06332015-03-05 14:33:38 -080042# CLANG_PATH is the location of the clang compiler to use for building
43# the host binaries.
Karl Schimpf8fcefc32014-09-15 12:56:50 -070044CLANG_PATH ?= $(shell readlink -e \
Jan Voung44c3a802015-03-27 16:29:08 -070045 $(NACL_ROOT)/../third_party/llvm-build/Release+Asserts/bin)
Karl Schimpf8fcefc32014-09-15 12:56:50 -070046
Jan Voung68a06332015-03-05 14:33:38 -080047# 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.
50LIBCXX_INSTALL_PATH ?= $(PNACL_TOOLCHAIN_ROOT)
Karl Schimpf9d928542015-04-16 15:08:05 -070051STDLIB_FLAGS := -stdlib=libc++ -I$(LIBCXX_INSTALL_PATH)/include/c++/v1
Jan Voung68a06332015-03-05 14:33:38 -080052
Jan Voung4c127ba2014-09-19 13:11:36 -070053HOST_ARCH ?= x86_64
Jan Voung839c4ce2014-07-28 15:19:43 -070054ifeq ($(HOST_ARCH),x86_64)
Jim Stichnoth6c6adf12015-04-07 14:22:25 -070055 HOST_FLAGS = -m64
Jan Voung839c4ce2014-07-28 15:19:43 -070056else
57 ifeq ($(HOST_ARCH),x86)
Jim Stichnoth6c6adf12015-04-07 14:22:25 -070058 HOST_FLAGS = -m32
Jan Voung839c4ce2014-07-28 15:19:43 -070059 endif
60endif
61
Jim Stichnothfddef242014-09-26 18:53:41 -070062ifdef DEBUG
63 OBJDIR = build/Debug
64 OPTLEVEL = -O0
Jan Voung44c3a802015-03-27 16:29:08 -070065 LINKOPTLEVEL = -O0
Jim Stichnothfddef242014-09-26 18:53:41 -070066else
67 OBJDIR = build/Release
Jim Stichnotha49e9d92014-12-07 14:25:34 -080068 OPTLEVEL = -O2 -ffunction-sections -fdata-sections
Jan Voung44c3a802015-03-27 16:29:08 -070069 LINKOPTLEVEL = -O2
Jim Stichnothfddef242014-09-26 18:53:41 -070070endif
71
Karl Schimpfb262c5e2014-10-27 14:41:57 -070072# The list of CXX defines that are dependent on build parameters.
Jan Voung44c3a802015-03-27 16:29:08 -070073BASE_CXX_DEFINES =
Jim Stichnothfa4efea2015-01-27 05:06:03 -080074CXX_EXTRA =
75LD_EXTRA =
Karl Schimpfb262c5e2014-10-27 14:41:57 -070076
77ifdef MINIMAL
Jim Stichnothe3c02c22014-12-05 14:16:07 -080078 NOASSERT = 1
Karl Schimpfb262c5e2014-10-27 14:41:57 -070079 OBJDIR := $(OBJDIR)+Min
Jan Voung44c3a802015-03-27 16:29:08 -070080 BASE_CXX_DEFINES += -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \
Karl Schimpfdf80eb82015-02-09 14:20:22 -080081 -DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_DISABLE_IR_GEN=0 \
Jan Voung44c3a802015-03-27 16:29:08 -070082 -DALLOW_MINIMAL_BUILD=1
Karl Schimpfb262c5e2014-10-27 14:41:57 -070083else
Jan Voung44c3a802015-03-27 16:29:08 -070084 BASE_CXX_DEFINES += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \
Karl Schimpfdf80eb82015-02-09 14:20:22 -080085 -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_DISABLE_IR_GEN=1 \
Jan Voung44c3a802015-03-27 16:29:08 -070086 -DALLOW_MINIMAL_BUILD=0
Karl Schimpfb262c5e2014-10-27 14:41:57 -070087endif
88
Jan Voung44c3a802015-03-27 16:29:08 -070089SB_CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=1
90CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=0
91
Jim Stichnoth9c234e22014-10-01 09:28:21 -070092ifdef NOASSERT
93 ASSERTIONS = -DNDEBUG
94else
95 ASSERTIONS =
96 OBJDIR := $(OBJDIR)+Asserts
97endif
98
Jim Stichnothfa4efea2015-01-27 05:06:03 -080099ifdef TSAN
100 OBJDIR := $(OBJDIR)+TSan
101 CXX_EXTRA += -fsanitize=thread
102 LD_EXTRA += -fsanitize=thread
103endif
104
Jan Voung44c3a802015-03-27 16:29:08 -0700105SB_OBJDIR := $(OBJDIR)+Sandboxed
106
Derek Schuffbc643132014-05-22 16:39:25 -0700107$(info -----------------------------------------------)
108$(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH))
Jan Voung44c3a802015-03-27 16:29:08 -0700109$(info Using SB_LLVM_PATH = $(SB_LLVM_PATH))
110$(info Using NACL_ROOT = $(NACL_ROOT))
Jan Voung8e32fed2015-06-17 10:16:23 -0700111$(info Using TOOLCHAIN_ROOT = $(TOOLCHAIN_ROOT))
Jan Voung68a06332015-03-05 14:33:38 -0800112$(info Using PNACL_TOOLCHAIN_ROOT = $(PNACL_TOOLCHAIN_ROOT))
Jan Voung44c3a802015-03-27 16:29:08 -0700113$(info Using PNACL_BIN_PATH = $(PNACL_BIN_PATH))
Karl Schimpf8fcefc32014-09-15 12:56:50 -0700114$(info Using CLANG_PATH = $(CLANG_PATH))
Jan Voung68a06332015-03-05 14:33:38 -0800115$(info Using LIBCXX_INSTALL_PATH = $(LIBCXX_INSTALL_PATH))
Jan Voung839c4ce2014-07-28 15:19:43 -0700116$(info Using HOST_ARCH = $(HOST_ARCH))
Derek Schuffbc643132014-05-22 16:39:25 -0700117$(info -----------------------------------------------)
118
Jim Stichnoth0a9e1262015-04-21 09:59:21 -0700119LLVM_CXXFLAGS := `$(PNACL_BIN_PATH)/llvm-config --cxxflags`
Jan Voung44c3a802015-03-27 16:29:08 -0700120SB_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 Stichnoth0a9e1262015-04-21 09:59:21 -0700126
127LLVM_LIBS_LIST := -lLLVMIRReader -lLLVMBitReader -lLLVMNaClBitTestUtils \
128 -lLLVMNaClBitReader -lLLVMNaClBitAnalysis -lLLVMNaClBitWriter \
129 -lLLVMAsmParser -lLLVMNaClAnalysis -lLLVMCore -lLLVMSupport
130
131ifeq ($(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)
138else
139 # LLVM autoconf build
Jim Stichnothe5b58fb2015-06-01 15:17:20 -0700140 LLVM_LIBS := -lLLVM-3.7svn
Jim Stichnoth0a9e1262015-04-21 09:59:21 -0700141 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
143endif
144
Jan Voung44c3a802015-03-27 16:29:08 -0700145LLVM_LDFLAGS := $(LLVM_LIBS) \
Jim Stichnoth0a9e1262015-04-21 09:59:21 -0700146 `$(PNACL_BIN_PATH)/llvm-config --ldflags` \
147 `$(PNACL_BIN_PATH)/llvm-config --system-libs`
148SB_LLVM_LDFLAGS := $(LLVM_LIBS_LIST) \
Jan Voung44c3a802015-03-27 16:29:08 -0700149 -L$(SB_LLVM_PATH)/lib
Derek Schuffbc643132014-05-22 16:39:25 -0700150
Jim Stichnoth5e06f9f2014-09-17 08:41:21 -0700151CCACHE := `command -v ccache`
152CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++
Jan Voung44c3a802015-03-27 16:29:08 -0700153SB_CXX := CCACHE_CPP2=yes $(CCACHE) $(PNACL_BIN_PATH)/pnacl-clang++
154SB_TRANSLATE := $(PNACL_BIN_PATH)/pnacl-translate
Jan Voung839c4ce2014-07-28 15:19:43 -0700155
Jan Voung44c3a802015-03-27 16:29:08 -0700156BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -Werror -fno-rtti \
157 -fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g -pedantic \
158 -Wno-error=unused-parameter $(CXX_EXTRA)
159
160CXXFLAGS := $(LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(CXX_DEFINES) $(HOST_FLAGS) \
Jim Stichnoth6c6adf12015-04-07 14:22:25 -0700161 $(STDLIB_FLAGS)
Jan Voung44c3a802015-03-27 16:29:08 -0700162SB_CXXFLAGS := $(SB_LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(SB_CXX_DEFINES)
163
Jim Stichnothfa4efea2015-01-27 05:06:03 -0800164LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib -Wl,--gc-sections \
Jim Stichnoth6c6adf12015-04-07 14:22:25 -0700165 $(LD_EXTRA) $(STDLIB_FLAGS)
Jan Voung44c3a802015-03-27 16:29:08 -0700166# Not specifying -Wl,--gc-sections but instead doing bitcode linking GC w/ LTO.
167SB_LDFLAGS := $(LINKOPTLEVEL) $(LD_EXTRA)
Derek Schuffbc643132014-05-22 16:39:25 -0700168
Karl Schimpfab06df32014-10-29 14:58:25 -0700169SRCS = \
John Portoaff4ccf2015-06-10 16:35:06 -0700170 IceAssembler.cpp \
171 IceAssemblerX8632.cpp \
Jan Voung44c3a802015-03-27 16:29:08 -0700172 IceBrowserCompileServer.cpp \
Derek Schuffbc643132014-05-22 16:39:25 -0700173 IceCfg.cpp \
174 IceCfgNode.cpp \
Jan Voung44c3a802015-03-27 16:29:08 -0700175 IceClFlags.cpp \
176 IceCompiler.cpp \
177 IceCompileServer.cpp \
Jan Voung08c3bcd2014-12-01 17:55:16 -0800178 IceELFObjectWriter.cpp \
179 IceELFSection.cpp \
Jan Voungec270732015-01-12 17:00:22 -0800180 IceFixups.cpp \
Derek Schuffbc643132014-05-22 16:39:25 -0700181 IceGlobalContext.cpp \
Karl Schimpfe3f64d02014-10-07 10:38:22 -0700182 IceGlobalInits.cpp \
Derek Schuffbc643132014-05-22 16:39:25 -0700183 IceInst.cpp \
Jan Voungb2d50842015-05-12 09:53:50 -0700184 IceInstARM32.cpp \
Derek Schuffbc643132014-05-22 16:39:25 -0700185 IceInstX8632.cpp \
Jan Voung3bd9f1a2014-06-18 10:50:57 -0700186 IceIntrinsics.cpp \
Jim Stichnothd97c7df2014-06-04 11:57:08 -0700187 IceLiveness.cpp \
Derek Schuffbc643132014-05-22 16:39:25 -0700188 IceOperand.cpp \
Jim Stichnothd97c7df2014-06-04 11:57:08 -0700189 IceRegAlloc.cpp \
Jim Stichnothc4554d72014-09-30 16:49:38 -0700190 IceRNG.cpp \
Derek Schuffbc643132014-05-22 16:39:25 -0700191 IceTargetLowering.cpp \
Jan Voungb36ad9b2015-04-21 17:01:49 -0700192 IceTargetLoweringARM32.cpp \
Derek Schuffbc643132014-05-22 16:39:25 -0700193 IceTargetLoweringX8632.cpp \
Jim Stichnoth6da4cef2015-06-11 13:26:33 -0700194 IceTargetLoweringMIPS32.cpp \
Jim Stichnothbbca7542015-02-11 16:08:31 -0800195 IceThreading.cpp \
Jim Stichnothc4554d72014-09-30 16:49:38 -0700196 IceTimerTree.cpp \
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700197 IceTranslator.cpp \
Derek Schuffbc643132014-05-22 16:39:25 -0700198 IceTypes.cpp \
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800199 main.cpp \
Karl Schimpf8d7abae2014-07-07 14:50:30 -0700200 PNaClTranslator.cpp
Derek Schuffbc643132014-05-22 16:39:25 -0700201
Karl Schimpfab06df32014-10-29 14:58:25 -0700202ifndef MINIMAL
Karl Schimpf4019f082014-12-15 13:45:00 -0800203 SRCS += IceConverter.cpp \
204 IceTypeConverter.cpp
Karl Schimpfab06df32014-10-29 14:58:25 -0700205endif
206
Jim Stichnothfddef242014-09-26 18:53:41 -0700207OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS))
Jan Voung44c3a802015-03-27 16:29:08 -0700208SB_OBJS=$(patsubst %.cpp, $(SB_OBJDIR)/%.o, $(SRCS))
Derek Schuffbc643132014-05-22 16:39:25 -0700209
Jan Voung08c3bcd2014-12-01 17:55:16 -0800210UNITTEST_SRCS = \
Karl Schimpf2e7daef2015-01-09 13:04:13 -0800211 BitcodeMunge.cpp \
212 IceELFSectionTest.cpp \
213 IceParseInstsTest.cpp
Jan Voung08c3bcd2014-12-01 17:55:16 -0800214
215UNITTEST_OBJS = $(patsubst %.cpp, $(OBJDIR)/unittest/%.o, $(UNITTEST_SRCS))
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800216UNITTEST_LIB_OBJS = $(filter-out $(OBJDIR)/main.o,$(OBJS))
Jan Voung08c3bcd2014-12-01 17:55:16 -0800217
Derek Schuffbc643132014-05-22 16:39:25 -0700218# Keep all the first target so it's the default.
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800219all: $(OBJDIR)/pnacl-sz make_symlink runtime
Derek Schuffbc643132014-05-22 16:39:25 -0700220
Jan Voung44c3a802015-03-27 16:29:08 -0700221ifdef TSAN
222sb:
223 @echo "Skipping pnacl-sz.*.nexe: TSAN isn't supported under NaCl."
224else
225sb: $(SB_OBJDIR)/pnacl-sz.x86-32.nexe
226endif
227
Karl Schimpf6af63362014-10-29 14:55:00 -0700228# Creates symbolic link so that testing is easier. Also runs
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800229# pnacl-sz to verify that the defines flags have valid values,
Karl Schimpf6af63362014-10-29 14:55:00 -0700230# as well as describe the corresponding build attributes.
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800231make_symlink: $(OBJDIR)/pnacl-sz
232 rm -rf pnacl-sz
233 ln -s $(OBJDIR)/pnacl-sz
Karl Schimpf6af63362014-10-29 14:55:00 -0700234 @echo "Build Attributes:"
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800235 @$(OBJDIR)/pnacl-sz --build-atts
Derek Schuffbc643132014-05-22 16:39:25 -0700236
Jan Voung44c3a802015-03-27 16:29:08 -0700237.PHONY: all make_symlink runtime bloat sb
Jim Stichnothfddef242014-09-26 18:53:41 -0700238
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800239$(OBJDIR)/pnacl-sz: $(OBJS)
Jim Stichnoth33246422014-11-24 14:36:23 -0800240 $(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \
Karl Schimpf8fcefc32014-09-15 12:56:50 -0700241 -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib)
Derek Schuffbc643132014-05-22 16:39:25 -0700242
Jan Voung44c3a802015-03-27 16:29:08 -0700243$(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 Stichnothdd842db2015-01-27 12:53:53 -0800250# TODO(stichnot): Be more precise than "*.h" here and elsewhere.
Jim Stichnothfddef242014-09-26 18:53:41 -0700251$(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def
Derek Schuffbc643132014-05-22 16:39:25 -0700252 $(CXX) -c $(CXXFLAGS) $< -o $@
253
Jan Voung44c3a802015-03-27 16:29:08 -0700254$(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp src/*.h src/*.def
255 $(SB_CXX) -c $(SB_CXXFLAGS) $< -o $@
256
Jan Voung08c3bcd2014-12-01 17:55:16 -0800257$(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS)
Jim Stichnothe7e9b022015-04-21 15:05:22 -0700258 $(CXX) $(GTEST_LIB_PATH) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \
259 -lgtest -lgtest_main -ldl \
Jan Voung08c3bcd2014-12-01 17:55:16 -0800260 -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib)
261
Jim Stichnoth6e861d52015-02-03 14:35:51 -0800262$(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp \
263 unittest/*.h src/*.h src/*.def
Jan Voung08c3bcd2014-12-01 17:55:16 -0800264 $(CXX) -c $(CXXFLAGS) \
265 -Isrc/ \
266 -I$(LLVM_SRC_PATH)/utils/unittest/googletest/include \
Karl Schimpfcbb1d3d2015-06-08 09:25:15 -0700267 -I$(LLVM_SRC_PATH) \
Jan Voung08c3bcd2014-12-01 17:55:16 -0800268 -DGTEST_HAS_RTTI=0 -DGTEST_USE_OWN_TR1_TUPLE \
269 $< -o $@
270
Jim Stichnothfddef242014-09-26 18:53:41 -0700271$(OBJS): | $(OBJDIR)
Jan Voung44c3a802015-03-27 16:29:08 -0700272$(SB_OBJS): | $(SB_OBJDIR)
Derek Schuffbc643132014-05-22 16:39:25 -0700273
Jan Voung08c3bcd2014-12-01 17:55:16 -0800274$(UNITTEST_OBJS): | $(OBJDIR)/unittest
275
Jim Stichnothfddef242014-09-26 18:53:41 -0700276$(OBJDIR):
Derek Schuffbc643132014-05-22 16:39:25 -0700277 @mkdir -p $@
Jan Voung44c3a802015-03-27 16:29:08 -0700278$(SB_OBJDIR):
279 @mkdir -p $@
Derek Schuffbc643132014-05-22 16:39:25 -0700280
Jan Voung08c3bcd2014-12-01 17:55:16 -0800281$(OBJDIR)/unittest: $(OBJDIR)
282 @mkdir -p $@
283
John Portof8b4cc82015-06-09 18:06:19 -0700284RT_SRC := runtime/szrt.c runtime/szrt_ll.ll runtime/szrt_profiler.c
Jan Voung050deaa2015-06-12 15:12:05 -0700285RT_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 Stichnoth9738a9e2015-02-23 16:39:06 -0800287
288runtime: $(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 Portof8b4cc82015-06-09 18:06:19 -0700294runtime.is.built: $(RT_SRC) pydir/build-runtime.py
Jim Stichnoth9738a9e2015-02-23 16:39:06 -0800295 @echo ================ Building Subzero runtime ================
Jan Voung68a06332015-03-05 14:33:38 -0800296 ./pydir/build-runtime.py -v --pnacl-root $(PNACL_TOOLCHAIN_ROOT)
Jim Stichnoth9738a9e2015-02-23 16:39:06 -0800297
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800298check-lit: $(OBJDIR)/pnacl-sz make_symlink
Jim Stichnoth0a9e1262015-04-21 09:59:21 -0700299 PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
Derek Schuffbc643132014-05-22 16:39:25 -0700300 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv tests_lit
Jim Stichnothac9c9432014-08-26 14:07:13 -0700301
Karl Schimpfab06df32014-10-29 14:58:25 -0700302ifdef MINIMAL
Jim Stichnothc9258222015-03-13 11:59:49 -0700303check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime
304 @echo "Crosstests disabled, minimal build"
Karl Schimpfab06df32014-10-29 14:58:25 -0700305else
Jim Stichnothc9258222015-03-13 11:59:49 -0700306check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime
Jim Stichnothdc7c5972015-03-10 11:17:15 -0700307 # 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 Voung8e32fed2015-06-17 10:16:23 -0700310 --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 Stichnoth0a9e1262015-04-21 09:59:21 -0700314 PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
Jim Stichnothdc7c5972015-03-10 11:17:15 -0700315 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv crosstest/Output
Karl Schimpfab06df32014-10-29 14:58:25 -0700316endif
Derek Schuffbc643132014-05-22 16:39:25 -0700317
Jim Stichnothc9258222015-03-13 11:59:49 -0700318check-unit: $(OBJDIR)/run_unittests
319 $(OBJDIR)/run_unittests
320
321check: check-lit check-unit check-xtest
322
Jim Stichnothdd842db2015-01-27 12:53:53 -0800323FORMAT_BLACKLIST =
324# Add one of the following lines for each source file to ignore.
325FORMAT_BLACKLIST += ! -name IceParseInstsTest.cpp
Derek Schuffbc643132014-05-22 16:39:25 -0700326format:
Jim Stichnoth0a9e1262015-04-21 09:59:21 -0700327 $(CLANG_FORMAT_PATH)/clang-format -style=LLVM -i \
Jim Stichnothdd842db2015-01-27 12:53:53 -0800328 `find . -regex '.*\.\(c\|h\|cpp\)' $(FORMAT_BLACKLIST)`
Jim Stichnoth240e0f82014-07-09 16:53:40 -0700329
Jim Stichnoth240e0f82014-07-09 16:53:40 -0700330format-diff:
Jim Stichnoth206833c2014-08-07 10:58:05 -0700331 git diff -U0 `git merge-base HEAD master` | \
Jim Stichnoth0a9e1262015-04-21 09:59:21 -0700332 PATH=$(PNACL_BIN_PATH):$(PATH) \
Jim Stichnothdd842db2015-01-27 12:53:53 -0800333 $(LLVM_SRC_PATH)/../clang/tools/clang-format/clang-format-diff.py \
334 -p1 -style=LLVM -i
Derek Schuffbc643132014-05-22 16:39:25 -0700335
Jim Stichnoth307e3262015-02-12 16:10:37 -0800336bloat: make_symlink
Jim Stichnothfa0cfa52015-02-26 09:42:36 -0800337 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 Stichnoth307e3262015-02-12 16:10:37 -0800340
Derek Schuffbc643132014-05-22 16:39:25 -0700341clean:
Jan Voung44c3a802015-03-27 16:29:08 -0700342 rm -rf pnacl-sz *.o $(OBJDIR) $(SB_OBJDIR) build/pnacl-sz.bloat.json
Karl Schimpfb262c5e2014-10-27 14:41:57 -0700343
344clean-all: clean
345 rm -rf build/