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:
5 # make LLVM_SRC_PATH=<path> LIBCXX_INSTALL_PATH=<path> CLANG_PATH=<path> \
6 # PNACL_BIN_PATH=<path> ...
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
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)
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()")
25 # TOOLCHAIN_ROOT is the location of NaCl/PNaCl toolchains and other
27 TOOLCHAIN_ROOT ?= $(shell readlink -e $(NACL_ROOT)/toolchain/linux_x86)
29 # PNACL_TOOLCHAIN_ROOT is the location of the PNaCl toolchain.
30 # This is used as the default root for finding binutils, libcxx, etc.
31 PNACL_TOOLCHAIN_ROOT ?= $(shell readlink -e $(TOOLCHAIN_ROOT)/pnacl_newlib_raw)
33 # The location of PNaCl tools (e.g., binutils objdump, pnacl-clang++, etc.).
34 PNACL_BIN_PATH ?= $(shell readlink -e $(PNACL_TOOLCHAIN_ROOT)/bin)
36 # Allow tests to be overridden, e.g.:
37 # make -f Makefile.standalone check-lit \
38 # CHECK_LIT_TESTS="tests_lit/llvm2ice_tests/{alloc,arith}.ll"
39 # make -f Makefile.standalone check-xtest \
40 # CHECK_XTEST_TESTS=crosstest/Output/simple_loop_x8632_native_O2_sse2.xtest
41 CHECK_LIT_TESTS ?= tests_lit
42 CHECK_XTEST_TESTS ?= crosstest/Output
44 # Hack to auto-detect autoconf versus cmake build of LLVM. If the LLVM tools
45 # were dynamically linked with something like libLLVM-3.7svn.so, it is an
46 # autoconf build, otherwise it is a cmake build. AUTOCONF is set to 0 for
47 # cmake, nonzero for autoconf.
48 AUTOCONF ?= $(shell ldd $(PNACL_BIN_PATH)/opt | grep -c libLLVM-)
50 # CLANG_PATH is the location of the clang compiler to use for building
52 CLANG_PATH ?= $(shell readlink -e \
53 $(NACL_ROOT)/../third_party/llvm-build/Release+Asserts/bin)
55 # LIBCXX_INSTALL_PATH is the directory where libc++ is located. It should
56 # contain header files and corresponding libraries. This is used for
57 # building the host binaries in conjuction with clang.
58 LIBCXX_INSTALL_PATH ?= $(PNACL_TOOLCHAIN_ROOT)
59 STDLIB_FLAGS := -stdlib=libc++ -I$(LIBCXX_INSTALL_PATH)/include/c++/v1
62 ifeq ($(HOST_ARCH),x86_64)
65 ifeq ($(HOST_ARCH),x86)
75 OBJDIR = build/Release
76 OPTLEVEL = -O2 -ffunction-sections -fdata-sections
80 # The list of CXX defines that are dependent on build parameters.
88 OBJDIR := $(OBJDIR)+Min
89 BASE_CXX_DEFINES += -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \
90 -DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_TIMERS=0 -DALLOW_MINIMAL_BUILD=1
92 BASE_CXX_DEFINES += -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \
93 -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_TIMERS=1 -DALLOW_MINIMAL_BUILD=0
97 OBJDIR := $(OBJDIR)+NoDump
98 BASE_CXX_DEFINES += -DALLOW_DUMP=0
100 BASE_CXX_DEFINES += -DALLOW_DUMP=1
103 # Restrict to a single supported target. Current options:
109 OBJDIR := $(OBJDIR)+T_$(SZTARGET)
110 BASE_CXX_DEFINES += -DSZTARGET=$(SZTARGET)
113 CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=0
116 ASSERTIONS = -DNDEBUG
119 OBJDIR := $(OBJDIR)+Asserts
123 OBJDIR := $(OBJDIR)+UBSan
124 CXX_EXTRA += -fsanitize=undefined -fno-sanitize=vptr \
125 -fno-sanitize=nonnull-attribute
126 LD_EXTRA += -fsanitize=undefined
130 OBJDIR := $(OBJDIR)+UBSan_Trap
131 CXX_EXTRA += -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error \
132 -fno-sanitize=vptr -fno-sanitize=nonnull-attribute
133 LD_EXTRA += -fsanitize=undefined-trap
137 OBJDIR := $(OBJDIR)+TSan
138 CXX_EXTRA += -fsanitize=thread
139 LD_EXTRA += -fsanitize=thread
143 OBJDIR := $(OBJDIR)+ASan
144 CXX_EXTRA += -fsanitize=address
145 LD_EXTRA += -fsanitize=address
149 # TODO(ascull): this has an as yet undiagnosed uninitialized memory access
150 OBJDIR := $(OBJDIR)+MSan
151 CXX_EXTRA += -fsanitize=memory
152 LD_EXTRA += -fsanitize=memory
156 FORCEASM_FLAG = --filetype=asm
157 # With --filetype=asm and --sandbox, the llvm-mc assembler emits the lock and
158 # 16-bit prefixes in the "wrong" order, causing the validator to reject the
159 # resulting nexe. So we just disable those tests for now.
160 FORCEASM_XTEST_EXCLUDES = -e x8632,sandbox,test_sync_atomic
161 FORCEASM_LIT_PARAM = --param=FORCEASM
162 # x86 sandboxing lit tests are disabled because filetype=asm does not
163 # handle bundle_lock pad-to-end correctly.
164 # TODO(jpp): fix this.
165 FORCEASM_LIT_TEST_EXCLUDES = --filter='^(?!.*/x86/sandboxing.ll).*'
168 FORCEASM_XTEST_EXCLUDES =
170 FORCEASM_LIT_TEST_EXCLUDES =
173 ifdef LINUX_MALLOC_PROFILE
174 OBJDIR := $(OBJDIR)+MalProf
175 CXX_EXTRA += -DALLOW_LINUX_MALLOC_PROFILE=1
176 LD_EXTRA += -Wl,--export-dynamic
179 SB_OBJDIR := $(OBJDIR)+Sandboxed
180 SBB_OBJDIR := $(OBJDIR)+SandboxedBrowser
182 V8_DIR = $(NACL_ROOT)/../v8
183 V8_CXXFLAGS := -I$(V8_DIR)
185 $(info -----------------------------------------------)
186 $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH))
187 $(info Using SB_LLVM_PATH = $(SB_LLVM_PATH))
188 $(info Using NACL_ROOT = $(NACL_ROOT))
189 $(info Using TOOLCHAIN_ROOT = $(TOOLCHAIN_ROOT))
190 $(info Using PNACL_TOOLCHAIN_ROOT = $(PNACL_TOOLCHAIN_ROOT))
191 $(info Using PNACL_BIN_PATH = $(PNACL_BIN_PATH))
192 $(info Using CLANG_PATH = $(CLANG_PATH))
193 $(info Using LIBCXX_INSTALL_PATH = $(LIBCXX_INSTALL_PATH))
194 $(info Using HOST_ARCH = $(HOST_ARCH))
195 $(info -----------------------------------------------)
197 LLVM_CXXFLAGS := `$(PNACL_BIN_PATH)/llvm-config --cxxflags`
198 SB_LLVM_CXXFLAGS := $(LLVM_CXXFLAGS)
200 # Listing specific libraries that are needed for pnacl-sz
201 # and the unittests, since we build "tools-only" for the
202 # sandboxed_translators (which doesn't include every library
203 # listed by llvm-config).
205 LLVM_LIBS_LIST := -lLLVMIRReader -lLLVMBitReader -lLLVMNaClBitTestUtils \
206 -lLLVMNaClBitReader -lLLVMNaClBitAnalysis -lLLVMNaClBitWriter \
207 -lLLVMAsmParser -lLLVMNaClAnalysis -lLLVMCore -lLLVMSupport
209 ifeq ($(AUTOCONF), 0)
211 LLVM_LIBS := $(LLVM_LIBS_LIST)
212 # For the cmake build, the gtest libs end up in the same place as the LLVM
213 # libs, so no "-L..." arg is needed.
215 CLANG_FORMAT_PATH ?= $(PNACL_BIN_PATH)
217 # LLVM autoconf build
218 LLVM_LIBS := -lLLVM-3.7svn
219 GTEST_LIB_PATH ?= -L../../out/llvm_x86_64_linux_work/Release+Asserts/lib
220 CLANG_FORMAT_PATH ?= ../../out/llvm_x86_64_linux_work/Release+Asserts/bin
223 LLVM_LDFLAGS := $(LLVM_LIBS) \
224 `$(PNACL_BIN_PATH)/llvm-config --ldflags` \
225 `$(PNACL_BIN_PATH)/llvm-config --system-libs`
226 SB_LLVM_LDFLAGS := -Wl,--start-group $(LLVM_LIBS_LIST) -Wl,--end-group \
227 -L$(SB_LLVM_PATH)/lib
229 CCACHE := `command -v ccache`
230 CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++
231 SB_CXX := CCACHE_CPP2=yes $(CCACHE) $(PNACL_BIN_PATH)/pnacl-clang++
232 SB_TRANSLATE := $(PNACL_BIN_PATH)/pnacl-translate
233 SB_FINALIZE := $(PNACL_BIN_PATH)/pnacl-finalize --no-strip-syms
235 # Extra warnings that LLVM's build system adds in addition to -Wall.
236 LLVM_EXTRA_WARNINGS := -Wcovered-switch-default
238 # Use g++ to compile, to check for errors/warnings that clang++ might have
239 # missed. It's unlikely to link, unless LLVM was also built with g++, so the
240 # compile_only target should be used. Note: This ifdef section is deliberately
241 # placed here instead of with the other ifdef sections, so that its redefinition
242 # of CXX/STDLIB_FLAGS/LLVM_EXTRA_WARNINGS follows their normal definitions.
244 CXX := CCACHE_CPP2=yes $(CCACHE) g++
246 LLVM_EXTRA_WARNINGS := \
250 -Wno-maybe-uninitialized \
251 -Wno-missing-field-initializers \
252 -Wno-unused-parameter \
254 OBJDIR := $(OBJDIR)+Gplusplus
257 BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -fno-rtti \
258 -fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g -pedantic \
259 $(LLVM_EXTRA_WARNINGS) $(CXX_EXTRA) -MP -MD -Werror
262 BASE_CXXFLAGS := $(BASE_CXXFLAGS) $(V8_CXXFLAGS) -DALLOW_WASM=1
263 OBJDIR := $(OBJDIR)+Wasm
265 BASE_CXXFLAGS := $(BASE_CXXFLAGS) -DALLOW_WASM=0
268 # TODO(stichnot,jpp): Restructure static fields in template classes to avoid
269 # needing -Wno-undefined-var-template .
270 CXXFLAGS := $(LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(CXX_DEFINES) $(HOST_FLAGS) \
271 $(STDLIB_FLAGS) -Wno-undefined-var-template
272 SB_CXXFLAGS := $(SB_LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(BASE_CXX_DEFINES) \
273 -Wno-unknown-pragmas -I$(NACL_ROOT) -I$(NACL_ROOT)/..
275 LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib -Wl,--gc-sections \
276 $(LD_EXTRA) $(STDLIB_FLAGS)
277 # Not specifying -Wl,--gc-sections but instead doing bitcode linking GC w/ LTO.
278 SB_LDFLAGS := $(LINKOPTLEVEL) $(LD_EXTRA)
280 # List the target-specific source files first, which generally take longer to
281 # compile, in the hope of improving parallel build time.
283 IceAssemblerARM32.cpp \
288 IceTargetLowering.cpp \
289 IceTargetLoweringARM32.cpp \
290 IceTargetLoweringMIPS32.cpp \
291 IceTargetLoweringX86.cpp \
292 IceTargetLoweringX8632.cpp \
293 IceTargetLoweringX8664.cpp \
295 IceBrowserCompileServer.cpp \
300 IceCompileServer.cpp \
301 IceELFObjectWriter.cpp \
304 IceGlobalContext.cpp \
309 IceLoopAnalyzer.cpp \
316 IceSwitchLowering.cpp \
321 LinuxMallocProfiling.cpp \
336 OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS))
337 SB_OBJS=$(patsubst %.cpp, $(SB_OBJDIR)/%.o, $(SRCS))
338 SBB_OBJS=$(patsubst %.cpp, $(SBB_OBJDIR)/%.o, $(SRCS))
342 IceELFSectionTest.cpp \
343 IceParseInstsTest.cpp
345 # The X86 assembler tests take too long to compile. Given how infrequently the
346 # assembler will change, we disable them.
349 $(error Run check-unit with DEBUG=1 lest your machine perish)
351 UNITTEST_SRCS += AssemblerX8632/LowLevel.cpp \
352 AssemblerX8632/DataMov.cpp \
353 AssemblerX8632/Locked.cpp \
354 AssemblerX8632/GPRArith.cpp \
355 AssemblerX8632/XmmArith.cpp \
356 AssemblerX8632/ControlFlow.cpp \
357 AssemblerX8632/Other.cpp \
358 AssemblerX8632/X87.cpp \
359 AssemblerX8664/LowLevel.cpp \
360 AssemblerX8664/DataMov.cpp \
361 AssemblerX8664/Locked.cpp \
362 AssemblerX8664/GPRArith.cpp \
363 AssemblerX8664/XmmArith.cpp \
364 AssemblerX8664/ControlFlow.cpp \
365 AssemblerX8664/Other.cpp
368 UNITTEST_OBJS = $(patsubst %.cpp, $(OBJDIR)/unittest/%.o, $(UNITTEST_SRCS))
369 UNITTEST_LIB_OBJS = $(filter-out $(OBJDIR)/main.o,$(OBJS))
371 NEXES = $(SB_OBJDIR)/pnacl-sz.x8632.nexe \
372 $(SB_OBJDIR)/pnacl-sz.x8664.nexe \
373 $(SBB_OBJDIR)/pnacl_public_x86_32_pnacl_sz_nexe \
374 $(SBB_OBJDIR)/pnacl_public_x86_64_pnacl_sz_nexe
375 NEXES_LITE = $(SB_OBJDIR)/pnacl-sz.x8664.nexe
377 # Keep all the first target so it's the default.
378 all: $(OBJDIR)/pnacl-sz make_symlink runtime
382 @echo "Skipping pnacl-sz.*.nexe: TSAN isn't supported under NaCl."
384 sb: $(NEXES) sb_make_symlink exists-sbtc
385 sb-lite: $(NEXES_LITE) exists-sbtc
388 # SHOW_BUILD_ATTS is an executable that is run to show what build
389 # attributes were used to build pnacl-sz.
390 SHOW_BUILD_ATTS = $(OBJDIR)/pnacl-sz --build-atts
392 # Creates symbolic link so that testing is easier. Also runs
393 # pnacl-sz to verify that the defines flags have valid values,
394 # as well as describe the corresponding build attributes.
395 make_symlink: $(OBJDIR)/pnacl-sz
397 ln -s $(OBJDIR)/pnacl-sz
398 @echo "Build Attributes:"
401 sb_make_symlink: $(NEXES)
402 $(foreach nexe,$(NEXES),rm -rf $(notdir $(nexe)); ln -s $(nexe);)
404 %.pexe : %.nonfinal.pexe
405 $(SB_FINALIZE) -o $@ $<
407 .PHONY: all compile_only make_symlink runtime bloat sb docs help \
408 help-check-lit help-check-xtest exists-nonsfi-x8632 \
409 exists-nonsfi-arm32 exists-sbtc exists-spec
411 compile_only: $(OBJS)
413 V8_LIBDIR=$(V8_DIR)/out/native/lib.target
417 $(V8_LIBDIR)/libv8.so \
418 $(V8_LIBDIR)/libicuuc.so \
419 $(V8_LIBDIR)/libicui18n.so
422 $(OBJDIR)/pnacl-sz: $(OBJS)
423 $(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \
424 -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) $(V8_LIBS)
426 $(SB_OBJDIR)/pnacl-sz.nonfinal.pexe: $(SB_OBJS)
427 $(SB_CXX) $(SB_LDFLAGS) -o $@ $^ $(SB_LLVM_LDFLAGS)
429 $(SBB_OBJDIR)/pnacl-sz.nonfinal.pexe: $(SBB_OBJS)
430 $(SB_CXX) $(SB_LDFLAGS) -o $@ $^ $(SB_LLVM_LDFLAGS) \
431 --pnacl-disable-abi-check
433 $(SB_OBJDIR)/pnacl-sz.x8632.nexe: $(SB_OBJDIR)/pnacl-sz.pexe
434 $(SB_TRANSLATE) -arch x86-32 $^ -o $@
436 $(SB_OBJDIR)/pnacl-sz.x8664.nexe: $(SB_OBJDIR)/pnacl-sz.pexe
437 $(SB_TRANSLATE) -arch x86-64 $^ -o $@
439 $(SBB_OBJDIR)/pnacl_public_x86_32_pnacl_sz_nexe: $(SBB_OBJDIR)/pnacl-sz.pexe
440 $(SB_TRANSLATE) -arch x86-32 $^ -o $@
442 $(SBB_OBJDIR)/pnacl_public_x86_64_pnacl_sz_nexe: $(SBB_OBJDIR)/pnacl-sz.pexe
443 $(SB_TRANSLATE) -arch x86-64 $^ -o $@
445 src/IceRegistersARM32.def: pydir/gen_arm32_reg_tables.py
448 -include $(foreach dep,$(SRCS:.cpp=.d),$(OBJDIR)/$(dep))
449 $(OBJS): $(OBJDIR)/%.o: src/%.cpp
450 $(CXX) -c $(CXXFLAGS) $< -o $@
452 -include $(foreach dep,$(SRCS:.cpp=.d),$(SB_OBJDIR)/$(dep))
453 $(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp
454 $(SB_CXX) -c $(SB_CXXFLAGS) -DPNACL_BROWSER_TRANSLATOR=0 $< -o $@
456 -include $(foreach dep,$(SRCS:.cpp=.d),$(SBB_OBJDIR)/$(dep))
457 $(SBB_OBJS): $(SBB_OBJDIR)/%.o: src/%.cpp
458 $(SB_CXX) -c $(SB_CXXFLAGS) -DPNACL_BROWSER_TRANSLATOR=1 $< -o $@
460 $(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS)
461 $(CXX) $(GTEST_LIB_PATH) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \
462 -lgtest -lgtest_main -ldl \
463 -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib)
465 -include $(foreach dep,$(UNITTEST_SRCS:.cpp=.d),$(OBJDIR)/unittest/$(dep))
466 $(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp
467 $(CXX) -c $(CXXFLAGS) \
470 -I$(LLVM_SRC_PATH)/utils/unittest/googletest/include \
472 -DGTEST_HAS_RTTI=0 -DGTEST_USE_OWN_TR1_TUPLE \
473 -Wno-expansion-to-defined \
477 $(SB_OBJS): | $(SB_OBJDIR)
478 $(SBB_OBJS): | $(SBB_OBJDIR)
480 $(UNITTEST_OBJS): | $(OBJDIR)/unittest $(OBJDIR)/unittest/AssemblerX8632 \
481 $(OBJDIR)/unittest/AssemblerX8664
490 $(OBJDIR)/unittest: $(OBJDIR)
493 $(OBJDIR)/unittest/AssemblerX8632: $(OBJDIR)/unittest
495 $(OBJDIR)/unittest/AssemblerX8664: $(OBJDIR)/unittest
498 RT_SRC := runtime/szrt.c runtime/szrt_ll.ll runtime/szrt_profiler.c \
499 runtime/szrt_asm_x8632.s runtime/szrt_asm_x8664.s \
500 runtime/szrt_asm_arm32.s
501 RT_OBJ := build/runtime/szrt_native_x8632.o build/runtime/szrt_sb_x8632.o \
502 build/runtime/szrt_nonsfi_x8632.o \
503 build/runtime/szrt_native_x8664.o build/runtime/szrt_sb_x8664.o \
504 build/runtime/szrt_nonsfi_x8664.o \
505 build/runtime/szrt_native_arm32.o build/runtime/szrt_sb_arm32.o \
506 build/runtime/szrt_nonsfi_arm32.o
510 # Use runtime.is.built so that build-runtime.py is invoked only once
511 # even in a parallel build.
512 .INTERMEDIATE: runtime.is.built
513 $(RT_OBJ): runtime.is.built
514 runtime.is.built: $(RT_SRC) pydir/build-runtime.py
515 @echo ================ Building Subzero runtime ================
516 ./pydir/build-runtime.py -v --pnacl-root $(PNACL_TOOLCHAIN_ROOT)
518 check-lit: $(OBJDIR)/pnacl-sz make_symlink
519 PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
520 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv $(CHECK_LIT_TESTS) \
521 $(FORCEASM_LIT_TEST_EXCLUDES) $(FORCEASM_LIT_PARAM)
524 check-xtest check-xtest-lite: $(OBJDIR)/pnacl-sz make_symlink runtime
525 @echo "Crosstests disabled, minimal build"
527 check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime \
528 exists-nonsfi-x8632 exists-nonsfi-arm32
529 # Do all native/sse2 tests, but only test_vector_ops for native/sse4.1.
530 # For (slow) sandboxed tests, limit to Om1/sse4.1.
531 # run.py (used to run the sandboxed xtests) does not support
532 # specifying -cpu cortex-a15 to qemu, hence we disable the
534 ./pydir/crosstest_generator.py -v --lit \
535 --toolchain-root $(TOOLCHAIN_ROOT) \
537 $(FORCEASM_XTEST_EXCLUDES) \
538 -i x8632,native,sse2 \
539 -i x8632,native,sse4.1,test_vector_ops \
540 -i x8632,sandbox,sse4.1,Om1 \
541 -i x8632,nonsfi,sse2,O2 \
542 -i x8664,native,sse2 \
543 -i x8664,native,sse4.1,test_vector_ops \
544 -i x8664,sandbox,sse4.1,Om1 \
546 -e arm32,sandbox,hwdiv-arm
547 PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
548 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv $(CHECK_XTEST_TESTS)
549 check-xtest-lite: $(OBJDIR)/pnacl-sz make_symlink runtime \
550 exists-nonsfi-x8632 exists-nonsfi-arm32
551 # Do all native/sse2/neon tests, which are relatively fast.
552 # Limit to test_global+mem_intrin for sandbox+nonsfi because sandbox and
553 # nonsfi builds are slow, and test_global and mem_intrin are the most
554 # common sources of problems.
555 ./pydir/crosstest_generator.py -v --lit \
556 --toolchain-root $(TOOLCHAIN_ROOT) \
558 $(FORCEASM_XTEST_EXCLUDES) \
559 -i x8632,native,sse2,O2 \
560 -i x8664,native,sse2,O2 \
561 -i arm32,native,neon,O2 \
562 -i x8632,sse2,O2,test_global \
563 -i x8632,sse2,O2,mem_intrin \
564 -i x8664,sse2,O2,test_global \
565 -i x8664,sse2,O2,mem_intrin \
566 -i arm32,neon,O2,test_global \
567 -i arm32,neon,O2,mem_intrin \
569 PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
570 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv $(CHECK_XTEST_TESTS)
573 check-unit: $(OBJDIR)/run_unittests
574 $(OBJDIR)/run_unittests
576 # List the spec2k components in roughly reverse order of runtime, to help with
577 # parallel execution speed.
578 ALLSPEC := 253.perlbmk 177.mesa 188.ammp 256.bzip2 164.gzip 179.art 183.equake \
579 175.vpr 176.gcc 181.mcf 186.crafty 197.parser 254.gap 255.vortex \
584 ifeq ($(TARGET),x8632)
586 SETUP=SetupGccX8632Opt
587 SPEC := --filetype=obj
589 ifeq ($(TARGET),x8664)
591 SETUP=SetupGccX8664Opt
592 SPEC := --filetype=obj
594 ifeq ($(TARGET),arm32)
597 SPEC := --filetype=obj
601 %.spec2k: % $(OBJDIR)/pnacl-sz make_symlink runtime
602 ./pydir/szbuild_spec2k.py -v \
603 $(SPECFLAGS) --target=$(TARGETFLAG) $(SPEC) $< $(SPECRUN)
605 check-spec: exists-spec $(ALLSPEC:=.spec2k)
607 check: check-lit check-unit check-xtest
609 NONSFI_LOADER_X8632 = \
610 $(NACL_ROOT)/scons-out/opt-linux-x86-32/obj/src/nonsfi/loader/nonsfi_loader
611 NONSFI_LOADER_ARM32 = \
612 $(NACL_ROOT)/scons-out/opt-linux-arm/obj/src/nonsfi/loader/nonsfi_loader
613 SBTC_LIBFILE = $(SB_LLVM_PATH)/lib/libLLVMSupport.a
614 SPEC_SAMPLE_PEXE = $(NACL_ROOT)/tests/spec2k/176.gcc/gcc.opt.stripped.pexe
617 @if [ ! -f $(NONSFI_LOADER_X8632) ] ; then \
618 echo "Missing file $(NONSFI_LOADER_X8632)"; \
619 echo "Consider running './scons nonsfi_loader'" \
620 "in the native_client directory."; \
625 @if [ ! -f $(NONSFI_LOADER_ARM32) ] ; then \
626 echo "Missing file $(NONSFI_LOADER_ARM32)"; \
627 echo "Consider running './scons platform=arm nonsfi_loader'" \
628 "in the native_client directory."; \
633 @if [ ! -f $(SBTC_LIBFILE) ] ; then \
634 echo "Missing file $(SBTC_LIBFILE)"; \
635 echo "Consider running 'toolchain_build_pnacl.py --build-sbtc'."; \
640 @if [ ! -f $(SPEC_SAMPLE_PEXE) ] ; then \
641 echo "Missing file $(SPEC_SAMPLE_PEXE)"; \
642 echo "Consider running" \
643 "'./run_all.sh BuildBenchmarks 0 SetupPnaclX8632Opt'" \
644 "in the native_client/tests/spec2k directory."; \
648 check-presubmit presubmit: exists-nonsfi-x8632 exists-nonsfi-arm32 \
649 exists-sbtc exists-spec
650 # Make sure clang-format gets run.
651 +make -f Makefile.standalone format
652 # Verify MINIMAL build, plus proper usage of REQUIRES in lit tests.
653 +make -f Makefile.standalone \
655 # Check that there are no g++ build errors or warnings.
656 +make -f Makefile.standalone \
657 GPLUSPLUS=1 compile_only
658 # Check the x86 assembler unit tests.
659 +make -f Makefile.standalone \
660 DEBUG=1 CHECK_X86_ASM=1 check-unit sb
661 # Run lit tests, cross tests, unit tests, and spec2k/x86-32.
662 +make -f Makefile.standalone \
665 +make -f Makefile.standalone \
666 TARGET=x8664 check-spec
667 # Run spec2k/x86-64 with sandboxing.
668 +make -f Makefile.standalone \
669 SPECFLAGS='-O2 --sandbox' TARGET=x8664 check-spec
670 # Build spec2k under -Om1/x86-32, to check for liveness errors.
671 +make -f Makefile.standalone \
672 SPECFLAGS='-Om1' SPECRUN= check-spec
673 # Build spec2k under -Om1/x86-64, to check for liveness errors.
674 +make -f Makefile.standalone \
675 SPECFLAGS='-Om1' TARGET=x8664 SPECRUN= check-spec
676 # Run spec2k for x86-32 without advanced phi lowering.
677 +make -f Makefile.standalone \
678 SPECFLAGS='-O2 --sz=--phi-edge-split=0' check-spec
679 # Run spec2k for x86-64 without advanced phi lowering.
680 +make -f Makefile.standalone \
681 SPECFLAGS='-O2 --sz=--phi-edge-split=0' TARGET=x8664 check-spec
682 # Run cross tests and lit tests to validate filetype=asm output.
683 +make -f Makefile.standalone \
684 FORCEASM=1 check-xtest check-lit
685 # Build spec2k for arm32.
686 +make -f Makefile.standalone \
687 TARGET=arm32 SPECRUN= check-spec
688 # Build spec2k under -Om1/arm32.
689 +make -f Makefile.standalone \
690 TARGET=arm32 SPECFLAGS='-Om1' SPECRUN= check-spec
691 # Run a few spec2k tests for arm32 using qemu. Keep the list sorted in
692 # roughly reverse order of runtime.
693 +make -f Makefile.standalone \
694 TARGET=arm32 ALLSPEC='252.eon 254.gap 176.gcc 181.mcf' check-spec
695 # Provide validation of user awesomeness!
698 presubmit-lite: exists-nonsfi-x8632 exists-nonsfi-arm32 \
699 exists-sbtc exists-spec
700 # Make sure clang-format gets run.
701 +make -f Makefile.standalone format
702 # Verify MINIMAL build, plus proper usage of REQUIRES in lit tests.
703 +make -f Makefile.standalone \
704 MINIMAL=1 check sb-lite
705 # Check that there are no g++ build errors or warnings.
706 +make -f Makefile.standalone \
707 GPLUSPLUS=1 compile_only
708 # Run lit tests, cross tests, unit tests, and spec2k/x86-32.
709 +make -f Makefile.standalone \
710 check-lit check-unit check-spec
711 +make -f Makefile.standalone \
714 +make -f Makefile.standalone \
715 TARGET=x8664 check-spec
716 # Build spec2k under -Om1/x86-32, to check for liveness errors.
717 +make -f Makefile.standalone \
718 SPECFLAGS='-Om1' SPECRUN= check-spec
719 # Build spec2k under -Om1/x86-64, to check for liveness errors.
720 +make -f Makefile.standalone \
721 SPECFLAGS='-Om1' TARGET=x8664 SPECRUN= check-spec
722 # Run cross tests and lit tests to validate filetype=asm output.
723 +make -f Makefile.standalone \
725 +make -f Makefile.standalone \
726 FORCEASM=1 check-xtest-lite
727 # Build spec2k under -Om1/arm32.
728 +make -f Makefile.standalone \
729 TARGET=arm32 SPECFLAGS='-Om1' SPECRUN= check-spec
730 # Run a few spec2k tests for arm32 using qemu. Keep the list sorted in
731 # roughly reverse order of runtime.
732 +make -f Makefile.standalone \
733 TARGET=arm32 ALLSPEC='254.gap 176.gcc 181.mcf' check-spec
734 # Provide validation of user awesomeness!
738 # Add one of the following lines for each source file to ignore.
739 FORMAT_BLACKLIST += ! -name IceParseInstsTest.cpp
740 FORMAT_BLACKLIST += ! -name IceParseTypesTest.cpp
741 FORMAT_BLACKLIST += ! -name assembler_arm.h
742 FORMAT_BLACKLIST += ! -name assembler_arm.cc
743 FORMAT_BLACKLIST += ! -path "./wasm-install/*"
745 $(CLANG_FORMAT_PATH)/clang-format -style=LLVM -i \
746 `find . -regex '.*\.\(c\|h\|cpp\)' $(FORMAT_BLACKLIST)`
749 git diff -U0 `git merge-base HEAD master` | \
750 PATH=$(PNACL_BIN_PATH):$(PATH) \
751 $(LLVM_SRC_PATH)/../clang/tools/clang-format/clang-format-diff.py \
755 nm -C -S -l pnacl-sz | \
756 bloat/bloat.py --nm-output=/dev/stdin syms > build/pnacl-sz.bloat.json
757 @echo See Subzero size breakdown in bloat/pnacl-sz.bloat.html
759 bloat-sb: sb_make_symlink
760 $(foreach nexe,$(NEXES),nm -C -S -l $(nexe) | bloat/bloat.py \
761 --nm-output=/dev/stdin syms > build/$(notdir $(nexe)).bloat.json;)
762 @echo "See Subzero size breakdown in:"
763 @$(foreach nexe,$(NEXES),echo " bloat/$(notdir $(nexe)).bloat.html";)
766 make -C docs -f Makefile.standalone
769 @cat Makefile.standalone-help/help.txt
772 @cat Makefile.standalone-help/check-lit.txt
775 @cat Makefile.standalone-help/check-xtest.txt
778 rm -rf pnacl-sz *.o $(foreach nexe,$(NEXES),$(notdir $(nexe))) \
779 $(OBJDIR) $(SB_OBJDIR) $(SBB_OBJDIR) build/*.bloat.json
782 rm -rf build/ crosstest/Output/