authorgravatar for sertonix@posteo.netSertonix <sertonix@posteo.net> 2026-04-23 13:01:49+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-04-24 07:33:22+02:00
log5cc281e7232b9f1bc5f4d732e4a37fb5df02f780
tree1b105d78bcf7fe18327d0f410d3fa270e1b45371
parentf6258b562d27aab7cfd57984e6ab51660158fc8d

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

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/os/linux/x86.zig+2-2
...@@ -109,8 +109,8 @@ pub fn syscall6(...@@ -109,8 +109,8 @@ pub fn syscall6(
109 \\ push %%ebp109 \\ push %%ebp
110 \\ mov 4(%%esp), %%ebp110 \\ mov 4(%%esp), %%ebp
111 \\ mov %%edi, 4(%%esp)111 \\ mov %%edi, 4(%%esp)
112 \\ // The saved %edi and %ebp are on the stack, and %ebp points to `args56`.112 \\ // The saved %%edi and %%ebp are on the stack, and %%ebp points to `args56`.
113 \\ // Prepare the last two args, syscall, then pop the saved %ebp and %edi.113 \\ // Prepare the last two args, syscall, then pop the saved %%ebp and %%edi.
114 \\ mov (%%ebp), %%edi114 \\ mov (%%ebp), %%edi
115 \\ mov 4(%%ebp), %%ebp115 \\ mov 4(%%ebp), %%ebp
116 \\ int $0x80116 \\ int $0x80