tools build: Add feature test for abi::__cxa_demangle
[linux-block.git] / tools / build / feature / Makefile
CommitLineData
b2441318 1# SPDX-License-Identifier: GPL-2.0
211a741c
SD
2include ../../scripts/Makefile.include
3
2fedf79b
JO
4FILES= \
5 test-all.bin \
6 test-backtrace.bin \
7 test-bionic.bin \
8 test-dwarf.bin \
9 test-dwarf_getlocations.bin \
11c6cbe7 10 test-eventfd.bin \
2fedf79b 11 test-fortify-source.bin \
8feb8efe 12 test-get_current_dir_name.bin \
2fedf79b
JO
13 test-glibc.bin \
14 test-gtk2.bin \
15 test-gtk2-infobar.bin \
16 test-hello.bin \
17 test-libaudit.bin \
18 test-libbfd.bin \
e71e19a9 19 test-libbfd-buildid.bin \
fb982666 20 test-disassembler-four-args.bin \
cfd59ca9 21 test-disassembler-init-styled.bin \
531b014e 22 test-reallocarray.bin \
14541b1e
SF
23 test-libbfd-liberty.bin \
24 test-libbfd-liberty-z.bin \
2fedf79b 25 test-cplus-demangle.bin \
4c72e2b3 26 test-cxa-demangle.bin \
74d5f3d0 27 test-libcap.bin \
2fedf79b
JO
28 test-libelf.bin \
29 test-libelf-getphdrnum.bin \
30 test-libelf-gelf_getnote.bin \
31 test-libelf-getshdrstrndx.bin \
c7a14fdc 32 test-libdebuginfod.bin \
2fedf79b
JO
33 test-libnuma.bin \
34 test-numa_num_possible_cpus.bin \
35 test-libperl.bin \
36 test-libpython.bin \
2fedf79b 37 test-libslang.bin \
cbefd24f 38 test-libslang-include-subdir.bin \
56d32d4c 39 test-libtraceevent.bin \
b758a61b 40 test-libtracefs.bin \
2fedf79b
JO
41 test-libcrypto.bin \
42 test-libunwind.bin \
43 test-libunwind-debug-frame.bin \
44 test-libunwind-x86.bin \
45 test-libunwind-x86_64.bin \
46 test-libunwind-arm.bin \
47 test-libunwind-aarch64.bin \
48 test-libunwind-debug-frame-arm.bin \
49 test-libunwind-debug-frame-aarch64.bin \
50 test-pthread-attr-setaffinity-np.bin \
25ab5abf 51 test-pthread-barrier.bin \
2fedf79b
JO
52 test-stackprotector-all.bin \
53 test-timerfd.bin \
54 test-libdw-dwarf-unwind.bin \
55 test-libbabeltrace.bin \
56 test-compile-32.bin \
57 test-compile-x32.bin \
58 test-zlib.bin \
59 test-lzma.bin \
60 test-bpf.bin \
7b65e203 61 test-libbpf.bin \
2fedf79b
JO
62 test-get_cpuid.bin \
63 test-sdt.bin \
64 test-cxx.bin \
4541a8bb 65 test-gettid.bin \
120010cb 66 test-jvmti.bin \
dd1d0044 67 test-jvmti-cmlr.bin \
86bcdb5a 68 test-sched_getcpu.bin \
aa6292f4 69 test-setns.bin \
36f9dc33
JO
70 test-libopencsd.bin \
71 test-clang.bin \
72 test-llvm.bin \
2a07d814 73 test-llvm-version.bin \
3b1c5d96 74 test-libaio.bin \
14e5728f 75 test-libzstd.bin \
05aca6da 76 test-clang-bpf-co-re.bin \
5ef86146
SE
77 test-file-handle.bin \
78 test-libpfm4.bin
b6aa9979 79
1925459b
JP
80FILES := $(addprefix $(OUTPUT),$(FILES))
81
9961aa66 82PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
8b6eb56a 83
b6aa9979
IM
84all: $(FILES)
85
9961aa66 86__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
1925459b 87 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
629b98e2
RS
88 BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
89 BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd -lcap
b6aa9979 90
9961aa66 91__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
87095f7d
WN
92 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
93
b6aa9979
IM
94###############################
95
1925459b 96$(OUTPUT)test-all.bin:
629b98e2 97 $(BUILD_ALL) || $(BUILD_ALL) -lopcodes -liberty
baa9c30e 98
1925459b 99$(OUTPUT)test-hello.bin:
b6aa9979
IM
100 $(BUILD)
101
1925459b 102$(OUTPUT)test-pthread-attr-setaffinity-np.bin:
b49f1a4b 103 $(BUILD) -D_GNU_SOURCE -lpthread
459a3df7 104
25ab5abf
ACM
105$(OUTPUT)test-pthread-barrier.bin:
106 $(BUILD) -lpthread
107
1925459b 108$(OUTPUT)test-stackprotector-all.bin:
b49f1a4b 109 $(BUILD) -fstack-protector-all
90ac5422 110
1925459b 111$(OUTPUT)test-fortify-source.bin:
b49f1a4b 112 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
1ea6f99e 113
1925459b 114$(OUTPUT)test-bionic.bin:
78e9d655
IM
115 $(BUILD)
116
74d5f3d0
IL
117$(OUTPUT)test-libcap.bin:
118 $(BUILD) -lcap
119
1925459b 120$(OUTPUT)test-libelf.bin:
8f7f8005
IM
121 $(BUILD) -lelf
122
11c6cbe7
ACM
123$(OUTPUT)test-eventfd.bin:
124 $(BUILD)
125
8feb8efe
ACM
126$(OUTPUT)test-get_current_dir_name.bin:
127 $(BUILD)
128
1925459b 129$(OUTPUT)test-glibc.bin:
e12762cf
IM
130 $(BUILD)
131
120010cb
ACM
132$(OUTPUT)test-sched_getcpu.bin:
133 $(BUILD)
134
86bcdb5a
ACM
135$(OUTPUT)test-setns.bin:
136 $(BUILD)
137
aa6292f4
MP
138$(OUTPUT)test-libopencsd.bin:
139 $(BUILD) # -lopencsd_c_api -lopencsd provided by
140 # $(FEATURE_CHECK_LDFLAGS-libopencsd)
141
7aec51cb
AK
142DWARFLIBS := -ldw
143ifeq ($(findstring -static,${LDFLAGS}),-static)
144DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
145endif
146
1925459b 147$(OUTPUT)test-dwarf.bin:
7aec51cb 148 $(BUILD) $(DWARFLIBS)
8295d4e2 149
bd0419e2
ACM
150$(OUTPUT)test-dwarf_getlocations.bin:
151 $(BUILD) $(DWARFLIBS)
152
1925459b 153$(OUTPUT)test-libelf-getphdrnum.bin:
b7bcef6f
IM
154 $(BUILD) -lelf
155
1c1a3a47
ACM
156$(OUTPUT)test-libelf-gelf_getnote.bin:
157 $(BUILD) -lelf
158
2492c465
ACM
159$(OUTPUT)test-libelf-getshdrstrndx.bin:
160 $(BUILD) -lelf
161
c7a14fdc
FCE
162$(OUTPUT)test-libdebuginfod.bin:
163 $(BUILD) -ldebuginfod
164
1925459b 165$(OUTPUT)test-libnuma.bin:
3ae069cf
IM
166 $(BUILD) -lnuma
167
1925459b 168$(OUTPUT)test-numa_num_possible_cpus.bin:
f8ac8606
ACM
169 $(BUILD) -lnuma
170
1925459b 171$(OUTPUT)test-libunwind.bin:
1448fef4 172 $(BUILD) -lelf
058f952d 173
1925459b 174$(OUTPUT)test-libunwind-debug-frame.bin:
1448fef4 175 $(BUILD) -lelf
b1d96000
HK
176$(OUTPUT)test-libunwind-x86.bin:
177 $(BUILD) -lelf -lunwind-x86
178
179$(OUTPUT)test-libunwind-x86_64.bin:
180 $(BUILD) -lelf -lunwind-x86_64
181
182$(OUTPUT)test-libunwind-arm.bin:
183 $(BUILD) -lelf -lunwind-arm
184
185$(OUTPUT)test-libunwind-aarch64.bin:
186 $(BUILD) -lelf -lunwind-aarch64
187
f9be7eef
HK
188$(OUTPUT)test-libunwind-debug-frame-arm.bin:
189 $(BUILD) -lelf -lunwind-arm
190
191$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
192 $(BUILD) -lelf -lunwind-aarch64
e310718d 193
1925459b 194$(OUTPUT)test-libaudit.bin:
d795a658
IM
195 $(BUILD) -laudit
196
1925459b 197$(OUTPUT)test-libslang.bin:
1955c8cf 198 $(BUILD) -lslang
b9498b50 199
cbefd24f
ACM
200$(OUTPUT)test-libslang-include-subdir.bin:
201 $(BUILD) -lslang
202
56d32d4c
MP
203$(OUTPUT)test-libtraceevent.bin:
204 $(BUILD) -ltraceevent
205
b758a61b
IR
206$(OUTPUT)test-libtracefs.bin:
207 $(BUILD) -ltracefs
208
8ee46460
SE
209$(OUTPUT)test-libcrypto.bin:
210 $(BUILD) -lcrypto
211
1925459b 212$(OUTPUT)test-gtk2.bin:
93e843f9 213 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) -Wno-deprecated-declarations
7ef9e055 214
1925459b 215$(OUTPUT)test-gtk2-infobar.bin:
a8a5cd8b 216 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
c7a79e96 217
7181a671
IM
218grep-libs = $(filter -l%,$(1))
219strip-libs = $(filter-out -l%,$(1))
220
221PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
222PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
223PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
541f695c 224PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
7181a671
IM
225FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
226
41caff45
ACM
227ifeq ($(CC_NO_CLANG), 0)
228 PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
229 PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
230 PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
231 FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro
232endif
233
1925459b 234$(OUTPUT)test-libperl.bin:
7181a671
IM
235 $(BUILD) $(FLAGS_PERL_EMBED)
236
1925459b 237$(OUTPUT)test-libpython.bin:
7be6b316 238 $(BUILD) $(FLAGS_PYTHON_EMBED)
9734163b 239
1925459b 240$(OUTPUT)test-libbfd.bin:
629b98e2 241 $(BUILD_BFD)
3b7646e4 242
e71e19a9 243$(OUTPUT)test-libbfd-buildid.bin:
629b98e2 244 $(BUILD_BFD) || $(BUILD_BFD) -liberty || $(BUILD_BFD) -liberty -lz
e71e19a9 245
fb982666 246$(OUTPUT)test-disassembler-four-args.bin:
629b98e2
RS
247 $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
248 $(BUILD_BFD) -lopcodes -liberty -lz
fb982666 249
cfd59ca9 250$(OUTPUT)test-disassembler-init-styled.bin:
629b98e2
RS
251 $(BUILD_BFD) -lopcodes || $(BUILD_BFD) -lopcodes -liberty || \
252 $(BUILD_BFD) -lopcodes -liberty -lz
cfd59ca9 253
531b014e
JK
254$(OUTPUT)test-reallocarray.bin:
255 $(BUILD)
256
14541b1e 257$(OUTPUT)test-libbfd-liberty.bin:
1925459b 258 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
1c47661a 259
14541b1e 260$(OUTPUT)test-libbfd-liberty-z.bin:
1925459b 261 $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
1c47661a 262
1925459b 263$(OUTPUT)test-cplus-demangle.bin:
1c47661a
IM
264 $(BUILD) -liberty
265
4c72e2b3
IR
266$(OUTPUT)test-cxa-demangle.bin:
267 $(BUILDXX)
268
1925459b 269$(OUTPUT)test-backtrace.bin:
4cc9117a
IM
270 $(BUILD)
271
1925459b 272$(OUTPUT)test-timerfd.bin:
87419c9a
DA
273 $(BUILD)
274
1925459b 275$(OUTPUT)test-libdw-dwarf-unwind.bin:
53d0a573
JO
276 $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
277
1925459b 278$(OUTPUT)test-libbabeltrace.bin:
53d0a573 279 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
45757895 280
1925459b
JP
281$(OUTPUT)test-compile-32.bin:
282 $(CC) -m32 -o $@ test-compile.c
e477f3f0 283
1925459b
JP
284$(OUTPUT)test-compile-x32.bin:
285 $(CC) -mx32 -o $@ test-compile.c
e477f3f0 286
1925459b 287$(OUTPUT)test-zlib.bin:
e92ce12e
NK
288 $(BUILD) -lz
289
1925459b 290$(OUTPUT)test-lzma.bin:
6c6f0f61
JO
291 $(BUILD) -llzma
292
1925459b 293$(OUTPUT)test-get_cpuid.bin:
b0063dbf
ACM
294 $(BUILD)
295
1925459b 296$(OUTPUT)test-bpf.bin:
1b76c13e
WN
297 $(BUILD)
298
7b65e203
JO
299$(OUTPUT)test-libbpf.bin:
300 $(BUILD) -lbpf
301
0ae065a5
ACM
302$(OUTPUT)test-libbpf-btf__load_from_kernel_by_id.bin:
303 $(BUILD) -lbpf
304
5c83eff3
JO
305$(OUTPUT)test-libbpf-bpf_prog_load.bin:
306 $(BUILD) -lbpf
307
df76e003
ACM
308$(OUTPUT)test-libbpf-bpf_map_create.bin:
309 $(BUILD) -lbpf
310
8916d725
JO
311$(OUTPUT)test-libbpf-bpf_object__next_program.bin:
312 $(BUILD) -lbpf
313
739c9180
JO
314$(OUTPUT)test-libbpf-bpf_object__next_map.bin:
315 $(BUILD) -lbpf
316
f1bdebbb
ACM
317$(OUTPUT)test-libbpf-bpf_program__set_insns.bin:
318 $(BUILD) -lbpf
319
982be477
JO
320$(OUTPUT)test-libbpf-btf__raw_data.bin:
321 $(BUILD) -lbpf
322
e26e63be
MH
323$(OUTPUT)test-sdt.bin:
324 $(BUILD)
325
87095f7d
WN
326$(OUTPUT)test-cxx.bin:
327 $(BUILDXX) -std=gnu++11
328
4541a8bb
ACM
329$(OUTPUT)test-gettid.bin:
330 $(BUILD)
331
285932a2
JO
332$(OUTPUT)test-jvmti.bin:
333 $(BUILD)
334
dd1d0044
JO
335$(OUTPUT)test-jvmti-cmlr.bin:
336 $(BUILD)
337
cb40d55b 338$(OUTPUT)test-llvm.bin:
d0d0f0c1 339 $(BUILDXX) -std=gnu++14 \
cb40d55b
WN
340 -I$(shell $(LLVM_CONFIG) --includedir) \
341 -L$(shell $(LLVM_CONFIG) --libdir) \
342 $(shell $(LLVM_CONFIG) --libs Core BPF) \
5fb3d8b7
JO
343 $(shell $(LLVM_CONFIG) --system-libs) \
344 > $(@:.bin=.make.output) 2>&1
cb40d55b 345
a940cad3 346$(OUTPUT)test-llvm-version.bin:
d0d0f0c1 347 $(BUILDXX) -std=gnu++14 \
5fb3d8b7
JO
348 -I$(shell $(LLVM_CONFIG) --includedir) \
349 > $(@:.bin=.make.output) 2>&1
a940cad3 350
c7fb4f62 351$(OUTPUT)test-clang.bin:
d0d0f0c1 352 $(BUILDXX) -std=gnu++14 \
c7fb4f62
WN
353 -I$(shell $(LLVM_CONFIG) --includedir) \
354 -L$(shell $(LLVM_CONFIG) --libdir) \
355 -Wl,--start-group -lclangBasic -lclangDriver \
356 -lclangFrontend -lclangEdit -lclangLex \
357 -lclangAST -Wl,--end-group \
358 $(shell $(LLVM_CONFIG) --libs Core option) \
5fb3d8b7
JO
359 $(shell $(LLVM_CONFIG) --system-libs) \
360 > $(@:.bin=.make.output) 2>&1
c7fb4f62 361
1925459b 362-include $(OUTPUT)*.d
8b6eb56a 363
2a07d814
AB
364$(OUTPUT)test-libaio.bin:
365 $(BUILD) -lrt
366
3b1c5d96
AB
367$(OUTPUT)test-libzstd.bin:
368 $(BUILD) -lzstd
369
05aca6da 370$(OUTPUT)test-clang-bpf-co-re.bin:
14e5728f
SL
371 $(CLANG) -S -g -target bpf -o - $(patsubst %.bin,%.c,$(@F)) | \
372 grep BTF_KIND_VAR
373
49f550ea
NK
374$(OUTPUT)test-file-handle.bin:
375 $(BUILD)
14e5728f 376
5ef86146
SE
377$(OUTPUT)test-libpfm4.bin:
378 $(BUILD) -lpfm
379
b6aa9979
IM
380###############################
381
382clean:
1925459b 383 rm -f $(FILES) $(OUTPUT)*.d $(FILES:.bin=.make.output)