Skip to content

cmd/compile: new codegen test harness grabs wrong go binary to run tests #24217

@ALTree

Description

@ALTree

The new code generation test harness introduced in CL 97355 does not work when working on tip with a codegen transformation only present on tip. For example, I recently taught the 386 backend to intrisify math.Sqrt and when I add the following test

func sqrt(x float64) float64 {
	// 386:"SQRTSD"
	return math.Sqrt(x)
}

to the tip repository and run it, it'll fail because the asmcheck driver in test/run.go uses this line to compile the codegen test files:

cmdline := []string{"go", "build", "-gcflags", "-S"}

and on my system go points to the stable installation in /usr/local/go, which is a 1.10 toolchain, where math.Sqrt is not intrisified on 386.

In the old test harness we use internal/testenv to ensure we're using the right go toolchain:

testenv.MustHaveGoRun(t)
gotool := testenv.GoToolPath(t)
cmd := exec.Command(gotool, "run",   [etc...])

but I believe we can't do this inside a test in the go/test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions