def FlagsForCpu(cpu, target_os, sysroot):
  """Returns the flags to build for the given CPU."""
  FLAGS = {
      'x64': '-m64',
      'x86': '-m32',
      'arm': '-arch armv7',
      'arm64': '-arch arm64',
  }
  assert ' ' not in sysroot, "sysroot path can't contain spaces"
  assert cpu in FLAGS, 'Unsupported CPU architecture'

  extra = ' -isysroot ' + sysroot if sysroot else ''
  if target_os == 'ios':
    if cpu == 'x86' or cpu == 'x64':
      extra += ' -mios-simulator-version-min=9.0'
    else:
      extra += ' -miphoneos-version-min=9.0'
  return FLAGS[cpu] + extra