def METHOD_NAME(go):
    pkg = go.declare_directory(go, path = "pkg")
    args = go.builder_args(go, "stdlib")
    args.add("-out", pkg.dirname)
    if go.mode.race:
        args.add("-race")
    args.add("-package", "std")
    if not go.mode.pure:
        args.add("-package", "runtime/cgo")
    args.add_all(link_mode_args(go.mode))
    args.add("-gcflags", quote_opts(go.mode.gc_goopts))
    inputs = (go.sdk.srcs +
              go.sdk.headers +
              go.sdk.tools +
              [go.sdk.go, go.sdk.package_list, go.sdk.root_file] +
              go.crosstool)
    if go.mode.pgoprofile:
        args.add("-pgoprofile", go.mode.pgoprofile)
        inputs.append(go.mode.pgoprofile)
    outputs = [pkg]
    go.actions.run(
        inputs = inputs,
        outputs = outputs,
        mnemonic = "GoStdlib",
        executable = go.toolchain._builder,
        arguments = [args],
        env = _build_env(go),
    )
    return GoStdLib(
        _list_json = _build_stdlib_list_json(go),
        libs = [pkg],
        root_file = pkg,
    )