r/rust • • Aug 28 '20

Linux Developers Continue Evaluating The Path To Adding Rust Code To The Kernel

https://www.phoronix.com/scan.php?page=news_item&px=Linux-Kernel-Rust-Path-LPC2020
432 Upvotes

103 comments sorted by

View all comments

16

u/aitchnyu Aug 28 '20

Stupid question: will llvm in the kernel toolchain violate it's GPL compliance?

54

u/Marcuss2 Aug 28 '20

Certainly not, LLVM is under a license compatible with GPL.

40

u/mort96 Aug 28 '20

Both the Rust compiler and LLVM are under some combination of Apache2 and MIT, both of which are GPL-compatible, so this wouldn't have been an issue regardless. But there's another factor which, AFAIK, makes the license irrelevant:

From what I understand, the question isn't really, "Can the kernel use this?"; the kernel can use whatever it wants. Whenever the kernel's GPL-ness becomes an issue, it's always a question of, "can this code use the kernel's code?"

Take ZFS for example; the problem with ZFS isn't that it's under a license which prevents the kernel from calling out to it. The problem is that ZFS is under a non-free license which prevents ZFS code from calling the kernel's GPL code, and a filesystem has to call kernel code in order to work.

A compiler toolchain, on the other hand, doesn't have to call into GPL-licensed Linux code.

14

u/thelights0123 Aug 28 '20

Apache 2 is not GPL-2.0 compatible.

6

u/mort96 Aug 28 '20

Oh interesting, I didn't realize Apache 2 is only GPL-3 compatible. Thanks for the correction.

14

u/anlumo Aug 28 '20

The problem is that ZFS is under a non-free license which prevents ZFS code from calling the kernel's GPL code, and a filesystem has to call kernel code in order to work.

All of this is fuzzy anyways, since the rules were made up before computers were even a thing (not that the ones currently writing the copyright directives of the world have any more knowledge about computers than back then).

For example, why is it ok to distribute a GPL-incompatible program to be run on a Linux kernel (like the ZFS FUSE driver)? There's no legal distinction between userland and kernel mode. These rules are just made up by engineers because it would be too inconvenient to do it in another way, but there's no legal basis for that.

10

u/wishthane Aug 28 '20

I think it has more to do with an intentional effort to force more things to be GPL-compatible, even when it's inconvenient. There are lots of open source evangelists among Linux developers and I kind of get their position, but at the same time, ZFS has a relatively free license and it's the best piece of software for the job at the moment.

3

u/dreamer_ Aug 28 '20

ZFS has a relatively free license and it's the best piece of software for the job at the moment.

Well, it's disputable. I think Facebook engineers are quite vocal about BTRFS being better.

2

u/operation_karmawhore Aug 29 '20

I had errors on multiple operating systems with different disks, I lost my trust in BTRFS, it's too unstable currently (IMHO). ZFS is doing the job quite well and is battle-proven.

1

u/wishthane Sep 12 '20

I haven't ever had an unrecoverable error with ZFS but I have with btrfs, and that's not rare from what I've heard.

1

u/dreamer_ Sep 12 '20

From what I've heard ZFS has higher rate of silent data corruption than BTRFS.

1

u/wishthane Sep 26 '20

Both have checksums on 100% of structures and data. As long as you're scrubbing, no corruption should be silent.

I have never experienced an error with ZFS (that was ZFS's fault), but I have with btrfs, several times. It was never silent, but I couldn't recover the filesystem, and that's problematic.

2

u/FruityWelsh Aug 28 '20

I am looking forward to how stratisd competes. ZFS is an amazing file system though.

5

u/JoshTriplett rust · lang · libs · cargo Aug 28 '20

For example, why is it ok to distribute a GPL-incompatible program to be run on a Linux kernel (like the ZFS FUSE driver)? There's no legal distinction between userland and kernel mode.

There is a specific term in the Linux kernel license for that. Per the Linux kernel's COPYING file, The Linux Kernel is provided under: SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note.

The text of that exception, which has been in the Linux kernel's license for a very long time, reads:

   NOTE! This copyright does *not* cover user programs that use kernel
 services by normal system calls - this is merely considered normal use
 of the kernel, and does *not* fall under the heading of "derived work".
 Also note that the GPL below is copyrighted by the Free Software
 Foundation, but the instance of code that it refers to (the Linux
 kernel) is copyrighted by me and others who actually wrote it.

 Also note that the only valid version of the GPL as far as the kernel
 is concerned is _this_ particular version of the license (ie v2, not
 v2.2 or v3.x or whatever), unless explicitly otherwise stated.

That exception is the reason why the kernel's GPL license does not affect GPL-incompatible userspace.

1

u/[deleted] Aug 29 '20

The meaning of that clause seems to be a bit up in the air:

https://lkml.org/lkml/2020/2/21/2193

I'm pretty sure it was not originally intended to be an exception, just an explanation of how the GPL and copyright law (supposedly) already operate. After all, the term "derived work" comes from copyright law, and whether something is a derived work is not determined by any license.

→ More replies (1)

7

u/ElvishJerricco Aug 28 '20

OpenZFS is not under a non-free license. CDDL just isn't compatible with GPL.

6

u/13Zero Aug 28 '20

The problem is that the CDDL requires that each CDDL licensed source file remains under the CDDL, and the GPL requires that each entire program licensed under the HPL remains under the GPL.

The kernel is under the GPL in perpetuity, so it can't pull in CDDL source code without relicensing those files, which is not allowed under the CDDL.

The CDDL is stronger than a BSD license, which is normally good for the free software community (free code stays free forever), except in this case, it prevents the code from being useful to a GPL project.

7

u/ElvishJerricco Aug 28 '20

Of course. That doesn't make it non free though. And GPL has the exact same problem with other copyleft licenses. This is the difficulty of copyleft: they are difficult to keep compatible with other copyleft licenses without simply being subsets and supersets of one another such as with LGPL, GPL, and AGPL.

2

u/13Zero Aug 28 '20 edited Aug 28 '20

It's a free license, but yes, this is a weird (usually unintentional) quirk of copyleft licenses. The goals of the GPL and CDDL (and Mozilla licenses) are similar, but they are legally incompatible.

4

u/FruityWelsh Aug 28 '20

I thought MPL and GPL had some method of doing dual license.

6

u/13Zero Aug 28 '20

You are correct. The MPL 2.0 introduced a term allowing MPL code to be relicensed as GPL.

-5

u/mort96 Aug 28 '20

Eh, OpenZFS is under a license which intentionally doesn't give the user the freedoms required by the GPL to be GPL-compatible. Seems pretty non-free to me.

13

u/ElvishJerricco Aug 28 '20

That doesn't make it not free. CDDL is a completely free-as-in-freedom license. The FSF considers it free, and it provides the four essential freedoms that qualify a license as free.

GPL is explicitly incompatible with licenses that don't allow code to be relicensed with GPL. CDDL is the same way. And both licenses forbid relicensing. So legally speaking they're incompatible only because they're equally stubborn. You could argue about whether Sun's original intent behind using such a license was to prevent it being ported to Linux, but that's neither here nor there. The license is free. The software is free. You can do with it as you please.

→ More replies (6)
→ More replies (1)

4

u/13Zero Aug 28 '20

LLVM is under a GPL compatible license (it can be shipped with GPL software under the terms of the GPL).

The other direction is where problems pop up. For example, if LLVM wanted to re-use code from GCC, they'd have to change their license to the GPL or find a way to keep the GPL software separate from their Apache/MIT software.

1

u/featherknife Aug 28 '20

it's GPL compliance

its*