xref: /aosp_15_r20/art/runtime/Android.bp (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1//
2// Copyright (C) 2011 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// Keep the __jit_debug_register_code symbol as a unique symbol during ICF for architectures where
18// we use gold as the linker (arm, x86, x86_64). The symbol is used by the debuggers to detect when
19// new jit code is generated. We don't want it to be called when a different function with the same
20// (empty) body is called.
21package {
22    // See: http://go/android-license-faq
23    // A large-scale-change added 'default_applicable_licenses' to import
24    // all of the 'license_kinds' from "art_license"
25    // to get the below license kinds:
26    //   SPDX-license-identifier-Apache-2.0
27    default_applicable_licenses: ["art_license"],
28    default_team: "trendy_team_art_performance",
29}
30
31JIT_DEBUG_REGISTER_CODE_LDFLAGS = [
32    "-Wl,--keep-unique,__jit_debug_register_code",
33    "-Wl,--keep-unique,__dex_debug_register_code",
34]
35
36// These are defaults for native shared libaries that are expected to be
37// in stack traces often.
38cc_defaults {
39    name: "libart_nativeunwind_defaults",
40    target: {
41        host: {
42            cflags: [
43                "-fsanitize-address-use-after-return=never",
44                "-Wno-unused-command-line-argument",
45            ],
46        },
47    },
48}
49
50cc_library_headers {
51    name: "libart_headers",
52    defaults: ["art_defaults"],
53    host_supported: true,
54
55    export_include_dirs: ["."],
56
57    // ART's macros.h depends on libbase's macros.h.
58    // Note: runtime_options.h depends on cmdline. But we don't really want to export this
59    //       generically. dex2oat takes care of it itself.
60    header_libs: [
61        "art_libartbase_headers",
62        "dlmalloc",
63    ],
64    export_header_lib_headers: [
65        "art_libartbase_headers",
66        "dlmalloc",
67    ],
68
69    // We optimize Thread::Current() with a direct TLS access. This requires
70    // access to a platform specific Bionic header.
71    target: {
72        android: {
73            header_libs: ["bionic_libc_platform_headers"],
74            export_header_lib_headers: ["bionic_libc_platform_headers"],
75        },
76        linux_bionic: {
77            header_libs: ["bionic_libc_platform_headers"],
78            export_header_lib_headers: ["bionic_libc_platform_headers"],
79        },
80    },
81
82    apex_available: [
83        "com.android.art",
84        "com.android.art.debug",
85    ],
86}
87
88// Generated headers target required by libart.
89cc_library_headers {
90    name: "libart_generated_headers",
91    defaults: ["art_defaults"],
92    host_supported: true,
93
94    // asm_support_gen.h (used by asm_support.h) is generated with cpp-define-generator
95    generated_headers: ["cpp-define-generator-asm-support"],
96    // export our headers so the libart(d)-gtest targets can use it as well.
97    export_generated_headers: ["cpp-define-generator-asm-support"],
98
99    apex_available: [
100        "com.android.art",
101        "com.android.art.debug",
102    ],
103}
104
105// Common dependencies for `libart-runtime_deps` and `libartd-runtime_deps`.
106cc_defaults {
107    name: "libart-runtime_common_deps",
108    defaults: ["art_defaults"],
109    host_supported: true,
110    target: {
111        android: {
112            header_libs: [
113                "libnativeloader-headers", // For dlext_namespaces.h
114            ],
115            shared_libs: [
116                "libdl_android",
117                "libstatspull", // for pulled atoms
118                "libstatssocket", // for pulled atoms
119                "libz", // For adler32.
120                "heapprofd_client_api",
121            ],
122            static_libs: [
123                "libmodules-utils-build",
124                "libstatslog_art",
125            ],
126        },
127        host: {
128            shared_libs: [
129                "libz", // For adler32.
130            ],
131        },
132    },
133    header_libs: [
134        "art_cmdlineparser_headers",
135        "cpp-define-generator-definitions",
136        "jni_platform_headers",
137        "libart_headers",
138        "libnativehelper_header_only",
139        "libart_generated_headers",
140        // `libart-runtime` doesn't depend on all `libart-compiler` headers, it only requires
141        // `jit_create` to initialize the JIT compiler.
142        "libart-compiler_jit_headers",
143    ],
144    export_header_lib_headers: [
145        "libart_headers",
146        "libart_generated_headers",
147    ],
148    shared_libs: [
149        "libartpalette",
150        "libbase", // For common macros.
151        "liblog",
152        "liblz4",
153        "liblzma", // libelffile(d) dependency; must be repeated here since it's a static lib.
154        "libnativebridge#impl",
155        "libnativeloader#impl",
156        "libsigchain#impl",
157        "libunwindstack",
158    ],
159    static_libs: ["libodrstatslog"],
160}
161
162cc_defaults {
163    name: "libart-runtime_deps",
164    defaults: ["libart-runtime_common_deps"],
165    static_libs: [
166        "libelffile",
167    ],
168    shared_libs: [
169        "libartbase",
170        "libdexfile#impl",
171        "libprofile",
172    ],
173    export_shared_lib_headers: [
174        "libdexfile#impl",
175    ],
176}
177
178cc_defaults {
179    name: "libartd-runtime_deps",
180    defaults: ["libart-runtime_common_deps"],
181    static_libs: [
182        "libelffiled",
183    ],
184    shared_libs: [
185        "libartbased",
186        "libdexfiled#impl",
187        "libprofiled",
188    ],
189    export_shared_lib_headers: [
190        "libdexfiled#impl",
191    ],
192}
193
194// Common defaults for `libart_defaults`, `libartd_defaults` and `libart-runtime_common_defaults`.
195cc_defaults {
196    name: "libart_common_defaults",
197    defaults: [
198        "art_defaults",
199        "libart_nativeunwind_defaults",
200        "art_hugepage_defaults",
201    ],
202    host_supported: true,
203    target: {
204        android_arm: {
205            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
206        },
207        android_arm64: {
208            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
209        },
210        android_x86: {
211            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
212        },
213        android_x86_64: {
214            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
215        },
216    },
217    runtime_libs: [
218        // Libraries loaded at runtime. Exceptions:
219        //
220        // - Libraries that cannot be listed here due to cyclic dependency:
221        //   - libopenjdk(d)
222        //   - libadbconnection(d)
223        //   - libopenjdkjvmti(d)
224        //     - This one is not loaded programmatically with dlopen, but the
225        //       user needs to specify it with -Xplugin.
226        //   - libperfetto_hprof(d)
227        //   All libraries above needs to be explicitly added to the ART APEX
228        //   (cf. art/build/apex/Android.bp).
229        //
230        // - libicu_jni.so is only loaded to handle dependency order in VM
231        //   startup (see Runtime::InitNativeMethods), but its API is internal
232        //   to com.android.i18n and not used by ART/libcore. Therefore it's not
233        //   listed here to avoid visibility issues. Instead it's linked from
234        //   the ART module namespace through an entry in requireNativeLibs in
235        //   manifest-art.json.
236        "libjavacore",
237    ],
238}
239
240// Common defaults for `libart-runtime_defaults` and `libartd-runtime_defaults`.
241cc_defaults {
242    name: "libart-runtime_common_defaults",
243    defaults: ["libart_common_defaults"],
244    srcs: [
245        "app_info.cc",
246        "art_field.cc",
247        "art_method.cc",
248        "backtrace_helper.cc",
249        "barrier.cc",
250        "base/gc_visited_arena_pool.cc",
251        "base/locks.cc",
252        "base/mem_map_arena_pool.cc",
253        "base/mutex.cc",
254        "base/quasi_atomic.cc",
255        "base/timing_logger.cc",
256        "cha.cc",
257        "class_linker.cc",
258        "class_loader_context.cc",
259        "class_root.cc",
260        "class_table.cc",
261        "common_throws.cc",
262        "compat_framework.cc",
263        "debug_print.cc",
264        "debugger.cc",
265        "dex/dex_file_annotations.cc",
266        "dex_register_location.cc",
267        "exec_utils.cc",
268        "fault_handler.cc",
269        "gc/accounting/bitmap.cc",
270        "gc/accounting/card_table.cc",
271        "gc/accounting/heap_bitmap.cc",
272        "gc/accounting/mod_union_table.cc",
273        "gc/accounting/remembered_set.cc",
274        "gc/accounting/space_bitmap.cc",
275        "gc/allocation_record.cc",
276        "gc/allocator/art-dlmalloc.cc",
277        "gc/allocator/rosalloc.cc",
278        "gc/collector/concurrent_copying.cc",
279        "gc/collector/garbage_collector.cc",
280        "gc/collector/immune_region.cc",
281        "gc/collector/immune_spaces.cc",
282        "gc/collector/mark_compact.cc",
283        "gc/collector/mark_sweep.cc",
284        "gc/collector/partial_mark_sweep.cc",
285        "gc/collector/semi_space.cc",
286        "gc/collector/sticky_mark_sweep.cc",
287        "gc/gc_cause.cc",
288        "gc/heap.cc",
289        "gc/reference_processor.cc",
290        "gc/reference_queue.cc",
291        "gc/scoped_gc_critical_section.cc",
292        "gc/space/bump_pointer_space.cc",
293        "gc/space/dlmalloc_space.cc",
294        "gc/space/image_space.cc",
295        "gc/space/large_object_space.cc",
296        "gc/space/malloc_space.cc",
297        "gc/space/region_space.cc",
298        "gc/space/rosalloc_space.cc",
299        "gc/space/space.cc",
300        "gc/space/zygote_space.cc",
301        "gc/task_processor.cc",
302        "gc/verification.cc",
303        "handle.cc",
304        "hidden_api.cc",
305        "hprof/hprof.cc",
306        "indirect_reference_table.cc",
307        "instrumentation.cc",
308        "intern_table.cc",
309        "interpreter/interpreter.cc",
310        "interpreter/interpreter_cache.cc",
311        "interpreter/interpreter_common.cc",
312        "interpreter/interpreter_switch_impl0.cc",
313        "interpreter/lock_count_data.cc",
314        "interpreter/shadow_frame.cc",
315        "interpreter/unstarted_runtime.cc",
316        "java_frame_root_info.cc",
317        "javaheapprof/javaheapsampler.cc",
318        "jit/debugger_interface.cc",
319        "jit/jit.cc",
320        "jit/jit_code_cache.cc",
321        "jit/jit_memory_region.cc",
322        "jit/jit_options.cc",
323        "jit/profile_saver.cc",
324        "jit/profiling_info.cc",
325        "jit/small_pattern_matcher.cc",
326        "jni/check_jni.cc",
327        "jni/java_vm_ext.cc",
328        "jni/jni_env_ext.cc",
329        "jni/jni_id_manager.cc",
330        "jni/jni_internal.cc",
331        "jni/local_reference_table.cc",
332        "method_handles.cc",
333        "metrics/reporter.cc",
334        "mirror/array.cc",
335        "mirror/class.cc",
336        "mirror/class_ext.cc",
337        "mirror/dex_cache.cc",
338        "mirror/emulated_stack_frame.cc",
339        "mirror/executable.cc",
340        "mirror/field.cc",
341        "mirror/method.cc",
342        "mirror/method_handle_impl.cc",
343        "mirror/method_handles_lookup.cc",
344        "mirror/method_type.cc",
345        "mirror/object.cc",
346        "mirror/stack_frame_info.cc",
347        "mirror/stack_trace_element.cc",
348        "mirror/string.cc",
349        "mirror/throwable.cc",
350        "mirror/var_handle.cc",
351        "monitor.cc",
352        "monitor_objects_stack_visitor.cc",
353        "native/dalvik_system_BaseDexClassLoader.cc",
354        "native/dalvik_system_DexFile.cc",
355        "native/dalvik_system_VMDebug.cc",
356        "native/dalvik_system_VMRuntime.cc",
357        "native/dalvik_system_VMStack.cc",
358        "native/dalvik_system_ZygoteHooks.cc",
359        "native/java_lang_Class.cc",
360        "native/java_lang_Object.cc",
361        "native/java_lang_StackStreamFactory.cc",
362        "native/java_lang_String.cc",
363        "native/java_lang_StringFactory.cc",
364        "native/java_lang_System.cc",
365        "native/java_lang_Thread.cc",
366        "native/java_lang_Throwable.cc",
367        "native/java_lang_VMClassLoader.cc",
368        "native/java_lang_invoke_MethodHandle.cc",
369        "native/java_lang_invoke_MethodHandleImpl.cc",
370        "native/java_lang_ref_FinalizerReference.cc",
371        "native/java_lang_ref_Reference.cc",
372        "native/java_lang_reflect_Array.cc",
373        "native/java_lang_reflect_Constructor.cc",
374        "native/java_lang_reflect_Executable.cc",
375        "native/java_lang_reflect_Field.cc",
376        "native/java_lang_reflect_Method.cc",
377        "native/java_lang_reflect_Parameter.cc",
378        "native/java_lang_reflect_Proxy.cc",
379        "native/java_util_concurrent_atomic_AtomicLong.cc",
380        "native/jdk_internal_misc_Unsafe.cc",
381        "native/libcore_io_Memory.cc",
382        "native/libcore_util_CharsetUtils.cc",
383        "native/org_apache_harmony_dalvik_ddmc_DdmServer.cc",
384        "native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc",
385        "native/sun_misc_Unsafe.cc",
386        "native_bridge_art_interface.cc",
387        "native_stack_dump.cc",
388        "non_debuggable_classes.cc",
389        "nterp_helpers.cc",
390        "oat/elf_file.cc",
391        "oat/image.cc",
392        "oat/index_bss_mapping.cc",
393        "oat/jni_stub_hash_map.cc",
394        "oat/oat.cc",
395        "oat/oat_file.cc",
396        "oat/oat_file_assistant.cc",
397        "oat/oat_file_assistant_context.cc",
398        "oat/oat_file_manager.cc",
399        "oat/oat_quick_method_header.cc",
400        "oat/stack_map.cc",
401        "object_lock.cc",
402        "offsets.cc",
403        "parsed_options.cc",
404        "plugin.cc",
405        "quick_exception_handler.cc",
406        "read_barrier.cc",
407        "reference_table.cc",
408        "reflection.cc",
409        "reflective_handle_scope.cc",
410        "reflective_value_visitor.cc",
411        "runtime.cc",
412        "runtime_callbacks.cc",
413        "runtime_common.cc",
414        "runtime_image.cc",
415        "runtime_intrinsics.cc",
416        "runtime_options.cc",
417        "scoped_thread_state_change.cc",
418        "signal_catcher.cc",
419        "stack.cc",
420        "startup_completed_task.cc",
421        "string_builder_append.cc",
422        "thread.cc",
423        "thread_list.cc",
424        "thread_pool.cc",
425        "ti/agent.cc",
426        "trace.cc",
427        "trace_profile.cc",
428        "var_handles.cc",
429        "vdex_file.cc",
430        "verifier/class_verifier.cc",
431        "verifier/instruction_flags.cc",
432        "verifier/method_verifier.cc",
433        "verifier/reg_type.cc",
434        "verifier/reg_type_cache.cc",
435        "verifier/register_line.cc",
436        "verifier/verifier_deps.cc",
437        "verify_object.cc",
438        "well_known_classes.cc",
439
440        "arch/context.cc",
441        "arch/instruction_set_features.cc",
442        "arch/memcmp16.cc",
443        "arch/arm/instruction_set_features_arm.cc",
444        "arch/arm/registers_arm.cc",
445        "arch/arm64/instruction_set_features_arm64.cc",
446        "arch/arm64/registers_arm64.cc",
447        "arch/riscv64/instruction_set_features_riscv64.cc",
448        "arch/riscv64/registers_riscv64.cc",
449        "arch/x86/instruction_set_features_x86.cc",
450        "arch/x86/registers_x86.cc",
451        "arch/x86_64/registers_x86_64.cc",
452        "entrypoints/entrypoint_utils.cc",
453        "entrypoints/jni/jni_entrypoints.cc",
454        "entrypoints/math_entrypoints.cc",
455        "entrypoints/quick/quick_alloc_entrypoints.cc",
456        "entrypoints/quick/quick_cast_entrypoints.cc",
457        "entrypoints/quick/quick_deoptimization_entrypoints.cc",
458        "entrypoints/quick/quick_dexcache_entrypoints.cc",
459        "entrypoints/quick/quick_entrypoints_enum.cc",
460        "entrypoints/quick/quick_field_entrypoints.cc",
461        "entrypoints/quick/quick_fillarray_entrypoints.cc",
462        "entrypoints/quick/quick_jni_entrypoints.cc",
463        "entrypoints/quick/quick_lock_entrypoints.cc",
464        "entrypoints/quick/quick_math_entrypoints.cc",
465        "entrypoints/quick/quick_string_builder_append_entrypoints.cc",
466        "entrypoints/quick/quick_thread_entrypoints.cc",
467        "entrypoints/quick/quick_throw_entrypoints.cc",
468        "entrypoints/quick/quick_trampoline_entrypoints.cc",
469    ],
470
471    arch: {
472        arm: {
473            srcs: [
474                "interpreter/mterp/nterp.cc",
475                ":libart_mterp.armng",
476                "arch/arm/context_arm.cc",
477                "arch/arm/entrypoints_init_arm.cc",
478                "arch/arm/instruction_set_features_assembly_tests.S",
479                "arch/arm/jni_entrypoints_arm.S",
480                "arch/arm/memcmp16_arm.S",
481                "arch/arm/quick_entrypoints_arm.S",
482                "arch/arm/native_entrypoints_arm.S",
483                "arch/arm/quick_entrypoints_cc_arm.cc",
484                "arch/arm/thread_arm.cc",
485                "arch/arm/fault_handler_arm.cc",
486            ],
487        },
488        arm64: {
489            srcs: [
490                "interpreter/mterp/nterp.cc",
491                ":libart_mterp.arm64ng",
492                "arch/arm64/context_arm64.cc",
493                "arch/arm64/entrypoints_init_arm64.cc",
494                "arch/arm64/jni_entrypoints_arm64.S",
495                "arch/arm64/memcmp16_arm64.S",
496                "arch/arm64/quick_entrypoints_arm64.S",
497                "arch/arm64/native_entrypoints_arm64.S",
498                "arch/arm64/thread_arm64.cc",
499                "monitor_pool.cc",
500                "arch/arm64/fault_handler_arm64.cc",
501            ],
502        },
503        riscv64: {
504            srcs: [
505                ":libart_mterp.riscv64",
506                "arch/riscv64/context_riscv64.cc",
507                "arch/riscv64/entrypoints_init_riscv64.cc",
508                "arch/riscv64/fault_handler_riscv64.cc",
509                "arch/riscv64/jni_entrypoints_riscv64.S",
510                "arch/riscv64/quick_entrypoints_riscv64.S",
511                "arch/riscv64/native_entrypoints_riscv64.S",
512                "arch/riscv64/thread_riscv64.cc",
513                "interpreter/mterp/nterp.cc",
514                "monitor_pool.cc",
515            ],
516        },
517        x86: {
518            srcs: [
519                "interpreter/mterp/nterp.cc",
520                ":libart_mterp.x86ng",
521                "arch/x86/context_x86.cc",
522                "arch/x86/entrypoints_init_x86.cc",
523                "arch/x86/jni_entrypoints_x86.S",
524                "arch/x86/memcmp16_x86.S",
525                "arch/x86/quick_entrypoints_x86.S",
526                "arch/x86/native_entrypoints_x86.S",
527                "arch/x86/thread_x86.cc",
528                "arch/x86/fault_handler_x86.cc",
529            ],
530            avx: {
531                asflags: ["-DMTERP_USE_AVX"],
532            },
533            avx2: {
534                asflags: ["-DMTERP_USE_AVX"],
535            },
536        },
537        x86_64: {
538            srcs: [
539                // Note that the fault_handler_x86.cc is not a mistake.  This file is
540                // shared between the x86 and x86_64 architectures.
541                "interpreter/mterp/nterp.cc",
542                ":libart_mterp.x86_64ng",
543                "arch/x86_64/context_x86_64.cc",
544                "arch/x86_64/entrypoints_init_x86_64.cc",
545                "arch/x86_64/jni_entrypoints_x86_64.S",
546                "arch/x86_64/memcmp16_x86_64.S",
547                "arch/x86_64/quick_entrypoints_x86_64.S",
548                "arch/x86_64/native_entrypoints_x86_64.S",
549                "arch/x86_64/thread_x86_64.cc",
550                "monitor_pool.cc",
551                "arch/x86/fault_handler_x86.cc",
552            ],
553            avx: {
554                asflags: ["-DMTERP_USE_AVX"],
555            },
556            avx2: {
557                asflags: ["-DMTERP_USE_AVX"],
558            },
559        },
560    },
561
562    target: {
563        android: {
564            srcs: [
565                "monitor_android.cc",
566                "runtime_android.cc",
567                "thread_android.cc",
568                "metrics/statsd.cc",
569            ],
570            generated_sources: [
571                "apex-info-list-tinyxml",
572                "art-apex-cache-info",
573            ],
574            tidy_disabled_srcs: [":art-apex-cache-info"],
575        },
576        host: {
577            srcs: [
578                "monitor_linux.cc",
579                "runtime_linux.cc",
580                "thread_linux.cc",
581            ],
582            cflags: [
583                "-fsanitize-address-use-after-return=never",
584                "-Wno-unused-command-line-argument",
585            ],
586        },
587    },
588    generated_sources: [
589        "art_operator_srcs",
590    ],
591    whole_static_libs: [
592        "libcpu_features",
593    ],
594    cflags: [
595        "-DBUILDING_LIBART",
596    ],
597}
598
599cc_defaults {
600    name: "libart-runtime_defaults",
601    defaults: [
602        "libart-runtime_common_defaults",
603        "libart-runtime_deps",
604    ],
605}
606
607cc_defaults {
608    name: "libartd-runtime_defaults",
609    defaults: [
610        "art_debug_defaults",
611        "libart-runtime_common_defaults",
612        "libartd-runtime_deps",
613    ],
614}
615
616cc_defaults {
617    name: "libart_defaults",
618    defaults: [
619        "libart_common_defaults",
620        "libart-runtime_deps",
621        "libart-compiler_deps",
622    ],
623}
624
625cc_defaults {
626    name: "libartd_defaults",
627    defaults: [
628        "art_debug_defaults",
629        "libart_common_defaults",
630        "libartd-runtime_deps",
631        "libartd-compiler_deps",
632    ],
633}
634
635// A defaults to link libunwindstack statically with necessary dependencies,
636// where all non-NDK dependencies are static as well.
637cc_defaults {
638    name: "art_libunwindstack_static_defaults",
639    whole_static_libs: [
640        "libunwindstack",
641        "libbase",
642        "liblzma",
643    ],
644    shared_libs: [
645        "liblog",
646    ],
647}
648
649cc_defaults {
650    name: "libart_static_base_defaults",
651    defaults: [
652        "art_libunwindstack_static_defaults",
653    ],
654    whole_static_libs: [
655        "libartpalette",
656        "libbase",
657        "liblog",
658        "liblz4",
659        "liblzma", // libelffile dependency; must be repeated here since it's a static lib.
660        "libnativebridge",
661        "libnativeloader",
662        "libodrstatslog",
663    ],
664    target: {
665        host: {
666            cflags: [
667                "-fsanitize-address-use-after-return=never",
668                "-Wno-unused-command-line-argument",
669            ],
670        },
671        android: {
672            whole_static_libs: [
673                "libPlatformProperties", // libnativeloader dependency.
674            ],
675        },
676    },
677}
678
679cc_defaults {
680    name: "libart-runtime_static_defaults",
681    defaults: [
682        "libart_static_base_defaults",
683        "libartbase_static_defaults",
684        "libdexfile_static_defaults",
685        "libdexfile_support_static_defaults",
686        "libprofile_static_defaults",
687    ],
688    whole_static_libs: [
689        "libart-runtime",
690        "libelffile",
691        "libsigchain_fake",
692    ],
693}
694
695cc_defaults {
696    name: "libartd-runtime_static_defaults",
697    defaults: [
698        "libart_static_base_defaults",
699        "libartbased_static_defaults",
700        "libdexfiled_static_defaults",
701        "libdexfiled_support_static_defaults",
702        "libprofiled_static_defaults",
703    ],
704    whole_static_libs: [
705        "libartd-runtime",
706        "libelffiled",
707        "libsigchain_fake",
708    ],
709}
710
711cc_defaults {
712    name: "libart_static_defaults",
713    defaults: [
714        "libart-runtime_static_defaults",
715        "libart-compiler_static_defaults",
716    ],
717}
718
719cc_defaults {
720    name: "libartd_static_defaults",
721    defaults: [
722        "libartd-runtime_static_defaults",
723        "libartd-compiler_static_defaults",
724    ],
725}
726
727// libart-runtime_static_defaults for standalone gtests.
728// Doesn't link libsigchain_fake/libnativeloader (see art_gtest_common_defaults
729// in test/Android.bp for explanation).
730// Uses libart-runtime-for-test instead of libart-runtime.
731cc_defaults {
732    name: "libart-runtime-for-test_static_defaults",
733    defaults: [
734        "libart_static_base_defaults",
735        "libartbase_static_defaults",
736        "libdexfile_static_defaults",
737        "libdexfile_support_static_defaults",
738        "libprofile_static_defaults",
739    ],
740    whole_static_libs: [
741        "libart-runtime-for-test",
742        "libelffile",
743    ],
744}
745
746// libartd-runtime_static_defaults for gtests.
747// Doesn't link libsigchain_fake/libnativeloader (see art_gtest_common_defaults
748// in test/Android.bp for explanation).
749// Note that `libartd-runtime-for-test` is not required here, because `libartd-runtime`
750// doesn't use LTO.
751cc_defaults {
752    name: "libartd-runtime-for-test_static_defaults",
753    defaults: [
754        "libart_static_base_defaults",
755        "libartbased_static_defaults",
756        "libdexfiled_static_defaults",
757        "libdexfiled_support_static_defaults",
758        "libprofiled_static_defaults",
759    ],
760    whole_static_libs: [
761        "libartd-runtime",
762        "libelffiled",
763    ],
764}
765
766gensrcs {
767    name: "art_operator_srcs",
768    cmd: "$(location generate_operator_out) art/runtime $(in) > $(out)",
769    tools: ["generate_operator_out"],
770    srcs: [
771        "base/callee_save_type.h",
772        "base/locks.h",
773        "class_status.h",
774        "compilation_kind.h",
775        "gc/allocator/rosalloc.h",
776        "gc/allocator_type.h",
777        "gc/collector/gc_type.h",
778        "gc/collector/mark_compact.h",
779        "gc/collector_type.h",
780        "gc/space/region_space.h",
781        "gc/space/space.h",
782        "gc/weak_root_state.h",
783        "gc_root.h",
784        "indirect_reference_table.h",
785        "instrumentation.h",
786        "jdwp_provider.h",
787        "jni_id_type.h",
788        "linear_alloc.h",
789        "lock_word.h",
790        "oat/image.h",
791        "oat/oat.h",
792        "oat/oat_file.h",
793        "process_state.h",
794        "reflective_value_visitor.h",
795        "stack.h",
796        "suspend_reason.h",
797        "thread.h",
798        "thread_state.h",
799        "trace.h",
800        "trace_profile.h",
801        "verifier/verifier_enums.h",
802    ],
803    output_extension: "operator_out.cc",
804}
805
806// We always build dex2oat and dependencies, even if the host build is otherwise disabled, since
807// they are used to cross compile for the target.
808
809// Release version of the ART runtime library.
810art_cc_library_static {
811    name: "libart-runtime",
812    defaults: ["libart-runtime_defaults"],
813    apex_available: [
814        "com.android.art",
815        "com.android.art.debug",
816        // This lib doesn't go into test_broken_com.android.art, but the libart-broken
817        // needs to have the same apex_available list as its dependencies in order
818        // to compile against their sources. Then that change comes back up to affect
819        // libart as well, because it also needs to have the same apex_available as its
820        // dependencies.
821        "test_broken_com.android.art",
822    ],
823    target: {
824        android: {
825            lto: {
826                thin: true,
827            },
828        },
829    },
830}
831
832// For static linking with gtests. Same as `libart-runtime`, but without LTO.
833// When gtests static link a library with LTO enabled, they are also built with LTO.
834// This makes the build process use a lot of memory. b/277207452
835art_cc_library_static {
836    name: "libart-runtime-for-test",
837    defaults: ["libart-runtime_defaults"],
838}
839
840// Debug version of the ART runtime library.
841art_cc_library_static {
842    name: "libartd-runtime",
843    defaults: ["libartd-runtime_defaults"],
844    apex_available: [
845        "com.android.art.debug",
846    ],
847}
848
849// Release version of the ART runtime library, bundled with `libart-compiler` for JIT support.
850art_cc_library {
851    name: "libart",
852    defaults: ["libart_defaults"],
853    whole_static_libs: [
854        "libart-compiler",
855        "libart-runtime",
856    ],
857    apex_available: [
858        "com.android.art.debug",
859        "com.android.art",
860        // This lib doesn't go into test_broken_com.android.art, but the libart-broken
861        // needs to have the same apex_available list as its dependencies in order
862        // to compile against their sources. Then that change comes back up to affect
863        // libart as well, because it also needs to have the same apex_available as its
864        // dependencies.
865        "test_broken_com.android.art",
866    ],
867    afdo: true,
868    target: {
869        android: {
870            lto: {
871                thin: true,
872            },
873        },
874    },
875}
876
877art_cc_library {
878    name: "libart-unstripped",
879    defaults: ["libart_defaults"],
880    whole_static_libs: [
881        "libart-compiler",
882        "libart-runtime",
883    ],
884    apex_available: [
885        "com.android.art",
886        "com.android.art.debug",
887        // This lib doesn't go into test_broken_com.android.art, but the libart-broken
888        // needs to have the same apex_available list as its dependencies in order
889        // to compile against their sources. Then that change comes back up to affect
890        // libart as well, because it also needs to have the same apex_available as its
891        // dependencies.
892        "test_broken_com.android.art",
893    ],
894    strip: {
895        none: true,
896    },
897}
898
899// "Broken" version of the libart, used only for testing.
900art_cc_test_library {
901    name: "libart-broken",
902    defaults: [
903        "libart-runtime_defaults",
904        "libart_defaults",
905    ],
906    cflags: ["-DART_CRASH_RUNTIME_DELIBERATELY"],
907    stem: "libart",
908    gtest: false,
909    whole_static_libs: [
910        "libart-compiler",
911    ],
912    apex_available: [
913        // libart-broken only goes into test_broken_com.android.art, but the libart-broken
914        // needs to have the same apex_available list as its dependencies in order
915        // to compile against their sources.
916        "com.android.art",
917        "com.android.art.debug",
918        "test_broken_com.android.art",
919    ],
920}
921
922// Debug version of the ART runtime library, bundled with `libartd-compiler` for JIT support.
923art_cc_library {
924    name: "libartd",
925    defaults: ["libartd_defaults"],
926    whole_static_libs: [
927        "libartd-compiler",
928        "libartd-runtime",
929    ],
930    apex_available: [
931        "com.android.art.debug",
932    ],
933}
934
935art_cc_defaults {
936    name: "libart-runtime-gtest-defaults",
937    target: {
938        host: {
939            cflags: [
940                "-fsanitize-address-use-after-return=never",
941                "-Wno-unused-command-line-argument",
942            ],
943        },
944    },
945    tidy_timeout_srcs: [
946        "common_runtime_test.cc",
947    ],
948    srcs: [
949        "common_runtime_test.cc",
950        "dexopt_test.cc",
951    ],
952    static_libs: [
953        "libprocinfo",
954    ],
955    header_libs: [
956        "libnativehelper_header_only",
957    ],
958}
959
960art_cc_library_static {
961    name: "libart-runtime-gtest",
962    defaults: [
963        "libart-runtime-gtest-defaults",
964        "libart-gtest-defaults",
965        "libart-runtime-for-test_static_defaults",
966    ],
967}
968
969art_cc_library_static {
970    name: "libartd-runtime-gtest",
971    defaults: [
972        "art_debug_defaults",
973        "libart-runtime-gtest-defaults",
974        "libart-gtest-defaults",
975        "libartd-runtime-for-test_static_defaults",
976    ],
977}
978
979art_cc_defaults {
980    name: "art_runtime_tests_defaults",
981    target: {
982        host: {
983            cflags: [
984                "-fsanitize-address-use-after-return=never",
985                "-Wno-unused-command-line-argument",
986            ],
987        },
988    },
989    device_common_data: [
990        ":art-gtest-jars-AllFields",
991        ":art-gtest-jars-DexVerificationFuzzerFolder",
992        ":art-gtest-jars-ClassVerificationFuzzerFolder",
993        ":art-gtest-jars-ErroneousA",
994        ":art-gtest-jars-ErroneousB",
995        ":art-gtest-jars-ErroneousInit",
996        ":art-gtest-jars-Extension1",
997        ":art-gtest-jars-Extension2",
998        ":art-gtest-jars-ForClassLoaderA",
999        ":art-gtest-jars-ForClassLoaderB",
1000        ":art-gtest-jars-ForClassLoaderC",
1001        ":art-gtest-jars-ForClassLoaderD",
1002        ":art-gtest-jars-HiddenApiSignatures",
1003        ":art-gtest-jars-IMTA",
1004        ":art-gtest-jars-IMTB",
1005        ":art-gtest-jars-Instrumentation",
1006        ":art-gtest-jars-Interfaces",
1007        ":art-gtest-jars-LinkageTest",
1008        ":art-gtest-jars-Main",
1009        ":art-gtest-jars-MainStripped",
1010        ":art-gtest-jars-MainUncompressedAligned",
1011        ":art-gtest-jars-MethodTypes",
1012        ":art-gtest-jars-MultiDex",
1013        ":art-gtest-jars-MultiDexModifiedSecondary",
1014        ":art-gtest-jars-MultiDexUncompressedAligned",
1015        ":art-gtest-jars-MyClass",
1016        ":art-gtest-jars-MyClassNatives",
1017        ":art-gtest-jars-Nested",
1018        ":art-gtest-jars-NonStaticLeafMethods",
1019        ":art-gtest-jars-Packages",
1020        ":art-gtest-jars-ProfileTestMultiDex",
1021        ":art-gtest-jars-ProtoCompare",
1022        ":art-gtest-jars-ProtoCompare2",
1023        ":art-gtest-jars-StaticLeafMethods",
1024        ":art-gtest-jars-Statics",
1025        ":art-gtest-jars-StaticsFromCode",
1026        ":art-gtest-jars-VerifierDeps",
1027        ":art-gtest-jars-VerifierDepsMulti",
1028        ":art-gtest-jars-XandY",
1029    ],
1030    tidy_timeout_srcs: [
1031        "arch/stub_test.cc",
1032        "class_linker_test.cc",
1033        "class_loader_context_test.cc",
1034        "hidden_api_test.cc",
1035        "instrumentation_test.cc",
1036        "interpreter/unstarted_runtime_test.cc",
1037        "jni/jni_internal_test.cc",
1038        "method_handles_test.cc",
1039        "mirror/object_test.cc",
1040        "mirror/var_handle_test.cc",
1041        "oat/oat_file_assistant_test.cc",
1042        "runtime_callbacks_test.cc",
1043        "subtype_check_test.cc",
1044        "verifier/reg_type_test.cc",
1045    ],
1046    srcs: [
1047        "app_info_test.cc",
1048        "arch/arch_test.cc",
1049        "arch/arm/instruction_set_features_arm_test.cc",
1050        "arch/arm64/instruction_set_features_arm64_test.cc",
1051        "arch/instruction_set_features_test.cc",
1052        "arch/memcmp16_test.cc",
1053        "arch/stub_test.cc",
1054        "arch/riscv64/instruction_set_features_riscv64_test.cc",
1055        "arch/x86/instruction_set_features_x86_test.cc",
1056        "arch/x86_64/instruction_set_features_x86_64_test.cc",
1057        "art_method_test.cc",
1058        "barrier_test.cc",
1059        "base/message_queue_test.cc",
1060        "base/mutex_test.cc",
1061        "base/timing_logger_test.cc",
1062        "cha_test.cc",
1063        "class_linker_test.cc",
1064        "class_loader_context_test.cc",
1065        "class_table_test.cc",
1066        "entrypoints/math_entrypoints_test.cc",
1067        "entrypoints/quick/quick_trampoline_entrypoints_test.cc",
1068        "entrypoints_order_test.cc",
1069        "exec_utils_test.cc",
1070        "fuzzer_corpus_test.cc",
1071        "gc/accounting/card_table_test.cc",
1072        "gc/accounting/mod_union_table_test.cc",
1073        "gc/accounting/space_bitmap_test.cc",
1074        "gc/collector/immune_spaces_test.cc",
1075        "gc/heap_test.cc",
1076        "gc/heap_verification_test.cc",
1077        "gc/reference_queue_test.cc",
1078        "gc/space/dlmalloc_space_random_test.cc",
1079        "gc/space/dlmalloc_space_static_test.cc",
1080        "gc/space/image_space_test.cc",
1081        "gc/space/large_object_space_test.cc",
1082        "gc/space/rosalloc_space_random_test.cc",
1083        "gc/space/rosalloc_space_static_test.cc",
1084        "gc/space/space_create_test.cc",
1085        "gc/system_weak_test.cc",
1086        "gc/task_processor_test.cc",
1087        "gtest_test.cc",
1088        "handle_scope_test.cc",
1089        "hidden_api_test.cc",
1090        "imtable_test.cc",
1091        "indirect_reference_table_test.cc",
1092        "instrumentation_test.cc",
1093        "intern_table_test.cc",
1094        "interpreter/safe_math_test.cc",
1095        "interpreter/unstarted_runtime_test.cc",
1096        "jit/jit_memory_region_test.cc",
1097        "jit/profile_saver_test.cc",
1098        "jit/profiling_info_test.cc",
1099        "jni/java_vm_ext_test.cc",
1100        "jni/jni_internal_test.cc",
1101        "jni/local_reference_table_test.cc",
1102        "method_handles_test.cc",
1103        "metrics/reporter_test.cc",
1104        "mirror/dex_cache_test.cc",
1105        "mirror/method_type_test.cc",
1106        "mirror/object_test.cc",
1107        "mirror/var_handle_test.cc",
1108        "monitor_pool_test.cc",
1109        "monitor_test.cc",
1110        "native_stack_dump_test.cc",
1111        "oat/oat_file_assistant_test.cc",
1112        "oat/oat_file_test.cc",
1113        "parsed_options_test.cc",
1114        "prebuilt_tools_test.cc",
1115        "proxy_test.cc",
1116        "reference_table_test.cc",
1117        "reflection_test.cc",
1118        "runtime_callbacks_test.cc",
1119        "runtime_test.cc",
1120        "subtype_check_info_test.cc",
1121        "subtype_check_test.cc",
1122        "thread_pool_test.cc",
1123        "thread_test.cc",
1124        "two_runtimes_test.cc",
1125        "vdex_file_test.cc",
1126        "verifier/method_verifier_test.cc",
1127        "verifier/reg_type_test.cc",
1128        "verifier/register_line_test.cc",
1129    ],
1130    static_libs: [
1131        "libgmock",
1132    ],
1133    header_libs: [
1134        "art_cmdlineparser_headers", // For parsed_options_test.
1135    ],
1136}
1137
1138// Version of ART gtest `art_runtime_tests` bundled with the ART APEX on target.
1139// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
1140art_cc_test {
1141    name: "art_runtime_tests",
1142    defaults: [
1143        "art_gtest_defaults",
1144        "art_runtime_tests_defaults",
1145    ],
1146    target: {
1147        host: {
1148            required: [
1149                "dex2oatd",
1150                "art_boot_images",
1151            ],
1152        },
1153    },
1154}
1155
1156// Standalone version of ART gtest `art_runtime_tests`, not bundled with the ART APEX on target.
1157art_cc_test {
1158    name: "art_standalone_runtime_tests",
1159    defaults: [
1160        "art_standalone_gtest_defaults",
1161        "art_runtime_tests_defaults",
1162    ],
1163    data: [":generate-boot-image"],
1164    target: {
1165        host: {
1166            required: ["dex2oat"],
1167        },
1168    },
1169    // Some tests are currently failing (observed on
1170    // `aosp_cf_x86_64_phone-userdebug`); use a special test configuration for
1171    // `art_standalone_runtime_tests` to filter them out for now.
1172    // TODO(b/204649079): Investigate these failures and re-enable these tests.
1173    test_config: "art_standalone_runtime_tests.xml",
1174}
1175
1176genrule {
1177    name: "libart_mterp.x86ng",
1178    out: ["mterp_x86ng.S"],
1179    srcs: [
1180        "interpreter/mterp/x86ng/*.S",
1181    ],
1182    tool_files: [
1183        "interpreter/mterp/gen_mterp.py",
1184        "interpreter/mterp/common/gen_setup.py",
1185        ":art_libdexfile_dex_instruction_list_header",
1186    ],
1187    cmd: "$(location interpreter/mterp/gen_mterp.py) $(out) $(in)",
1188}
1189
1190genrule {
1191    name: "libart_mterp.x86_64ng",
1192    out: ["mterp_x86_64ng.S"],
1193    srcs: [
1194        "interpreter/mterp/x86_64ng/*.S",
1195    ],
1196    tool_files: [
1197        "interpreter/mterp/gen_mterp.py",
1198        "interpreter/mterp/common/gen_setup.py",
1199        ":art_libdexfile_dex_instruction_list_header",
1200    ],
1201    cmd: "$(location interpreter/mterp/gen_mterp.py) $(out) $(in)",
1202}
1203
1204genrule {
1205    name: "libart_mterp.arm64ng",
1206    out: ["mterp_arm64ng.S"],
1207    srcs: [
1208        "interpreter/mterp/arm64ng/*.S",
1209    ],
1210    tool_files: [
1211        "interpreter/mterp/gen_mterp.py",
1212        "interpreter/mterp/common/gen_setup.py",
1213        ":art_libdexfile_dex_instruction_list_header",
1214    ],
1215    cmd: "$(location interpreter/mterp/gen_mterp.py) $(out) $(in)",
1216}
1217
1218genrule {
1219    name: "libart_mterp.armng",
1220    out: ["mterp_armng.S"],
1221    srcs: [
1222        "interpreter/mterp/armng/*.S",
1223    ],
1224    tool_files: [
1225        "interpreter/mterp/gen_mterp.py",
1226        "interpreter/mterp/common/gen_setup.py",
1227        ":art_libdexfile_dex_instruction_list_header",
1228    ],
1229    cmd: "$(location interpreter/mterp/gen_mterp.py) $(out) $(in)",
1230}
1231
1232genrule {
1233    name: "libart_mterp.riscv64",
1234    out: ["mterp_riscv64.S"],
1235    srcs: [
1236        "interpreter/mterp/riscv64/*.S",
1237    ],
1238    tool_files: [
1239        "interpreter/mterp/gen_mterp.py",
1240        "interpreter/mterp/common/gen_setup.py",
1241        ":art_libdexfile_dex_instruction_list_header",
1242    ],
1243    cmd: "$(location interpreter/mterp/gen_mterp.py) $(out) $(in)",
1244}
1245
1246cc_library_static {
1247    name: "libstatslog_art",
1248    defaults: ["art_defaults"],
1249    generated_sources: ["statslog_art.cpp"],
1250    generated_headers: ["statslog_art.h"],
1251    export_generated_headers: ["statslog_art.h"],
1252    shared_libs: [
1253        "liblog",
1254        "libstatspull",
1255        "libstatssocket",
1256        "libutils",
1257    ],
1258    apex_available: [
1259        "com.android.art",
1260        "com.android.art.debug",
1261    ],
1262}
1263
1264genrule {
1265    name: "statslog_art.h",
1266    tools: ["stats-log-api-gen"],
1267    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_art.h --module art --namespace art,metrics,statsd",
1268    out: [
1269        "statslog_art.h",
1270    ],
1271}
1272
1273genrule {
1274    name: "statslog_art.cpp",
1275    tools: ["stats-log-api-gen"],
1276    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_art.cpp --module art --namespace art,metrics,statsd --importHeader statslog_art.h",
1277    out: [
1278        "statslog_art.cpp",
1279    ],
1280}
1281