12 ms·
Linux apps running on iOS via userspace x86 emulation and syscall translation
- recuter 8y agoThis is a very nice effort but I can't help but dream of something like xhyve + alpine side loaded on an iPad Pro. I just want to run neovim and use its terminal emulator and a few cli tools.
- saagarjha 8y agoiOS doesn't have Hypervisor.framework like macOS does, unfortunately, which makes a project like this significantly more difficult. Hence the need for an emulation layer. However, > I just want to run neovim and use its terminal emulator and a few cli tools. This is doable with the project as it is currently.
- recuter 8y agoBe that as it may, the lack of Hypervisor.framework just means there is no Apple sanctioned way to publish an app like VirtualBox in the App Store. I'd still happily pay the yearly Apple developer tax to side load until Apple ends up shipping one when it transitions from x86 to ARM. ;) AFAIC rolling your own hypervisor is technically feasible just would not be very performant.
- lemoncucumber 8y agoYour scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should.
- deleted 8y ago[deleted]
- RavlaAvlar 8y agoI thought apple disallow apps like these?
- deleted 8y ago[deleted]
- saagarjha 8y agoThey have disallowed similar apps, but I’ve made a case that this app in particular doesn’t violate any of Apple’s guidelines.
- akshayaurora 8y agoThis is really cool, can anyone detail how the syscall translation works?
- saagarjha 8y agoWhen a syscall occurs, handle_interrupt is called to translate the call into a system one: https://github.com/tbodt/ish/blob/master/kernel/calls.c#L135 https://github.com/tbodt/ish/blob/master/kernel/calls.c#L135
- wenning 8y agoi think a ssh client is enough.
- saagarjha 8y agoSSH only works when you have a network connection.
- leibwiht 8y agoYou also need another computer, which kind of defeats the purpose. That's like saying you don't need wine when you have VNC.
- anticensor 8y agoYou have something called loopback.
- saagarjha 8y ago…which requires your device to listen to SSH connections, right? This isn't something your iPad is doing.
- anticensor 8y agoYou would jailbreak your iThing and install ssh server.
- saagarjha 8y agoIf you're jailbroken, you can just spawn a shell. No need to do a SSH loopback dance.
- deleted 8y ago[deleted]
- yakkers 8y ago
- zer0zzz 8y agoWhy not build a simple aarch64 machine code runtime and skip the emulation by running aarch64 Linux ?
- saagarjha 8y agoI've described why this doesn't work when this thread came up earlier today: https://news.ycombinator.com/item?id=18425906 https://news.ycombinator.com/item?id=18425906. In essence, you will need an emulation layer anyways, so it doesn't really matter whether you're running x86 or ARM.
- umanwizard 8y agoPrevious discussion at a link to the github repository: https://news.ycombinator.com/item?id=18421016 https://news.ycombinator.com/item?id=18421016
- mikenew 8y agoLooks like you have to compile it yourself (meaning you need a mac with Xcode) or install it through testflight. Although I'm surprised that it's even allowed on testflight. iOS doesn't allow you to execute code of any kind locally, which is why if you download a "learn python" app or something it has to send your code off to a server, execute it, and then send you back the result. It's part of the reason why I recently moved away from iOS. Things like this are not supposed to exist, and you have to bend over backwards to make it work. EDIT: Okay apparently this changed as of last year-ish? Looks like they have an exception in place for "a programming environment intended for use in learning how to program"* Regardless I think this kind of shell environment is still against the app store guidelines. *https://www.theregister.co.uk/2017/06/07/apple_relaxes_developer_rules/ https://www.theregister.co.uk/2017/06/07/apple_relaxes_devel...
- Operyl 8y agoUh. There’s definitely a local python interpreter on the App Store. Pythonista3 is one, and Blink has one as well iirc.
- eptcyka 8y agoYes, and python isn't JIT'ed, so it really doesn't matter. It all boils down to write XOR exec memory.
- saagarjha 8y ago> iOS doesn't allow you to execute code of any kind locally Yes, it does. And as of recently you can even put apps like this on the App Store!
- gcb0 8y agoit took a decade to "be allowed" and is still extremely rudimentary, not to mention its a very fine line to the point that mozilla and google still wont invest in a browser engine port because apple already told in the past that simply running JS in the browser is enough to breach their policy. so please stop shouting like its common place. pythonista3 is a very controlled experiment as it is now. and it exploits a "tiny blessing" apple gave on the policy of running "user inputed source code" only!
- selimnairb 8y agoWhy run x86 Linux binaries? Wouldn’t it be easier and more efficient to run ARM binaries? Then you’d only need syscall translation, no? I guess you would also need a thuniking layer to handle binary format/ABI differences. But that would still be better in terms of time and space than emulation I would think.
- saagarjha 8y agoSee discussion from earlier today as to why this wouldn't really help: https://news.ycombinator.com/item?id=18425906 https://news.ycombinator.com/item?id=18425906
- monocasa 8y agoI'm still not convinced. Even something like early VMware that scanned for the gnarly pieces that break Popek&Goldberg but just passes through most instructions should be better. In this case probably just syscall, some crazy system register reads that might return different things (but there aren't many of those in AArch64 EL0), and enough thunks that code can pretend it's executing at it's original location. Hell, equally sized RISC instructions should mean you can more quickly scan code than VMWare had to put up with doing crazy CISC decode just find out if they need to translate an instruction or not.
- headmelted 8y agoLikewise. Obviously it's not as simple as in Android where you're already inside a Linux shell under the covers, but there's no technical requirement I've read here that should mandate emulation. Aside from the above, the syscall layer alone would be much more useful than bundling emulation into the picture that we know is going to perform poorly. An aarch64 Linux rootfs on the A12x would have me throwing my money at one right now.
- saagarjha 8y ago> there's no technical requirement I've read here that should mandate emulation I mean, what's wrong with the requirements that I mentioned? It's fundamentally impossible to run these binaries unaltered and still hook syscalls, which means that emulation is required.
- shmerl 8y agoCan't you run ARM binaries straight? No need to emulate the CPU. Same as Wine runs Windows programs without emulating it (as long as it's used on x86 arch).
- saagarjha 8y agoYou can, but not in the way you'd expect. Codesigning is a big issue, but one that can be circumvented if everything is signed in advance, though you probably wouldn't be able to publish to the App Store. But specifically for an app like this, you'd need an emulation layer: https://news.ycombinator.com/item?id=18425906 https://news.ycombinator.com/item?id=18425906
- tluyben2 8y agoThanks to saagarjha for the effort and making the case to Apple that this should be fine. If it is allowed, it opens up a lot more possibilities.
- AnonymousRider 8y agoThis is an awesome feat you have accomplished and just when I had given up on anything new & cool coming out of the crAPP Store. Thanks for your work.
- akerro 8y agoDoes that mean I can install Steam and Proton and play (WindowS)-Linux games on iOS?
- saagarjha 8y agoI doubt it. Alpine Linux would need to support Steam (which I don't think it does?) and then this project would need to implement all the syscalls to make this work, which hasn't quite been done yet. Plus it will be really slow.
- saurik 8y agoThis project happens to ship a userland from Alpine Linux, but it is not at all clear to me why it would be limited to run software from Alpine Linux.
- saagarjha 8y agoBy "Alpine Linux", I meant "the stuff that Alpine Linux usually ships with", which I doubt is rich enough to support everything that Steam needs, plus you're not going to get a nice package to install as you might on another distribution: https://developer.valvesoftware.com/wiki/Steam_under_Linux https://developer.valvesoftware.com/wiki/Steam_under_Linux. So I'm pretty sure the answer to the original question is still "no, not yet", though I don't think it is "no, not ever".
- petecox 8y agoAlpine will have a growing catalogue of software for phone and tablet as the popularity of postmarketOS increases.
- saurik 8y agoYou still don't seem to get it: this project happens to ship with an Alpine Linux userland, but you can just build it with Ubuntu Core instead, it will just be insanely large. Alternatively, you can just download Ubuntu Core and either replace the Alpine parts or put it in a chroot. Steam isn't going to run because it doesn't have a graphics layer, but it isn't because this is somehow--and I mean right now as it is installed on your phone without even having to reinstall it--in any way tied to Alpine Linux.
- tambourine_man 8y agoIt would be interesting to run it nativity as well, ARM compiled.
- aasasd 8y agoThere's been a sorta similar thing for Windows for almost fifteen years now, called CoLinux: https://en.wikipedia.org/wiki/Cooperative_Linux https://en.wikipedia.org/wiki/Cooperative_Linux It runs a Linux kernel on top of the Windows one, without processor emulation, so you could say it translates Linux calls and semantics to Windows' control of resources. However, it didn't gain any significant use, and is apparently abandoned.
- swiftcoder 8y agoHow different is that to what Microsoft is officially supporting via the Windows Subsystem for Linux?
- rhinoceraptor 8y agoWSL isn't Linux, it's an re-implementation of the Linux kernel syscall table, that translates them to the Windows equivalent. It allows userspace Linux programs to run on Windows. It would be more accurate if they called it the Windows Subsystem for Linux Apps. If you give a Linux program a complete syscall interface, it will run (provided it has its' libraries and a libc to work with).
- dana321 8y agoI can see apple buying this!
- vermaden 8y agoSomeone just ported FreeBSD Linux Binary Compatibility layer to iOS? :) https://www.freebsd.org/doc/handbook/linuxemu.html https://www.freebsd.org/doc/handbook/linuxemu.html
- snazz 8y agoIt would be awesome if they let you type commonly used symbols with the swipe down feature like in Swift Playgrounds—then you would not have to go through multiple screens full of characters to get the angle bracket or curly braces.
- saagarjha 8y agoOn iPad, this keyboard comes by default for all apps (including iSH), since it’s provided by the system.
- snazz 8y agoSwift Playgrounds changes the symbols that you can type with the keyboard in that mode. Normally, you can’t type curly braces or angle brackets on the first level of the iOS keyboard, but you can in Swift Playgrounds (and when entering LaTeX into Pages). All I’m saying is that it would be nice if iSH customized the keyboard the same way.
- sureaboutthis 8y agoIt seems like no one wants to run Linux or its applications lately and they seem happier when Microsoft develops Windows applications and operating system things to handle Linux things. Now Linux apps run on iOS and it's starting to sound like Linux people are happy to see their stuff built by others and running on everything but Linux. Now, in this day of so much fake news, I wouldn't be surprised that all the happy comments I read are by Microsoft and, now, iOS shills but it's an observation I've made.
- metildaa 8y agoI think much of this is Microsoft and Apple attempting to retain marketshare. Niether has well maintained, vast software archives like Debian, or instant rollback after a package install or update like SUSE (thanks to btrfs and zypper). Meanwhile the non-phone computer market is shrinking each year, and what remains is mostly a market for devices that are good at running browsers.
- sureaboutthis 8y agoI am positive Microsoft does it for that reason but this isn't a project by Apple.
- skrowl 8y agoOr... you know... you could just get a Chromebook that has Android apps and Linux apps (via Crostini) in a supported fashion.
- ninjamisto 8y agoish seem to work in macos as well... There’s also this interesting project: Noah is a Darwin subsystem for Linux, or "Bash on Ubuntu on Mac OS X". Noah is implemented as a hypervisor that traps linux system calls and translates them into Darwin's system calls. Noah also has an interpreter of ELF files so that binary executables of Linux run directly and flawlessly without any modifications. https://github.com/linux-noah/noah https://github.com/linux-noah/noah https://events.static.linuxfound.org/sites/events/files/slides/Noah%20Hypervisor-Based%20Darwin%20Subsystem%20for%20Linux.pdf https://events.static.linuxfound.org/sites/events/files/slid...