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