26 ms·
Linux Rust Support
- lugged 5y agoIt's happening!
- 0x008 5y agoWe have been in contact with a set of companies and academia members that would like to use Rust as a second language in the kernel. Some of them have already started to evaluate Rust for their needs using the infrastructure we have already in place. In particular, we have got a few statements from major companies. In no particular order: Microsoft's Linux Systems Group is interested in contributing to getting Rust into Linux kernel. Hopefully we will be able to submit select Hyper-V drivers written in Rust in the coming months. Arm recognises the Rust value proposition and is actively working with the Rust community to improve Rust for Arm based systems. A good example is Arm’s RFC contribution to the Rust language which made Linux on 64-bit Arm systems a Tier-1 Rust supported platform. Rustaceans at Arm are excited about the Rust for Linux initiative and look forward to assisting in this effort. Google supports and contributes directly to the Rust for Linux project. Our Android team is evaluating a new Binder implementation and considering other drivers where Rust could be adopted. In addition, IBM contributed the Rust kernel support for PowerPC which was already included in the RFC.
- transitory_pce 5y agoEvery one of these companies except has a competing OS. Just saying.
- rvz 5y ago'except' Who? ARM? Well [0] [0] https://github.com/ARMmbed/mbed-os https://github.com/ARMmbed/mbed-os
- pjmlp 5y agoAlso to note, ARM toyed with the idea of using a Linux distribution as alternative to MBed, but it was short love, it is already dead, it only lasted one release. https://os.mbed.com/docs/mbed-linux-os/deprecated-product/welcome/index.html https://os.mbed.com/docs/mbed-linux-os/deprecated-product/we...
- _wldu 5y agoAll of them are interested in good technical security (actually being secure).
- grumblenum 5y agoSo why not formal verification or static analysis tools of an existing codebase (Frama-C)? Or dropping in C derived from a formally verified source (Idris / F-Star)? Or a language with good performance and a verified subset (Ada/Spark)? I've never read anything to make me think that Rust is a safer alternative than any of these options; the guarantees of the language are just assurances of its advocates.
- kaba0 5y agoFormal verification techniques don’t scale, not even to your average CRUD app, let alone to an OS-scale.
- hulitu 5y agoTesting is hard. And (very) expensive.
- kaba0 5y agoFormal verification is even harder. And even more (very) expensive.
- tonyarkles 5y agoIn a number of ways I'd argue that FV of an average CRUD app is a very hard problem, for two reasons: - the requirements generally change quite frequently - the requirements are generally a long way from being "formally verifiable" Where I, personally, have found the most value so far using FV techniques is from modelling "tricky" things whose requirements are quite solid. A few examples from my work: - A state machine for managing LoRa communication. The requirements in the LoRa spec are pretty good. I took those requirements and designed a state machine I could implement on a low-power device and modelled that SM in TLA+ to verify that there were no deadlocks/attempted transitions to invalid states. - A state machine for managing the Bluetooth communication between an Android app, a Bluetooth-Iridium (satellite) bridge, and the server on the other side of the Iridium link. Similar to the LoRa case, I used TLA+ to ensure that there were no deadlocks in my proposed SM (and uhh made a number of corrections as I went). Ultimately, due to the design of the BT/Iridium gateway, the exercise resulted in the conclusion that it wasn't actually possible for this process to be 100% reliable but it was possible to detect and retry the edge cases. - Modelling a somewhat awkward email/SMS invite flow for a mobile app. You could get an invitation over email or SMS, and your account transitioned through a few different states as both your email address and your phone number were verified. Modelling this helped ensure that your account couldn't get into a state where no forward progress was possible or into a state where you could use a half-completed account.
- wongarsu 5y agoHaving Linux make the first move, then learn from their successes and mistakes to implement a better version in your own OS seems like a good move that profits everyone. It's not like Microsoft isn't pushing Rust on their own platform. Every time a Windows driver does a use-after-free somebody swears at Microsoft for causing a bluescreen.
- cogman10 5y agoFrom what I've heard (3rd hand :D), Rust has already made it's way into the windows kernel.
- yawaramin 5y agoLinux isn't an OS and every one of them relies on it for mission-critical infrastructure.
- pjmlp 5y ago> Microsoft's Linux Systems Group is interested in contributing to getting Rust into Linux kernel. Hopefully we will be able to submit select Hyper-V drivers written in Rust in the coming months. At very least the Azure Sphere OS team should finally adopt Rust, instead of doing security marketing with the 7 layers of whatever, and then shipping a C only SDK. It is like they are absent of the company security efforts, while trying to sell us a story of how much they care about security.
- somebody_amzn 5y agoAzure Sphere OS was designed to fit in a 4MB of SRAM envelope... while actually using a Linux kernel. If I remember well, only 512KB is actually usable by OEM applications on that platform.
- pjmlp 5y agoAnd? I was using C++ on MS-DOS. Not even C++ is supported on the Azure Sphere OS SDK. Ironically they usally tend to evade the question when asked about it, to the point they ended up writing a very long blog post trying to justify C, and it had nothing to do with space requirements. Rather industry expectations and other marketing speak.
- somebody_amzn 5y agoThe libc and libraries that they already add to apps don't leave enough space for an off-the-shelf C++ runtime to be included. So instead of including a custom runtime they just bailed out...
- ksec 5y agoI never quite understood why Ada/Spark dont get the same attention or love.
- programmer_dude 5y agoAda syntax is too verbose.
- MaxBarraclough 5y agoAda deliberately places readability before writeability. It's interested in the maintainability of large mature programs, and isn't intended for rapid application development. I don't have enough experience with Ada to comment on whether its verbose and keyword-heavy syntax succeeds in this goal.
- zerr 5y agoCode is not a prose. C-like syntax is much easier to read compared to Ada/Pascal's text blobs.
- oblio 5y agoAccording to studies which we have none of right now. So that's like... your opinion, man.
- zerr 5y agoBesides, if the prose would have been preferable over symbols, we'd be writing e.g. "an unknown number of apples summed up with an unknown number of pears equals to one hundred entities" instead of "x + y = 100" in math classes :)
- MaxBarraclough 5y agoThat's a caricature. We sometimes use words for summation, e.g. Python's sum and fsum functions. I do wonder though if people had to write like that before the development of modern mathematical syntax. Even the '=' symbol is relatively young. Wikipedia tells me it was invented in 1557. SQL is another 'wordy' language. There are many, many things wrong with the SQL language, but I wouldn't say its wordiness is one of them.
- mapgrep 5y agoFunnily similar wording to an old slashdot troll message about rewriting the Linux kernel in Visual Basic: “I hope to see a switch from C to VB very soon. I've already spoken with various luminaries in the C coding world and most are eager to begin to transition. Having just gotten off the phone with Mr. Alan Cox, I can say that he is quite thrilled with the speed increases that will occur when the Linux kernel is completely rewritten in Visual Basic. Richard Stallman plans to support this, and hopes that the great Swede himself, Linux Torvaldis, won't object to renaming Linux to VB/Linux. Although not a C coder himself, I'm told that Slashdot's very own Admiral Taco will support this on his web site. Finally, Dennis Ritchie is excited about the switch!”
- Igelau 5y agoDid Netcraft confirm it?
- staz 5y agoAnyone feel like we get a "Linux Rust support" post every month lately? Feels a bit like the "new more efficient battery technology" recurring post. edit: to precise it's not that I'm not supportive of the effort, just that it would be nice to just have a post when it's actually merged. The title is a bit deceptive
- mpartel 5y agoIf enough people find it interesting enough to follow, why not?
- Shadonototro 5y agoyou can't trust and randomly follow "people", they don't exist
- ndesaulniers 5y agoThat's because the "merge window" is open once every ~2 months; this is the second time this series is being sent, with improvements based on feedback from v1.
- _ph_ 5y agoI quite appreciate the reports. I normally don't follow the linux kernel development, but the possible support of Rust is one major step for the kernel which is hugely interesting. The Linux kernel has become one of the most, if not the most important piece of IT infrastructure. Progress of any further developments of it as well as the security itself are prime concerns for all users. So far the development was solely limited to C, with all the tradeoffs. It is highly interesting to see whether a more modern language can be incorporated and the Rust effort looks very promising. Both from the language capabilities as well as the progress being made.
- deleted 5y ago[deleted]
- pjmlp 5y agoAny UNIX clone that decides to have other languages alongside C on their internals is welcomed news, Ada, C++, Java, Objective-C, Swift and yes Rust.
- lmilcin 5y agoIsn't it a little bit early? I have distinct feeling this would benefit from waiting a little bit more to have various kinks straightened out.
- mkl 5y agoThe kinks get straightened out by people working with it and trying to make things. Waiting won't accomplish that. > Like it was mentioned in the RFC, the Rust support is still to be considered experimental. However, as noted back in April, support is good enough that kernel developers can start working on the Rust abstractions for subsystems and write drivers and other modules.
- johnnycerberus 5y agoI also believe that this is a little bit hype driven but not quite. I've been talking with a Linux dev at a conference in Cluj and he said that people nowadays are not interested in Linux development as he was in high-school because there's so much more out there and way easier to enter (web, mobile, game dev etc.). A new language like Rust can reinvigorate the Linux ecosystem + the benefits of safety and other language features. Zig could have been an alternative but unfortunately it's still under development and quite far from a 1.0. But, in my opinion, once you fragment the ecosystem with Rust, adding a third language like Zig should not be a problem. So, yeah, the train still hasn't left the station.
- lmilcin 5y agoHonestly, I think this particular argument is bogus. From my point of view what counts is actual kernel development. If you are going to develop kernel because it uses cool new language but you would not if it was still C, you are probably not the right person. Now, I think Rust has potential to be good kernel language, I am mostly concerned with toolchain, ability for people to read the code with comprehension, ensure correct code, etc.
- johnnycerberus 5y agoIt is a little bit bogus, I did not say that I stand by it or that I think that this is the WAY. I'm not even a Linux developer or a kernel dev, though I've done embedded programming at the beginning of my career. Just that if we won't take risks, we will never know whether the approach of Rust or Zig or just plain-old C would prove to be THE approach to systems programming. Besides fragmentation, how else can you harm what we already have? I believe the ecosystems fix themselves, if you offer to the developer three choices (in our case C, Zig, Rust), we will see how things pan out and we will have a clearer picture. Java did not become the language of Fortune 500 companies out of sheer luck, people simply chose it more often than its counterparts because the feedback was positive. I expect the same in systems programming.
- Shadonototro 5y agoWhy do they want to make the kernel even more complicated? Now to contribute not only you have to learn C, but also Rust and get their complex dev environment setup.. This fragmentation is very bad, seems like they embrace the linux distro spirit.. what's gonna be tomorrow? zig support? Lot of effort wasted in making things more complicated, definitely not a positive move
- diegocg 5y agoWell, if there is a competition to replace C it would be interesting to see some competition.
- authorityofnil 5y agoI feel Rust offers several strong points whilst actually being performant and widespread enough to be in the kernel. I doubt you absolutely _need_ to know both to work on specific parts written in either
- ladyattis 5y agoI think Rust support should be in a more experimental branch for the kernel first before even thinking of adding it to the main code base. Mostly because I think it needs more supporting code and documentation to get people on board with such an inclusion: complexity or not.
- rswail 5y ago"linux-next" is the experimental branch for the kernel. "The linux-next tree is the holding area for patches aimed at the next kernel merge window. If you're doing bleeding edge kernel development, you may want to work from that tree rather than Linus Torvalds' mainline tree. " https://www.kernel.org/doc/man-pages/linux-next.html https://www.kernel.org/doc/man-pages/linux-next.html
- drexlspivey 5y agoOn the flip side you can now contribute if you know rust but not C
- MrBuddyCasino 5y agoToo bad that Ziglang is still too immature at this point. It seems to be more in spirit with C and UNIX - simple yet powerful, while avoiding most of C's footguns. Would have been interesting to see what Linus thinks of it. Adding a 3rd language would be madness, Rust is already complex enough - so that window of opportunity will be closed.
- roca 5y agoRust can prevent use-after-free bugs and data races, which is very useful for the kernel.
- phendrenad2 5y agoYou can still use Zig for out-of-kernel modules, which unfortunately are a concept that doesn't get much love.
- moltonel3x 5y agoZig is a really nice language, but it doesn't go as far as Rust in the correctness department, which is what's motivating Rust adoption in Linux (other Rust aspects being merely nice-to-haves). It's not clear that Zig would bring sufficient gains to overcome the cost of adding a language, even if it was as mature as Rust.
- unrealhoang 5y agoI think the reverse is true, with Rust explore the new multi-language codebase and tooling (LLVM) for Linux, it would be easier for Zig to be another supported language for the kernel.
- MrBuddyCasino 5y agoEvery language added means less people are able to review patches, and it means a higher barrier to participation. Do you think there should be a limit to the number of supported languages or not? If yes, what would that number be?
- 5y ago
- rvz 5y agoSome architectures are probably going to be excluded since GCC supports more architectures than LLVM, which is what Rust uses as its compiler backend. I'd rather see a new kernel optimised and written in Rust from scratch rather than dragging the legacy skeletons around and also bringing the vulnerabilities with us.
- henrikeh 5y agoIn the post they mention two efforts to use GCC for compiling Rust.
- Denvercoder9 5y ago> I'd rather see a new kernel optimised and written in Rust from scratch That'll take a momentous amount of effort and it'll take 20 years to get close to the adoption Linux has today. I'd rather see if we can improve Linux in that timespan.
- paavohtl 5y agoWhich of those architectures are relevant in 2021?
- henrikeh 5y agoGiven that they devote a section of the notes to discussing efforts in supporting multiple architectures and, explicitly, GCC, you'd figure that some do find those efforts are worthwhile and relevant.
- rcxdude 5y agoFor this reason rust is currently being proposed to be used for drivers and other code which is already platform or architecture specific, not the core, so as not to affect the support for these architectures. When rust has a mature enough GCC backend then this won't be an issue and it may be possible for it to move into core (though this would still be a big step and likely quite a while away, for example because it would introduce a hard dependency on a rust compiler).
- mkl 5y ago
- the_duke 5y agoIt seems like this now has enough momentum and strong industry support to actually happen. With the initial announcement I mentioned that Linux will need quite a customized Rust experience, and was hopeful that this effort could improve the situation for everyone. It's great to see this actually happen, with changes already flowing back into core and alloc. A lot of progress in just a few months!
- Ericson2314 5y ago> With the initial announcement I mentioned that Linux will need quite a customized Rust experience, and was hopeful that this effort could improve the situation for everyone. My small contribution to this, https://github.com/rust-lang/rust/pull/84266 https://github.com/rust-lang/rust/pull/84266, is supposed to be just that!
- kzrdude 5y agoNeat. Is anything needed to disable SIMD in rust libcore? Maybe with this style of feature flag, core can maybe finally start using SIMD properly (conditionally)?
- Ericson2314 5y agoWorking on a proposal to shore up opt-out feature so the stdlib can use them without fear, rather than the stop-gap ad-hoc CFG tokens the PR used temporarily.
- quotemstr 5y agoRust support in the kernel is good news, but it's just inexcusable that we've had to wait this long for a post-C language. Human beings cannot consistently write correct C --- not you, not me, not Linus Torvalds. Spending decades writing C when a safer language was available caused the industry needless pain. C++ support could have been viable a decade ago had it not been for strong egos on LKML refusing to admit they were wrong. Rust support in Linux is at least partially a face-saving way of backtracking on C++ in the kernel. Rust is great, but with the sole exception of Rust's reified lifetime management, C++ is the better language.
- harry8 5y agoCan't disagree with the idea of having C++ in an os kernel strongly enough. It has certainly been tried and in the cases I know of, regretted.
- quotemstr 5y ago> Can't disagree with the idea of having C++ in an os kernel strongly enough Why? How, precisely, does C++ hurt? > It has certainly been tried and in the cases I know of, regretted. Did it? Fuchsia didn't regret C++ in the kernel. GDB didn't regret moving to C++. (I know GDB isn't the kernel, but it's systems-y.) Android's libc, Bionic, is also written in C++. Every single argument I've seen against C++ in systems code has been specious: people act like typing "g++" instantly implants a copy of the GoF book in your head and turns you into a design patterns robot. "I don't like it" is not a technical argument. Neither is a profanity-laced rant, as satisfying as it might be to pound out such a thing. You can just use C++ as a safer C. Linux would have gotten huge rewards in both safety and developer efficiency if LKML hadn't spent a decade doubling down on their nonsense arguments against C++.
- inglor_cz 5y agoSymbian OS was AFAIK written in a specific dialect of C++ as well.
- 5y ago
- eejjjj82 5y agoBest reply from Linus thus far ... Also, why is this in big-endian order? Let's just try to kill big-endian data, it's disgusting and should just die already. BE is practically dead anyway, we shouldn't add new cases. Networking has legacy reasons from the bad old days when byte order wars were still a thing, but those days are gone. https://lore.kernel.org/lkml/CAHk-=wisMFiBHT7dLFOtHqX=fEve3JafZjSvbd5cy=MpW4u7zQ@mail.gmail.com/ https://lore.kernel.org/lkml/CAHk-=wisMFiBHT7dLFOtHqX=fEve3J...
- gpm 5y agoAlso note that that was the first reply, minutes after the patches were posted. I'm half convinced that he was racing to be first to give it a seal of partial-approval to keep comments more on track.
- ashtonkem 5y agoIf that’s true, it would be extremely good community management on his part.
- Unklejoe 5y agoIs there a technical reason why little endian is better besides the fact that it's more popular due to x86/ARM? To me, big endian makes a lot more sense - integers are stored in the order which you read them (mentally). I do remember reading about how little endian enabled some type of optimization inside the CPU, but I forget the specifics.
- quietbritishjim 5y agoOne small argument for little endian is that if you have a pointer void* then in little endian format you can interpret it as a int8_t*, int16_t*, etc. (or char*, short*, etc. in old money) and get the same numerical value if the number is small enough that it fits into all the types you try. I don't think that has much practical use but it does have a nice feel about it.
- geewee 5y agoThis might be a stupid question because I don't know much about Linux development. Have these patches been accepted into the kernel? Or are they still just "propsals"?
- CryZe 5y agoI don't fully understand it either, but they seem to be merged into linux-next, whatever that exactly means.
- gpm 5y agoStill just proposals. They've been accepted into linux-next, which is a staging ground and used for testing, but that by no means guarantees that they will ever be accepted into the mainline kernel.
- geewee 5y agoThanks!
- moltonel3x 5y agoNot going to be merged into a release branch yet, this is more of a "status update, give it a try" posting. We'll certainly see a few more of those before we get a proper Rust-enabled Linux release.
- iagovar 5y agoSo, as a self-taught programmer looking for future job prospects... is this a signal to learn rust?
- k__ 5y agoCompanies like Amazon and Microsoft are using Rust in their products, that alone is probably a good signal. Also, if you're "just starting" don't burden yourself with legacy stuff. Unlearning that when starting with Rust isn't a cake walk.
- iagovar 5y agoIm pretty fresh, but I do intend to learn some legacy so I can comprehend code from other people.
- Darmody 5y agoThat depends. Rust is a pretty good language but it's not the most used. Also you have to take into account that you can't use Rust on every field. If you're looking to be an Android/iOS/web dev, Rust is not the best option.
- mkl 5y agoDepends what you want to work on. Relative to other software projects, not many jobs involve kernel development, and those that do will mostly continue to use C, as it's production-ready for the Linux kernel, and development often involves extending or modifying existing code.
- eatonphil 5y agoNot learning Rust or C (what it's replacing in this context) will probably not seriously dent your career prospects unless your career is already in systems programming. Learning a language people do systems programming in can be a good experience but it doesn't need to be Rust for you to get that experience. If you want to learn Rust because you want to, that's fair too.
- vaylian 5y agoOne of many signals. Yes. Not because there are a lot of kernel programming jobs, but because Rust has gained a lot of credibility.
- tonetheman 5y agoAh well let the Rust fanboy-ism come in with full force. It was less than 6 comments from the top as I write where some annoying prick said we should rewrite the kernel in Rust. It finally hit me today. It feels like a religion. The fanboys cry to re-write everything in Rust. But it sounds like fanaticism. Like immature children who think that re-writing always solves the problem. Hopefully there will still be enough adults in the room to stop them.
- detaro 5y agoThere is not a single comment saying the Linux kernel should be rewritten in Rust...
- tonetheman 5y agoHere is the text of the comment. --[[ Some architectures are probably going to be excluded since GCC supports more architectures than LLVM, which is what Rust uses as its compiler backend. I'd rather see a new kernel optimised and written in Rust from scratch rather than dragging the legacy skeletons around and also bringing the vulnerabilities with us. ]]--
- kubb 5y agonew kernel, not linux sooner or later it's gonna happen, rust just offers too much value over C
- cerved 5y agoactually I recall seeing that as well
- cerved 5y agoit's almost as if someone is getting royalties every time Rust is mentioned
- fsloth 5y agoA new systems programming language that gains wide industrial adoption is a historically momentuous thing. Lots of discussion is totally warranted - it's not just another hype thing anymore.
- cerved 5y agoI merely pointed out how often the word Rust was mentioned
- VWWHFSfQ 5y agoafter the first usage it should have just been referred to as The Language™ from then on.
- cerved 5y ago> it pronouns are an alternative
- cogman10 5y agoIMO, especially for short nouns, using the full name goes a long way towards making something more readable. Using pronouns can very quickly become confusing. When someone says "it" are they talking about rust, linux, the kernel, linus's temper? Using "rust" instead of "it" completely removes that ambiguity.
- cerved 5y agoIt reads like corporate speak. But I now see that these were quotes so I guess that makes sense
- grumblenum 5y agoI'm hoping that somebody will maintain a Linux fork called "stainless." Really, the jokes write themselves. On a more serious note, I am curious to see what license RIIR Linux will have.
- geenat 5y agoSeems driven by people VERY passionate about Rust.
- ant1112 5y agoSome people who now are now singing the praises of Rust have been "active" and gotten commit rights in more than 5 major open source projects. Of course they didn't do much and mostly used the projects to climb the politician's ladder and badmouth productive developers. I'm very worried about these kinds of people infiltrating the kernel.
- cfcf14 5y agoThis is a very strong condemnation of their efforts, and I'm skeptical that you're making this claim in good faith.
- trs102 5y agoThe parent comment is generic and not about the patch submitter. "in good faith" is precisely the kind of phrase that you'll hear more often on lkml if the people in question (again, not the patch submitter) become more active.
- kzrdude 5y agoWhich people? It seems like you're not talking about the people in the email thread, so who is it? And why would they be close to the kernel?
- volta83 5y agoNames please / citation needed.
- vlang1dot0 5y agoGiven that those people are Linux kernel devs, that's great!
- layoutIfNeeded 5y ago
- bitL 5y agoBeginning of the end of Linux I guess... Mixing multiple languages deeply in the core rarely works due to different requirements and limited interoperability. 5 years later we are going to read about how to migrate existing Rust code to C, like what's happening to Scala projects these days. It seems to me like a Trojan horse from G and MS that pursue their own interests with their own OSes.
- vips7L 5y agoScala actually reminds me a lot of Rust. It’s at about the same complexity level in my eyes.
- asteroidbelt 5y agoExcept that Scala does not bring much above what modern Java with modern IDE can (writing complex programs in Java and in Scala is equally fast), while Rust brings a lot compared to C or C++.
- refenestrator 5y agoScala doesn't care about efficiency or cost of what it's doing, all the fun fancy features allocate like crazy.
- divs1210 5y agoNot in my experience. To me, Scala feels like a kitchen sink language - like C++.
- kafkawatcher 5y ago> like what's happening to Scala projects these days. I don't know much about Rust so can't comment on that part. But agreed on the Scala part. Having seen Apache Kafka use Scala in the early days, when Scala was considered "hip", alongside Java code in the same codebase, I can relate to the mess it created and continues to be even today. At some point there was a plan to move away from Scala in Kafka, not sure where that reached, I stopped following that project since a few years now.
- skor 5y agoWhat is really good about Rust that you cannot get in C?
- mvolfik 5y agoI'd guess guaranteed memory safety (unless you use `unsafe` blocks) without compromising for some garbage collector or ref. counting is a big thing
- whb07 5y agoCompile time guarantees that you didn’t access memory you didn’t really “own”. Dangling pointers are not a thing. No double free. Forces you to think up front about what are the possible state something could be in, and so you won’t get runtime or weird UB. lastly, to be more pedantic for everyone who is at Linus-levels, it’s like all the best static analysis and warnings/errors all rolled up natively into the language. Please don’t bombard me with “but I can just run clang’s X and get the same thing”. No you can’t, and if you did this forces you to run it regardless.
- The_rationalist 5y agoIt's quite trivial to enforce the use and absence of X warnings/error from a static analysis tool Y during merge review and CI. C++ with ASAN enforced is quite close, not compile time granted but much more familiar. Btw there are lifetime checker for c++ in development.
- emilfihlman 5y agoAll easily achievable with gcc. Yes, we can.
- Aissen 5y agoWow, I'm impressed that alloc crate modifications are already there ! Seeing this rate of progress (and the funding behind this work) makes me quite optimistic !
- The_rationalist 5y agoBut how is that solved? If the information of failure (a null returned adress) isn't provided by the language then the program can't observe allocation failure and react to it.
- layoutIfNeeded 5y agoTime to abandon Linux.
- dgb23 5y agoIt's interesting to me that there is not as much push back against Rust from the kernel. Linus (I guess everyone addresses him with his first name), has been very critical, even dismissive of systems programming languages other than C. But with Rust he has a more, I guess we could say passive approach. This might be a good indicator that Rust is doing something very respectable. On the other hand I'm slightly suspicious of this movement. Rustaceans are very, very eager to promote the language. It would be interesting to know how much this movement comes from within the Linux kernel community or if it is driven more by the Rust community. In any case the language seems to have potential of becoming a new mainstream systems programming language in a few years.
- gpm 5y agoThis is a very weird comment, of course the people driving this have a long history with the kernel... It takes about 2 minutes of using git to find out that Miguel's (the main author) first commit to the kernel was back in 2006, and that he's the maintainer of multiple different drivers. The rust community is naturally happy to help out, but I can't even imagine us being able to drive this sort of work...
- cerved 5y agoWhat about it is so very weird? They cautiously raise some legitimate questions.
- gpm 5y agoIt has an undertone implying some sort of strange conspiracy amongst rust people. Generally to be suspicious of something means there is something nefarious going on. It has an implication that Linux is something that any enthusiastic group of outsiders could force their changes into. And that there are rust people would create such a group of outsiders. It has an implication that rust people and linux people are disjoint sets. It's generally taking this strange adversarial view to a collaborative endeavour. People aren't "rustaceans" or not, it's not a sports team. People are people, they generally program in a wide variety of languages, and use whatever they think is best given a certain context. I'm not sure if I've fully captured what seems "off" to me about the comment, but hopefully you get the gist. As for asking questions, that's a clear example of https://rationalwiki.org/wiki/Just_asking_questions https://rationalwiki.org/wiki/Just_asking_questions - but at the same time the general sentiment seems to be frequently reflected in internet comments. I don't think it's a malicious case of this, just how they chose to express their opinions.
- encryptluks2 5y agoReading the comments here makes me less optimistic about Rust support in Linux. It starts with adding support, and will perpetuate into flame wars about why so and so needs to be replaced with Rust cause C sucks. Before long the kernel devs will no longer enjoy working in a toxic environment.
- slezyr 5y agoOk. So... Will I need to have two compilers to build the kernel? gcc and rustc(LLVM)?
- galgalesh 5y agoThe email also gives an update on ongoing work to add rust support to GCC.
- slimginz 5y agoNot familiar with C compiling besides a few small programs I wrote back in college but can Linux not be compiled currently with LLVM?
- gpm 5y agoLinux can be compiled with LLVM (clang), and the current rust code strongly prefers that you do so. It's possible to do gcc + rustc, but it's less supported, and if you pass the wrong gcc flags I believe it just won't work.
- edgyquant 5y agoIt can, but up until just a couple of years ago it could not as it used a lot of GCC specific syntax
- cesarb 5y ago> until just a couple of years ago it could not as it used a lot of GCC specific syntax Note that the kernel still uses a lot of GCC specific syntax; it's just that LLVM/clang was laboriously made to understand all of that (with a few exceptions where the kernel was changed instead). And when they were almost done, the kernel started requiring another new GCC specific syntax, so they had to chase after that too.
- varajelle 5y agoYou'll also need make, bash, perl, and more... [https://www.kernel.org/doc/html/v4.15/process/changes.html https://www.kernel.org/doc/html/v4.15/process/changes.html]
- synergy20 5y agoNice, looking for some intro tutorials about this, such as use rust to write device drivers, rust for linux kernel modules, etc. rust is more of a secure c++, that has its own object oriented pattern, which linux kernel uses a lot but in C.
- xena 5y agoAs far as I know this is all still so new that such a thing doesn't really exist yet. I think the closest that there is to that is probably my post on implementing /dev/printerfact: https://christine.website/blog/dev-printerfact-2021-04-17 https://christine.website/blog/dev-printerfact-2021-04-17
- cjohansson 5y agoThis is great news I think and it's great for both Rust and Linux
- pacman2 5y agoThere is an OS based on Rust https://en.wikipedia.org/wiki/Redox_(operating_system) https://en.wikipedia.org/wiki/Redox_(operating_system)
- dang 5y agoPast related threads (may be incomplete): Rust heads into the kernel? - https://news.ycombinator.com/item?id=27248059 https://news.ycombinator.com/item?id=27248059 - May 2021 (179 comments) Linus Torvalds on Rust support in kernel - https://news.ycombinator.com/item?id=26831841 https://news.ycombinator.com/item?id=26831841 - April 2021 (290 comments) An RFC that adds support for Rust to the Linux kernel - https://news.ycombinator.com/item?id=26812047 https://news.ycombinator.com/item?id=26812047 - April 2021 (261 comments) Supporting Linux kernel development in Rust - https://news.ycombinator.com/item?id=24334731 https://news.ycombinator.com/item?id=24334731 - Aug 2020 (354 comments) Linux kernel in-tree Rust support - https://news.ycombinator.com/item?id=23800201 https://news.ycombinator.com/item?id=23800201 - July 2020 (491 comments) Linux kernel drivers in Rust might become an option in the future - https://news.ycombinator.com/item?id=20833639 https://news.ycombinator.com/item?id=20833639 - Aug 2019 (254 comments)
- _hug_0 5y agoI'm very suprised that Linus is accepting this. In my experience with mid size projects the key to success has always been controlling complexity. I can only imagine that this is even more true for large projects. Generally the complexity an additional language brings to the table is immense in several aspects. Specifically Rust has it's own problems and drawbacks. Looking back at the history of Rust and Firefox/Servo, introducing Rust was overall quite a disservice.
- nicetryguy 5y agoWhich is more bloated? Rust or the egos of its holy crusaders?
- onox 5y agoIt seems you can already write kernel modules in Ada: https://github.com/alkhimey/Ada_Kernel_Module_Framework https://github.com/alkhimey/Ada_Kernel_Module_Framework. Obviously it comes with a boatload of restrictions [1], so no tasking, RAII, exception propagation, or dynamic allocations. [1] https://github.com/alkhimey/Ada_Kernel_Module_Framework/blob/master/examples/template/gnat.adc https://github.com/alkhimey/Ada_Kernel_Module_Framework/blob...
- Uther 5y agoYou can already write kernel modules in Rust too. The point is to integrate the Rust language to the Linux infrastructure so you can merge rust drivers to the official code base.
- l0b0 5y agoAre there any other devs who think this might be what enables them to contribute to the kernel? I've always felt like there's this enormous mountain of knowledge I'd have to know to implement the smallest feature in the kernel: - C pitfalls, probably documented all over the place. - C idioms. These are hard to locate for most languages; I wouldn't know where to look in case of C. - Kernel-specific C idioms. This is probably easy to locate and well documented, but I'd still expect it to be several thousand words. - Code formatting tools. Are there any canonical formatting tools for C, or is it fragmented like for most older languages? - How to test C code, which IIRC requires jumping through quite a few hoops. - How to deal with text, which is a nightmare outside of ASCII in most languages.
- tristan957 5y agoNone of that is specific to C except maybe the last one when compared to Rust. 1. Rust has pitfalls 2. Rust has idioms 3. Rust in kernel would have specific idioms 4. clang-format and uncrustify are two solid choices 5. Nothing is special about C that would make testing hard.
- fastasucan 5y agoI think the commenter you replied to meant that they know Rust a lot better than they do C, which makes it easier, particularly since C has such a long history.
- dexterlemmer 5y ago1. Yea, a road that was used for target practice during a large-scale NATO training exercise is the same as a road that could do with a bit of maintenance with painted potholes to warn people. After all, they both have potholes. 2. You are cherry picking. He also said "These are hard to locate for most languages; I wouldn't know where to look in case of C." Rust has some advantages from for example Clippy and from a very newcomer-welcoming and helpful community. 3. Rust in kernel would indeed have kernel-specific idioms. But it'll probably be very similar to other embedded Rust and relatively easy for a newcomer to pick up. (Ee'll have to wait and see, but there is good reason to expect this.) C in kernel is known to be very hard for other C developers to pick up. 4. Thanks for the info. 5. But some things are special about Rust that makes testing easy. 6. The kernel doesn't deal much with text and even when it does, it generally doesn't need to deal with encodings (let alone modern encodings). That said, text is really a nightmare in C. Even just ASCII is needlessly complex due to null-terination, badly designed functions and the regular C UB pitfalls. At least you did acknowledge it may indeed be a problem for C compared to Rust.
- expnkx 5y agoRRIV. Rewrite Rust in V. What abomination is this? https://github.com/Rust-for-Linux/linux/blob/rust/rust/alloc/rc.rs https://github.com/Rust-for-Linux/linux/blob/rust/rust/alloc... How could this code be safe? Linus Torvalds is brainwashed and now a Google puppet. Nothing more. Rust is dead.
- andy_threos_io 5y agoJust a not so recent news from the rust compiler: https://blog.rust-lang.org/2021/05/10/Rust-1.52.1.html https://blog.rust-lang.org/2021/05/10/Rust-1.52.1.html "The Rust team has prepared a new release, 1.52.1, working around a bug in incremental compilation which was made into a compiler error in 1.52.0. We recommend all Rust users, including those currently using stable versions prior to 1.52.0, upgrade to 1.52.1 or disable incremental compilation. Guidance on how to do so is available below." Is this mature enough to be bring in the kernel ????