From e0cfbdb5a25daaf07de19128753bb83c4fbcfd70 Mon Sep 17 00:00:00 2001 From: Jah-yee <166608075+Jah-yee@users.noreply.github.com> Date: Fri, 24 Apr 2026 18:32:24 +0800 Subject: [PATCH] plan9: replace Exit assembly stub with os.Exit The Exit function in plan9 package currently uses assembly that references syscall.exit, which does not exist on Plan 9. This causes build failures when cross-compiling to plan9/amd64: # golang.org/x/sys/plan9.exit: relocation target syscall.exit not defined Fix by replacing the assembly stub with os.Exit, which properly terminates the process on Plan 9. Also remove the now-orphaned asm_plan9_amd64.s file which only existed for this function. Fixes golang/go#78506 --- plan9/asm_plan9_amd64.s | 30 ------------------------------ plan9/syscall_plan9.go | 9 +++++---- 2 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 plan9/asm_plan9_amd64.s diff --git a/plan9/asm_plan9_amd64.s b/plan9/asm_plan9_amd64.s deleted file mode 100644 index d3448e675..000000000 --- a/plan9/asm_plan9_amd64.s +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2009 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. - -#include "textflag.h" - -// -// System call support for amd64, Plan 9 -// - -// Just jump to package syscall's implementation for all these functions. -// The runtime may know about them. - -TEXT ·Syscall(SB),NOSPLIT,$0-64 - JMP syscall·Syscall(SB) - -TEXT ·Syscall6(SB),NOSPLIT,$0-88 - JMP syscall·Syscall6(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-56 - JMP syscall·RawSyscall(SB) - -TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 - JMP syscall·RawSyscall6(SB) - -TEXT ·seek(SB),NOSPLIT,$0-56 - JMP syscall·seek(SB) - -TEXT ·exit(SB),NOSPLIT,$8-8 - JMP syscall·exit(SB) diff --git a/plan9/syscall_plan9.go b/plan9/syscall_plan9.go index 761912237..a04574f38 100644 --- a/plan9/syscall_plan9.go +++ b/plan9/syscall_plan9.go @@ -13,6 +13,7 @@ package plan9 import ( "bytes" + "os" "syscall" "unsafe" ) @@ -61,10 +62,10 @@ func errstr() string { return cstring(buf[:]) } -// Implemented in assembly to import from runtime. -func exit(code int) - -func Exit(code int) { exit(code) } +// Exit causes the current process to exit with the given status code. +// Previously implemented in assembly referencing syscall.exit, which does +// not exist on Plan 9, causing build failures on plan9/amd64. +func Exit(code int) { os.Exit(code) } func readnum(path string) (uint, error) { var b [12]byte