]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/internal/startlinetest: work around shared buildmode linking issue
authorCherry Mui <cherryyz@google.com>
Tue, 20 Dec 2022 22:26:18 +0000 (17:26 -0500)
committerCherry Mui <cherryyz@google.com>
Thu, 22 Dec 2022 04:34:33 +0000 (04:34 +0000)
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>

src/runtime/internal/startlinetest/func_amd64.go
src/runtime/internal/startlinetest/func_amd64.s
src/runtime/start_line_amd64_test.go

index 6cd9a3f417e9db4ea4baddee1b1b52f3d7990f50..ab7063d615fc37fcf3b3cb7ef634587a18ef6a29 100644 (file)
@@ -8,3 +8,6 @@ package startlinetest
 // Defined in func_amd64.s, this is a trivial assembly function that calls
 // runtime_test.callerStartLine.
 func AsmFunc() int
+
+// Provided by runtime_test.
+var CallerStartLine func(bool) int
index ace5b34e70f833efa4533a90b62536054128ec8e..96982bedab82c502d3a6e846238bb2d0e1926094 100644 (file)
@@ -23,5 +23,6 @@
 TEXT   ·AsmFunc<ABIInternal>(SB),NOSPLIT,$8-0
        NO_LOCAL_POINTERS
        MOVQ    $0, AX // wantInlined
-       CALL    runtime_test·callerStartLine<ABIInternal>(SB)
+       MOVQ    ·CallerStartLine(SB), DX
+       CALL    (DX)
        RET
index 57001e71de92759cd8492ffc6487f8d7785411b7..305ed0b126621f24942fc13bfa16822b3ca3d037 100644 (file)
@@ -13,6 +13,8 @@ import (
 // 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 {