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.
Этот коммит содержится в:
родитель
4262f0ff1f
коммит
a4e2e09457
1 изменённых файлов: 1 добавлений и 34 удалений
|
@ -16,20 +16,7 @@ import (
|
||||||
func (b *builder) createRawSyscall(call *ssa.CallCommon) (llvm.Value, error) {
|
func (b *builder) createRawSyscall(call *ssa.CallCommon) (llvm.Value, error) {
|
||||||
num := b.getValue(call.Args[0])
|
num := b.getValue(call.Args[0])
|
||||||
switch {
|
switch {
|
||||||
case b.GOARCH == "amd64":
|
case b.GOARCH == "amd64" && b.GOOS == "linux":
|
||||||
if b.GOOS == "darwin" {
|
|
||||||
// Darwin adds this magic number to system call numbers:
|
|
||||||
//
|
|
||||||
// > Syscall classes for 64-bit system call entry.
|
|
||||||
// > For 64-bit users, the 32-bit syscall number is partitioned
|
|
||||||
// > with the high-order bits representing the class and low-order
|
|
||||||
// > bits being the syscall number within that class.
|
|
||||||
// > The high-order 32-bits of the 64-bit syscall number are unused.
|
|
||||||
// > All system classes enter the kernel via the syscall instruction.
|
|
||||||
//
|
|
||||||
// Source: https://opensource.apple.com/source/xnu/xnu-792.13.8/osfmk/mach/i386/syscall_sw.h
|
|
||||||
num = b.CreateOr(num, llvm.ConstInt(b.uintptrType, 0x2000000, false), "")
|
|
||||||
}
|
|
||||||
// Sources:
|
// Sources:
|
||||||
// https://stackoverflow.com/a/2538212
|
// https://stackoverflow.com/a/2538212
|
||||||
// https://en.wikibooks.org/wiki/X86_Assembly/Interfacing_with_Linux#syscall
|
// 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) {
|
||||||
retval = b.CreateInsertValue(retval, zero, 1, "")
|
retval = b.CreateInsertValue(retval, zero, 1, "")
|
||||||
retval = b.CreateInsertValue(retval, errResult, 2, "")
|
retval = b.CreateInsertValue(retval, errResult, 2, "")
|
||||||
return retval, nil
|
return retval, nil
|
||||||
case "darwin":
|
|
||||||
syscallResult, err := b.createRawSyscall(call)
|
|
||||||
if err != nil {
|
|
||||||
return syscallResult, err
|
|
||||||
}
|
|
||||||
// Return values: r0, r1 uintptr, err Errno
|
|
||||||
// Pseudocode:
|
|
||||||
// var err uintptr
|
|
||||||
// if syscallResult != 0 {
|
|
||||||
// err = syscallResult
|
|
||||||
// }
|
|
||||||
// return syscallResult, 0, err
|
|
||||||
zero := llvm.ConstInt(b.uintptrType, 0, false)
|
|
||||||
hasError := b.CreateICmp(llvm.IntNE, syscallResult, llvm.ConstInt(b.uintptrType, 0, false), "")
|
|
||||||
errResult := b.CreateSelect(hasError, syscallResult, zero, "syscallError")
|
|
||||||
retval := llvm.Undef(b.ctx.StructType([]llvm.Type{b.uintptrType, b.uintptrType, b.uintptrType}, false))
|
|
||||||
retval = b.CreateInsertValue(retval, syscallResult, 0, "")
|
|
||||||
retval = b.CreateInsertValue(retval, zero, 1, "")
|
|
||||||
retval = b.CreateInsertValue(retval, errResult, 2, "")
|
|
||||||
return retval, nil
|
|
||||||
case "windows":
|
case "windows":
|
||||||
// On Windows, syscall.Syscall* is basically just a function pointer
|
// On Windows, syscall.Syscall* is basically just a function pointer
|
||||||
// call. This is complicated in gc because of stack switching and the
|
// call. This is complicated in gc because of stack switching and the
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче