Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/tools/gopackagesdriver: pass Compiler and Arch in DriverResponse #3657

Merged
merged 3 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions go/tools/gopackagesdriver/json_packages_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package main

import (
"fmt"
"go/types"
"runtime"
)

type JSONPackagesDriver struct {
Expand Down Expand Up @@ -52,8 +52,10 @@ func (b *JSONPackagesDriver) GetResponse(labels []string) *driverResponse {

return &driverResponse{
NotHandled: false,
Sizes: types.SizesFor("gc", "amd64").(*types.StdSizes),
Roots: rootPkgs,
Packages: packages,
// Reviewer: see comment in main.go about the Arch field in the driver response.
Compiler: "gc",
Arch: runtime.GOARCH,
Roots: rootPkgs,
Packages: packages,
}
}
19 changes: 13 additions & 6 deletions go/tools/gopackagesdriver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"context"
"encoding/json"
"fmt"
"go/types"
"os"
"runtime"
"strings"
)

Expand All @@ -31,8 +31,10 @@ type driverResponse struct {
// lists of multiple drivers, go/packages will fall back to the next driver.
NotHandled bool

// Sizes, if not nil, is the types.Sizes to use when type checking.
Sizes *types.StdSizes
// Compiler and Arch are the arguments pass of types.SizesFor
// to get a types.Sizes to use when type checking.
Compiler string
Arch string

// Roots is the set of package IDs that make up the root packages.
// We have to encode this separately because when we encode a single package
Expand Down Expand Up @@ -63,9 +65,14 @@ var (
additionalKinds = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_KINDS"))
emptyResponse = &driverResponse{
NotHandled: true,
Sizes: types.SizesFor("gc", "amd64").(*types.StdSizes),
Roots: []string{},
Packages: []*FlatPackage{},
// For the reviewer: Does bazel ever use gccgo? I assume bazel can build for other
matloob marked this conversation as resolved.
Show resolved Hide resolved
// platforms. If that's the case, how do we find out the actual arch to use here?
// Is it reasonable to assume that the configuration that gopackagesdriver is built
// with matches the configuration
Compiler: "gc",
Arch: runtime.GOARCH,
Roots: []string{},
Packages: []*FlatPackage{},
}
)

Expand Down