mirror of
https://github.com/golang/go.git
synced 2025-05-28 19:02:22 +00:00
The runtime/internal/startlinetest package contains a call to a function defined in runtime_test. Generally this is fine as this package is only linked in for runtime_test. Except that for "go install -buildmode=shared std", which include all packages in std, including this test-only internal package. In this mode, the caller is included in the linking but the callee is not, causing linking error. Work around it by calling runtime_test.callerStartLine via a function pointer. The function pointer is only set in runtime_test. In the shared std build, the function pointer will not be set, and this is fine. Fixes #57334. Change-Id: I7d871c50ce6599c6ea2802cf6e14bb749deab220 Reviewed-on: https://go-review.googlesource.com/c/go/+/458696 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
24 lines
647 B
Go
24 lines
647 B
Go
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package runtime_test
|
|
|
|
import (
|
|
"runtime/internal/startlinetest"
|
|
"testing"
|
|
)
|
|
|
|
// TestStartLineAsm tests the start line metadata of an assembly function. This
|
|
// is only tested on amd64 to avoid the need for a proliferation of per-arch
|
|
// copies of this function.
|
|
func TestStartLineAsm(t *testing.T) {
|
|
startlinetest.CallerStartLine = callerStartLine
|
|
|
|
const wantLine = 23
|
|
got := startlinetest.AsmFunc()
|
|
if got != wantLine {
|
|
t.Errorf("start line got %d want %d", got, wantLine)
|
|
}
|
|
}
|