message: Guard -lrt adding in check for linux variant
diff: @@ -262,6 +262,17 @@ def if_nccl(if_true, if_false = []):
  "//conditions:default": if_true,
  })
  +# Linux systems may required -lrt linker flag for e.g. clock_gettime
  +# see https://github.com/tensorflow/tensorflow/issues/15129
  +def lrt_if_needed():
  + lrt = ["-lrt"]
  + return select({
  + clean_dep("//tensorflow:linux_aarch64"): lrt,
  + clean_dep("//tensorflow:linux_x86_64"): lrt,
  + clean_dep("//tensorflow:linux_ppc64le"): lrt,
  + "//conditions:default": [],
  + })
  +
  def get_win_copts(is_external = False):
  WINDOWS_COPTS = [
  "/DPLATFORM_WINDOWS",
  @@ -537,7 +548,7 @@ def tf_cc_shared_object(
  srcs = [],
  deps = [],
  data = [],
  - linkopts = if_not_windows(["-lrt"]),
  + linkopts = lrt_if_needed(),
  framework_so = tf_binary_additional_srcs(),
  soversion = None,
  kernels = [],
  @@ -641,7 +652,7 @@ def tf_cc_binary(
  srcs = [],
  deps = [],
  data = [],
  - linkopts = if_not_windows(["-lrt"]),
  + linkopts = lrt_if_needed(),
  copts = tf_copts(),
  kernels = [],
  per_os_targets = False, # Generate targets with SHARED_LIBRARY_NAME_PATTERNS
  @@ -737,7 +748,7 @@ def tf_gen_op_wrapper_cc(
  tf_cc_binary(
  name = tool,
  copts = tf_copts(),
  - linkopts = if_not_windows(["-lm", "-Wl,-ldl", "-lrt"]),
  + linkopts = if_not_windows(["-lm", "-Wl,-ldl"]) + lrt_if_needed(),
  linkstatic = 1, # Faster to link this one-time-use binary dynamically
  deps = [op_gen] + deps,
  )
  @@ -910,7 +921,7 @@ def tf_gen_op_wrapper_py(
  hidden_file = None,
  generated_target_name = None,
  op_whitelist = [],
  - cc_linkopts = [],
  + cc_linkopts = lrt_if_needed(),
  api_def_srcs = []):
  _ = require_shape_functions # Unused.
  @@ -924,7 +935,7 @@ def tf_gen_op_wrapper_py(
  tf_cc_binary(
  name = tool_name,
  copts = tf_copts(),
  - linkopts = if_not_windows(["-lm", "-Wl,-ldl", "-lrt"]) + cc_linkopts,
  + linkopts = if_not_windows(["-lm", "-Wl,-ldl"]) + cc_linkopts,
  linkstatic = 1, # Faster to link this one-time-use binary dynamically
  visibility = [clean_dep("//tensorflow:internal")],
  deps = ([
  @@ -1221,7 +1232,7 @@ def tf_cc_tests(
  tags = [],
  size = "medium",
  args = None,
  - linkopts = if_not_windows(["-lrt"]),
  + linkopts = lrt_if_needed(),
  kernels = [],
  create_named_test_suite = False,
  visibility = None):
  