diff --git a/tensorflow/BUILD b/tensorflow/BUILD
index 2bfce72d566..bb0784a68ec 100644
--- a/tensorflow/BUILD
+++ b/tensorflow/BUILD
@@ -589,7 +589,7 @@ tf_cc_shared_object(
         "//tensorflow/core:gpu_runtime_impl",
         "//tensorflow/core/grappler/optimizers:custom_graph_optimizer_registry_impl",
         "//tensorflow/core:lib_internal_impl",
-        "//tensorflow/core/profiler/lib:profiler_session_impl",
+        "//tensorflow/core/profiler:profiler_impl",
         "//tensorflow/stream_executor:stream_executor_impl",
         "//tensorflow:tf_framework_version_script.lds",
     ] + tf_additional_binary_deps(),
diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD
index 4cb06074ea1..bd059705328 100644
--- a/tensorflow/core/BUILD
+++ b/tensorflow/core/BUILD
@@ -2291,9 +2291,6 @@ tf_cuda_library(
         "//tensorflow/core/framework:tensor_shape",
         "//tensorflow/core/kernels:bounds_check",
         "//tensorflow/core/platform/default/build_config:platformlib",
-        "//tensorflow/core/profiler/internal:annotation_stack_impl",
-        "//tensorflow/core/profiler/internal:traceme_recorder_impl",
-        "//tensorflow/core/profiler/internal:profiler_factory_impl",
         "//tensorflow/core/profiler/lib:annotated_traceme",
         "//tensorflow/core/profiler/lib:traceme",
         "//tensorflow/core/util:einsum_op_util",
@@ -2719,7 +2716,7 @@ tf_cuda_library(
         ":protos_all_cc",
         "//tensorflow/core/debug:debug_graph_utils",
         "//tensorflow/core/kernels:function_ops",
-        "//tensorflow/core/profiler/lib:profiler_lib",
+        "//tensorflow/core/profiler/lib:profiler_backends",
         "//tensorflow/core/profiler/lib:profiler_session",
         "//tensorflow/core/profiler/lib:traceme",
         "@com_google_absl//absl/container:flat_hash_set",
diff --git a/tensorflow/core/profiler/BUILD b/tensorflow/core/profiler/BUILD
index 6398478e8de..3a627e3afb3 100644
--- a/tensorflow/core/profiler/BUILD
+++ b/tensorflow/core/profiler/BUILD
@@ -72,6 +72,18 @@ tf_proto_library(
     visibility = [":friends"],
 )
 
+cc_library(
+    name = "profiler_impl",
+    visibility = ["//tensorflow:__pkg__"],
+    deps = [
+        "//tensorflow/core/profiler/internal:annotation_stack_impl",
+        "//tensorflow/core/profiler/internal:profiler_factory_impl",
+        "//tensorflow/core/profiler/internal:traceme_recorder_impl",
+        "//tensorflow/core/profiler/lib:profiler_session_impl",
+    ],
+    alwayslink = True,
+)
+
 # Libraries and binaries of TensorFlow profiler 1.x.
 tf_cc_binary(
     name = "profiler",
diff --git a/tensorflow/core/profiler/internal/BUILD b/tensorflow/core/profiler/internal/BUILD
index 0147a7394b3..3c9d662d1da 100644
--- a/tensorflow/core/profiler/internal/BUILD
+++ b/tensorflow/core/profiler/internal/BUILD
@@ -400,7 +400,6 @@ cc_library(
     ]),
 )
 
-# Linked into libtensorflow_framework.so via :framework_internal_impl.
 cc_library(
     name = "traceme_recorder_impl",
     srcs = [
@@ -408,7 +407,7 @@ cc_library(
         "traceme_recorder.h",
     ],
     visibility = [
-        "//tensorflow/core:__pkg__",
+        "//tensorflow/core/profiler:__pkg__",
         "//tensorflow/python:__pkg__",
     ],
     deps = [
@@ -449,7 +448,6 @@ cc_library(
     ]),
 )
 
-# Linked into libtensorflow_framework.so via :framework_internal_impl.
 cc_library(
     name = "profiler_factory_impl",
     srcs = [
@@ -457,7 +455,7 @@ cc_library(
         "profiler_factory.h",
     ],
     visibility = [
-        "//tensorflow/core:__pkg__",
+        "//tensorflow/core/profiler:__pkg__",
     ],
     deps = [
         ":profiler_interface",
@@ -491,7 +489,6 @@ cc_library(
     ]),
 )
 
-# Linked into libtensorflow_framework.so via :framework_internal_impl.
 cc_library(
     name = "annotation_stack_impl",
     srcs = [
@@ -499,7 +496,7 @@ cc_library(
         "annotation_stack.h",
     ],
     visibility = [
-        "//tensorflow/core:__pkg__",
+        "//tensorflow/core/profiler:__pkg__",
         "//tensorflow/python:__pkg__",
     ],
     deps = [
diff --git a/tensorflow/core/profiler/lib/BUILD b/tensorflow/core/profiler/lib/BUILD
index 32eff436ee8..f73ad258c0b 100644
--- a/tensorflow/core/profiler/lib/BUILD
+++ b/tensorflow/core/profiler/lib/BUILD
@@ -1,5 +1,5 @@
 load("//tensorflow/core/platform:build_config_root.bzl", "if_static")
-load("//tensorflow:tensorflow.bzl", "tf_cuda_library")
+load("//tensorflow:tensorflow.bzl", "if_not_mobile", "tf_cuda_library")
 
 package(
     default_visibility = [
@@ -23,9 +23,6 @@ cc_library(
     ]),
 )
 
-# Linked directly into ":tensorflow_framework".
-# Unlike other "_impl" targets in the profiler, this one depends on "core:framework" so linking it
-# to "core:framework_internal_impl" causes a circular dependency.
 cc_library(
     name = "profiler_session_impl",
     srcs = [
@@ -33,34 +30,31 @@ cc_library(
         "profiler_session.h",
     ],
     visibility = [
-        "//tensorflow:__pkg__",
+        "//tensorflow/core/profiler:__pkg__",
         "//tensorflow/python:__pkg__",
     ],
     deps = [
-        ":profiler_utils",
         "//tensorflow/core:lib",
         "//tensorflow/core:lib_internal",
         "//tensorflow/core:framework",
         "//tensorflow/core:protos_all_cc",
         "//tensorflow/core/platform",
         "//tensorflow/core/profiler/internal:profiler_interface",
-        "//tensorflow/core/profiler/internal:profiler_factory",
         "//tensorflow/core/profiler/protobuf:xplane_proto_cc",
         "//tensorflow/core/util:ptr_util",
-    ] + select({
-        "//tensorflow:android": [],
-        "//conditions:default": [
-            "//tensorflow/core/profiler/convert:xplane_to_trace_events",
-            "//tensorflow/core/profiler/utils:derived_timeline",
-            "//tensorflow/core/profiler/utils:group_events",
-            "//tensorflow/core/profiler/utils:xplane_utils",
-        ],
-    }),
+    ] + if_not_mobile([
+        ":profiler_utils",
+        "//tensorflow/core/profiler/internal:profiler_factory",
+        "//tensorflow/core/profiler/convert:xplane_to_trace_events",
+        "//tensorflow/core/profiler/utils:derived_timeline",
+        "//tensorflow/core/profiler/utils:group_events",
+        "//tensorflow/core/profiler/utils:xplane_utils",
+    ]),
     alwayslink = True,
 )
 
 tf_cuda_library(
-    name = "profiler_lib",
+    name = "profiler_backends",
     cuda_deps = [
         "//tensorflow/core/profiler/internal/gpu:device_tracer",
     ],
@@ -76,11 +70,12 @@ cc_library(
     hdrs = ["traceme.h"],
     visibility = ["//visibility:public"],
     deps = [
+        "@com_google_absl//absl/strings",
         "//tensorflow/core:lib",
         "//tensorflow/core/platform",
+    ] + if_not_mobile([
         "//tensorflow/core/profiler/internal:traceme_recorder",
-        "@com_google_absl//absl/strings",
-    ],
+    ]),
 )
 
 cc_library(
@@ -100,11 +95,12 @@ cc_library(
     hdrs = ["scoped_annotation.h"],
     visibility = ["//visibility:public"],
     deps = [
+        "@com_google_absl//absl/strings",
         "//tensorflow/core:lib",
         "//tensorflow/core/platform",
+    ] + if_not_mobile([
         "//tensorflow/core/profiler/internal:annotation_stack",
-        "@com_google_absl//absl/strings",
-    ],
+    ]),
 )
 
 cc_library(