def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
    self.configname = configname
    ldflags = []

    # The xcode build is relative to a gyp file's directory, and OTHER_LDFLAGS
    # can contain entries that depend on this. Explicitly absolutify these.
    for ldflag in self._Settings().get('OTHER_LDFLAGS', []):
      ldflags.append(self._MapLinkerFlagFilename(ldflag, gyp_to_build_path))

    if self._Test('DEAD_CODE_STRIPPING', 'YES', default='NO'):
      ldflags.append('-Wl,-dead_strip')

    if self._Test('PREBINDING', 'YES', default='NO'):
      ldflags.append('-Wl,-prebind')

    self._Appendf(
        ldflags, 'DYLIB_COMPATIBILITY_VERSION', '-compatibility_version %s')
    self._Appendf(
        ldflags, 'DYLIB_CURRENT_VERSION', '-current_version %s')

    self._AppendPlatformVersionMinFlags(ldflags)

    if 'SDKROOT' in self._Settings() and self._SdkPath():
      ldflags.append('-isysroot ' + self._SdkPath())

    for library_path in self._Settings().get('LIBRARY_SEARCH_PATHS', []):
      ldflags.append('-L' + gyp_to_build_path(library_path))

    if 'ORDER_FILE' in self._Settings():
      ldflags.append('-Wl,-order_file ' +
                     '-Wl,' + gyp_to_build_path(
                                  self._Settings()['ORDER_FILE']))

    if arch is not None:
      archs = [arch]
    else:
      assert self.configname
      archs = self.GetActiveArchs(self.configname)
    if len(archs) != 1:
      # TODO: Supporting fat binaries will be annoying.
      self._WarnUnimplemented('ARCHS')
      archs = ['i386']
    ldflags.append('-arch ' + archs[0])

    # Xcode adds the product directory by default.
    ldflags.append('-L' + product_dir)

    install_name = self.GetInstallName()
    if install_name and self.spec['type'] != 'loadable_module':
      ldflags.append('-install_name ' + install_name.replace(' ', r'\ '))

    for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []):
      ldflags.append('-Wl,-rpath,' + rpath)

    sdk_root = self._SdkPath()
    if not sdk_root:
      sdk_root = ''
    config = self.spec['configurations'][self.configname]
    framework_dirs = config.get('mac_framework_dirs', [])
    for directory in framework_dirs:
      ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))

    is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension()
    if sdk_root and is_extension:
      # Adds the link flags for extensions. These flags are common for all
      # extensions and provide loader and main function.
      # These flags reflect the compilation options used by xcode to compile
      # extensions.
      ldflags.append('-lpkstart')
      if XcodeVersion() < '0900':
        ldflags.append(sdk_root +
            '/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit')
      ldflags.append('-fapplication-extension')
      ldflags.append('-Xlinker -rpath '
          '-Xlinker @executable_path/../../Frameworks')

    self._Appendf(ldflags, 'CLANG_CXX_LIBRARY', '-stdlib=%s')

    self.configname = None
    return ldflags
Returns flags that need to be passed to the linker.
dataset/ETHPy150Open adblockplus/gyp/pylib/gyp/xcode_emulation.py/XcodeSettings.GetLdflags