def METHOD_NAME(go):
    env = go.env
    if go.mode.pure:
        env.update({"CGO_ENABLED": "0"})
        return env
    # NOTE(#2545): avoid unnecessary dynamic link
    # go std library doesn't use C++, so should not have -lstdc++
    # Also drop coverage flags as nothing in the stdlib is compiled with
    # coverage - we disable it for all CGo code anyway.
    # NOTE(#3590): avoid forcing static linking.
    ldflags = [
        option
        for option in extldflags_from_cc_toolchain(go)
        if option not in ("-lstdc++", "-lc++", "-static") and option not in COVERAGE_OPTIONS_DENYLIST
    ]
    env.update({
        "CGO_ENABLED": "1",
        "CC": go.cgo_tools.c_compiler_path,
        "CGO_CFLAGS": " ".join(go.cgo_tools.c_compile_options),
        "CGO_LDFLAGS": " ".join(ldflags),
    })
    return env