commit 5cc281e7232b9f1bc5f4d732e4a37fb5df02f780 (tree)
parent f6258b562d27aab7cfd57984e6ab51660158fc8d
Author: Sertonix <sertonix@posteo.net>
Date: Thu, 23 Apr 2026 13:01:49 +0200
std.os.linux: avoid invalid asm error with gcc on x86
Even though these registry mentions are supposed to be in a comment they
seem to still be interpreted by gcc.
Alternatively one could try to make zig not include comments in assembly
blocks when generating C code.
In function 'os_linux_x86_syscall6__6685',
inlined from 'os_linux_copy_file_range__4300' at zig2.c:396643:7,
inlined from 'link_MappedFile_copyFileRange__14079.isra' at zig2.c:289222:10:
zig2.c:396692:2: error: invalid 'asm': operand number missing after %-letter
396692 | __asm volatile(" push %[args56]\n push %%ebp\n mov 4(%%esp), %%ebp\n mov %%edi, 4(%%esp)\n // The saved %edi and %ebp are on the stack, and %ebp points to `args56`.\n // Prepare the last two args, syscall, then pop the saved %ebp and %edi.\n mov (%%ebp), %%edi\n mov 4(%%ebp), %%ebp\n int $0x80\n pop %%ebp\n pop %%edi": [ret]"=r"(t5): [number]"r"(t6), [arg1]"r"(t7), [arg2]"r"(t8), [arg3]"r"(t9), [arg4]"r"(t10), [args56]"rm"(t2): "memory");
| ^~~~~
zig2.c:396692:2: error: invalid 'asm': operand number missing after %-letter
zig2.c:396692:2: error: invalid 'asm': operand number missing after %-letter
zig2.c:396692:2: error: invalid 'asm': operand number missing after %-letter
zig2.c:396692:2: error: invalid 'asm': operand number missing after %-letter
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/std/os/linux/x86.zig b/lib/std/os/linux/x86.zig
@@ -109,8 +109,8 @@ pub fn syscall6(
\\ push %%ebp
\\ mov 4(%%esp), %%ebp
\\ mov %%edi, 4(%%esp)
- \\ // The saved %edi and %ebp are on the stack, and %ebp points to `args56`.
- \\ // Prepare the last two args, syscall, then pop the saved %ebp and %edi.
+ \\ // The saved %%edi and %%ebp are on the stack, and %%ebp points to `args56`.
+ \\ // Prepare the last two args, syscall, then pop the saved %%ebp and %%edi.
\\ mov (%%ebp), %%edi
\\ mov 4(%%ebp), %%ebp
\\ int $0x80