OLD | NEW |
1 # The following variables will likely need to be modified, depending on where | 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 | 2 # and how you built LLVM & Clang. They can be overridden in a command-line |
3 # invocation of make, like: | 3 # invocation of make, like: |
4 # | 4 # |
5 # make LLVM_SRC_PATH=<path> LLVM_BIN_PATH=<path> \ | 5 # make LLVM_SRC_PATH=<path> LIBCXX_INSTALL_PATH=<path> CLANG_PATH=<path> \ |
6 # LIBCXX_INSTALL_PATH=<path> CLANG_PATH=<path> \ | |
7 # PNACL_BIN_PATH=<path> ... | 6 # PNACL_BIN_PATH=<path> ... |
8 # | 7 # |
9 | 8 |
10 # LLVM_SRC_PATH is the path to the root of the checked out source code. This | 9 # 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/ | 10 # directory should contain the configure script, the include/ and lib/ |
12 # directories of LLVM, Clang in tools/clang/, etc. | 11 # directories of LLVM, Clang in tools/clang/, etc. |
13 # Alternatively, if you're building vs. a binary download of LLVM, then | 12 # Alternatively, if you're building vs. a binary download of LLVM, then |
14 # LLVM_SRC_PATH can point to the main untarred directory. | 13 # LLVM_SRC_PATH can point to the main untarred directory. |
15 LLVM_SRC_PATH ?= ../llvm | 14 LLVM_SRC_PATH ?= ../llvm |
16 | 15 |
17 # LLVM_BIN_PATH is the directory where binaries are placed by the LLVM build | |
18 # process. It should contain the tools like clang, clang-format, llc, | |
19 # llvm-as, llvm-config, llvm-mc, pnacl-bcdis, and pnacl-freeze. | |
20 ifdef CMAKE | |
21 # LLVM cmake build | |
22 LLVM_BIN_PATH ?= ../../out/llvm_x86_64_linux_work/bin | |
23 else | |
24 # LLVM autoconf build | |
25 LLVM_BIN_PATH ?= ../../out/llvm_x86_64_linux_work/Release+Asserts/bin | |
26 endif | |
27 | |
28 # The x86-32-specific sandboxed translator directory. | 16 # The x86-32-specific sandboxed translator directory. |
29 # It holds sandboxed versions of libraries and binaries. | 17 # It holds sandboxed versions of libraries and binaries. |
30 SB_LLVM_PATH ?= $(shell readlink -e \ | 18 SB_LLVM_PATH ?= $(shell readlink -e \ |
31 ../../out/sandboxed_translators_work/translator-i686/llvm-sb/Release) | 19 ../../out/sandboxed_translators_work/translator-i686/llvm-sb/Release) |
32 | 20 |
33 # NACL_ROOT is the root of the native client repository. | 21 # NACL_ROOT is the root of the native client repository. |
34 NACL_ROOT ?= $(shell python -c "import sys; sys.path.insert(0, 'pydir'); \ | 22 NACL_ROOT ?= $(shell python -c "import sys; sys.path.insert(0, 'pydir'); \ |
35 import utils; print utils.FindBaseNaCl()") | 23 import utils; print utils.FindBaseNaCl()") |
36 | 24 |
37 # PNACL_TOOLCHAIN_ROOT is the location of the PNaCl toolchain. | 25 # PNACL_TOOLCHAIN_ROOT is the location of the PNaCl toolchain. |
38 # This is used as the default root for finding binutils, libcxx, etc. | 26 # This is used as the default root for finding binutils, libcxx, etc. |
39 PNACL_TOOLCHAIN_ROOT ?= $(shell readlink -e \ | 27 PNACL_TOOLCHAIN_ROOT ?= $(shell readlink -e \ |
40 » $(NACL_ROOT)/toolchain/linux_x86/pnacl_newlib) | 28 » $(NACL_ROOT)/toolchain/linux_x86/pnacl_newlib_raw) |
41 | 29 |
42 # The location of PNaCl tools (e.g., binutils objdump, pnacl-clang++, etc.). | 30 # The location of PNaCl tools (e.g., binutils objdump, pnacl-clang++, etc.). |
43 PNACL_BIN_PATH ?= $(shell readlink -e $(PNACL_TOOLCHAIN_ROOT)/bin) | 31 PNACL_BIN_PATH ?= $(shell readlink -e $(PNACL_TOOLCHAIN_ROOT)/bin) |
44 | 32 |
| 33 # Hack to auto-detect autoconf versus cmake build of LLVM. If the LLVM tools |
| 34 # were dynamically linked with something like libLLVM-3.6svn.so, it is an |
| 35 # autoconf build, otherwise it is a cmake build. AUTOCONF is set to 0 for |
| 36 # cmake, nonzero for autoconf. |
| 37 AUTOCONF ?= $(shell ldd $(PNACL_BIN_PATH)/opt | grep -c libLLVM-) |
| 38 |
45 # CLANG_PATH is the location of the clang compiler to use for building | 39 # CLANG_PATH is the location of the clang compiler to use for building |
46 # the host binaries. | 40 # the host binaries. |
47 CLANG_PATH ?= $(shell readlink -e \ | 41 CLANG_PATH ?= $(shell readlink -e \ |
48 $(NACL_ROOT)/../third_party/llvm-build/Release+Asserts/bin) | 42 $(NACL_ROOT)/../third_party/llvm-build/Release+Asserts/bin) |
49 | 43 |
50 # LIBCXX_INSTALL_PATH is the directory where libc++ is located. It should | 44 # LIBCXX_INSTALL_PATH is the directory where libc++ is located. It should |
51 # contain header files and corresponding libraries. This is used for | 45 # contain header files and corresponding libraries. This is used for |
52 # building the host binaries in conjuction with clang. | 46 # building the host binaries in conjuction with clang. |
53 LIBCXX_INSTALL_PATH ?= $(PNACL_TOOLCHAIN_ROOT) | 47 LIBCXX_INSTALL_PATH ?= $(PNACL_TOOLCHAIN_ROOT) |
54 STDLIB_FLAGS := -stdlib=libc++ -I$(LIBCXX_INSTALL_PATH)/include/c++/v1 | 48 STDLIB_FLAGS := -stdlib=libc++ -I$(LIBCXX_INSTALL_PATH)/include/c++/v1 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 ifdef TSAN | 96 ifdef TSAN |
103 OBJDIR := $(OBJDIR)+TSan | 97 OBJDIR := $(OBJDIR)+TSan |
104 CXX_EXTRA += -fsanitize=thread | 98 CXX_EXTRA += -fsanitize=thread |
105 LD_EXTRA += -fsanitize=thread | 99 LD_EXTRA += -fsanitize=thread |
106 endif | 100 endif |
107 | 101 |
108 SB_OBJDIR := $(OBJDIR)+Sandboxed | 102 SB_OBJDIR := $(OBJDIR)+Sandboxed |
109 | 103 |
110 $(info -----------------------------------------------) | 104 $(info -----------------------------------------------) |
111 $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH)) | 105 $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH)) |
112 $(info Using LLVM_BIN_PATH = $(LLVM_BIN_PATH)) | |
113 $(info Using SB_LLVM_PATH = $(SB_LLVM_PATH)) | 106 $(info Using SB_LLVM_PATH = $(SB_LLVM_PATH)) |
114 $(info Using NACL_ROOT = $(NACL_ROOT)) | 107 $(info Using NACL_ROOT = $(NACL_ROOT)) |
115 $(info Using PNACL_TOOLCHAIN_ROOT = $(PNACL_TOOLCHAIN_ROOT)) | 108 $(info Using PNACL_TOOLCHAIN_ROOT = $(PNACL_TOOLCHAIN_ROOT)) |
116 $(info Using PNACL_BIN_PATH = $(PNACL_BIN_PATH)) | 109 $(info Using PNACL_BIN_PATH = $(PNACL_BIN_PATH)) |
117 $(info Using CLANG_PATH = $(CLANG_PATH)) | 110 $(info Using CLANG_PATH = $(CLANG_PATH)) |
118 $(info Using LIBCXX_INSTALL_PATH = $(LIBCXX_INSTALL_PATH)) | 111 $(info Using LIBCXX_INSTALL_PATH = $(LIBCXX_INSTALL_PATH)) |
119 $(info Using HOST_ARCH = $(HOST_ARCH)) | 112 $(info Using HOST_ARCH = $(HOST_ARCH)) |
120 $(info -----------------------------------------------) | 113 $(info -----------------------------------------------) |
121 | 114 |
122 LLVM_CXXFLAGS := `$(LLVM_BIN_PATH)/llvm-config --cxxflags` | 115 LLVM_CXXFLAGS := `$(PNACL_BIN_PATH)/llvm-config --cxxflags` |
123 SB_LLVM_CXXFLAGS := $(LLVM_CXXFLAGS) | 116 SB_LLVM_CXXFLAGS := $(LLVM_CXXFLAGS) |
124 | 117 |
125 # Listing specific libraries that are needed for pnacl-sz | 118 # Listing specific libraries that are needed for pnacl-sz |
126 # and the unittests, since we build "tools-only" for the | 119 # and the unittests, since we build "tools-only" for the |
127 # sandboxed_translators (which doesn't include every library | 120 # sandboxed_translators (which doesn't include every library |
128 # listed by llvm-config). | 121 # listed by llvm-config). |
129 LLVM_LIBS := -lLLVMIRReader -lLLVMBitReader -lLLVMNaClBitTestUtils \ | 122 |
130 » -lLLVMNaClBitReader -lLLVMNaClBitAnalysis -lLLVMNaClBitWriter \ | 123 LLVM_LIBS_LIST := -lLLVMIRReader -lLLVMBitReader -lLLVMNaClBitTestUtils \ |
131 » -lLLVMAsmParser -lLLVMNaClAnalysis -lLLVMCore -lLLVMSupport | 124 -lLLVMNaClBitReader -lLLVMNaClBitAnalysis -lLLVMNaClBitWriter \ |
| 125 -lLLVMAsmParser -lLLVMNaClAnalysis -lLLVMCore -lLLVMSupport |
| 126 |
| 127 ifeq ($(AUTOCONF), 0) |
| 128 # LLVM cmake build |
| 129 LLVM_LIBS := $(LLVM_LIBS_LIST) |
| 130 # For the cmake build, the gtest libs end up in the same place as the LLVM |
| 131 # libs, so no "-L..." arg is needed. |
| 132 GTEST_LIB_PATH ?= |
| 133 CLANG_FORMAT_PATH ?= $(PNACL_BIN_PATH) |
| 134 else |
| 135 # LLVM autoconf build |
| 136 LLVM_LIBS := -lLLVM-3.6svn |
| 137 GTEST_LIB_PATH ?= -L../../out/llvm_x86_64_linux_work/Release+Asserts/lib |
| 138 CLANG_FORMAT_PATH ?= ../../out/llvm_x86_64_linux_work/Release+Asserts/bin |
| 139 endif |
| 140 |
132 LLVM_LDFLAGS := $(LLVM_LIBS) \ | 141 LLVM_LDFLAGS := $(LLVM_LIBS) \ |
133 `$(LLVM_BIN_PATH)/llvm-config --ldflags` \ | 142 `$(PNACL_BIN_PATH)/llvm-config --ldflags` \ |
134 `$(LLVM_BIN_PATH)/llvm-config --system-libs` | 143 `$(PNACL_BIN_PATH)/llvm-config --system-libs` |
135 SB_LLVM_LDFLAGS := $(LLVM_LIBS) \ | 144 SB_LLVM_LDFLAGS := $(LLVM_LIBS_LIST) \ |
136 -L$(SB_LLVM_PATH)/lib | 145 -L$(SB_LLVM_PATH)/lib |
137 | 146 |
138 CCACHE := `command -v ccache` | 147 CCACHE := `command -v ccache` |
139 CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++ | 148 CXX := CCACHE_CPP2=yes $(CCACHE) $(CLANG_PATH)/clang++ |
140 SB_CXX := CCACHE_CPP2=yes $(CCACHE) $(PNACL_BIN_PATH)/pnacl-clang++ | 149 SB_CXX := CCACHE_CPP2=yes $(CCACHE) $(PNACL_BIN_PATH)/pnacl-clang++ |
141 SB_TRANSLATE := $(PNACL_BIN_PATH)/pnacl-translate | 150 SB_TRANSLATE := $(PNACL_BIN_PATH)/pnacl-translate |
142 | 151 |
143 BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -Werror -fno-rtti \ | 152 BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -Werror -fno-rtti \ |
144 -fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g -pedantic \ | 153 -fno-exceptions $(OPTLEVEL) $(ASSERTIONS) -g -pedantic \ |
145 -Wno-error=unused-parameter $(CXX_EXTRA) | 154 -Wno-error=unused-parameter $(CXX_EXTRA) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 --allow-llvm-bitcode-input | 241 --allow-llvm-bitcode-input |
233 | 242 |
234 # TODO(stichnot): Be more precise than "*.h" here and elsewhere. | 243 # TODO(stichnot): Be more precise than "*.h" here and elsewhere. |
235 $(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def | 244 $(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def |
236 $(CXX) -c $(CXXFLAGS) $< -o $@ | 245 $(CXX) -c $(CXXFLAGS) $< -o $@ |
237 | 246 |
238 $(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp src/*.h src/*.def | 247 $(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp src/*.h src/*.def |
239 $(SB_CXX) -c $(SB_CXXFLAGS) $< -o $@ | 248 $(SB_CXX) -c $(SB_CXXFLAGS) $< -o $@ |
240 | 249 |
241 $(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS) | 250 $(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS) |
242 » $(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) -lgtest -lgtest_main -ldl \ | 251 » $(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \ |
| 252 $(GTEST_LIB_PATH) -lgtest -lgtest_main -ldl \ |
243 -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) | 253 -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) |
244 | 254 |
245 $(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp \ | 255 $(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp \ |
246 unittest/*.h src/*.h src/*.def | 256 unittest/*.h src/*.h src/*.def |
247 $(CXX) -c $(CXXFLAGS) \ | 257 $(CXX) -c $(CXXFLAGS) \ |
248 -Isrc/ \ | 258 -Isrc/ \ |
249 -I$(LLVM_SRC_PATH)/utils/unittest/googletest/include \ | 259 -I$(LLVM_SRC_PATH)/utils/unittest/googletest/include \ |
250 -DGTEST_HAS_RTTI=0 -DGTEST_USE_OWN_TR1_TUPLE \ | 260 -DGTEST_HAS_RTTI=0 -DGTEST_USE_OWN_TR1_TUPLE \ |
251 $< -o $@ | 261 $< -o $@ |
252 | 262 |
(...skipping 17 matching lines...) Expand all Loading... |
270 | 280 |
271 # Use runtime.is.built so that build-runtime.py is invoked only once | 281 # Use runtime.is.built so that build-runtime.py is invoked only once |
272 # even in a parallel build. | 282 # even in a parallel build. |
273 .INTERMEDIATE: runtime.is.built | 283 .INTERMEDIATE: runtime.is.built |
274 $(RT_OBJ): runtime.is.built | 284 $(RT_OBJ): runtime.is.built |
275 runtime.is.built: $(RT_SRC) | 285 runtime.is.built: $(RT_SRC) |
276 @echo ================ Building Subzero runtime ================ | 286 @echo ================ Building Subzero runtime ================ |
277 ./pydir/build-runtime.py -v --pnacl-root $(PNACL_TOOLCHAIN_ROOT) | 287 ./pydir/build-runtime.py -v --pnacl-root $(PNACL_TOOLCHAIN_ROOT) |
278 | 288 |
279 check-lit: $(OBJDIR)/pnacl-sz make_symlink | 289 check-lit: $(OBJDIR)/pnacl-sz make_symlink |
280 » LLVM_BIN_PATH=$(LLVM_BIN_PATH) \ | 290 » PNACL_BIN_PATH=$(PNACL_BIN_PATH) \ |
281 » BINUTILS_BIN_PATH=$(PNACL_BIN_PATH) \ | |
282 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv tests_lit | 291 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv tests_lit |
283 | 292 |
284 ifdef MINIMAL | 293 ifdef MINIMAL |
285 check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime | 294 check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime |
286 @echo "Crosstests disabled, minimal build" | 295 @echo "Crosstests disabled, minimal build" |
287 else | 296 else |
288 check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime | 297 check-xtest: $(OBJDIR)/pnacl-sz make_symlink runtime |
289 # Do all native/sse2 tests, but only test_vector_ops for native/sse4.1. | 298 # Do all native/sse2 tests, but only test_vector_ops for native/sse4.1. |
290 # For (slow) sandboxed tests, limit to Om1/sse4.1. | 299 # For (slow) sandboxed tests, limit to Om1/sse4.1. |
291 ./pydir/crosstest_generator.py -v --lit \ | 300 ./pydir/crosstest_generator.py -v --lit \ |
292 -i native,sse2 -i native,sse4.1,test_vector_ops \ | 301 -i native,sse2 -i native,sse4.1,test_vector_ops \ |
293 -i sandbox,sse4.1,Om1 | 302 -i sandbox,sse4.1,Om1 |
294 » LLVM_BIN_PATH=$(LLVM_BIN_PATH) \ | 303 » PNACL_BIN_PATH=$(PNACL_BIN_PATH) \ |
295 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv crosstest/Output | 304 $(LLVM_SRC_PATH)/utils/lit/lit.py -sv crosstest/Output |
296 endif | 305 endif |
297 | 306 |
298 check-unit: $(OBJDIR)/run_unittests | 307 check-unit: $(OBJDIR)/run_unittests |
299 $(OBJDIR)/run_unittests | 308 $(OBJDIR)/run_unittests |
300 | 309 |
301 check: check-lit check-unit check-xtest | 310 check: check-lit check-unit check-xtest |
302 | 311 |
303 FORMAT_BLACKLIST = | 312 FORMAT_BLACKLIST = |
304 # Add one of the following lines for each source file to ignore. | 313 # Add one of the following lines for each source file to ignore. |
305 FORMAT_BLACKLIST += ! -name IceParseInstsTest.cpp | 314 FORMAT_BLACKLIST += ! -name IceParseInstsTest.cpp |
306 format: | 315 format: |
307 » $(LLVM_BIN_PATH)/clang-format -style=LLVM -i \ | 316 » $(CLANG_FORMAT_PATH)/clang-format -style=LLVM -i \ |
308 `find . -regex '.*\.\(c\|h\|cpp\)' $(FORMAT_BLACKLIST)` | 317 `find . -regex '.*\.\(c\|h\|cpp\)' $(FORMAT_BLACKLIST)` |
309 | 318 |
310 format-diff: | 319 format-diff: |
311 git diff -U0 `git merge-base HEAD master` | \ | 320 git diff -U0 `git merge-base HEAD master` | \ |
312 » PATH=$(LLVM_BIN_PATH):$(PATH) \ | 321 » PATH=$(PNACL_BIN_PATH):$(PATH) \ |
313 $(LLVM_SRC_PATH)/../clang/tools/clang-format/clang-format-diff.py \ | 322 $(LLVM_SRC_PATH)/../clang/tools/clang-format/clang-format-diff.py \ |
314 -p1 -style=LLVM -i | 323 -p1 -style=LLVM -i |
315 | 324 |
316 bloat: make_symlink | 325 bloat: make_symlink |
317 nm -C -S -l pnacl-sz | \ | 326 nm -C -S -l pnacl-sz | \ |
318 bloat/bloat.py --nm-output=/dev/stdin syms > build/pnacl-sz.bloat.json | 327 bloat/bloat.py --nm-output=/dev/stdin syms > build/pnacl-sz.bloat.json |
319 @echo See Subzero size breakdown in bloat/pnacl-sz.bloat.html | 328 @echo See Subzero size breakdown in bloat/pnacl-sz.bloat.html |
320 | 329 |
321 clean: | 330 clean: |
322 rm -rf pnacl-sz *.o $(OBJDIR) $(SB_OBJDIR) build/pnacl-sz.bloat.json | 331 rm -rf pnacl-sz *.o $(OBJDIR) $(SB_OBJDIR) build/pnacl-sz.bloat.json |
323 | 332 |
324 clean-all: clean | 333 clean-all: clean |
325 rm -rf build/ | 334 rm -rf build/ |
OLD | NEW |