Skip to content

Commit a4e2e09

Browse files
aykevldeadprogram
authored andcommitted
compiler: drop support for macos syscalls via inline assembly
This has always been unsupported on MacOS and has in fact been removed from upstream Go a few releases ago. So do the same for TinyGo. Linux seems to be the only supported OS with a stable syscall interface.
1 parent 4262f0f commit a4e2e09

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

compiler/syscall.go

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,7 @@ import (
1616
func (b *builder) createRawSyscall(call *ssa.CallCommon) (llvm.Value, error) {
1717
num := b.getValue(call.Args[0])
1818
switch {
19-
case b.GOARCH == "amd64":
20-
if b.GOOS == "darwin" {
21-
// Darwin adds this magic number to system call numbers:
22-
//
23-
// > Syscall classes for 64-bit system call entry.
24-
// > For 64-bit users, the 32-bit syscall number is partitioned
25-
// > with the high-order bits representing the class and low-order
26-
// > bits being the syscall number within that class.
27-
// > The high-order 32-bits of the 64-bit syscall number are unused.
28-
// > All system classes enter the kernel via the syscall instruction.
29-
//
30-
// Source: https://opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/mach/i386/syscall_sw.h
31-
num = b.CreateOr(num, llvm.ConstInt(b.uintptrType, 0x2000000, false), "")
32-
}
19+
case b.GOARCH == "amd64" && b.GOOS == "linux":
3320
// Sources:
3421
// https://stackoverflow.com/a/2538212
3522
// https://en.wikibooks.org/wiki/X86_Assembly/Interfacing_with_Linux#syscall
@@ -179,26 +166,6 @@ func (b *builder) createSyscall(call *ssa.CallCommon) (llvm.Value, error) {
179166
retval = b.CreateInsertValue(retval, zero, 1, "")
180167
retval = b.CreateInsertValue(retval, errResult, 2, "")
181168
return retval, nil
182-
case "darwin":
183-
syscallResult, err := b.createRawSyscall(call)
184-
if err != nil {
185-
return syscallResult, err
186-
}
187-
// Return values: r0, r1 uintptr, err Errno
188-
// Pseudocode:
189-
// var err uintptr
190-
// if syscallResult != 0 {
191-
// err = syscallResult
192-
// }
193-
// return syscallResult, 0, err
194-
zero := llvm.ConstInt(b.uintptrType, 0, false)
195-
hasError := b.CreateICmp(llvm.IntNE, syscallResult, llvm.ConstInt(b.uintptrType, 0, false), "")
196-
errResult := b.CreateSelect(hasError, syscallResult, zero, "syscallError")
197-
retval := llvm.Undef(b.ctx.StructType([]llvm.Type{b.uintptrType, b.uintptrType, b.uintptrType}, false))
198-
retval = b.CreateInsertValue(retval, syscallResult, 0, "")
199-
retval = b.CreateInsertValue(retval, zero, 1, "")
200-
retval = b.CreateInsertValue(retval, errResult, 2, "")
201-
return retval, nil
202169
case "windows":
203170
// On Windows, syscall.Syscall* is basically just a function pointer
204171
// call. This is complicated in gc because of stack switching and the

0 commit comments

Comments
 (0)