code: def fix_sanitize_flag(cmd, opts):
      """
      Remove -fsanitize=address flag if sanitazers are linked explicitly for linux target.
      """
      for flag in cmd:
          if (
              flag.startswith("--target")
              and "linux" not in flag.lower()
          ):
              # use toolchained sanitize libraries
              return cmd
      assert opts.clang_ver
      CLANG_RT = "contrib/libs/clang" + opts.clang_ver + "-rt/lib/"
      sanitize_flags = {
          "-fsanitize=address": CLANG_RT + "asan",
          "-fsanitize=memory": CLANG_RT + "msan",
          "-fsanitize=leak": CLANG_RT + "lsan",
          "-fsanitize=undefined": CLANG_RT + "ubsan",
          "-fsanitize=thread": CLANG_RT + "tsan",
      }
  
      used_sanitize_libs = []
      aux = []
      for flag in cmd:
          if flag.startswith("-fsanitize-coverage="):
              # do not link sanitizer libraries from clang
              aux.append("-fno-sanitize-link-runtime")
          if flag in sanitize_flags and any(
              s.startswith(sanitize_flags[flag]) for s in cmd
          ):
              # exclude '-fsanitize=' if appropriate library is linked explicitly
              continue
          if any(
              flag.startswith(lib) for lib in sanitize_flags.values()
          ):
              used_sanitize_libs.append(flag)
              continue
          aux.append(flag)
  
      # move sanitize libraries out of the repeatedly searched group of archives
      flags = []
      for flag in aux:
          if flag == "-Wl,--start-group":
              flags += (
                  ["-Wl,--whole-archive"]
                  + used_sanitize_libs
                  + ["-Wl,--no-whole-archive"]
              )
          flags.append(flag)
  
      return flags
  
file_path: catboost/build/scripts/link_exe.py
imports: import sys
  import subprocess
  import optparse
  import process_command_files
  from process_whole_archive_option import ProcessWholeArchiveOption
label_desc: Use image node_id 3 for calling a global function with example usage: fix_sanitize_flag(cmd, opts) and returns: flags, cmd