forked from google/swiftshader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.standalone
861 lines (756 loc) · 28.7 KB
/
Makefile.standalone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
# The following variables will likely need to be modified, depending on where
# and how you built LLVM & Clang. They can be overridden in a command-line
# invocation of make, like:
#
# make LLVM_SRC_PATH=<path> LIBCXX_INSTALL_PATH=<path> CLANG_PATH=<path> \
# PNACL_BIN_PATH=<path> ...
#
# LLVM_SRC_PATH is the path to the root of the checked out source code. This
# directory should contain the configure script, the include/ and lib/
# directories of LLVM, Clang in tools/clang/, etc.
# Alternatively, if you're building vs. a binary download of LLVM, then
# LLVM_SRC_PATH can point to the main untarred directory.
LLVM_SRC_PATH ?= ../llvm
# The x86-32-specific sandboxed translator directory.
# It holds sandboxed versions of libraries and binaries.
SB_LLVM_PATH ?= $(shell readlink -e \
../../out/sandboxed_translators_work/translator-i686/llvm-sb/Release)
# NACL_ROOT is the root of the native client repository.
NACL_ROOT ?= $(shell python -c "import sys; sys.path.insert(0, 'pydir'); \
import utils; print utils.FindBaseNaCl()")
# TOOLCHAIN_ROOT is the location of NaCl/PNaCl toolchains and other
# tools like qemu.
TOOLCHAIN_ROOT ?= $(shell readlink -e $(NACL_ROOT)/toolchain/linux_x86)
# PNACL_TOOLCHAIN_ROOT is the location of the PNaCl toolchain.
# This is used as the default root for finding binutils, libcxx, etc.
PNACL_TOOLCHAIN_ROOT ?= $(shell readlink -e $(TOOLCHAIN_ROOT)/pnacl_newlib_raw)
# The location of PNaCl tools (e.g., binutils objdump, pnacl-clang++, etc.).
PNACL_BIN_PATH ?= $(shell readlink -e $(PNACL_TOOLCHAIN_ROOT)/bin)
# Allow tests to be overridden, e.g.:
# make -f Makefile.standalone check-lit \
# CHECK_LIT_TESTS="tests_lit/llvm2ice_tests/{alloc,arith}.ll"
# make -f Makefile.standalone check-xtest \
# CHECK_XTEST_TESTS=crosstest/Output/simple_loop_x8632_native_O2_sse2.xtest
CHECK_LIT_TESTS ?= tests_lit
CHECK_XTEST_TESTS ?= crosstest/Output
# Hack to auto-detect autoconf versus cmake build of LLVM. If the LLVM tools
# were dynamically linked with something like libLLVM-3.7svn.so, it is an
# autoconf build, otherwise it is a cmake build. AUTOCONF is set to 0 for
# cmake, nonzero for autoconf.
AUTOCONF ?= $(shell ldd $(PNACL_BIN_PATH)/opt | grep -c libLLVM-)
# CLANG_PATH is the location of the clang compiler to use for building
# the host binaries.
CLANG_PATH ?= $(shell readlink -e \
$(NACL_ROOT)/../third_party/llvm-build/Release+Asserts/bin)
# LIBCXX_INSTALL_PATH is the directory where libc++ is located. It should
# contain header files and corresponding libraries. This is used for
# building the host binaries in conjuction with clang.
LIBCXX_INSTALL_PATH ?= $(PNACL_TOOLCHAIN_ROOT)
STDLIB_FLAGS := -stdlib=libc++ -I$(LIBCXX_INSTALL_PATH)/include/c++/v1
HOST_ARCH ?= x86_64
ifeq ($(HOST_ARCH),x86_64)
HOST_FLAGS = -m64
else
ifeq ($(HOST_ARCH),x86)
HOST_FLAGS = -m32
endif
endif
ifdef DEBUG
OBJDIR = build/Debug
OPTLEVEL = -O0
LINKOPTLEVEL = -O0
else
OBJDIR = build/Release
OPTLEVEL = -O2 -ffunction-sections -fdata-sections
LINKOPTLEVEL = -O2
endif
# The list of CXX defines that are dependent on build parameters.
BASE_CXX_DEFINES =
CXX_EXTRA =
LD_EXTRA =
ifdef MINIMAL
NOASSERT = 1
NODUMP = 1
OBJDIR := $(OBJDIR)+Min
BASE_CXX_DEFINES += -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \
-DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_TIMERS=0 -DALLOW_MINIMAL_BUILD=1
else
BASE_CXX_DEFINES += -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \
-DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_TIMERS=1 -DALLOW_MINIMAL_BUILD=0
endif
ifdef NODUMP
OBJDIR := $(OBJDIR)+NoDump
BASE_CXX_DEFINES += -DALLOW_DUMP=0
else
BASE_CXX_DEFINES += -DALLOW_DUMP=1
endif
# Restrict to a single supported target. Current options:
# SZTARGET=ARM32
# SZTARGET=MIPS32
# SZTARGET=X8632
# SZTARGET=X8664
ifdef SZTARGET
OBJDIR := $(OBJDIR)+T_$(SZTARGET)
BASE_CXX_DEFINES += -DSZTARGET=$(SZTARGET)
endif
BASE_CXX_DEFINES += -DPNACL_LLVM
SZ_COMMIT_COUNT := $(shell git rev-list --count HEAD)
SZ_GIT_HASH := $(shell git rev-parse HEAD)
BASE_CXX_DEFINES += -DSUBZERO_REVISION=$(SZ_COMMIT_COUNT)_$(SZ_GIT_HASH)
CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=0
ifdef NOASSERT
ASSERTIONS = -DNDEBUG
else
ASSERTIONS =
OBJDIR := $(OBJDIR)+Asserts
endif
ifdef UBSAN
OBJDIR := $(OBJDIR)+UBSan
CXX_EXTRA += -fsanitize=undefined -fno-sanitize=vptr \
-fno-sanitize=nonnull-attribute
LD_EXTRA += -fsanitize=undefined
endif
ifdef UBSAN_TRAP
OBJDIR := $(OBJDIR)+UBSan_Trap
CXX_EXTRA += -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error \
-fno-sanitize=vptr -fno-sanitize=nonnull-attribute
LD_EXTRA += -fsanitize=undefined-trap
endif
ifdef TSAN
OBJDIR := $(OBJDIR)+TSan
CXX_EXTRA += -fsanitize=thread
LD_EXTRA += -fsanitize=thread
endif
ifdef ASAN
OBJDIR := $(OBJDIR)+ASan
CXX_EXTRA += -fsanitize=address
LD_EXTRA += -fsanitize=address
endif
ifdef MSAN
# TODO(ascull): this has an as yet undiagnosed uninitialized memory access
OBJDIR := $(OBJDIR)+MSan
CXX_EXTRA += -fsanitize=memory
LD_EXTRA += -fsanitize=memory
endif
ifdef FORCEASM
FORCEASM_FLAG = --filetype=asm
# With --filetype=asm and --sandbox, the llvm-mc assembler emits the lock and
# 16-bit prefixes in the "wrong" order, causing the validator to reject the
# resulting nexe. So we just disable those tests for now.
FORCEASM_XTEST_EXCLUDES = -e x8632,sandbox,test_sync_atomic
FORCEASM_LIT_PARAM = --param=FORCEASM
# x86 sandboxing lit tests are disabled because filetype=asm does not
# handle bundle_lock pad-to-end correctly.
# TODO(jpp): fix this.
FORCEASM_LIT_TEST_EXCLUDES = --filter='^(?!.*/x86/sandboxing.ll).*'
else
FORCEASM_FLAG =
FORCEASM_XTEST_EXCLUDES =
FORCEASM_LIT_PARAM =
FORCEASM_LIT_TEST_EXCLUDES =
endif
ifdef LINUX_MALLOC_PROFILE
OBJDIR := $(OBJDIR)+MalProf
CXX_EXTRA += -DALLOW_LINUX_MALLOC_PROFILE=1
LD_EXTRA += -Wl,--export-dynamic
endif
SB_OBJDIR := $(OBJDIR)+Sandboxed
SBB_OBJDIR := $(OBJDIR)+SandboxedBrowser
V8_DIR = $(NACL_ROOT)/../v8
V8_CXXFLAGS := -I$(V8_DIR)
$(info -----------------------------------------------)
$(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH))
$(info Using SB_LLVM_PATH = $(SB_LLVM_PATH))
$(info Using NACL_ROOT = $(NACL_ROOT))
$(info Using TOOLCHAIN_ROOT = $(TOOLCHAIN_ROOT))
$(info Using PNACL_TOOLCHAIN_ROOT = $(PNACL_TOOLCHAIN_ROOT))
$(info Using PNACL_BIN_PATH = $(PNACL_BIN_PATH))
$(info Using CLANG_PATH = $(CLANG_PATH))
$(info Using LIBCXX_INSTALL_PATH = $(LIBCXX_INSTALL_PATH))
$(info Using HOST_ARCH = $(HOST_ARCH))
$(info -----------------------------------------------)
LLVM_CXXFLAGS := `$(PNACL_BIN_PATH)/llvm-config --cxxflags`
SB_LLVM_CXXFLAGS := $(LLVM_CXXFLAGS)
# Listing specific libraries that are needed for pnacl-sz
# and the unittests, since we build "tools-only" for the
# sandboxed_translators (which doesn't include every library
# listed by llvm-config).
LLVM_LIBS_LIST := -lLLVMIRReader -lLLVMBitReader -lLLVMNaClBitTestUtils \
-lLLVMNaClBitReader -lLLVMNaClBitAnalysis -lLLVMNaClBitWriter \
-lLLVMAsmParser -lLLVMNaClAnalysis -lLLVMCore -lLLVMSupport
ifeq ($(AUTOCONF), 0)
# LLVM cmake build
LLVM_LIBS := $(LLVM_LIBS_LIST)
# For the cmake build, the gtest libs end up in the same place as the LLVM
# libs, so no "-L..." arg is needed.
GTEST_LIB_PATH ?=
CLANG_FORMAT_PATH ?= $(PNACL_BIN_PATH)
else
# LLVM autoconf build
LLVM_LIBS := -lLLVM-3.7svn
GTEST_LIB_PATH ?= -L../../out/llvm_x86_64_linux_work/Release+Asserts/lib
ifneq ($(wildcard \
../../out/llvm_x86_64_linux_work/Release+Asserts/bin/clang-format),)
CLANG_FORMAT_PATH ?= ../../out/llvm_x86_64_linux_work/Release+Asserts/bin
else
CLANG_FORMAT_PATH ?= \
../../out/llvm_x86_64_linux_debug_work/Debug+Asserts/bin
endif
endif
LLVM_LDFLAGS := $(LLVM_LIBS) \
`$(PNACL_BIN_PATH)/llvm-config --ldflags` \
`$(PNACL_BIN_PATH)/llvm-config --system-libs`
SB_LLVM_LDFLAGS := -Wl,--start-group $(LLVM_LIBS_LIST) -Wl,--end-group \
-L$(SB_LLVM_PATH)/lib
CCACHE := `command -v ccache`
CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++
SB_CXX := CCACHE_CPP2=yes $(CCACHE) $(PNACL_BIN_PATH)/pnacl-clang++
SB_TRANSLATE := $(PNACL_BIN_PATH)/pnacl-translate
SB_FINALIZE := $(PNACL_BIN_PATH)/pnacl-finalize --no-strip-syms
# Extra warnings that LLVM's build system adds in addition to -Wall.
LLVM_EXTRA_WARNINGS := -Wcovered-switch-default
# Use g++ to compile, to check for errors/warnings that clang++ might have
# missed. It's unlikely to link, unless LLVM was also built with g++, so the
# compile_only target should be used. Note: This ifdef section is deliberately
# placed here instead of with the other ifdef sections, so that its redefinition
# of CXX/STDLIB_FLAGS/LLVM_EXTRA_WARNINGS follows their normal definitions.
ifdef GPLUSPLUS
CXX := CCACHE_CPP2=yes $(CCACHE) g++
STDLIB_FLAGS :=
LLVM_EXTRA_WARNINGS := \
-Wcast-qual \
-Wno-comment \
-Wno-long-long \
-Wno-maybe-uninitialized \
-Wno-missing-field-initializers \
-Wno-unused-parameter \
-Wwrite-strings
OBJDIR := $(OBJDIR)+Gplusplus
endif
BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -fno-rtti \
-fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g -pedantic \
$(LLVM_EXTRA_WARNINGS) $(CXX_EXTRA) -MP -MD -Werror
ifdef WASM
BASE_CXXFLAGS := $(BASE_CXXFLAGS) $(V8_CXXFLAGS) -DALLOW_WASM=1
OBJDIR := $(OBJDIR)+Wasm
else
BASE_CXXFLAGS := $(BASE_CXXFLAGS) -DALLOW_WASM=0
endif
# TODO(stichnot,jpp): Restructure static fields in template classes to avoid
# needing -Wno-undefined-var-template .
CXXFLAGS := $(LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(CXX_DEFINES) $(HOST_FLAGS) \
$(STDLIB_FLAGS) -Wno-undefined-var-template
SB_CXXFLAGS := $(SB_LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(BASE_CXX_DEFINES) \
-Wno-unknown-pragmas -I$(NACL_ROOT) -I$(NACL_ROOT)/..
LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib -Wl,--gc-sections \
$(LD_EXTRA) $(STDLIB_FLAGS)
# Not specifying -Wl,--gc-sections but instead doing bitcode linking GC w/ LTO.
SB_LDFLAGS := $(LINKOPTLEVEL) $(LD_EXTRA)
# List the target-specific source files first, which generally take longer to
# compile, in the hope of improving parallel build time.
SRCS = \
IceAssemblerARM32.cpp \
IceAssemblerMIPS32.cpp \
IceInstARM32.cpp \
IceInstMIPS32.cpp \
IceInstX8632.cpp \
IceInstX8664.cpp \
IceTargetLowering.cpp \
IceTargetLoweringARM32.cpp \
IceTargetLoweringMIPS32.cpp \
IceTargetLoweringX86.cpp \
IceTargetLoweringX8632.cpp \
IceTargetLoweringX8664.cpp \
IceAssembler.cpp \
IceBrowserCompileServer.cpp \
IceCfg.cpp \
IceCfgNode.cpp \
IceClFlags.cpp \
IceCompiler.cpp \
IceCompileServer.cpp \
IceELFObjectWriter.cpp \
IceELFSection.cpp \
IceFixups.cpp \
IceGlobalContext.cpp \
IceGlobalInits.cpp \
IceInst.cpp \
IceIntrinsics.cpp \
IceLiveness.cpp \
IceLoopAnalyzer.cpp \
IceMangling.cpp \
IceMemory.cpp \
IceOperand.cpp \
IceRangeSpec.cpp \
IceRegAlloc.cpp \
IceRevision.cpp \
IceRNG.cpp \
IceSwitchLowering.cpp \
IceThreading.cpp \
IceTimerTree.cpp \
IceTranslator.cpp \
IceTypes.cpp \
IceVariableSplitting.cpp \
LinuxMallocProfiling.cpp \
main.cpp \
PNaClTranslator.cpp
ifndef MINIMAL
SRCS += \
IceASanInstrumentation.cpp \
IceConverter.cpp \
IceInstrumentation.cpp \
IceTypeConverter.cpp
endif
ifdef WASM
SRCS += \
WasmTranslator.cpp
endif
OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS))
SB_OBJS=$(patsubst %.cpp, $(SB_OBJDIR)/%.o, $(SRCS))
SBB_OBJS=$(patsubst %.cpp, $(SBB_OBJDIR)/%.o, $(SRCS))
UNITTEST_SRCS = \
BitcodeMunge.cpp \
IceELFSectionTest.cpp \
IceParseInstsTest.cpp
# The X86 assembler tests take too long to compile. Given how infrequently the
# assembler will change, we disable them.
ifdef CHECK_X86_ASM
ifndef DEBUG
$(error Run check-unit with DEBUG=1 lest your machine perish)
endif
UNITTEST_SRCS += AssemblerX8632/LowLevel.cpp \
AssemblerX8632/DataMov.cpp \
AssemblerX8632/Locked.cpp \
AssemblerX8632/GPRArith.cpp \
AssemblerX8632/XmmArith.cpp \
AssemblerX8632/ControlFlow.cpp \
AssemblerX8632/Other.cpp \
AssemblerX8632/X87.cpp \
AssemblerX8664/LowLevel.cpp \
AssemblerX8664/DataMov.cpp \
AssemblerX8664/Locked.cpp \
AssemblerX8664/GPRArith.cpp \
AssemblerX8664/XmmArith.cpp \
AssemblerX8664/ControlFlow.cpp \
AssemblerX8664/Other.cpp
endif
UNITTEST_OBJS = $(patsubst %.cpp, $(OBJDIR)/unittest/%.o, $(UNITTEST_SRCS))
UNITTEST_LIB_OBJS = $(filter-out $(OBJDIR)/main.o,$(OBJS))
NEXES = $(SB_OBJDIR)/pnacl-sz.x8632.nexe \
$(SB_OBJDIR)/pnacl-sz.x8664.nexe \
$(SBB_OBJDIR)/pnacl_public_x86_32_pnacl_sz_nexe \
$(SBB_OBJDIR)/pnacl_public_x86_64_pnacl_sz_nexe
NEXES_LITE = $(SB_OBJDIR)/pnacl-sz.x8664.nexe
# Keep all the first target so it's the default.
all: $(OBJDIR)/pnacl-sz make_symlink runtime
ifdef TSAN
sb sb-lite:
@echo "Skipping pnacl-sz.*.nexe: TSAN isn't supported under NaCl."
else
sb: $(NEXES) sb_make_symlink exists-sbtc
sb-lite: $(NEXES_LITE) exists-sbtc
endif
# SHOW_BUILD_ATTS is an executable that is run to show what build
# attributes were used to build pnacl-sz.
SHOW_BUILD_ATTS = $(OBJDIR)/pnacl-sz --build-atts
# Creates symbolic link so that testing is easier. Also runs
# pnacl-sz to verify that the defines flags have valid values,
# as well as describe the corresponding build attributes.
make_symlink: $(OBJDIR)/pnacl-sz
rm -rf pnacl-sz
ln -s $(OBJDIR)/pnacl-sz
@echo "Build Attributes:"
@$(SHOW_BUILD_ATTS)
sb_make_symlink: $(NEXES)
$(foreach nexe,$(NEXES),rm -rf $(notdir $(nexe)); ln -s $(nexe);)
%.pexe : %.nonfinal.pexe
$(SB_FINALIZE) -o $@ $<
.PHONY: all compile_only make_symlink runtime bloat sb docs help \
help-check-lit help-check-xtest exists-nonsfi-x8632 \
exists-nonsfi-arm32 exists-sbtc exists-spec
compile_only: $(OBJS)
V8_LIBDIR=$(V8_DIR)/out/native/lib.target
ifdef WASM
V8_LIBS := \
$(V8_LIBDIR)/libv8.so \
$(V8_LIBDIR)/libicuuc.so \
$(V8_LIBDIR)/libicui18n.so
endif
$(OBJDIR)/pnacl-sz: $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \
-Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) $(V8_LIBS)
$(SB_OBJDIR)/pnacl-sz.nonfinal.pexe: $(SB_OBJS)
$(SB_CXX) $(SB_LDFLAGS) -o $@ $^ $(SB_LLVM_LDFLAGS)
$(SBB_OBJDIR)/pnacl-sz.nonfinal.pexe: $(SBB_OBJS)
$(SB_CXX) $(SB_LDFLAGS) -o $@ $^ $(SB_LLVM_LDFLAGS) \
--pnacl-disable-abi-check
$(SB_OBJDIR)/pnacl-sz.x8632.nexe: $(SB_OBJDIR)/pnacl-sz.pexe
$(SB_TRANSLATE) -arch x86-32 $^ -o $@
$(SB_OBJDIR)/pnacl-sz.x8664.nexe: $(SB_OBJDIR)/pnacl-sz.pexe
$(SB_TRANSLATE) -arch x86-64 $^ -o $@
$(SBB_OBJDIR)/pnacl_public_x86_32_pnacl_sz_nexe: $(SBB_OBJDIR)/pnacl-sz.pexe
$(SB_TRANSLATE) -arch x86-32 $^ -o $@
$(SBB_OBJDIR)/pnacl_public_x86_64_pnacl_sz_nexe: $(SBB_OBJDIR)/pnacl-sz.pexe
$(SB_TRANSLATE) -arch x86-64 $^ -o $@
src/IceRegistersARM32.def: pydir/gen_arm32_reg_tables.py
python $< > $@
-include $(foreach dep,$(SRCS:.cpp=.d),$(OBJDIR)/$(dep))
$(OBJS): $(OBJDIR)/%.o: src/%.cpp
$(CXX) -c $(CXXFLAGS) $< -o $@
-include $(foreach dep,$(SRCS:.cpp=.d),$(SB_OBJDIR)/$(dep))
$(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp
$(SB_CXX) -c $(SB_CXXFLAGS) -DPNACL_BROWSER_TRANSLATOR=0 $< -o $@
-include $(foreach dep,$(SRCS:.cpp=.d),$(SBB_OBJDIR)/$(dep))
$(SBB_OBJS): $(SBB_OBJDIR)/%.o: src/%.cpp
$(SB_CXX) -c $(SB_CXXFLAGS) -DPNACL_BROWSER_TRANSLATOR=1 $< -o $@
$(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS)
$(CXX) $(GTEST_LIB_PATH) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \
-lgtest -lgtest_main -ldl \
-Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib)
-include $(foreach dep,$(UNITTEST_SRCS:.cpp=.d),$(OBJDIR)/unittest/$(dep))
$(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp
$(CXX) -c $(CXXFLAGS) \
-Isrc/ \
-Iunittest/ \
-I$(LLVM_SRC_PATH)/utils/unittest/googletest/include \
-I$(LLVM_SRC_PATH) \
-DGTEST_HAS_RTTI=0 -DGTEST_USE_OWN_TR1_TUPLE \
-Wno-expansion-to-defined \
$< -o $@
$(OBJS): | $(OBJDIR)
$(SB_OBJS): | $(SB_OBJDIR)
$(SBB_OBJS): | $(SBB_OBJDIR)
$(UNITTEST_OBJS): | $(OBJDIR)/unittest $(OBJDIR)/unittest/AssemblerX8632 \
$(OBJDIR)/unittest/AssemblerX8664
$(OBJDIR):
@mkdir -p $@
$(SB_OBJDIR):
@mkdir -p $@
$(SBB_OBJDIR):
@mkdir -p $@
$(OBJDIR)/unittest: $(OBJDIR)
@mkdir -p $@
$(OBJDIR)/unittest/AssemblerX8632: $(OBJDIR)/unittest
@mkdir -p $@
$(OBJDIR)/unittest/AssemblerX8664: $(OBJDIR)/unittest
@mkdir -p $@
RT_SRC := runtime/szrt.c runtime/szrt_ll.ll runtime/szrt_profiler.c \
runtime/szrt_asm_x8632.s runtime/szrt_asm_x8664.s \
runtime/szrt_asm_arm32.s runtime/szrt_asan.c
RT_OBJ := build/runtime/szrt_native_x8632.o build/runtime/szrt_sb_x8632.o \
build/runtime/szrt_nonsfi_x8632.o \
build/runtime/szrt_native_x8664.o build/runtime/szrt_sb_x8664.o \
build/runtime/szrt_nonsfi_x8664.o \
build/runtime/szrt_native_arm32.o build/runtime/szrt_sb_arm32.o \
build/runtime/szrt_nonsfi_arm32.o \
build/runtime/szrt_asan_x8632.o build/runtime/szrt_asan_x8664.o \
build/runtime/szrt_asan_arm32.o
EXCLUDED_RT :=
ifdef MIPS
RT_SRC += runtime/szrt_asm_mips32.s
RT_OBJ += build/runtime/szrt_native_mips32.o build/runtime/szrt_sb_mips32.o
else
EXCLUDED_RT += --exclude-target=mips32
endif
runtime: $(RT_OBJ)
# Use runtime.is.built so that build-runtime.py is invoked only once
# even in a parallel build.
.INTERMEDIATE: runtime.is.built
$(RT_OBJ): runtime.is.built
runtime.is.built: $(RT_SRC) pydir/build-runtime.py
@echo ================ Building Subzero runtime ================
./pydir/build-runtime.py -v --pnacl-root $(PNACL_TOOLCHAIN_ROOT) \
$(EXCLUDED_RT)
check-lit: $(OBJDIR)/pnacl-sz make_symlink runtime
PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
$(LLVM_SRC_PATH)/utils/lit/lit.py -sv $(CHECK_LIT_TESTS) \
$(FORCEASM_LIT_TEST_EXCLUDES) $(FORCEASM_LIT_PARAM)
ifdef MINIMAL
check-xtest check-xtest-lite: $(OBJDIR)/pnacl-sz make_symlink runtime
@echo "Crosstests disabled, minimal build"
else
ifdef MIPS
check-xtest check-xtest-lite: $(OBJDIR)/pnacl-sz make_symlink runtime \
crosstest/test_arith_ll.ll
# Do all x8664/native/sse2 tests as a smoke test.
# Add in mips32 tests as they come online.
./pydir/crosstest_generator.py -v --lit \
--toolchain-root $(TOOLCHAIN_ROOT) \
$(FORCEASM_FLAG) \
$(FORCEASM_XTEST_EXCLUDES) \
-i x8664,native,sse2 \
-i mips32,native,Om1,simple_loop \
-i mips32,native,Om1,test_strengthreduce
PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
$(LLVM_SRC_PATH)/utils/lit/lit.py -sv $(CHECK_XTEST_TESTS)
else
check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime \
exists-nonsfi-x8632 exists-nonsfi-arm32 crosstest/test_arith_ll.ll
# Do all native/sse2 tests, but only test_vector_ops for native/sse4.1.
# For (slow) sandboxed tests, limit to Om1/sse4.1.
# run.py (used to run the sandboxed xtests) does not support
# specifying -cpu cortex-a15 to qemu, hence we disable the
# hwdiv-arm tests.
./pydir/crosstest_generator.py -v --lit \
--toolchain-root $(TOOLCHAIN_ROOT) \
$(FORCEASM_FLAG) \
$(FORCEASM_XTEST_EXCLUDES) \
-i x8632,native,sse2 \
-i x8632,native,sse4.1,test_vector_ops \
-i x8632,sandbox,sse4.1,Om1 \
-i x8632,nonsfi,sse2,O2 \
-i x8664,native,sse2 \
-i x8664,native,sse4.1,test_vector_ops \
-i x8664,sandbox,sse4.1,Om1 \
-i arm32 \
-e arm32,sandbox,hwdiv-arm
PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
$(LLVM_SRC_PATH)/utils/lit/lit.py -sv $(CHECK_XTEST_TESTS)
check-xtest-lite: $(OBJDIR)/pnacl-sz make_symlink runtime \
exists-nonsfi-x8632 exists-nonsfi-arm32 crosstest/test_arith_ll.ll
# Do all native/sse2/neon tests, which are relatively fast.
# Limit to test_global+mem_intrin for sandbox+nonsfi because sandbox and
# nonsfi builds are slow, and test_global and mem_intrin are the most
# common sources of problems.
./pydir/crosstest_generator.py -v --lit \
--toolchain-root $(TOOLCHAIN_ROOT) \
$(FORCEASM_FLAG) \
$(FORCEASM_XTEST_EXCLUDES) \
-i x8632,native,sse2,O2 \
-i x8664,native,sse2,O2 \
-i arm32,native,neon,O2 \
-i x8632,sse2,O2,test_global \
-i x8632,sse2,O2,mem_intrin \
-i x8664,sse2,O2,test_global \
-i x8664,sse2,O2,mem_intrin \
-i arm32,neon,O2,test_global \
-i arm32,neon,O2,mem_intrin \
-e x8664,nonsfi
PNACL_BIN_PATH=$(PNACL_BIN_PATH) \
$(LLVM_SRC_PATH)/utils/lit/lit.py -sv $(CHECK_XTEST_TESTS)
crosstest/test_arith_ll.ll: pydir/gen_test_arith_ll.py
python $< > $@
endif
endif
check-unit: $(OBJDIR)/run_unittests
$(OBJDIR)/run_unittests
# List the spec2k components in roughly reverse order of runtime, to help with
# parallel execution speed.
ALLSPEC := 253.perlbmk 177.mesa 188.ammp 256.bzip2 164.gzip 179.art 183.equake \
175.vpr 176.gcc 181.mcf 186.crafty 197.parser 254.gap 255.vortex \
300.twolf 252.eon
.PHONY: $(ALLSPEC)
TARGET := x8632
ifeq ($(TARGET),x8632)
TARGETFLAG=x8632
SETUP=SetupGccX8632Opt
SPEC := --filetype=obj
endif
ifeq ($(TARGET),x8664)
TARGETFLAG=x8664
SETUP=SetupGccX8664Opt
SPEC := --filetype=obj
endif
ifeq ($(TARGET),arm32)
TARGETFLAG=arm32
SETUP=SetupGccArmOpt
SPEC := --filetype=obj
endif
ifeq ($(TARGET),mips32)
# native_client/tests/spec2k/{Makefile.common,run_all.sh} do not currently
# have MIPS configs, so those would need to be added for proper Subzero
# testing.
TARGETFLAG=mips32
SETUP=SetupGccMipsOpt
SPEC := --filetype=asm
endif
SPECFLAGS := -O2
SPECRUN := --run
%.spec2k: % $(OBJDIR)/pnacl-sz make_symlink runtime
./pydir/szbuild_spec2k.py -v \
$(SPECFLAGS) --target=$(TARGETFLAG) $(SPEC) $< $(SPECRUN)
ifdef MIPS
# Don't test spec2k on mips32, at least not yet.
check-spec:
else
check-spec: exists-spec $(ALLSPEC:=.spec2k)
endif
check: check-lit check-unit check-xtest
NONSFI_LOADER_X8632 = \
$(NACL_ROOT)/scons-out/opt-linux-x86-32/obj/src/nonsfi/loader/nonsfi_loader
NONSFI_LOADER_ARM32 = \
$(NACL_ROOT)/scons-out/opt-linux-arm/obj/src/nonsfi/loader/nonsfi_loader
SBTC_LIBFILE = $(SB_LLVM_PATH)/lib/libLLVMSupport.a
SPEC_SAMPLE_PEXE = $(NACL_ROOT)/tests/spec2k/176.gcc/gcc.opt.stripped.pexe
exists-nonsfi-x8632:
@if [ ! -f $(NONSFI_LOADER_X8632) ] ; then \
echo "Missing file $(NONSFI_LOADER_X8632)"; \
echo "Consider running './scons nonsfi_loader'" \
"in the native_client directory."; \
exit 1 ; \
fi
exists-nonsfi-arm32:
@if [ ! -f $(NONSFI_LOADER_ARM32) ] ; then \
echo "Missing file $(NONSFI_LOADER_ARM32)"; \
echo "Consider running './scons platform=arm nonsfi_loader'" \
"in the native_client directory."; \
exit 1 ; \
fi
exists-sbtc:
@if [ ! -f $(SBTC_LIBFILE) ] ; then \
echo "Missing file $(SBTC_LIBFILE)"; \
echo "Consider running 'toolchain_build_pnacl.py --build-sbtc'."; \
exit 1 ; \
fi
exists-spec:
@if [ ! -f $(SPEC_SAMPLE_PEXE) ] ; then \
echo "Missing file $(SPEC_SAMPLE_PEXE)"; \
echo "Consider running" \
"'./run_all.sh BuildBenchmarks 0 SetupPnaclX8632Opt'" \
"in the native_client/tests/spec2k directory."; \
exit 1 ; \
fi
ifdef MIPS
check-presubmit presubmit: exists-sbtc
# Make sure clang-format gets run.
+make -f Makefile.standalone format
# Verify MINIMAL build, plus proper usage of REQUIRES in lit tests.
+make -f Makefile.standalone \
MINIMAL=1 check
# Check that there are no g++ build errors or warnings.
+make -f Makefile.standalone \
GPLUSPLUS=1 compile_only
# Run lit tests, cross tests, and unit tests.
+make -f Makefile.standalone \
check
# Check a sandboxed translator build.
+make -f Makefile.standalone \
DEBUG=1 sb
# Provide validation of user awesomeness!
echo Success
else
check-presubmit presubmit: exists-nonsfi-x8632 exists-nonsfi-arm32 \
exists-sbtc exists-spec
# Make sure clang-format gets run.
+make -f Makefile.standalone format
# Verify MINIMAL build, plus proper usage of REQUIRES in lit tests.
+make -f Makefile.standalone \
MINIMAL=1 check
# Check that there are no g++ build errors or warnings.
+make -f Makefile.standalone \
GPLUSPLUS=1 compile_only
# Check the x86 assembler unit tests.
+make -f Makefile.standalone \
DEBUG=1 CHECK_X86_ASM=1 check-unit sb
# Run lit tests, cross tests, unit tests, and spec2k/x86-32.
+make -f Makefile.standalone \
check check-spec
# Run spec2k/x86-64.
+make -f Makefile.standalone \
TARGET=x8664 check-spec
# Run spec2k/x86-64 with sandboxing.
+make -f Makefile.standalone \
SPECFLAGS='-O2 --sandbox' TARGET=x8664 check-spec
# Build spec2k under -Om1/x86-32, to check for liveness errors.
+make -f Makefile.standalone \
SPECFLAGS='-Om1' SPECRUN= check-spec
# Build spec2k under -Om1/x86-64, to check for liveness errors.
+make -f Makefile.standalone \
SPECFLAGS='-Om1' TARGET=x8664 SPECRUN= check-spec
# Run spec2k for x86-32 without advanced phi lowering.
+make -f Makefile.standalone \
SPECFLAGS='-O2 --sz=--phi-edge-split=0' check-spec
# Run spec2k for x86-64 without advanced phi lowering.
+make -f Makefile.standalone \
SPECFLAGS='-O2 --sz=--phi-edge-split=0' TARGET=x8664 check-spec
# Run cross tests and lit tests to validate filetype=asm output.
+make -f Makefile.standalone \
FORCEASM=1 check-xtest check-lit
# Build spec2k for arm32.
+make -f Makefile.standalone \
TARGET=arm32 SPECRUN= check-spec
# Build spec2k under -Om1/arm32.
+make -f Makefile.standalone \
TARGET=arm32 SPECFLAGS='-Om1' SPECRUN= check-spec
# Run a few spec2k tests for arm32 using qemu. Keep the list sorted in
# roughly reverse order of runtime.
+make -f Makefile.standalone \
TARGET=arm32 ALLSPEC='252.eon 254.gap 176.gcc 181.mcf' check-spec
# Provide validation of user awesomeness!
echo Success
endif
presubmit-lite: exists-nonsfi-x8632 exists-nonsfi-arm32 \
exists-sbtc exists-spec
# Make sure clang-format gets run.
+make -f Makefile.standalone format
# Verify MINIMAL build, plus proper usage of REQUIRES in lit tests.
+make -f Makefile.standalone \
MINIMAL=1 check sb-lite
# Check that there are no g++ build errors or warnings.
+make -f Makefile.standalone \
GPLUSPLUS=1 compile_only
# Run lit tests, cross tests, unit tests, and spec2k/x86-32.
+make -f Makefile.standalone \
check-lit check-unit check-spec
+make -f Makefile.standalone \
check-xtest-lite
# Run spec2k/x86-64.
+make -f Makefile.standalone \
TARGET=x8664 check-spec
# Build spec2k under -Om1/x86-32, to check for liveness errors.
+make -f Makefile.standalone \
SPECFLAGS='-Om1' SPECRUN= check-spec
# Build spec2k under -Om1/x86-64, to check for liveness errors.
+make -f Makefile.standalone \
SPECFLAGS='-Om1' TARGET=x8664 SPECRUN= check-spec
# Run cross tests and lit tests to validate filetype=asm output.
+make -f Makefile.standalone \
FORCEASM=1 check-lit
+make -f Makefile.standalone \
FORCEASM=1 check-xtest-lite
# Build spec2k under -Om1/arm32.
+make -f Makefile.standalone \
TARGET=arm32 SPECFLAGS='-Om1' SPECRUN= check-spec
# Run a few spec2k tests for arm32 using qemu. Keep the list sorted in
# roughly reverse order of runtime.
+make -f Makefile.standalone \
TARGET=arm32 ALLSPEC='254.gap 176.gcc 181.mcf' check-spec
# Provide validation of user awesomeness!
echo Success
FORMAT_BLACKLIST =
# Add one of the following lines for each source file to ignore.
FORMAT_BLACKLIST += ! -name IceParseInstsTest.cpp
FORMAT_BLACKLIST += ! -name IceParseTypesTest.cpp
FORMAT_BLACKLIST += ! -name assembler_arm.h
FORMAT_BLACKLIST += ! -name assembler_arm.cc
FORMAT_BLACKLIST += ! -path "./wasm-install/*"
FORMAT_BLACKLIST += ! -path "./pnacl-llvm/*"
format:
$(CLANG_FORMAT_PATH)/clang-format -style=LLVM -i \
`find . -regex '.*\.\(c\|h\|cpp\)' $(FORMAT_BLACKLIST)`
format-diff:
git diff -U0 `git merge-base HEAD master` | \
PATH=$(PNACL_BIN_PATH):$(PATH) \
$(LLVM_SRC_PATH)/../clang/tools/clang-format/clang-format-diff.py \
-p1 -style=LLVM -i
bloat: make_symlink
nm -C -S -l pnacl-sz | \
bloat/bloat.py --nm-output=/dev/stdin syms > build/pnacl-sz.bloat.json
@echo See Subzero size breakdown in bloat/pnacl-sz.bloat.html
bloat-sb: sb_make_symlink
$(foreach nexe,$(NEXES),nm -C -S -l $(nexe) | bloat/bloat.py \
--nm-output=/dev/stdin syms > build/$(notdir $(nexe)).bloat.json;)
@echo "See Subzero size breakdown in:"
@$(foreach nexe,$(NEXES),echo " bloat/$(notdir $(nexe)).bloat.html";)
docs:
make -C docs -f Makefile.standalone
help:
@cat Makefile.standalone-help/help.txt
help-check-lit:
@cat Makefile.standalone-help/check-lit.txt
help-check-xtest:
@cat Makefile.standalone-help/check-xtest.txt
clean:
rm -rf pnacl-sz *.o $(foreach nexe,$(NEXES),$(notdir $(nexe))) \
$(OBJDIR) $(SB_OBJDIR) $(SBB_OBJDIR) build/*.bloat.json
clean-all: clean
rm -rf build/ crosstest/Output/