"linux compatibility"? reddit / BSD ---------------------------------------------------------------------- VerticalMonitorSetup · 2022-05-25 12:51 hi, im kinda new to bsd as a whole (yes im a linux user), and i was wondering what is this "linux compatibilty" freebsd and maybe some other bsds have? I mean linux and bsd both use the elf format, don't they? Speaking of, I heard somewhere that a.out is still used somewhere in some bsd, is this true? (sorry for the many questions lol) ---------------------------------------------------------------------- briantehownerer · 2022-05-25 14:00 FreeBSD has a totally different kernel to Linux, so it’s not like a simple distro hop. The Linux compatibility is pretty good though. And most open source projects are in the FreeBSD ports tree. For more info on the binary compatibility layer here is a link to the handbook, http s://docs.freebsd.org/en/books/handbook/linuxemu/index.html#linuxemu ---------------------------------------------------------------------- VENTDEV · 2022-05-25 14:54 Linux Compatibility is what it says, a compatibility layer. Every program makes calls to libraries and the kernel. The compatibility layer takes those calls and reroutes them to the host system's functions so that the host system can understand them. Being a Linux user, you might already be familiar with WINE (Steam's Proton). That is a Windows compatibility layer. It takes code relying on Windows libraries and kernel and redirects it to the host's system's functions. The big difference between WINE and Net/FreeBSD's compatibility layers is that the former is a userland program. Whereas with Net/FreeBSD, I believe both have some Kernel elements, thus making them faster and tighter integrated. (I could be wrong on that point.) Many people mistakenly refer to compat layers as emulators. The difference is that emulators implement the host machine in software. Take DOSBOX, DOSBOX reads the dos program, and instead of translating it into FreeBSD function code, it translates it to DOSBOX functions. It is agnostic to the host machine it is running on. That is why DOSBOX can run on nearly any computer you can compile it on. WINE, being a userland layer, is a little harder to port and can run on Linux, FBSD, NetBSD, DBSD, and OSX. And the Linux Compatibility layers found in Free and Net are rarely ported anywhere else because they're implemented at a lower level. Hopefully that makes sense. I haven't looked at the code for Linux Compat in many many years and probably have forgotten how it works exactly, so everything above might not be 100% accurate. ---------------------------------------------------------------------- rlmaers · 2022-05-25 18:28 The fact that most open source projects are in the ports tree has nothing to do with the Linux compatibility layer, but the fact that the software (mostly) adheres to POSIX. Not that you don't know the difference, but it's easy to misunderstand when it's injected in between sentences about binary compatibility layers. ---------------------------------------------------------------------- Kernigh · 2022-05-25 20:14 *Linux compatibility* is about system calls like [open(2)](https://www.man7.org/linux/man-pages/man2/open.2.html), [ioctl(2)](https://www.man7.org/linux/man-pages/man2/ioctl.2.html), and [socket(2)](https://www.man7.org/linux/man- pages/man2/socket.2.html). These calls have different numbers and structures in FreeBSD, NetBSD, and Linux. When FreeBSD or NetBSD loads a Linux program, they use Linux's numbers and structures for system calls. BSDs and Linux all use [elf(5)](https://man.openbsd.org/elf.5), a format for loading programs. ELF also defines the conventions for passing arguments to functions, but ELF doesn't define any system call. An ELF file might identify the required system. If the ELF requires Linux, then FreeBSD or NetBSD uses their Linux compatibility. I know almost nothing about the old [a.out(5)](https://man.netbsd.org/a.out.5) format. Today, `a.out` is the default name for a program from my C compiler; but my a.out is in ELF, not in the old a.out format. ---------------------------------------------------------------------- IanArcad · 2022-05-25 21:13 While it is of technical interest, in practice as a user it's not something you need to worry about. FreeBSD (and other BSDs AFAIK) all have a ports and package system, and you can just choose and install the software you want, and you'll find that most Linux software you are used to has already been ported. Where FreeBSD tends to lag behind (IMHO) is on hardware comparability, and unfortunately I don't think the Linux comparability layer helps with that. The strength of BSD is in its consistency and stability. ---------------------------------------------------------------------- VerticalMonitorSetup · 2022-05-26 00:17 This is a really good explanation, thanks ---------------------------------------------------------------------- sehnsuchtbsd · 2022-05-26 07:55 Wonderful write-up, that's the sort of reply I'd always wish to see, whenever the topic pops-up (and it happens relatively often o *BSD envs, as you may have noticed). A small note: > WINE, being a userland layer, is a little harder to port and can run on Linux, FBSD, NetBSD, DBSD, and OSX. WINE has been removed from DPorts long ago (can't say exactly when, but in 2017, when I first tried DragonFly, it wasn't there anymore already). The latest patch for DragonFly BSD on upstream WineHQ is [da ted](https://source.winehq.org/git/wine.git/?a=search&h=HEAD&st=commit &s=DragonFly) 2012. WINE however runs [well](https://openindiana.org/pipermail/openindiana- discuss/2018-May/022160.html) on illumos, even though nobody cared to update the IPS package past 4.x; you can see the package on [OpenIndia na's](https://pkg.openindiana.org/hipster/info/0/runtime%2Fwine%404.17 %2C5.11-2020.0.1.0%3A20210114T111142Z) and [Tribblix](http://www.tribblix.org/overlays.html) repos. The up-to- date package provided by pkgsrc should work on illumos too though, with a little dedication. Illumos also has better Linux binary compatibility via the [LX branded](https://omnios.org/info/lxzones) non global zones. That's why Joyent has been deploying [Docker on SmartOS](https://www.cyber- tec.org/2018/02/11/run-docker-images-on-smartos/) for years in production and why a port of [Kubernetes for illumos](https://medium.com/@norlin.t/port-of-kubernetes-v1-24-0-for- illumos-and-solaris-98a8775ef04b) has been recently made available. As for NetBSD, its compat_linux(8) is currently more or less where FreeBSD's linuxulator was a couple of years ago. It works well and a user recently reported successfully running WPS office on it. A rework to include support for further syscalls is [planned](https://summerofc ode.withgoogle.com/programs/2022/projects/37Q8OZNU) as part of the upcomin g GSoC. ---------------------------------------------------------------------- sehnsuchtbsd · 2022-05-26 09:16 Linux and BSDs are not binary compatible, as aren't BSDs between them either. These systems use different kernels. *DOS, Windows 3.x/9.x, Windows NT, OpenVMS, OS/2 and derivatives (eComStation, ArcaOS) also all share the .exe format, but this doesn't make them binary compatible with each other. ---------------------------------------------------------------------- Dangerous_Shoe_6181 · 2022-05-26 12:02 Brave, Chrome and Vivaldi can be used on Freebsd thanks to Linux ABI and Ubuntu/Debian chroot. It works pretty well. ---------------------------------------------------------------------- VENTDEV · 2022-05-28 18:45 Shame to hear that DBSD doesn't have WINE anymore. I haven't touched it in years, but I am eagerly waiting for HAMMER2 to get feature parity with ZFS. It may take over my data storage needs. I omitted some of the other obscure Unixes that WINE runs on. I believe the list I gave was sufficient to say that it is portable to POSIX OSs. Here's to NetBSD catching up to FreeBSD's Linuxulator, although I am watching Net's wifi improvements myself. But that's my bias. I use NetBSD on sbc/sbc-laptops.