Add a phenotype flag to disable compact dex in dex2oat.
The purpose is in particular to control usage of libart-dexlayout.so to
conduct an experiment on its impact.
Add the flag to odrefresh recompile logic since odex files are
invalidated when it changes.
Test: Gtests and run tests on host and in chroot
with the flag defaulting to true and dexlayout dependencies
temporarily commented out from dex2oat/linker/oat_writer.cc.
Intentional failures in compact dex related gtests in
art_dex2oat_tests:
Dex2oatTest.LayoutSections
Dex2oatTest.GenerateCompactDex
Dex2oatTest.CompactDexInZip
Bug: 256664509
Change-Id: If518f7d128e99eddbd8f643c2d8b8b4a39efaef4
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index d0e22a5..fa15e53 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -39,6 +39,7 @@
#endif
#include "android-base/parseint.h"
+#include "android-base/properties.h"
#include "android-base/scopeguard.h"
#include "android-base/stringprintf.h"
#include "android-base/strings.h"
@@ -1101,6 +1102,19 @@
AssignIfExists(args, M::PublicSdk, &public_sdk_);
AssignIfExists(args, M::ApexVersions, &apex_versions_argument_);
+ // Check for phenotype flag to override compact_dex_level_, if it isn't "none" already.
+ // TODO(b/256664509): Clean this up.
+ if (compact_dex_level_ != CompactDexLevel::kCompactDexLevelNone) {
+ std::string ph_disable_compact_dex =
+ android::base::GetProperty(kPhDisableCompactDex, "false");
+ if (ph_disable_compact_dex == "true") {
+ LOG(WARNING)
+ << "Overriding --compact-dex-level due to "
+ "persist.device_config.runtime_native_boot.disable_compact_dex set to `true`";
+ compact_dex_level_ = CompactDexLevel::kCompactDexLevelNone;
+ }
+ }
+
AssignIfExists(args, M::Backend, &compiler_kind_);
parser_options->requested_specific_compiler = args.Exists(M::Backend);
diff --git a/libartbase/base/globals.h b/libartbase/base/globals.h
index 8d37b8a..f4d44b8 100644
--- a/libartbase/base/globals.h
+++ b/libartbase/base/globals.h
@@ -107,6 +107,12 @@
static constexpr bool kHostStaticBuildEnabled = false;
#endif
+// System property for phenotype flag to test disabling compact dex and in
+// particular dexlayout.
+// TODO(b/256664509): Clean this up.
+static constexpr char kPhDisableCompactDex[] =
+ "persist.device_config.runtime_native_boot.disable_compact_dex";
+
} // namespace art
#endif // ART_LIBARTBASE_BASE_GLOBALS_H_
diff --git a/odrefresh/odr_config.h b/odrefresh/odr_config.h
index 420f680..5261fe4 100644
--- a/odrefresh/odr_config.h
+++ b/odrefresh/odr_config.h
@@ -67,7 +67,8 @@
// requirement (go/platform-experiments-flags#pre-requisites).
const android::base::NoDestructor<std::vector<SystemPropertyConfig>> kSystemProperties{
{SystemPropertyConfig{.name = "persist.device_config.runtime_native_boot.enable_uffd_gc",
- .default_value = "false"}}};
+ .default_value = "false"},
+ SystemPropertyConfig{.name = kPhDisableCompactDex, .default_value = "false"}}};
// An enumeration of the possible zygote configurations on Android.
enum class ZygoteKind : uint8_t {