cmd: simplify some handling of package paths

We have obj.Link.Pkgpath, so we don't need to pass it redundantly in
places where we already have an *obj.Link.

Also, renaming the parser's "compilingRuntime" field to "allowABI", to
match the "AllowAsmABI" name used by objabi.LookupPkgSpecial.

Finally, push the handling of GOEXPERIMENT_* flags up to cmd/asm's
main entry point, by simply appending them to flags.D.

Change-Id: I6ada134522b0cbc90d35bcb145fbe045338fefb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/523297
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2023-08-26 19:06:33 -07:00 committed by Gopher Robot
parent f7f1c4f86d
commit eaae2d45c7
16 changed files with 85 additions and 91 deletions

View file

@ -6,7 +6,6 @@ package lex
import (
"fmt"
"internal/buildcfg"
"os"
"path/filepath"
"strconv"
@ -34,33 +33,18 @@ type Input struct {
}
// NewInput returns an Input from the given path.
func NewInput(name string, compilingRuntime bool) *Input {
func NewInput(name string) *Input {
return &Input{
// include directories: look in source dir, then -I directories.
includes: append([]string{filepath.Dir(name)}, flags.I...),
beginningOfLine: true,
macros: predefine(flags.D, compilingRuntime),
macros: predefine(flags.D),
}
}
// predefine installs the macros set by the -D flag on the command line.
func predefine(defines flags.MultiFlag, compilingRuntime bool) map[string]*Macro {
func predefine(defines flags.MultiFlag) map[string]*Macro {
macros := make(map[string]*Macro)
// Set macros for GOEXPERIMENTs so we can easily switch
// runtime assembly code based on them.
if compilingRuntime {
for _, exp := range buildcfg.Experiment.Enabled() {
// Define macro.
name := "GOEXPERIMENT_" + exp
macros[name] = &Macro{
name: name,
args: nil,
tokens: Tokenize("1"),
}
}
}
for _, name := range defines {
value := "1"
i := strings.IndexRune(name, '=')