Debian Codegraph @

mcs/tools/linker/Makefile

raw
1 thisdir = tools/linker
2 SUBDIRS =
3 include ../../build/rules.make
4
5 PROGRAM = monolinker.exe
6
7 LIB_REFS = System System.Core System.Xml Mono.Cecil
8 LOCAL_MCS_FLAGS = -unsafe
9
10 TEST_CASES := \
11 mscorlib/test-array.cs \
12 mscorlib/test-calendar-01.cs \
13 mscorlib/test-calendar-02.cs \
14 mscorlib/test-exception-01.cs \
15 mscorlib/test-locale-01.cs \
16 mscorlib/test-methodimpl-01.cs \
17 mscorlib/test-reflection-01.cs \
18 mscorlib/test-reflection-02.cs \
19 mscorlib/test-reflection-03.cs \
20 mscorlib/test-reflection-04.cs \
21 mscorlib/test-string-01.cs \
22 mscorlib/test-string-02.cs \
23 mscorlib/test-string-03.cs \
24 mscorlib/test-task-01.cs \
25 System/test-security.cs \
26 System/test-typeconverter.cs \
27 System.Core/test-plinq-01.cs
28
29 ifdef INCLUDE_DISABLED
30 TEST_CASES += \
31 System.Runtime.Serialization/test-dcs-01.cs \
32 mscorlib/test-marshaling.cs
33 endif
34
35 ifdef MOBILE_PROFILE
36 TEST_CASES += \
37 mscorlib/test-crypto-01.cs \
38 System.Net.Http/test-handler-01.cs
39 endif
40
41 ifndef AOT_FRIENDLY_PROFILE
42 TEST_CASES += \
43 mscorlib/test-remoting.cs \
44 mscorlib/test-reflection.cs \
45 System.Core/test-queryable-01.cs \
46 System.Core/test-queryable-02.cs
47 endif
48
49 ifdef MCS_MODE
50 NO_INSTALL=1
51 NO_BUILD=1
52 NO_TEST=1
53 endif
54
55 TESTS_COMPILER = $(MCS) -nologo -noconfig -unsafe -nostdlib -debug:portable -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/mscorlib.dll
56
57 MARSHALING_TEST_NATIVE = mscorlib/test-marshaling-native.so
58
59 check: compile-tests
60 $(MAKE) run-tests
61
62 compile-tests: $(TEST_CASES)
63
64 mscorlib/test-%.cs:
65 $(TESTS_COMPILER) Tests/$@ /out:Tests/$(@:.cs=.exe)
66
67 $(MARSHALING_TEST_NATIVE): $(@:.so=.c)
68 $(CCOMPILE) Tests/$(@:.so=.c) -shared -o Tests/$@
69
70 mscorlib/test-marshaling.cs: $(MARSHALING_TEST_NATIVE)
71 $(TESTS_COMPILER) Tests/$@ /out:Tests/$(@:.cs=.exe)
72
73 System/test-%.cs:
74 $(TESTS_COMPILER) -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/System.dll Tests/$@ /out:Tests/$(@:.cs=.exe)
75
76 System.Core/test-%.cs:
77 $(TESTS_COMPILER) -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/System.Core.dll Tests/$@ /out:Tests/$(@:.cs=.exe)
78
79 System.Runtime.Serialization/test-%.cs:
80 $(TESTS_COMPILER) -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/System.Runtime.Serialization.dll -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/System.Xml.dll Tests/$@ /out:Tests/$(@:.cs=.exe)
81
82 System.Net.Http/test-%.cs:
83 $(TESTS_COMPILER) -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/System.dll -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/System.Net.Http.dll Tests/$@ /out:Tests/$(@:.cs=.exe)
84
85 run-tests: $(TEST_CASES:.cs=.exe)
86
87 LINKER_PROFILE_OPTIONS :=
88
89 BINARY_TEST_CASES =
90
91 ifeq ($(PROFILE),net_4_x)
92 BINARY_TEST_CASES_ROOT:=../../../external/illinker-test-assets/net_4_x/
93
94 BINARY_TEST_CASES = \
95 $(BINARY_TEST_CASES_ROOT)Newtonsoft.Json.Test/bin/Release/Newtonsoft.Json.Test.exe
96 endif
97
98 ifeq ($(PROFILE),monotouch)
99
100 # Should be in sync with runtime sdk flags
101 LINKER_PROFILE_OPTIONS += --exclude-feature remoting --exclude-feature com --exclude-feature etw
102
103 # System.Net.Http needs Xamarin.iOS.dll
104 LINKER_PROFILE_OPTIONS += -d ../../../external/binary-reference-assemblies/build/monotouch
105
106 BINARY_TEST_CASES_ROOT:=../../../external/illinker-test-assets/monotouch/
107
108 BINARY_TEST_CASES = \
109 $(BINARY_TEST_CASES_ROOT)Newtonsoft.Json.Test/bin/iPhoneSimulator/Release/Newtonsoft.Json.Test.exe
110 endif
111
112 ifeq ($(PROFILE),wasm)
113 LINKER_PROFILE_OPTIONS += --exclude-feature remoting --exclude-feature com --exclude-feature etw -d $(topdir)/../external/binary-reference-assemblies/build/monowasm
114
115 BINARY_TEST_CASES_ROOT:=../../../external/illinker-test-assets/wasm/
116
117 BINARY_TEST_CASES = \
118 $(BINARY_TEST_CASES_ROOT)Newtonsoft/bin/Release/netstandard2.0/dist/_framework/_bin/Newtonsoft.dll \
119 $(BINARY_TEST_CASES_ROOT)HelloWorld/bin/Release/netstandard2.0/dist/_framework/_bin/HelloWorld.dll \
120 $(BINARY_TEST_CASES_ROOT)Microsoft.AspNetCore.Blazor.E2EPerformance/bin/Release/netstandard2.0/Microsoft.AspNetCore.Blazor.E2EPerformance.dll \
121 $(BINARY_TEST_CASES_ROOT)BlazingPizza.Client/bin/Release/netstandard2.0/BlazingPizza.Client.dll
122 endif
123
124 LINKER_OUTPUT := illink-output-$(PROFILE_DIRECTORY)
125 PROFILE_PATH = $(topdir)/class/lib/$(PROFILE_DIRECTORY)
126 LINKER = MONO_PATH=$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE) $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/monolinker.exe -c link -o $(LINKER_OUTPUT) -b true -d $(PROFILE_PATH)
127 LINKER_DEFAULT = $(LINKER) -l none $(LINKER_PROFILE_OPTIONS)
128 TEST_EXEC = MONO_PATH=$(LINKER_OUTPUT) $(RUNTIME) $(RUNTIME_FLAGS) --debug -O=-aot
129
130 .NOTPARALLEL:
131
132 System.Net.Http/test-%.exe System.Runtime.Serialization/test-%.exe System.Core/test-%.exe System/test-%.exe mscorlib/test-%.exe:
133 @rm -rf $(LINKER_OUTPUT)
134 @mkdir $(LINKER_OUTPUT)
135 @echo Testing $@
136 $(LINKER_DEFAULT) -a Tests/$@
137 $(TEST_EXEC) $(LINKER_OUTPUT)/$(@F)
138 @rm -rf $(LINKER_OUTPUT)
139
140 mscorlib/test-calendar-01.exe:
141 @rm -rf $(LINKER_OUTPUT)
142 @mkdir $(LINKER_OUTPUT)
143 @echo Testing $@
144 $(LINKER) -l mideast $(LINKER_PROFILE_OPTIONS) -a Tests/$@
145 $(TEST_EXEC) $(LINKER_OUTPUT)/$(@F)
146 @rm -rf $(LINKER_OUTPUT)
147
148 mscorlib/test-marshaling.exe: $(MARSHALING_TEST_NATIVE)
149 @rm -rf $(LINKER_OUTPUT)
150 @mkdir $(LINKER_OUTPUT)
151 @echo Testing $@
152 $(LINKER_DEFAULT) -a Tests/$@
153 cp Tests/$(MARSHALING_TEST_NATIVE) $(LINKER_OUTPUT)
154 (cd $(LINKER_OUTPUT); MONO_PATH=. $(RUNTIME) $(RUNTIME_FLAGS) --debug -O=-aot ./$(@F))
155 @rm -rf $(LINKER_OUTPUT)
156
157 BCL_ASSEMBLIES_CORE=mscorlib.dll System.dll System.Core.dll System.Xml.dll
158 BCL_ASSEMBLIES=$(BCL_ASSEMBLIES_CORE) $(sort $(filter-out $(BCL_ASSEMBLIES_CORE), $(notdir $(wildcard $(PROFILE_PATH)/System.*.dll $(PROFILE_PATH)/Microsoft.*.dll $(PROFILE_PATH)/I18*.dll )) ))
159
160 COMMA=,
161 REPORT_FILE=$(PROFILE)-linked-size.csv
162
163 bcl-size-current: compile-tests
164 @echo "App,$$(echo '$(BCL_ASSEMBLIES)' | tr ' ' ',')" > $(REPORT_FILE)
165 @for app in $(sort $(BINARY_TEST_CASES) $(patsubst %.cs,Tests/%.exe,$(TEST_CASES))); do \
166 rm -rf $(LINKER_OUTPUT); \
167 mkdir $(LINKER_OUTPUT); \
168 app_name=$${app#$(BINARY_TEST_CASES_ROOT)}; \
169 app_name=$${app_name#Tests/}; \
170 echo Checking linked BCL size in $(PROFILE) profile for $$app_name; \
171 $(LINKER_DEFAULT) -a $$app; \
172 sizes=""; \
173 for asm in $(BCL_ASSEMBLIES); do \
174 if [ -f "$(LINKER_OUTPUT)/$$asm" ]; then size=$$(wc -c < "$(LINKER_OUTPUT)/$$asm" | tr -d "[:space:]"); else size="0"; fi; \
175 sizes="$$sizes,$$size"; \
176 done; \
177 echo "$$app_name$$sizes" >> $(REPORT_FILE); \
178 rm -rf $(LINKER_OUTPUT); \
179 done;
180
181 bcl-size-diff:
182 @echo "Regenerating BCL Linked Size diff..."
183 $(Q) $(MAKE) bcl-size-current PROFILE=net_4_x || true
184 $(Q) $(MAKE) bcl-size-current PROFILE=monotouch || true
185 $(Q) $(MAKE) bcl-size-current PROFILE=monodroid || true
186 $(Q) $(MAKE) bcl-size-current PROFILE=wasm || true
187 @echo "Checking size differences..."
188 @mkdir -p sizediff
189 $(Q) git diff HEAD "*.csv" > temp.patch
190 $(Q) git show HEAD:./net_4_x-linked-size.csv > net_4_x-linked-size.old.csv
191 $(Q) git show HEAD:./monotouch-linked-size.csv > monotouch-linked-size.old.csv
192 $(Q) git show HEAD:./monodroid-linked-size.csv > monodroid-linked-size.old.csv
193 $(Q) git show HEAD:./wasm-linked-size.csv > wasm-linked-size.old.csv
194 $(Q) sed -e "/@diffdata@/r temp.patch" -e "/@diffdata@/d" -e "/@olddata-net_4_x@/r net_4_x-linked-size.old.csv" -e "/@olddata-net_4_x@/d" -e "/@olddata-monotouch@/r monotouch-linked-size.old.csv" -e "/@olddata-monotouch@/d" -e "/@olddata-monodroid@/r monodroid-linked-size.old.csv" -e "/@olddata-monodroid@/d" -e "/@olddata-wasm@/r wasm-linked-size.old.csv" -e "/@olddata-wasm@/d" -e "/@newdata-net_4_x@/r net_4_x-linked-size.csv" -e "/@newdata-net_4_x@/d" -e "/@newdata-monotouch@/r monotouch-linked-size.csv" -e "/@newdata-monotouch@/d" -e "/@newdata-monodroid@/r monodroid-linked-size.csv" -e "/@newdata-monodroid@/d" -e "/@newdata-wasm@/r wasm-linked-size.csv" -e "/@newdata-wasm@/d" linked-size-diff.html.in > sizediff/index.html
195 $(Q) if [ -s temp.patch ]; then echo "Error: Found BCL Linked Size differences, see mcs/tools/linker/sizediff/index.html."; rm -f temp.patch *.old.csv; exit 1; else echo "No differences found."; rm -f temp.patch *.old.csv; fi
196
197 include ../../build/executable.make