Skip to content

cmd/compile: TestScript doesn't work with GOARCH=386 #72800

Closed

Description

@randall77

Run (on linux):

cd src
GOARCH=386 ./all.bash

This fails on two packages with script tests:

--- FAIL: TestScript (0.02s)
    --- FAIL: TestScript/README (0.00s)
        readme.go:43: /usr/local/google/home/khr/sandbox/tmp/bin/go doc cmd/internal/script : exit status 2
    --- FAIL: TestScript/issue70173 (0.04s)
        run.go:223: 2025-03-11T20:41:11Z
        run.go:225: $WORK=/tmp/TestScriptissue701733149297723/001
        run.go:232: 
            > go run main.go
            [stderr]
            go: no such tool "compile"
        run.go:232: FAIL: testdata/script/issue70173.txt:1: go run main.go: exit status 2
    --- FAIL: TestScript/script_test_basics (0.04s)
        run.go:223: 2025-03-11T20:41:11Z
        run.go:225: $WORK=/tmp/TestScriptscript_test_basics12210642/001
        run.go:232: 
            # Test of the linker's script test harness. (0.038s)
            > go build
            [stderr]
            go: no such tool "compile"
        run.go:232: FAIL: testdata/script/script_test_basics.txt:4: go build: exit status 2
    --- FAIL: TestScript/embedbad (0.05s)
        run.go:223: 2025-03-11T20:41:11Z
        run.go:225: $WORK=/tmp/TestScriptembedbad4008521766/001
        run.go:232: 
            # Check that compiler does not silently crash at bad embed error. (0.045s)
            > ! go build
            [stderr]
            go: no such tool "compile"
            [exit status 2]
            > stderr 'multiple files for type string'
        run.go:232: FAIL: testdata/script/embedbad.txt:4: stderr 'multiple files for type string': no match for `(?m)multiple files for type string` in stderr
FAIL
FAIL	cmd/compile	0.080s
--- FAIL: TestScript (0.06s)
    --- FAIL: TestScript/README (0.01s)
        readme.go:43: /usr/local/google/home/khr/sandbox/tmp/bin/go doc cmd/internal/script : exit status 2
    --- FAIL: TestScript/script_test_basics (0.08s)
        run.go:223: 2025-03-11T20:41:25Z
        run.go:225: $WORK=/tmp/TestScriptscript_test_basics1513812270/001
        run.go:232: 
            # Test of the linker's script test harness. (0.075s)
            > go build
            [stderr]
            go: no such tool "compile"
        run.go:232: FAIL: testdata/script/script_test_basics.txt:4: go build: exit status 2
FAIL
FAIL	cmd/link	1.155s

I think the operative error is "no such tool "compile"", which leads be to believe the test is trying to find the wrong (the 64-bit?) compile and failing.

I'm not sure why the trybots aren't failing on this. Maybe I am holding it wrong? Is GOARCH=386 ./all.bash not the right way to test?

Also setting GOHOSTARCH=386 seems to fix the problem. Maybe that's what I should be doing? Maybe that's what the trybots are doing?

@thanm

Activity

  1. added
    BugReportIssues describing a possible bug in the Go implementation.
    on Mar 11, 2025
  2. ianlancetaylor commented on Mar 11, 2025

    @ianlancetaylor
    Contributor

    Running GOARCH=386 go test cmd/compile builds the test program for 386, so the test program sees runtime.GOARCH == "386". The test program runs SetupTestGoRoot in cmd/internal/script/scripttest. That copies the contents of $GOROOT/pkg/tool/$GOOS_$GOARCH to a temporary GOROOT. So it copies $GOOS_386, which is not where the actual tools live.

    I think the fix is to use GOHOSTARCH.

  3. gopherbot commented on Mar 11, 2025

    @gopherbot
    Contributor

    Change https://go.dev/cl/656855 mentions this issue: cmd/internal/script/scripttest: use GOHOSTARCH to find tool directory

  4. added a commit that references this issue on Mar 12, 2025
    4364893
  5. thanm commented on Mar 12, 2025

    @thanm
    Contributor

    LGTM, thanks for fixing this.

  6. locked and limited conversation to collaborators on Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.FrozenDueToAgecompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions