You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Failing to specify the NeedFiles mode flag seems to trigger the erroneous inclusion of .s files among CompiledGoFiles. Adding the flag fixes the problem. I suspect this is related to #28749, but even so:
(a) go/packages could implement a workaround if the underlying go list bug can't be quickly fixed;
(b) the NeedFiles flag shouldn't have any effect on the CompiledGoFiles field; and
(c) why is the CompiledGoFiles field populated at all when that mode bit wasn't specified?
$ cat main.go
package main
import (
"fmt"
"log"
"strings"
"golang.org/x/tools/go/packages"
)
func main() {
cfg := &packages.Config{
Mode: packages.NeedImports |
// packages.NeedFiles | // try with and without this line
packages.NeedCompiledGoFiles,
}
pkgs, err := packages.Load(cfg, "runtime")
if err != nil {
log.Fatalf("load: %v", err)
}
fmt.Println(strings.Join(pkgs[0].CompiledGoFiles, "\n"))
}
$ go run ./main.go > without
# now uncomment the NeedFiles line
$ go run ./main.go > with
$ diff with without
123a124,133
> /usr/local/go/src/runtime/asm.s
> /usr/local/go/src/runtime/asm_arm64.s
> /usr/local/go/src/runtime/atomic_arm64.s
> /usr/local/go/src/runtime/duff_arm64.s
> /usr/local/go/src/runtime/memclr_arm64.s
> /usr/local/go/src/runtime/memmove_arm64.s
> /usr/local/go/src/runtime/preempt_arm64.s
> /usr/local/go/src/runtime/rt0_darwin_arm64.s
> /usr/local/go/src/runtime/sys_darwin_arm64.s
> /usr/local/go/src/runtime/tls_arm64.s
The text was updated successfully, but these errors were encountered:
gopherbot
added
the
Tools
This label describes issues relating to any tools in the x/tools repository.
label
Nov 7, 2022
This has an additional consequence that NeedSyntax without specifying NeedFiles tries to parse the .s files as Go source, and then produces invalid ASTs that fail type checking.
Failing to specify the NeedFiles mode flag seems to trigger the erroneous inclusion of .s files among CompiledGoFiles. Adding the flag fixes the problem. I suspect this is related to #28749, but even so:
(a) go/packages could implement a workaround if the underlying go list bug can't be quickly fixed;
(b) the NeedFiles flag shouldn't have any effect on the CompiledGoFiles field; and
(c) why is the CompiledGoFiles field populated at all when that mode bit wasn't specified?
The text was updated successfully, but these errors were encountered: