Issues Generating New System Calls for Golang Syscall on Ubuntu 20.04.6 LTS AARCH64

191 views
Skip to first unread message

mr....@gmail.com

unread,
Aug 27, 2025, 2:08:56 AM (9 days ago) Aug 27
to golang-nuts

Hello,

I am attempting to generate new system calls for Golang's syscall package. While running ./mkall.sh on Ubuntu 20.04.6 LTS AARCH64, I consistently encounter the following error:

plaintext
./zsyscall_linux_arm64.go:1336:23: undefined: SYS_SYNC_FILE_RANGE2 go tool cgo: signal: broken pipe

This issue suggests that SYS_SYNC_FILE_RANGE2 is not defined in the context of the build. Could someone advise which Linux distribution (and version) is recommended for successfully generating system calls for AARCH64?

Thank you in advance for your guidance!



Linux lima-default 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:55:34 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux


AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/dingli.linux/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/dingli.linux/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1072417917=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/dingli.linux/work/go/src/go.mod'
GOMODCACHE='/home/dingli.linux/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/dingli.linux/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/dingli.linux/work/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/dingli.linux/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/dingli.linux/work/go/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.26-devel_77f911e31c Fri Aug 15 18:10:28 2025 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

Kurtis Rader

unread,
Aug 27, 2025, 2:26:34 AM (9 days ago) Aug 27
to mr....@gmail.com, golang-nuts
Insufficient information. Can you provide a link to your proposed change as well as an explanation for the change? Is there an open issue that provides background information for what you are attempting?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/4bdaf596-06b2-431f-b7aa-9f6c18ce97d0n%40googlegroups.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

mr....@gmail.com

unread,
Aug 27, 2025, 3:34:27 AM (9 days ago) Aug 27
to golang-nuts
I am trying to address this issue https://github.com/golang/go/issues/45886, which involves new system calls.

I added the corresponding //sys comments in syscall_linux_*.go, but I am unable to generate them; some errors keep occurring. I'm wondering if it might be an issue with the kernel of the Linux distribution I'm using?

This is how I execute it.

export GOOS=linux
export GOARCH=arm64
./mkall.sh

Of course, even if I haven't made any changes to any files, running ./mkall.sh still results in some strange issues.


I have made the following attempts.

I did not make any adjustments and only used the code from the Go master branch. When executing ./mkall.sh, the following error occurs.

./mkall.sh
# syscall
./zsyscall_linux_arm64.go:1117:22: undefined: SYS_FSTAT
./zsyscall_linux_arm64.go:1132:23: undefined: SYS_FSTATAT
./zsyscall_linux_arm64.go:1248:23: undefined: SYS_RENAMEAT

./zsyscall_linux_arm64.go:1336:23: undefined: SYS_SYNC_FILE_RANGE2


uname -a

Linux lima-default 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:55:34 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux

// /usr/include/asm-generic/unistd.h
....
#define __NR_readlinkat 78
__SYSCALL(__NR_readlinkat, sys_readlinkat)
#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
#define __NR3264_fstatat 79
__SC_3264(__NR3264_fstatat, sys_fstatat64, sys_newfstatat)
#define __NR3264_fstat 80
__SC_3264(__NR3264_fstat, sys_fstat64, sys_newfstat)
#endif
....

The reason is that __ARCH_WANT_NEW_STAT or __ARCH_WANT_STAT64 were not defined. In mksysnum_linux.pl, gcc -E -dD was used to export all definitions, but __NR3264_fstatat and __NR3264_fstat were not included.

Finally, I found a similar file at /usr/include/aarch64-linux-gnu/asm/unistd.h. Running gcc -E -dD /usr/include/aarch64-linux-gnu/asm/unistd.h correctly exports __NR3264_fstatat and __NR3264_fstat.

However, SYS_SYNC_FILE_RANGE2 is not present.

So, could it be that there is an issue with the distribution I am using? I would like to know how others handle generating the corresponding files when developing system calls. I couldn't find any related documentation in src/syscall.

TheDiveO

unread,
Aug 28, 2025, 1:33:03 PM (8 days ago) Aug 28
to golang-nuts
While I can't tell you the exact Ubuntu version, I would expect 20.04LTS to be problematic at this point. You could try with a devcontainer and a more recent Ubuntu base image, from the 24.04LTS era, installing more recent kernel headers into the devcontainer than the kernel the devcontainer is deployed on. There is a well-maintained go devcontainer feature by Microsoft to install specific or the latest stable Go toolchain into the devcontainer if necessary. A devcontainer is a Docker/OCI container used for development, well supported in VSCode, created from simple json configurations, which are modular thanks to the feature mechanism. No need for a separate VM, just Docker.

mr....@gmail.com

unread,
Aug 28, 2025, 11:08:28 PM (7 days ago) Aug 28
to golang-nuts
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
{
"name": "Go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"features": {
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"remoteEnv": {
"PATH": "/workspaces/go/bin:${containerEnv:PATH}",
"GOBIN": "/workspaces/go/bin",
"GOROOT": "/workspaces/go"
}
}



This is the configuration of devcontainers I use, and the same error occurred

➜  syscall git:(master) ✗ GOOS=linux GOARCH=arm64 ./mkall.sh

# syscall
./zsyscall_linux_arm64.go:1117:22: undefined: SYS_FSTAT
./zsyscall_linux_arm64.go:1132:23: undefined: SYS_FSTATAT
./zsyscall_linux_arm64.go:1248:23: undefined: SYS_RENAMEAT
./zsyscall_linux_arm64.go:1336:23: undefined: SYS_SYNC_FILE_RANGE2


Is there something wrong with the way I operate?

mr....@gmail.com

unread,
Aug 28, 2025, 11:43:15 PM (7 days ago) Aug 28
to golang-nuts
syscall has been frozen, I should maintain it in a new package, thank you everyone

Dan Kortschak

unread,
Aug 29, 2025, 1:36:05 AM (7 days ago) Aug 29
to golan...@googlegroups.com
On Thu, 2025-08-28 at 20:43 -0700, mr....@gmail.com wrote:
> syscall has been frozen, I should maintain it in a new package, thank
> you everyone

There is also https://pkg.go.dev/golang.org/x/sys/unix which is the
actively developed syscall package.

Reply all
Reply to author
Forward
0 new messages