1//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// TODO We should really separate out those files that are actually needed for both variants of an
18// architecture into its own category. Currently we just include all of the 32bit variant in the
19// 64bit variant. It also might be good to allow one to compile only the 64bit variant without the
20// 32bit one.
21
22package {
23    // See: http://go/android-license-faq
24    // A large-scale-change added 'default_applicable_licenses' to import
25    // all of the 'license_kinds' from "art_license"
26    // to get the below license kinds:
27    //   SPDX-license-identifier-Apache-2.0
28    default_applicable_licenses: ["art_license"],
29    default_team: "trendy_team_art_performance",
30}
31
32// Common dependencies for libart-compiler_deps and libartd-compiler_deps.
33cc_defaults {
34    name: "libart-compiler_common_deps",
35    shared_libs: [
36        "libbase",
37        "liblzma", // libelffile(d) dependency; must be repeated here since it's a static lib.
38        "libartpalette",
39    ],
40    header_libs: [
41        "libart_headers",
42        "libart_generated_headers",
43    ],
44}
45
46// Dependencies of libart-compiler, used to propagate libart-compiler deps when static linking.
47art_cc_defaults {
48    name: "libart-compiler_deps",
49    defaults: ["libart-compiler_common_deps"],
50    shared_libs: [
51        "libartbase",
52        "libprofile",
53        "libdexfile",
54    ],
55    static_libs: ["libelffile"],
56    codegen: {
57        arm: {
58            // VIXL assembly support for ARM targets.
59            static_libs: [
60                "libvixl",
61            ],
62        },
63        arm64: {
64            // VIXL assembly support for ARM64 targets.
65            static_libs: [
66                "libvixl",
67            ],
68        },
69    },
70    // In order to save memory on device `art::HGraphVisualizerDisassembler` loads
71    // `libart-disassembler.so` dynamically. Host builds of `libart-compiler` depend on
72    // `libart-disassembler` directly with `shared_libs` or `static_libs`.
73    target: {
74        host: {
75            shared: {
76                shared_libs: [
77                    "libart-disassembler",
78                ],
79            },
80        },
81        android: {
82            runtime_libs: [
83                "libart-disassembler",
84            ],
85        },
86    },
87}
88
89// Dependencies of libartd-compiler, used to propagate libartd-compiler deps when static linking.
90art_cc_defaults {
91    name: "libartd-compiler_deps",
92    defaults: ["libart-compiler_common_deps"],
93    shared_libs: [
94        "libartbased",
95        "libprofiled",
96        "libdexfiled",
97    ],
98    static_libs: ["libelffiled"],
99    codegen: {
100        arm: {
101            // VIXL assembly support for ARM targets.
102            static_libs: [
103                "libvixld",
104            ],
105        },
106        arm64: {
107            // VIXL assembly support for ARM64 targets.
108            static_libs: [
109                "libvixld",
110            ],
111        },
112    },
113    // In order to save memory on device `art::HGraphVisualizerDisassembler` loads
114    // `libartd-disassembler.so` dynamically. Host builds of `libartd-compiler` depend on
115    // `libartd-disassembler` directly with `shared_libs` or `static_libs`.
116    target: {
117        host: {
118            shared: {
119                shared_libs: [
120                    "libartd-disassembler",
121                ],
122            },
123        },
124        android: {
125            runtime_libs: [
126                "libartd-disassembler",
127            ],
128        },
129    },
130}
131
132art_cc_defaults {
133    name: "libart-compiler-defaults",
134    defaults: ["art_defaults"],
135    host_supported: true,
136    srcs: [
137        "debug/elf_debug_writer.cc",
138        "dex/inline_method_analyser.cc",
139        "driver/compiler_options.cc",
140        "driver/dex_compilation_unit.cc",
141        "jit/jit_compiler.cc",
142        "jit/jit_logger.cc",
143        "jni/quick/calling_convention.cc",
144        "jni/quick/jni_compiler.cc",
145        "optimizing/block_builder.cc",
146        "optimizing/block_namer.cc",
147        "optimizing/bounds_check_elimination.cc",
148        "optimizing/builder.cc",
149        "optimizing/cha_guard_optimization.cc",
150        "optimizing/code_generation_data.cc",
151        "optimizing/code_generator.cc",
152        "optimizing/code_generator_utils.cc",
153        "optimizing/code_sinking.cc",
154        "optimizing/constant_folding.cc",
155        "optimizing/constructor_fence_redundancy_elimination.cc",
156        "optimizing/data_type.cc",
157        "optimizing/dead_code_elimination.cc",
158        "optimizing/escape.cc",
159        "optimizing/graph_checker.cc",
160        "optimizing/graph_visualizer.cc",
161        "optimizing/gvn.cc",
162        "optimizing/induction_var_analysis.cc",
163        "optimizing/induction_var_range.cc",
164        "optimizing/inliner.cc",
165        "optimizing/instruction_builder.cc",
166        "optimizing/instruction_simplifier.cc",
167        "optimizing/intrinsic_objects.cc",
168        "optimizing/intrinsics.cc",
169        "optimizing/licm.cc",
170        "optimizing/linear_order.cc",
171        "optimizing/load_store_analysis.cc",
172        "optimizing/load_store_elimination.cc",
173        "optimizing/locations.cc",
174        "optimizing/loop_analysis.cc",
175        "optimizing/loop_optimization.cc",
176        "optimizing/nodes.cc",
177        "optimizing/optimization.cc",
178        "optimizing/optimizing_compiler.cc",
179        "optimizing/parallel_move_resolver.cc",
180        "optimizing/prepare_for_register_allocation.cc",
181        "optimizing/profiling_info_builder.cc",
182        "optimizing/reference_type_propagation.cc",
183        "optimizing/register_allocation_resolver.cc",
184        "optimizing/register_allocator.cc",
185        "optimizing/register_allocator_linear_scan.cc",
186        "optimizing/select_generator.cc",
187        "optimizing/scheduler.cc",
188        "optimizing/sharpening.cc",
189        "optimizing/side_effects_analysis.cc",
190        "optimizing/ssa_builder.cc",
191        "optimizing/ssa_liveness_analysis.cc",
192        "optimizing/ssa_phi_elimination.cc",
193        "optimizing/stack_map_stream.cc",
194        "optimizing/superblock_cloner.cc",
195        "optimizing/write_barrier_elimination.cc",
196        "trampolines/trampoline_compiler.cc",
197        "utils/assembler.cc",
198        "utils/jni_macro_assembler.cc",
199        "compiler.cc",
200    ],
201
202    codegen: {
203        arm: {
204            srcs: [
205                "jni/quick/arm/calling_convention_arm.cc",
206                "optimizing/code_generator_arm_vixl.cc",
207                "optimizing/code_generator_vector_arm_vixl.cc",
208                "optimizing/critical_native_abi_fixup_arm.cc",
209                "optimizing/instruction_simplifier_arm.cc",
210                "optimizing/instruction_simplifier_shared.cc",
211                "optimizing/intrinsics_arm_vixl.cc",
212                "optimizing/nodes_shared.cc",
213                "optimizing/scheduler_arm.cc",
214                "utils/arm/assembler_arm_vixl.cc",
215                "utils/arm/constants_arm.cc",
216                "utils/arm/jni_macro_assembler_arm_vixl.cc",
217                "utils/arm/managed_register_arm.cc",
218            ],
219        },
220        arm64: {
221            srcs: [
222                "jni/quick/arm64/calling_convention_arm64.cc",
223                "optimizing/code_generator_arm64.cc",
224                "optimizing/code_generator_vector_arm64_neon.cc",
225                "optimizing/code_generator_vector_arm64_sve.cc",
226                "optimizing/jit_patches_arm64.cc",
227                "optimizing/scheduler_arm64.cc",
228                "optimizing/instruction_simplifier_arm64.cc",
229                "optimizing/intrinsics_arm64.cc",
230                "utils/arm64/assembler_arm64.cc",
231                "utils/arm64/jni_macro_assembler_arm64.cc",
232                "utils/arm64/managed_register_arm64.cc",
233            ],
234        },
235        riscv64: {
236            srcs: [
237                "jni/quick/riscv64/calling_convention_riscv64.cc",
238                "optimizing/code_generator_riscv64.cc",
239                "optimizing/critical_native_abi_fixup_riscv64.cc",
240                "optimizing/instruction_simplifier_riscv64.cc",
241                "optimizing/intrinsics_riscv64.cc",
242                "utils/riscv64/assembler_riscv64.cc",
243                "utils/riscv64/jni_macro_assembler_riscv64.cc",
244                "utils/riscv64/managed_register_riscv64.cc",
245            ],
246        },
247        x86: {
248            srcs: [
249                "jni/quick/x86/calling_convention_x86.cc",
250                "optimizing/code_generator_x86.cc",
251                "optimizing/code_generator_vector_x86.cc",
252                "optimizing/intrinsics_x86.cc",
253                "optimizing/instruction_simplifier_x86_shared.cc",
254                "optimizing/instruction_simplifier_x86.cc",
255                "optimizing/pc_relative_fixups_x86.cc",
256                "optimizing/x86_memory_gen.cc",
257                "utils/x86/assembler_x86.cc",
258                "utils/x86/jni_macro_assembler_x86.cc",
259                "utils/x86/managed_register_x86.cc",
260            ],
261        },
262        x86_64: {
263            srcs: [
264                "jni/quick/x86_64/calling_convention_x86_64.cc",
265                "optimizing/intrinsics_x86_64.cc",
266                "optimizing/instruction_simplifier_x86_64.cc",
267                "optimizing/code_generator_x86_64.cc",
268                "optimizing/code_generator_vector_x86_64.cc",
269                "utils/x86_64/assembler_x86_64.cc",
270                "utils/x86_64/jni_macro_assembler_x86_64.cc",
271                "utils/x86_64/managed_register_x86_64.cc",
272            ],
273        },
274    },
275    generated_sources: ["art_compiler_operator_srcs"],
276    header_libs: [
277        "art_cmdlineparser_headers", // For compiler_options.
278        "art_disassembler_headers",
279        "libnativehelper_header_only",
280    ],
281
282    export_include_dirs: ["."],
283}
284
285cc_defaults {
286    name: "libart-compiler_static_base_defaults",
287    whole_static_libs: [
288        "libbase",
289    ],
290}
291
292gensrcs {
293    name: "art_compiler_operator_srcs",
294    cmd: "$(location generate_operator_out) art/compiler $(in) > $(out)",
295    tools: ["generate_operator_out"],
296    srcs: [
297        "linker/linker_patch.h",
298        "optimizing/locations.h",
299        "optimizing/nodes.h",
300        "optimizing/optimizing_compiler_stats.h",
301
302        "utils/arm/constants_arm.h",
303    ],
304    output_extension: "operator_out.cc",
305}
306
307art_cc_library_static {
308    name: "libart-compiler",
309    defaults: [
310        "libart-compiler-defaults",
311        "libart-compiler_deps",
312    ],
313    target: {
314        android: {
315            lto: {
316                thin: true,
317            },
318        },
319    },
320    apex_available: [
321        "com.android.art",
322        "com.android.art.debug",
323        "test_broken_com.android.art",
324    ],
325}
326
327// For static linking with gtests. Same as `libart-compiler`, but without LTO.
328// When gtests static link a library with LTO enabled, they are also built with LTO.
329// This makes the build process use a lot of memory. b/277207452
330art_cc_library_static {
331    name: "libart-compiler-for-test",
332    defaults: [
333        "libart-compiler-defaults",
334        "libart-compiler_deps",
335    ],
336}
337
338cc_defaults {
339    name: "libart-compiler_static_defaults",
340    defaults: [
341        "libart-compiler_static_base_defaults",
342        "libart-disassembler_static_defaults",
343        "libartbase_static_defaults",
344        "libdexfile_static_defaults",
345        "libprofile_static_defaults",
346    ],
347    whole_static_libs: ["libart-compiler"],
348}
349
350// libart-compiler_static_defaults for standalone gtests.
351// Uses libart-compiler-for-test instead of libart-compiler.
352cc_defaults {
353    name: "libart-compiler-for-test_static_defaults",
354    defaults: [
355        "libart-compiler_static_base_defaults",
356        "libart-disassembler_static_defaults",
357        "libartbase_static_defaults",
358        "libdexfile_static_defaults",
359        "libprofile_static_defaults",
360    ],
361    whole_static_libs: ["libart-compiler-for-test"],
362}
363
364art_cc_library_static {
365    name: "libartd-compiler",
366    defaults: [
367        "art_debug_defaults",
368        "libart-compiler-defaults",
369        "libartd-compiler_deps",
370    ],
371    apex_available: [
372        "com.android.art.debug",
373        // TODO(b/183882457): This lib doesn't go into com.android.art, but
374        // apex_available lists need to be the same for internal libs to avoid
375        // stubs, and this depends on libdexfiled.
376        "com.android.art",
377    ],
378}
379
380cc_defaults {
381    name: "libartd-compiler_static_defaults",
382    defaults: [
383        "libart-compiler_static_base_defaults",
384        "libartbased_static_defaults",
385        "libartd-disassembler_static_defaults",
386        "libdexfiled_static_defaults",
387        "libprofiled_static_defaults",
388    ],
389    whole_static_libs: ["libartd-compiler"],
390}
391
392// Export headers required by `libart-runtime` to use JIT from `libart-compiler`.
393cc_library_headers {
394    name: "libart-compiler_jit_headers",
395    defaults: ["art_defaults"],
396    host_supported: true,
397    export_include_dirs: ["export"],
398    apex_available: [
399        "com.android.art",
400        "com.android.art.debug",
401        "test_broken_com.android.art",
402    ],
403}
404
405// Properties common to `libart-compiler-gtest` and `libartd-compiler-gtest`.
406art_cc_defaults {
407    name: "libart-compiler-gtest-common",
408    srcs: [
409        "common_compiler_test.cc",
410    ],
411    header_libs: [
412        "libart_headers",
413    ],
414}
415
416art_cc_library_static {
417    name: "libart-compiler-gtest",
418    defaults: [
419        "libart-gtest-defaults",
420        "libart-compiler-gtest-common",
421        "libart-compiler-for-test_static_defaults",
422    ],
423}
424
425art_cc_library_static {
426    name: "libartd-compiler-gtest",
427    defaults: [
428        "art_debug_defaults",
429        "libart-gtest-defaults",
430        "libart-compiler-gtest-common",
431        // Note that `libartd-compiler-for-test` is not required here, because
432        // `libartd-compiler` doesn't use LTO.
433        "libartd-compiler_static_defaults",
434    ],
435}
436
437art_cc_defaults {
438    name: "art_compiler_tests_defaults",
439    data: [
440        ":art-gtest-jars-ExceptionHandle",
441        ":art-gtest-jars-Interfaces",
442        ":art-gtest-jars-Main",
443        ":art-gtest-jars-MyClassNatives",
444    ],
445    tidy_timeout_srcs: [
446        "jni/jni_compiler_test.cc",
447        "optimizing/codegen_test.cc",
448        "optimizing/constant_folding_test.cc",
449        "optimizing/induction_var_range_test.cc",
450        "optimizing/load_store_elimination_test.cc",
451        "optimizing/ssa_test.cc",
452    ],
453    srcs: [
454        "compiler_reflection_test.cc",
455        "debug/dwarf/dwarf_test.cc",
456        "debug/src_map_elem_test.cc",
457        "exception_test.cc",
458        "jni/jni_compiler_test.cc",
459        "linker/linker_patch_test.cc",
460        "linker/output_stream_test.cc",
461        "optimizing/bounds_check_elimination_test.cc",
462        "optimizing/constant_folding_test.cc",
463        "optimizing/data_type_test.cc",
464        "optimizing/dead_code_elimination_test.cc",
465        "optimizing/dominator_test.cc",
466        "optimizing/find_loops_test.cc",
467        "optimizing/graph_checker_test.cc",
468        "optimizing/graph_test.cc",
469        "optimizing/gvn_test.cc",
470        "optimizing/induction_var_analysis_test.cc",
471        "optimizing/induction_var_range_test.cc",
472        "optimizing/licm_test.cc",
473        "optimizing/linearize_test.cc",
474        "optimizing/live_interval_test.cc",
475        "optimizing/live_ranges_test.cc",
476        "optimizing/liveness_test.cc",
477        "optimizing/loop_optimization_test.cc",
478        "optimizing/nodes_test.cc",
479        "optimizing/nodes_vector_test.cc",
480        "optimizing/parallel_move_test.cc",
481        "optimizing/pretty_printer_test.cc",
482        "optimizing/reference_type_propagation_test.cc",
483        "optimizing/select_generator_test.cc",
484        "optimizing/side_effects_test.cc",
485        "optimizing/ssa_liveness_analysis_test.cc",
486        "optimizing/ssa_test.cc",
487        "optimizing/stack_map_test.cc",
488        "optimizing/superblock_cloner_test.cc",
489        "optimizing/suspend_check_test.cc",
490        "utils/atomic_dex_ref_map_test.cc",
491        "utils/dedupe_set_test.cc",
492
493        "optimizing/codegen_test.cc",
494        "optimizing/instruction_simplifier_test.cc",
495        "optimizing/load_store_analysis_test.cc",
496        "optimizing/load_store_elimination_test.cc",
497        "optimizing/scheduler_test.cc",
498    ],
499
500    codegen: {
501        arm: {
502            srcs: [
503                "utils/arm/managed_register_arm_test.cc",
504            ],
505        },
506        arm64: {
507            srcs: [
508                "utils/arm64/managed_register_arm64_test.cc",
509            ],
510        },
511        riscv64: {
512            srcs: [
513                "utils/riscv64/managed_register_riscv64_test.cc",
514            ],
515        },
516        x86: {
517            srcs: [
518                "utils/x86/managed_register_x86_test.cc",
519
520                // This test is testing architecture-independent functionality,
521                // but happens to use x86 codegen as part of the test.
522                "optimizing/register_allocator_test.cc",
523            ],
524        },
525        x86_64: {
526            srcs: [
527                // Is this test a bit-rotten copy of the x86 test? b/77951326
528                // "utils/x86_64/managed_register_x86_64_test.cc",
529            ],
530        },
531    },
532
533    header_libs: [
534        "libart_simulator_headers",
535        "libnativehelper_header_only",
536    ],
537
538    target: {
539        host: {
540            shared_libs: [
541                "libartd-simulator",
542            ],
543        },
544    },
545}
546
547// Version of ART gtest `art_compiler_tests` bundled with the ART APEX on target.
548// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
549art_cc_test {
550    name: "art_compiler_tests",
551    defaults: [
552        "art_gtest_defaults",
553        "art_compiler_tests_defaults",
554    ],
555    static_libs: [
556        "libartd-simulator-container",
557    ],
558}
559
560// Standalone version of ART gtest `art_compiler_tests`, not bundled with the ART APEX on target.
561art_cc_test {
562    name: "art_standalone_compiler_tests",
563    defaults: [
564        "art_standalone_gtest_defaults",
565        "art_compiler_tests_defaults",
566    ],
567    data: [":generate-boot-image"],
568    static_libs: [
569        "libart-simulator-container",
570    ],
571    test_config: "art_standalone_compiler_tests.xml",
572}
573
574art_cc_test {
575    name: "art_compiler_host_tests",
576    device_supported: false,
577    defaults: [
578        "art_gtest_defaults",
579    ],
580    srcs: [
581        "jni/jni_cfi_test.cc",
582        "optimizing/optimizing_cfi_test.cc",
583    ],
584    tidy_timeout_srcs: [
585        "utils/x86/assembler_x86_test.cc",
586        "utils/x86_64/assembler_x86_64_test.cc",
587    ],
588    codegen: {
589        arm: {
590            srcs: [
591                "utils/assembler_thumb_test.cc",
592            ],
593        },
594        riscv64: {
595            srcs: [
596                "utils/riscv64/assembler_riscv64_test.cc",
597                "utils/riscv64/jni_macro_assembler_riscv64_test.cc",
598            ],
599        },
600        x86: {
601            srcs: [
602                "utils/x86/assembler_x86_test.cc",
603            ],
604        },
605        x86_64: {
606            srcs: [
607                "utils/x86_64/assembler_x86_64_test.cc",
608            ],
609        },
610    },
611    static_libs: [
612        "libvixld",
613    ],
614}
615