forked from ponylang/ponyc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile-lib-llvm
136 lines (120 loc) · 5.25 KB
/
Makefile-lib-llvm
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
# This makefile invokes lib/llvm/Makefile before invoking Makefile-ponyc.
# The reason for doing this is that Makefile-ponyc requires llvm-config to
# be present before it is invoked, thus the need to build lib/llvm/Makefile
# first.
#
# The default configuraton of this makefile builds llvm defined by the submodule,
# which is currently llvm-7.0.1. You may also build other configurations by setting
# LLVM_CFG on the command line. See `make -f Makefile-lib-llvm help` for more info.
#
# In the future compiling lib/llvm will be incorporated into Makefile
# and Makefile-lib-llvm will be removed.
config ?= release
root_dir := $(shell pwd)
pony_lib_llvm_dir := $(root_dir)/lib/llvm
llvm_target := all
ifneq ($(llvm_proj),)
$(error "llvm_proj is now named llvm_target")
endif
llvm_config := $(pony_lib_llvm_dir)/dist/bin/llvm-config
new_path := $(pony_lib_llvm_dir)/dist/bin:$(PATH)
pony_targets := libponyc libponyrt libponyrt-pic libponyc.tests libponyrt.tests libponyc.benchmarks
pony_targets += libponyrt.benchmarks ponyc benchmark install uninstall stats test all
pony_targets += stdlib test-stdlib stdlib-debug test-stdlib-debug test-examples test-ci docs-online
.PHONY: $(pony_targets)
$(pony_targets): $(llvm_config)
@PATH="$(new_path)" $(MAKE) -f Makefile-ponyc LLVM_VENDOR=true config=$(config) LLVM_CONFIG=$(llvm_config) $(MAKECMDGOALS)
.PHONY: $(llvm_config)
$(llvm_config):
@$(MAKE) -C $(pony_lib_llvm_dir) $(llvm_target)
# Clean is needed otherwise the rebuild of llvm won't be linked
.PHONY: rebuild
rebuild: clean
@$(MAKE) -C $(pony_lib_llvm_dir) rebuild
@PATH="$(new_path)" $(MAKE) -f Makefile-ponyc LLVM_VENDOR=true config=$(config)
# Clean is needed otherwise the rebuild of llvm won't be linked
.PHONY: rebuild-test
rebuild-test: clean
@$(MAKE) -C $(pony_lib_llvm_dir) rebuild
@PATH="$(new_path)" $(MAKE) test -f Makefile-ponyc LLVM_VENDOR=true config=$(config)
# Rebuild and then run some tests as passed in the command line parameter gtest_filter.
# Note, the clean is needed otherwise the rebuild of llvm won't be linked.
#
# For example:
# $ time CC=clang CXX=clang++ make -j10 -f Makefile-lib-llvm \
# verbose=1 config=debug default_pic=true llvm_target=llvm-current rebuild-some-tests \
# gtest_filter=--gtest_filter=CodegenOptimisationTest.MergeSendMessageReordering 2>&1 | tee clang-rebuild-some-tests.txt
.PHONY: rebuild-some-tests
rebuild-some-tests: clean
@$(MAKE) -C $(pony_lib_llvm_dir) rebuild
@PATH="$(new_path)" $(MAKE) -f Makefile-ponyc LLVM_VENDOR=true config=$(config)
@$(MAKE) -f Makefile-lib-llvm some-tests
# Run the some passing gtest_filter on command line, for example:
# make -f Makefile-lib-llvm some-tests gtest_filter=--gtest_filter=CodegenOptimisationTest.MergeSendMessageReordering
.PHONY: some-tests
some-tests:
@PATH="$(new_path)" ./build/debug/libponyc.tests $(gtest_filter)
# Clean just ponyc
.PHONY: clean
clean:
@PATH="$(new_path)" $(MAKE) -f Makefile-ponyc LLVM_VENDOR=true config=$(config) clean
# Clean ponyc and lib/llvm
.PHONY: clean-all
clean-all: clean
@$(MAKE) -C lib/llvm clean
# Clean ponyc and distclean llvm
.PHONY: distclean
distclean: clean
@$(MAKE) -C lib/llvm distclean
.PHONY: help
help:
@echo 'Usage: make [config=name] [options] [use=opt,...] [target]'
@echo
@echo 'CONFIGURATIONS:'
@echo ' debug'
@echo ' release (default)'
@echo
@echo 'ARCHITECTURE:'
@echo ' native (default)'
@echo ' [any compiler supported architecture]'
@echo
@echo 'options:'
@echo ' arch=Name Architecture if Name not specified then host name'
@echo ' default_pic=true Make --pic the default'
@echo ' llvm_target=Target Make llvm where Target is one of:'
@echo ' all (default if not specified)'
@echo ' rebuild'
@echo ' link=XXX ponyc linking strategy'
@echo ' static (completely static only works with musl)'
@echo ' llvm-static (default - statically link LLVM)'
@echo ' llvm-dynamic (dynamically link LLVM)'
@sh $(pony_lib_llvm_dir)/llvm-options.sh
@echo
@echo 'USE OPTIONS:'
@echo ' valgrind'
@echo ' pooltrack'
@echo ' dtrace'
@echo ' actor_continuations'
@echo ' coverage'
@echo ' scheduler_scaling_pthreads'
@echo
@echo 'TARGETS:'
@echo ' libponyc Pony compiler library'
@echo ' libponyrt Pony runtime'
@echo ' libponyrt-pic Pony runtime -fpic'
@echo ' libponyc.tests Test suite for libponyc'
@echo ' libponyrt.tests Test suite for libponyrt'
@echo ' libponyc.benchmarks Benchmark suite for libponyc'
@echo ' libponyrt.benchmarks Benchmark suite for libponyrt'
@echo ' ponyc Pony compiler executable'
@echo
@echo ' all Build all of the above (default)'
@echo ' test Run test suite'
@echo ' benchmark Build and run benchmark suite'
@echo ' install Install ponyc'
@echo ' uninstall Remove all versions of ponyc'
@echo ' stats Print Pony cloc statistics'
@echo ' clean Delete all build files but nothing in $(pony_llvm_dir)'
@echo ' clean-all clean plus clean $(pony_llvm_dir)'
@echo ' distclean clean plus distclean $(pony_llvm_dir)'
@echo