def _get_clang_compiler_defines(compiler: T.List[str], lang: str) -> T.Dict[str, str]:
    """
    Get the list of Clang pre-processor defines
    """
    from .mixins.clang import clang_lang_map

    def _try_obtain_compiler_defines(args: T.List[str]) -> str:
        mlog.debug(f'Running command: {join_args(args)}')
        p, output, error = Popen_safe(compiler + args, write='', stdin=subprocess.PIPE)
        if p.returncode != 0:
            raise EnvironmentException('Unable to get clang pre-processor defines:\n'
                                       f'Compiler stdout:\n{output}\n-----\n'
                                       f'Compiler stderr:\n{error}\n-----\n')
        return output

    # Arguments to output compiler pre-processor defines to stdout
    baseline_test_args = ['-E', '-dM', '-']
    try:
        # We assume that when _get_clang_compiler_defines is called, it's
        # close enough to a Clangish compiler so we reuse the _LANG_MAP
        # from the Clang mixin. This isn't a dangerous assumption because
        # we fallback if the detection fails anyway.

        # We might not have a match for Fortran, so fallback to detection
        # based on the driver.
        lang = clang_lang_map[lang]

        # The compiler may not infer the target language based on the driver name.
        # Try first with '-x lang' to supported systemwide language level overrides,
        # then fallback to without since it's a more recent option.
        output = _try_obtain_compiler_defines(['-x', lang] + baseline_test_args)
    except (EnvironmentException, KeyError):
        mlog.debug(f'pre-processor extraction using -x {lang} failed, falling back w/o lang')
        output = _try_obtain_compiler_defines(baseline_test_args)

    defines: T.Dict[str, str] = {}
    for line in output.split('\n'):
        if not line:
            continue
        d, *rest = line.split(' ', 2)
        if d != '#define':
            continue
        if len(rest) == 1:
            defines[rest[0]] = ''
        if len(rest) == 2:
            defines[rest[0]] = rest[1]
    return defines

    Get the list of Clang pre-processor defines
    
mesonbuild/compilers/detect.py