blob: d2545a401d096dfc1a97710a27a29b2415fed1a2 [file] [log] [blame]
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "art_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["art_license"],
}
bootstrap_go_package {
name: "soong-art",
pkgPath: "android/soong/art",
deps: [
"blueprint",
"blueprint-pathtools",
"blueprint-proptools",
"soong",
"soong-android",
"soong-apex",
"soong-cc",
],
srcs: [
"art.go",
"codegen.go",
"makevars.go",
],
pluginFor: ["soong_build"],
}
art_clang_tidy_errors = [
"android-cloexec-open",
"bugprone-lambda-function-name",
"bugprone-unused-raii", // Protect scoped things like MutexLock.
"bugprone-virtual-near-miss",
"modernize-use-bool-literals",
"performance-implicit-conversion-in-loop",
"performance-unnecessary-copy-initialization",
]
art_clang_tidy_allowed = [
// Many files have these warnings. Move them to art_clang_tidy_errors
// when all files are free of these warnings.
"android-cloexec-dup",
"bugprone-argument-comment",
"bugprone-unused-return-value",
"misc-unused-using-decls",
"modernize-use-nullptr",
"modernize-use-using",
"performance-faster-string-find",
"performance-for-range-copy",
"performance-noexcept-move-constructor",
"performance-unnecessary-value-param",
]
art_clang_tidy_disabled = [
"-google-default-arguments",
// We have local stores that are only used for debug checks.
"-clang-analyzer-deadcode.DeadStores",
// We are OK with some static globals and that they can, in theory, throw.
"-cert-err58-cpp",
// We have lots of C-style variadic functions, and are OK with them. JNI ensures
// that working around this warning would be extra-painful.
"-cert-dcl50-cpp",
// "Modernization" we don't agree with.
"-modernize-use-auto",
"-modernize-return-braced-init-list",
"-modernize-use-default-member-init",
"-modernize-pass-by-value",
]
soong_config_module_type_import {
from: "art/build/SoongConfig.bp",
module_types: [
"art_module_art_global_defaults",
"art_module_cc_defaults",
"art_module_java_defaults",
"art_module_genrule_defaults",
"art_module_prebuilt_defaults",
],
}
art_module_art_global_defaults {
// Additional flags are computed by art.go
name: "art_defaults",
// Disable all ART Soong modules by default when ART prebuilts are in use.
// TODO(b/172480617): Clean up when sources are gone from the platform tree
// and we no longer need to support sources present when prebuilts are used.
enabled: false,
soong_config_variables: {
source_build: {
enabled: true,
},
},
// This is the default visibility for the //art package, but we repeat it
// here so that it gets merged with other visibility rules in modules
// extending these defaults.
visibility: ["//art:__subpackages__"],
cflags: [
// Base set of cflags used by all things ART.
"-fno-rtti",
"-ggdb3",
"-Wall",
"-Werror",
"-Wextra",
"-Wstrict-aliasing",
"-fstrict-aliasing",
"-Wunreachable-code",
"-Wredundant-decls",
"-Wshadow",
"-Wunused",
"-fvisibility=protected",
// Warn about thread safety violations with clang.
"-Wthread-safety",
// TODO(b/144045034): turn on -Wthread-safety-negative
//"-Wthread-safety-negative",
// Warn if switch fallthroughs aren't annotated.
"-Wimplicit-fallthrough",
// Enable float equality warnings.
"-Wfloat-equal",
// Enable warning of converting ints to void*.
"-Wint-to-void-pointer-cast",
// Enable warning of wrong unused annotations.
"-Wused-but-marked-unused",
// Enable warning for deprecated language features.
"-Wdeprecated",
// Enable warning for unreachable break & return.
"-Wunreachable-code-break",
"-Wunreachable-code-return",
// Disable warning for use of offsetof on non-standard layout type.
// We use it to implement OFFSETOF_MEMBER - see macros.h.
"-Wno-invalid-offsetof",
// Enable inconsistent-missing-override warning. This warning is disabled by default in
// Android.
"-Winconsistent-missing-override",
// Enable thread annotations for std::mutex, etc.
"-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
],
arch: {
x86: {
avx2: {
cflags: [
"-mavx2",
"-mfma",
],
},
},
x86_64: {
avx2: {
cflags: [
"-mavx2",
"-mfma",
],
},
},
},
target: {
android: {
cflags: [
// To use oprofile_android --callgraph, uncomment this and recompile with
// mmma -j art
// "-fno-omit-frame-pointer",
// "-marm",
// "-mapcs",
],
},
linux: {
cflags: [
// Enable missing-noreturn only on non-Mac. As lots of things are not implemented for
// Apple, it's a pain.
"-Wmissing-noreturn",
],
},
linux_bionic: {
strip: {
// Do not strip art libs when building for linux-bionic.
// Otherwise we can't get any symbols out of crashes.
none: true,
},
},
darwin: {
enabled: false,
},
windows: {
// When the module is enabled globally in the soong_config_variables
// stanza above, it may get enabled on windows too for some module
// types. Hence we need to disable it explicitly.
// TODO(b/172480617): Clean up with that.
enabled: false,
},
host: {
cflags: [
// Bug: 15446488. We don't omit the frame pointer to work around
// clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
"-fno-omit-frame-pointer",
],
},
// The build assumes that all our x86/x86_64 hosts (such as buildbots and developer
// desktops) support at least sse4.2/popcount. This firstly implies that the ART
// runtime binary itself may exploit these features. Secondly, this implies that
// the ART runtime passes these feature flags to dex2oat and JIT by calling the
// method InstructionSetFeatures::FromCppDefines(). Since invoking dex2oat directly
// does not pick up these flags, cross-compiling from a x86/x86_64 host to a
// x86/x86_64 target should not be affected.
linux_x86: {
cflags: [
"-msse4.2",
"-mpopcnt",
],
},
linux_x86_64: {
cflags: [
"-msse4.2",
"-mpopcnt",
],
},
},
codegen: {
arm: {
cflags: ["-DART_ENABLE_CODEGEN_arm"],
},
arm64: {
cflags: ["-DART_ENABLE_CODEGEN_arm64"],
},
x86: {
cflags: ["-DART_ENABLE_CODEGEN_x86"],
},
x86_64: {
cflags: ["-DART_ENABLE_CODEGEN_x86_64"],
},
},
tidy_checks: art_clang_tidy_errors + art_clang_tidy_allowed + art_clang_tidy_disabled,
tidy_checks_as_errors: art_clang_tidy_errors,
tidy_flags: [
// The static analyzer treats DCHECK as always enabled; we sometimes get
// false positives when we use DCHECKs with code that relies on NDEBUG.
"-extra-arg=-UNDEBUG",
// clang-tidy complains about functions like:
// void foo() { CHECK(kIsFooEnabled); /* do foo... */ }
// not being marked noreturn if kIsFooEnabled is false.
"-extra-arg=-Wno-missing-noreturn",
// Because tidy doesn't like our flow checks for compile-time configuration and thinks that
// the following code is dead (it is, but not for all configurations), disable unreachable
// code detection in Clang for tidy builds. It is still on for regular build steps, so we
// will still get the "real" errors.
"-extra-arg=-Wno-unreachable-code",
],
min_sdk_version: "31",
}
// Used to generate binaries that can be backed by transparent hugepages.
cc_defaults {
name: "art_hugepage_defaults",
arch: {
arm64: {
ldflags: ["-z max-page-size=0x200000"],
},
x86_64: {
ldflags: ["-z max-page-size=0x200000"],
},
},
}
art_debug_defaults {
name: "art_debug_defaults",
defaults: ["art_defaults"],
visibility: ["//art:__subpackages__"],
cflags: [
"-DDYNAMIC_ANNOTATIONS_ENABLED=1",
"-DVIXL_DEBUG",
"-UNDEBUG",
],
asflags: [
"-UNDEBUG",
],
target: {
// This has to be duplicated for android and host to make sure it
// comes after the -Wframe-larger-than warnings inserted by art.go
// target-specific properties
android: {
cflags: ["-Wno-frame-larger-than="],
},
host: {
cflags: ["-Wno-frame-larger-than="],
},
},
}
// A version of conscrypt only for enabling the "-hostdex" version to test ART on host.
java_library {
// We need our own name to not clash with the conscrypt library.
name: "conscrypt-host",
installable: true,
hostdex: true,
static_libs: ["conscrypt-for-host"],
// Tests and build files rely on this file to be installed as "conscrypt-hostdex",
// therefore set a stem. Without it, the file would be installed as
// "conscrypt-host-hostdex".
stem: "conscrypt",
sdk_version: "core_platform",
target: {
hostdex: {
required: ["libjavacrypto"],
},
darwin: {
// required module "libjavacrypto" is disabled on darwin
enabled: false,
},
},
}
// A version of core-icu4j only for enabling the "-hostdex" version to test ART on host.
java_library {
// We need our own name to not clash with the core-icu4j library.
name: "core-icu4j-host",
installable: true,
hostdex: true,
static_libs: ["core-icu4j-for-host"],
// Tests and build files rely on this file to be installed as "core-icu4j-hostdex",
// therefore set a stem. Without it, the file would be installed as
// "core-icu4j-host-hostdex".
stem: "core-icu4j",
sdk_version: "core_platform",
target: {
hostdex: {
required: ["libicu_jni"],
},
},
}
// Defaults for different module types to enable them only when building ART
// from sources. TODO(b/172480617): Clean up when sources are gone from the
// platform tree and we no longer need to support sources present when prebuilts
// are used.
art_module_cc_defaults {
name: "art_module_source_build_defaults",
defaults_visibility: [
"//art:__subpackages__",
"//libcore:__subpackages__",
"//libnativehelper:__subpackages__",
],
enabled: false,
soong_config_variables: {
source_build: {
enabled: true,
},
},
target: {
windows: {
// Windows is disabled by default, but if we set enabled:true
// globally above we need to disable it explicitly.
enabled: false,
},
},
}
art_module_java_defaults {
name: "art_module_source_build_java_defaults",
defaults_visibility: [
"//art:__subpackages__",
"//libcore:__subpackages__",
"//libnativehelper:__subpackages__",
],
enabled: false,
soong_config_variables: {
source_build: {
enabled: true,
},
},
target: {
windows: {
enabled: false,
},
},
}
art_module_genrule_defaults {
name: "art_module_source_build_genrule_defaults",
defaults_visibility: [
"//art:__subpackages__",
"//libcore:__subpackages__",
"//libnativehelper:__subpackages__",
],
enabled: false,
soong_config_variables: {
source_build: {
enabled: true,
},
},
target: {
windows: {
enabled: false,
},
},
}
art_module_prebuilt_defaults {
name: "art_module_source_build_prebuilt_defaults",
defaults_visibility: [
"//art:__subpackages__",
"//libcore:__subpackages__",
"//libnativehelper:__subpackages__",
],
enabled: false,
soong_config_variables: {
source_build: {
enabled: true,
},
},
target: {
windows: {
enabled: false,
},
},
}