diff options
| -rw-r--r-- | build/art.go | 28 | ||||
| -rw-r--r-- | runtime/Android.bp | 3 | ||||
| -rw-r--r-- | runtime/hidden_api.cc | 14 |
3 files changed, 40 insertions, 5 deletions
diff --git a/build/art.go b/build/art.go index 59480a0d0f..3dabce3975 100644 --- a/build/art.go +++ b/build/art.go @@ -278,6 +278,7 @@ func init() { android.RegisterModuleType("art_cc_test", artTest) android.RegisterModuleType("art_cc_test_library", artTestLibrary) android.RegisterModuleType("art_cc_defaults", artDefaultsFactory) + android.RegisterModuleType("libart_cc_defaults", libartDefaultsFactory) android.RegisterModuleType("art_global_defaults", artGlobalDefaultsFactory) android.RegisterModuleType("art_debug_defaults", artDebugDefaultsFactory) } @@ -304,6 +305,33 @@ func artDefaultsFactory() android.Module { return module } +func libartDefaultsFactory() android.Module { + c := &codegenProperties{} + module := cc.DefaultsFactory(c) + android.AddLoadHook(module, func(ctx android.LoadHookContext) { + codegen(ctx, c, true) + + type props struct { + Target struct { + Android struct { + Shared_libs []string + } + } + } + + p := &props{} + // TODO: express this in .bp instead b/79671158 + if !envTrue(ctx, "ART_TARGET_LINUX") { + p.Target.Android.Shared_libs = []string { + "libmetricslogger", + } + } + ctx.AppendProperties(p) + }) + + return module +} + func artLibrary() android.Module { m, _ := cc.NewLibrary(android.HostAndDeviceSupported) module := m.Init() diff --git a/runtime/Android.bp b/runtime/Android.bp index 64e6796ba0..6a585c17f9 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -23,7 +23,7 @@ JIT_DEBUG_REGISTER_CODE_LDFLAGS = [ "-Wl,--keep-unique,__dex_debug_register_code" ] -cc_defaults { +libart_cc_defaults { name: "libart_defaults", defaults: ["art_defaults"], host_supported: true, @@ -396,7 +396,6 @@ cc_defaults { "libbacktrace", "liblz4", "liblog", - "libmetricslogger", // For atrace, properties, ashmem, set_sched_policy and socket_peer_is_trusted. "libcutils", // For common macros. diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc index 9354d721b7..ee518ae1ea 100644 --- a/runtime/hidden_api.cc +++ b/runtime/hidden_api.cc @@ -14,8 +14,6 @@ * limitations under the License. */ -#include <metricslogger/metrics_logger.h> - #include "hidden_api.h" #include <nativehelper/scoped_local_ref.h> @@ -24,11 +22,14 @@ #include "thread-current-inl.h" #include "well_known_classes.h" +#ifdef ART_TARGET_ANDROID +#include <metricslogger/metrics_logger.h> using android::metricslogger::ComplexEventLogger; using android::metricslogger::ACTION_HIDDEN_API_ACCESSED; using android::metricslogger::FIELD_HIDDEN_API_ACCESS_METHOD; using android::metricslogger::FIELD_HIDDEN_API_ACCESS_DENIED; using android::metricslogger::FIELD_HIDDEN_API_SIGNATURE; +#endif namespace art { namespace hiddenapi { @@ -137,6 +138,7 @@ void MemberSignature::WarnAboutAccess(AccessMethod access_method, LOG(WARNING) << "Accessing hidden " << (type_ == kField ? "field " : "method ") << Dumpable<MemberSignature>(*this) << " (" << list << ", " << access_method << ")"; } +#ifdef ART_TARGET_ANDROID // Convert an AccessMethod enum to a value for logging from the proto enum. // This method may look odd (the enum values are current the same), but it // prevents coupling the internal enum to the proto enum (which should never @@ -156,8 +158,10 @@ inline static int32_t GetEnumValueForLog(AccessMethod access_method) { DCHECK(false); } } +#endif void MemberSignature::LogAccessToEventLog(AccessMethod access_method, Action action_taken) { +#ifdef ART_TARGET_ANDROID if (access_method == kLinking || access_method == kNone) { // Linking warnings come from static analysis/compilation of the bytecode // and can contain false positives (i.e. code that is never run). We choose @@ -174,6 +178,10 @@ void MemberSignature::LogAccessToEventLog(AccessMethod access_method, Action act Dump(signature_str); log_maker.AddTaggedData(FIELD_HIDDEN_API_SIGNATURE, signature_str.str()); log_maker.Record(); +#else + UNUSED(access_method); + UNUSED(action_taken); +#endif } static ALWAYS_INLINE bool CanUpdateMemberAccessFlags(ArtField*) { @@ -228,7 +236,7 @@ Action GetMemberActionImpl(T* member, } } - if (kIsTargetBuild) { + if (kIsTargetBuild && !kIsTargetLinux) { uint32_t eventLogSampleRate = runtime->GetHiddenApiEventLogSampleRate(); // Assert that RAND_MAX is big enough, to ensure sampling below works as expected. static_assert(RAND_MAX >= 0xffff, "RAND_MAX too small"); |