code: def _construct_cmd_linux(self, args):
      whole_archive_flag = "-Wl,--whole-archive"
      no_whole_archive_flag = "-Wl,--no-whole-archive"
  
      def replace_markers(arg):
          if arg == self.start_wa_marker:
              return whole_archive_flag
          if arg == self.end_wa_marker:
              return no_whole_archive_flag
          return arg
  
      args = [replace_markers(arg) for arg in args]
  
      cmd = []
      is_inside_whole_archive = False
      is_whole_archive = False
      # We are trying not to create excessive sequences of consecutive flags
      # -Wl,--no-whole-archive  -Wl,--whole-archive ('externally' specified
      # flags -Wl,--[no-]whole-archive are not taken for consideration in this
      # optimization intentionally)
      for arg in args:
          if arg == whole_archive_flag:
              is_inside_whole_archive = True
              is_whole_archive = False
          elif arg == no_whole_archive_flag:
              is_inside_whole_archive = False
              is_whole_archive = False
          else:
              key = self._process_arg(arg)
              if not is_inside_whole_archive:
                  if key:
                      if not is_whole_archive:
                          cmd.append(whole_archive_flag)
                          is_whole_archive = True
                  elif is_whole_archive:
                      cmd.append(no_whole_archive_flag)
                      is_whole_archive = False
  
          cmd.append(arg)
  
      if is_whole_archive:
          cmd.append(no_whole_archive_flag)
  
      # There can be an empty sequence of archive files between
      # -Wl, --whole-archive and -Wl, --no-whole-archive flags.
      # As a result an unknown option error may occur, therefore to
      # prevent this case we need to remove both flags from cmd.
      # These flags affects only on subsequent archive files.
      if len(cmd) == 2:
          return []
  
      self._check_peers()
  
      return cmd
  
file_path: catboost/build/scripts/process_whole_archive_option.py
imports: import os
  import process_command_files
label_desc: Use image node_id 8 for calling the ProcessWholeArchiveOption obj's underlying member method code with example usage: obj._construct_cmd_linux(args) and returns: cmd, arg, list, whole_archive_flag, no_whole_archive_flag