def build_type_flags(compiler, build_type, vs_toolset=None):
    """
    returns flags specific to the build type (Debug, Release, etc.)
    (-s, -g, /Zi, etc.)
    """
    if not compiler or not build_type:
        return ''
    if str(compiler) == 'Visual Studio':
        if vs_toolset and 'clang' in str(vs_toolset):
            flags = {'Debug': ['-gline-tables-only', '-fno-inline', '-O0'],
                'Release': ['-O2'], 'RelWithDebInfo': ['-gline-tables-only',
                '-O2', '-fno-inline'], 'MinSizeRel': []}.get(build_type, [
                '-O2', '-Ob2'])
        else:
            flags = {'Debug': ['-Zi', '-Ob0', '-Od'], 'Release': ['-O2',
                '-Ob2'], 'RelWithDebInfo': ['-Zi', '-O2', '-Ob1'],
                'MinSizeRel': ['-O1', '-Ob1']}.get(build_type, [])
        return flags
    elif str(compiler) in ['clang', 'gcc', 'apple-clang', 'qcc']:
        flags = {'Debug': ['-g'], 'Release': ['-O3', '-s'] if str(compiler) ==
            'gcc' else ['-O3'], 'RelWithDebInfo': ['-O2', '-g'],
            'MinSizeRel': ['-Os']}.get(build_type, [])
        return flags
    elif str(compiler) == 'sun-cc':
        flags = {'Debug': ['-g'], 'Release': ['-xO3'], 'RelWithDebInfo': [
            '-xO2', '-g'], 'MinSizeRel': ['-xO2', '-xspace']}.get(build_type,
            [])
        return flags
    return ''
