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.
21JIT_DEBUG_REGISTER_CODE_LDFLAGS = [
22    "-Wl,--keep-unique,__jit_debug_register_code",
23    "-Wl,--keep-unique,__dex_debug_register_code"
24]
25
26cc_defaults {
27    name: "libart_defaults",
28    defaults: ["art_defaults"],
29    host_supported: true,
30    srcs: [
31        "aot_class_linker.cc",
32        "art_field.cc",
33        "art_method.cc",
34        "barrier.cc",
35        "base/arena_allocator.cc",
36        "base/arena_bit_vector.cc",
37        "base/file_utils.cc",
38        "base/mutex.cc",
39        "base/quasi_atomic.cc",
40        "base/scoped_arena_allocator.cc",
41        "base/timing_logger.cc",
42        "cha.cc",
43        "check_jni.cc",
44        "class_linker.cc",
45        "class_loader_context.cc",
46        "class_table.cc",
47        "common_throws.cc",
48        "compiler_filter.cc",
49        "debug_print.cc",
50        "debugger.cc",
51        "dex/art_dex_file_loader.cc",
52        "dex/dex_file_annotations.cc",
53        "dex_to_dex_decompiler.cc",
54        "elf_file.cc",
55        "exec_utils.cc",
56        "fault_handler.cc",
57        "gc/allocation_record.cc",
58        "gc/allocator/dlmalloc.cc",
59        "gc/allocator/rosalloc.cc",
60        "gc/accounting/bitmap.cc",
61        "gc/accounting/card_table.cc",
62        "gc/accounting/heap_bitmap.cc",
63        "gc/accounting/mod_union_table.cc",
64        "gc/accounting/remembered_set.cc",
65        "gc/accounting/space_bitmap.cc",
66        "gc/collector/concurrent_copying.cc",
67        "gc/collector/garbage_collector.cc",
68        "gc/collector/immune_region.cc",
69        "gc/collector/immune_spaces.cc",
70        "gc/collector/mark_compact.cc",
71        "gc/collector/mark_sweep.cc",
72        "gc/collector/partial_mark_sweep.cc",
73        "gc/collector/semi_space.cc",
74        "gc/collector/sticky_mark_sweep.cc",
75        "gc/gc_cause.cc",
76        "gc/heap.cc",
77        "gc/reference_processor.cc",
78        "gc/reference_queue.cc",
79        "gc/scoped_gc_critical_section.cc",
80        "gc/space/bump_pointer_space.cc",
81        "gc/space/dlmalloc_space.cc",
82        "gc/space/image_space.cc",
83        "gc/space/large_object_space.cc",
84        "gc/space/malloc_space.cc",
85        "gc/space/region_space.cc",
86        "gc/space/rosalloc_space.cc",
87        "gc/space/space.cc",
88        "gc/space/zygote_space.cc",
89        "gc/task_processor.cc",
90        "gc/verification.cc",
91        "hidden_api.cc",
92        "hprof/hprof.cc",
93        "image.cc",
94        "index_bss_mapping.cc",
95        "indirect_reference_table.cc",
96        "instrumentation.cc",
97        "intern_table.cc",
98        "interpreter/interpreter.cc",
99        "interpreter/interpreter_common.cc",
100        "interpreter/interpreter_intrinsics.cc",
101        "interpreter/interpreter_switch_impl.cc",
102        "interpreter/lock_count_data.cc",
103        "interpreter/shadow_frame.cc",
104        "interpreter/unstarted_runtime.cc",
105        "java_frame_root_info.cc",
106        "java_vm_ext.cc",
107        "jdwp/jdwp_event.cc",
108        "jdwp/jdwp_expand_buf.cc",
109        "jdwp/jdwp_handler.cc",
110        "jdwp/jdwp_main.cc",
111        "jdwp/jdwp_request.cc",
112        "jdwp/jdwp_socket.cc",
113        "jdwp/object_registry.cc",
114        "jni_env_ext.cc",
115        "jit/debugger_interface.cc",
116        "jit/jit.cc",
117        "jit/jit_code_cache.cc",
118        "jit/profile_compilation_info.cc",
119        "jit/profiling_info.cc",
120        "jit/profile_saver.cc",
121        "jni_internal.cc",
122        "jobject_comparator.cc",
123        "linear_alloc.cc",
124        "managed_stack.cc",
125        "mem_map.cc",
126        "memory_region.cc",
127        "method_handles.cc",
128        "mirror/array.cc",
129        "mirror/call_site.cc",
130        "mirror/class.cc",
131        "mirror/class_ext.cc",
132        "mirror/dex_cache.cc",
133        "mirror/emulated_stack_frame.cc",
134        "mirror/executable.cc",
135        "mirror/field.cc",
136        "mirror/method.cc",
137        "mirror/method_handle_impl.cc",
138        "mirror/method_handles_lookup.cc",
139        "mirror/method_type.cc",
140        "mirror/object.cc",
141        "mirror/reference.cc",
142        "mirror/stack_trace_element.cc",
143        "mirror/string.cc",
144        "mirror/throwable.cc",
145        "mirror/var_handle.cc",
146        "monitor.cc",
147        "native_bridge_art_interface.cc",
148        "native_stack_dump.cc",
149        "native/dalvik_system_DexFile.cc",
150        "native/dalvik_system_VMDebug.cc",
151        "native/dalvik_system_VMRuntime.cc",
152        "native/dalvik_system_VMStack.cc",
153        "native/dalvik_system_ZygoteHooks.cc",
154        "native/java_lang_Class.cc",
155        "native/java_lang_Object.cc",
156        "native/java_lang_String.cc",
157        "native/java_lang_StringFactory.cc",
158        "native/java_lang_System.cc",
159        "native/java_lang_Thread.cc",
160        "native/java_lang_Throwable.cc",
161        "native/java_lang_VMClassLoader.cc",
162        "native/java_lang_invoke_MethodHandleImpl.cc",
163        "native/java_lang_ref_FinalizerReference.cc",
164        "native/java_lang_ref_Reference.cc",
165        "native/java_lang_reflect_Array.cc",
166        "native/java_lang_reflect_Constructor.cc",
167        "native/java_lang_reflect_Executable.cc",
168        "native/java_lang_reflect_Field.cc",
169        "native/java_lang_reflect_Method.cc",
170        "native/java_lang_reflect_Parameter.cc",
171        "native/java_lang_reflect_Proxy.cc",
172        "native/java_util_concurrent_atomic_AtomicLong.cc",
173        "native/libcore_util_CharsetUtils.cc",
174        "native/org_apache_harmony_dalvik_ddmc_DdmServer.cc",
175        "native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc",
176        "native/sun_misc_Unsafe.cc",
177        "non_debuggable_classes.cc",
178        "oat.cc",
179        "oat_file.cc",
180        "oat_file_assistant.cc",
181        "oat_file_manager.cc",
182        "oat_quick_method_header.cc",
183        "object_lock.cc",
184        "offsets.cc",
185        "parsed_options.cc",
186        "plugin.cc",
187        "quick_exception_handler.cc",
188        "read_barrier.cc",
189        "reference_table.cc",
190        "reflection.cc",
191        "runtime.cc",
192        "runtime_callbacks.cc",
193        "runtime_common.cc",
194        "runtime_intrinsics.cc",
195        "runtime_options.cc",
196        "scoped_thread_state_change.cc",
197        "signal_catcher.cc",
198        "stack.cc",
199        "stack_map.cc",
200        "thread.cc",
201        "thread_list.cc",
202        "thread_pool.cc",
203        "ti/agent.cc",
204        "trace.cc",
205        "transaction.cc",
206        "type_lookup_table.cc",
207        "vdex_file.cc",
208        "verifier/instruction_flags.cc",
209        "verifier/method_verifier.cc",
210        "verifier/reg_type.cc",
211        "verifier/reg_type_cache.cc",
212        "verifier/register_line.cc",
213        "verifier/verifier_deps.cc",
214        "verify_object.cc",
215        "well_known_classes.cc",
216        "zip_archive.cc",
217
218        "arch/context.cc",
219        "arch/instruction_set.cc",
220        "arch/instruction_set_features.cc",
221        "arch/memcmp16.cc",
222        "arch/arm/instruction_set_features_arm.cc",
223        "arch/arm/registers_arm.cc",
224        "arch/arm64/instruction_set_features_arm64.cc",
225        "arch/arm64/registers_arm64.cc",
226        "arch/mips/instruction_set_features_mips.cc",
227        "arch/mips/registers_mips.cc",
228        "arch/mips64/instruction_set_features_mips64.cc",
229        "arch/mips64/registers_mips64.cc",
230        "arch/x86/instruction_set_features_x86.cc",
231        "arch/x86/registers_x86.cc",
232        "arch/x86_64/registers_x86_64.cc",
233        "entrypoints/entrypoint_utils.cc",
234        "entrypoints/jni/jni_entrypoints.cc",
235        "entrypoints/math_entrypoints.cc",
236        "entrypoints/quick/quick_alloc_entrypoints.cc",
237        "entrypoints/quick/quick_cast_entrypoints.cc",
238        "entrypoints/quick/quick_deoptimization_entrypoints.cc",
239        "entrypoints/quick/quick_dexcache_entrypoints.cc",
240        "entrypoints/quick/quick_entrypoints_enum.cc",
241        "entrypoints/quick/quick_field_entrypoints.cc",
242        "entrypoints/quick/quick_fillarray_entrypoints.cc",
243        "entrypoints/quick/quick_jni_entrypoints.cc",
244        "entrypoints/quick/quick_lock_entrypoints.cc",
245        "entrypoints/quick/quick_math_entrypoints.cc",
246        "entrypoints/quick/quick_thread_entrypoints.cc",
247        "entrypoints/quick/quick_throw_entrypoints.cc",
248        "entrypoints/quick/quick_trampoline_entrypoints.cc",
249    ],
250
251    arch: {
252        arm: {
253            clang_asflags: ["-no-integrated-as"],
254            srcs: [
255                "interpreter/mterp/mterp.cc",
256                "interpreter/mterp/out/mterp_arm.S",
257                "arch/arm/context_arm.cc",
258                "arch/arm/entrypoints_init_arm.cc",
259                "arch/arm/instruction_set_features_assembly_tests.S",
260                "arch/arm/jni_entrypoints_arm.S",
261                "arch/arm/memcmp16_arm.S",
262                "arch/arm/quick_entrypoints_arm.S",
263                "arch/arm/quick_entrypoints_cc_arm.cc",
264                "arch/arm/thread_arm.cc",
265                "arch/arm/fault_handler_arm.cc",
266            ],
267        },
268        arm64: {
269            srcs: [
270                "interpreter/mterp/mterp.cc",
271                "interpreter/mterp/out/mterp_arm64.S",
272                "arch/arm64/context_arm64.cc",
273                "arch/arm64/entrypoints_init_arm64.cc",
274                "arch/arm64/jni_entrypoints_arm64.S",
275                "arch/arm64/memcmp16_arm64.S",
276                "arch/arm64/quick_entrypoints_arm64.S",
277                "arch/arm64/thread_arm64.cc",
278                "monitor_pool.cc",
279                "arch/arm64/fault_handler_arm64.cc",
280            ],
281        },
282        x86: {
283            srcs: [
284                "interpreter/mterp/mterp.cc",
285                "interpreter/mterp/out/mterp_x86.S",
286                "arch/x86/context_x86.cc",
287                "arch/x86/entrypoints_init_x86.cc",
288                "arch/x86/jni_entrypoints_x86.S",
289                "arch/x86/memcmp16_x86.S",
290                "arch/x86/quick_entrypoints_x86.S",
291                "arch/x86/thread_x86.cc",
292                "arch/x86/fault_handler_x86.cc",
293            ],
294        },
295        x86_64: {
296            srcs: [
297                // Note that the fault_handler_x86.cc is not a mistake.  This file is
298                // shared between the x86 and x86_64 architectures.
299                "interpreter/mterp/mterp.cc",
300                "interpreter/mterp/out/mterp_x86_64.S",
301                "arch/x86_64/context_x86_64.cc",
302                "arch/x86_64/entrypoints_init_x86_64.cc",
303                "arch/x86_64/jni_entrypoints_x86_64.S",
304                "arch/x86_64/memcmp16_x86_64.S",
305                "arch/x86_64/quick_entrypoints_x86_64.S",
306                "arch/x86_64/thread_x86_64.cc",
307                "monitor_pool.cc",
308                "arch/x86/fault_handler_x86.cc",
309            ],
310        },
311        mips: {
312            srcs: [
313                "interpreter/mterp/mterp.cc",
314                "interpreter/mterp/out/mterp_mips.S",
315                "arch/mips/context_mips.cc",
316                "arch/mips/entrypoints_init_mips.cc",
317                "arch/mips/jni_entrypoints_mips.S",
318                "arch/mips/memcmp16_mips.S",
319                "arch/mips/quick_entrypoints_mips.S",
320                "arch/mips/thread_mips.cc",
321                "arch/mips/fault_handler_mips.cc",
322            ],
323        },
324        mips64: {
325            srcs: [
326                "interpreter/mterp/mterp.cc",
327                "interpreter/mterp/out/mterp_mips64.S",
328                "arch/mips64/context_mips64.cc",
329                "arch/mips64/entrypoints_init_mips64.cc",
330                "arch/mips64/jni_entrypoints_mips64.S",
331                "arch/mips64/memcmp16_mips64.S",
332                "arch/mips64/quick_entrypoints_mips64.S",
333                "arch/mips64/thread_mips64.cc",
334                "monitor_pool.cc",
335                "arch/mips64/fault_handler_mips64.cc",
336            ],
337        },
338    },
339    target: {
340        android: {
341            srcs: [
342                "jdwp/jdwp_adb.cc",
343                "monitor_android.cc",
344                "runtime_android.cc",
345                "thread_android.cc",
346            ],
347            shared_libs: [
348                // For android::FileMap used by libziparchive.
349                "libutils",
350                "libtombstoned_client",
351            ],
352            static_libs: [
353                // ZipArchive support, the order matters here to get all symbols.
354                "libziparchive",
355                "libz",
356            ],
357        },
358        android_arm: {
359            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
360        },
361        android_arm64: {
362            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
363        },
364        android_x86: {
365            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
366        },
367        android_x86_64: {
368            ldflags: JIT_DEBUG_REGISTER_CODE_LDFLAGS,
369        },
370        host: {
371            srcs: [
372                "monitor_linux.cc",
373                "runtime_linux.cc",
374                "thread_linux.cc",
375            ],
376            shared_libs: [
377                "libziparchive",
378                "libz",
379            ],
380        },
381    },
382    cflags: ["-DBUILDING_LIBART=1"],
383    generated_sources: ["art_operator_srcs"],
384    // asm_support_gen.h (used by asm_support.h) is generated with cpp-define-generator
385    generated_headers: ["cpp-define-generator-asm-support"],
386    // export our headers so the libart-gtest targets can use it as well.
387    export_generated_headers: ["cpp-define-generator-asm-support"],
388    include_dirs: [
389        "art/sigchainlib",
390        "external/icu/icu4c/source/common",
391        "external/lz4/lib",
392        "external/zlib",
393    ],
394    header_libs: [
395        "art_cmdlineparser_headers",
396        "libnativehelper_header_only",
397        "jni_platform_headers",
398    ],
399    shared_libs: [
400        "libnativebridge",
401        "libnativeloader",
402        "libbacktrace",
403        "liblz4",
404        "liblog",
405        "libmetricslogger",
406        // For atrace, properties, ashmem, set_sched_policy and socket_peer_is_trusted.
407        "libcutils",
408        // For common macros.
409        "libbase",
410    ],
411    static: {
412        static_libs: ["libsigchain_dummy"],
413    },
414    shared: {
415        shared_libs: ["libsigchain"],
416    },
417    export_include_dirs: ["."],
418    // ART's macros.h depends on libbase's macros.h.
419    // Note: runtime_options.h depends on cmdline. But we don't really want to export this
420    //       generically. dex2oat takes care of it itself.
421    export_shared_lib_headers: ["libbase"],
422}
423
424gensrcs {
425    name: "art_operator_srcs",
426    cmd: "$(location generate_operator_out) art/runtime $(in) > $(out)",
427    tools: ["generate_operator_out"],
428    srcs: [
429        "arch/instruction_set.h",
430        "base/mutex.h",
431        "class_status.h",
432        "debugger.h",
433        "gc_root.h",
434        "gc/allocator_type.h",
435        "gc/allocator/rosalloc.h",
436        "gc/collector_type.h",
437        "gc/collector/gc_type.h",
438        "gc/heap.h",
439        "gc/space/region_space.h",
440        "gc/space/space.h",
441        "gc/weak_root_state.h",
442        "image.h",
443        "instrumentation.h",
444        "indirect_reference_table.h",
445        "jdwp_provider.h",
446        "jdwp/jdwp.h",
447        "jdwp/jdwp_constants.h",
448        "lock_word.h",
449        "oat.h",
450        "object_callbacks.h",
451        "process_state.h",
452        "stack.h",
453        "suspend_reason.h",
454        "thread.h",
455        "thread_state.h",
456        "ti/agent.h",
457        "verifier/verifier_enums.h",
458    ],
459    output_extension: "operator_out.cc",
460}
461
462// We always build dex2oat and dependencies, even if the host build is otherwise disabled, since
463// they are used to cross compile for the target.
464
465art_cc_library {
466    name: "libart",
467    defaults: ["libart_defaults"],
468    // Leave the symbols in the shared library so that stack unwinders can
469    // produce meaningful name resolution.
470    strip: {
471        keep_symbols: true,
472    },
473    whole_static_libs: [
474        "libartbase",
475    ],
476    shared_libs: [
477        "libdexfile",
478    ],
479    export_shared_lib_headers: [
480        "libdexfile",
481    ],
482    target: {
483        android: {
484            lto: {
485                 thin: true,
486            },
487        },
488    },
489}
490
491art_cc_library {
492    name: "libartd",
493    defaults: [
494        "art_debug_defaults",
495        "libart_defaults",
496    ],
497    whole_static_libs: [
498        "libartbased",
499    ],
500    shared_libs: [
501        "libdexfiled",
502    ],
503    export_shared_lib_headers: [
504        "libdexfiled",
505    ],
506}
507
508art_cc_library {
509    name: "libart-runtime-gtest",
510    defaults: ["libart-gtest-defaults"],
511    srcs: [
512        "common_runtime_test.cc",
513        "dexopt_test.cc",
514    ],
515    shared_libs: [
516        "libartd",
517        "libbase",
518        "libbacktrace",
519    ],
520    header_libs: [
521        "libnativehelper_header_only",
522    ],
523    include_dirs: [
524        "external/icu/icu4c/source/common",
525    ],
526}
527
528art_cc_test {
529    name: "art_runtime_tests",
530    defaults: [
531        "art_gtest_defaults",
532    ],
533    srcs: [
534        "arch/arch_test.cc",
535        "arch/instruction_set_test.cc",
536        "arch/instruction_set_features_test.cc",
537        "arch/memcmp16_test.cc",
538        "arch/stub_test.cc",
539        "arch/arm/instruction_set_features_arm_test.cc",
540        "arch/arm64/instruction_set_features_arm64_test.cc",
541        "arch/mips/instruction_set_features_mips_test.cc",
542        "arch/mips64/instruction_set_features_mips64_test.cc",
543        "arch/x86/instruction_set_features_x86_test.cc",
544        "arch/x86_64/instruction_set_features_x86_64_test.cc",
545        "barrier_test.cc",
546        "base/arena_allocator_test.cc",
547        "base/file_utils_test.cc",
548        "base/mutex_test.cc",
549        "base/timing_logger_test.cc",
550        "cha_test.cc",
551        "class_linker_test.cc",
552        "class_loader_context_test.cc",
553        "class_table_test.cc",
554        "compiler_filter_test.cc",
555        "dex/art_dex_file_loader_test.cc",
556        "entrypoints/math_entrypoints_test.cc",
557        "entrypoints/quick/quick_trampoline_entrypoints_test.cc",
558        "entrypoints_order_test.cc",
559        "exec_utils_test.cc",
560        "gc/accounting/card_table_test.cc",
561        "gc/accounting/mod_union_table_test.cc",
562        "gc/accounting/space_bitmap_test.cc",
563        "gc/collector/immune_spaces_test.cc",
564        "gc/heap_test.cc",
565        "gc/heap_verification_test.cc",
566        "gc/reference_queue_test.cc",
567        "gc/space/dlmalloc_space_static_test.cc",
568        "gc/space/dlmalloc_space_random_test.cc",
569        "gc/space/image_space_test.cc",
570        "gc/space/large_object_space_test.cc",
571        "gc/space/rosalloc_space_static_test.cc",
572        "gc/space/rosalloc_space_random_test.cc",
573        "gc/space/space_create_test.cc",
574        "gc/system_weak_test.cc",
575        "gc/task_processor_test.cc",
576        "gtest_test.cc",
577        "handle_scope_test.cc",
578        "hidden_api_test.cc",
579        "imtable_test.cc",
580        "indenter_test.cc",
581        "indirect_reference_table_test.cc",
582        "instrumentation_test.cc",
583        "intern_table_test.cc",
584        "interpreter/safe_math_test.cc",
585        "interpreter/unstarted_runtime_test.cc",
586        "jdwp/jdwp_options_test.cc",
587        "java_vm_ext_test.cc",
588        "jit/profile_compilation_info_test.cc",
589        "mem_map_test.cc",
590        "memory_region_test.cc",
591        "method_handles_test.cc",
592        "mirror/dex_cache_test.cc",
593        "mirror/method_type_test.cc",
594        "mirror/object_test.cc",
595        "mirror/var_handle_test.cc",
596        "monitor_pool_test.cc",
597        "monitor_test.cc",
598        "oat_file_test.cc",
599        "oat_file_assistant_test.cc",
600        "parsed_options_test.cc",
601        "prebuilt_tools_test.cc",
602        "reference_table_test.cc",
603        "runtime_callbacks_test.cc",
604        "subtype_check_info_test.cc",
605        "subtype_check_test.cc",
606        "thread_pool_test.cc",
607        "transaction_test.cc",
608        "type_lookup_table_test.cc",
609        "vdex_file_test.cc",
610        "verifier/method_verifier_test.cc",
611        "verifier/reg_type_test.cc",
612        "zip_archive_test.cc",
613    ],
614    shared_libs: [
615        "libbacktrace",
616        "libziparchive",
617    ],
618    header_libs: [
619        "art_cmdlineparser_headers", // For parsed_options_test.
620    ],
621    include_dirs: [
622        "external/zlib",
623    ],
624}
625
626art_cc_test {
627    name: "art_runtime_compiler_tests",
628    defaults: [
629        "art_gtest_defaults",
630    ],
631    srcs: [
632        "jni_internal_test.cc",
633        "proxy_test.cc",
634        "reflection_test.cc",
635    ],
636    shared_libs: [
637        "libartd-compiler",
638        "libvixld-arm",
639        "libvixld-arm64",
640    ],
641}
642
643cc_library_headers {
644    name: "libart_runtime_headers",
645    host_supported: true,
646    export_include_dirs: ["."],
647}
648