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
This commit is contained in:
Sertonix
2026-04-23 13:01:49 +02:00
committed by Alex Rønne Petersen
parent f6258b562d
commit 5cc281e723
+2 -2
View File
@@ -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