r/linux • • Aug 29 '24

Kernel One Of The Rust Linux Kernel Maintainers Steps Down - Cites "Nontechnical Nonsense"

https://www.phoronix.com/news/Rust-Linux-Maintainer-Step-Down
1.1k Upvotes

794 comments sorted by

View all comments

Show parent comments

28

u/LvS Aug 29 '24

The problem with Rust is that it presents itself as its own ecosystem while C/C++ is built on the idea of interoperability.

And the C/C++ community feels like everything that's ported to Rust is taken away from them and they will never be able to use it.

44

u/small_kimono Aug 29 '24 edited Aug 29 '24

The problem with Rust is that it presents itself as its own ecosystem while C/C++ is built on the idea of interoperability.

I mean -- that maybe the POV of some, but I'm not sure it accords with the facts on the ground.

C is interoperable, sure, because it's the base system API/ABI, everyone has to work around it and it rarely changes.

AFAIK C++ ABI, such as it is, is just as in flux as Rust, unless firmed up as the system ABI.

And the C/C++ community feels like everything that's ported to Rust is taken away from them and they will never be able to use it.

This just doesn't make any sense to me. Can you explain?

11

u/not_a_novel_account Aug 29 '24

AFAIK C++ ABI, such as it is, is just as in flux as Rust, unless firmed up as the system ABI.

Completely untrue, the STL ABI changes but that's irrelevant in a freestanding context where the STL is never used (such as kernel development). The STL ABI is unstable for the same reason any library's ABI is unstable, if the library changes something the ABI changes with it.

The Itanium standard does not change, the ABI of a given freestanding C++ codebase is exactly as stable as the C ABI of a given codebase.

7

u/simon_o Aug 29 '24

It's still nonsense, because it's impossible to interop with C++ without embedding half of LLVM into your language's compiler.

4

u/small_kimono Aug 29 '24

Completely untrue, the STL ABI changes but that's irrelevant in a freestanding context where the STL is never used (such as kernel development).

Okay, but C++ is not proposed for Linux kernel development? Aren't we kind of far afield from the initial point, which is "things need to interoperate with other things, mostly via the C ABI, in the kernel", with our assumptions?

The Itanium standard does not change, the ABI of a given freestanding C++ codebase is exactly as stable as the C ABI of a given codebase.

AFAIK, and I'm not that close to this, the Itanium standard has been proposed but not adopted. It is used as a de facto standard by GCC, and Windows has it's own de facto ABI, but, in my (dim) view, this really isn't the same as the language having an adopted standard (yet).

7

u/not_a_novel_account Aug 29 '24 edited Aug 29 '24

the Itanium standard has been proposed but not adopted

Not adopted by who? It's the standard used by GCC and Clang (on *Nix, on Windows Clang uses the MSVC ABI). The MSVC ABI is indeed different but equally stable.

For C, GCC and Clang use the SysV ABI on *Nix, and MSVC also uses its own C ABI. C and C++, in this respect, have identically standardized and stable ABIs. Neither language standard mandates anything about ABI.

Rust does not have a stable ABI, as the implementation makes no commitment to stability of calling convention or structure layout (unlike GCC/Clang/MSVC)

1

u/small_kimono Aug 29 '24

My statement:

AFAIK C++ ABI, such as it is, is just as in flux as Rust, unless firmed up as the system ABI.

Again AFAIK C++, the language, makes no such guarantees. As I said, the platform/system however has instead given you one.

Rust does not, as it makes no commitment to stability of calling convention or structure layout.

This is partially true, but again less important in the context to which you confined the argument:

Completely untrue, the STL ABI changes but that's irrelevant in a freestanding context where the STL is never used (such as kernel development).

The C ABI and interop is really the only thing important here.

And Rust can commit to a C calling convention and you can express a C type layout.

6

u/not_a_novel_account Aug 29 '24 edited Aug 29 '24

Again AFAIK C++, the language, makes no such guarantees.

C, the language, also makes no such guarantees. That's why I said C and C++ are equally stable. They both have widely adopted standards outside the language providing the guarantees that their languages do not.

Muting this. It's like trying to explain the C and C++ language standards to a wall. A wall that didn't pay attention in its compiler class.

2

u/Days_End Aug 29 '24

Their point is C++'s ABI is perfectly stable in the context of this discussion (use inside the Linux kernel).

3

u/small_kimono Aug 29 '24

Their point is C++'s ABI is perfectly stable in the context of this discussion (use inside the Linux kernel).

But that wasn't the commenter's point. I think the commenter's point was abstractly C++ was interoperable, but Rust wasn't. And my point was I think they are just as interoperable, which I think they are?

If you want to dig deeper and say "in the kernel", I'd say again, they both have to use a C ABI, and are similarly interoperable.

5

u/Days_End Aug 29 '24

If you want to dig deeper and say "in the kernel", I'd say again, they both have to use a C ABI, and are similarly interoperable.

But they don't..... They can use the C++ ABI unlike Rust which will have to use the C ABI. Once you drop the STL, which they don't use in the kernel, for GCC and Clang you have the Itanium ABI which has been stable for more than a decade at this point.

I can load and call some C++ library code compiled 10 years ago from a random program I built today.

1

u/NotFromSkane Aug 29 '24

Sure, but you can't do that with 20 year old code. C++11 broke a bunch of stuff, like banning Cow Strings for the sake of SSO.

1

u/Days_End Aug 29 '24

like banning Cow Strings for the sake of SSO.

That's STL changes which doesn't effect the ABI for the in kernel uses as they don't use the STL.

1

u/josefx Aug 29 '24

You can still force the old implementation of the standard library classes by setting _GLIBCXX_USE_CXX11_ABI=0. However changes to the standard library do not affect the plattform ABI and it is unlikely that the kernel would find a user space standard library very usefull.

→ More replies (1)

-2

u/SnooCompliments7914 Aug 29 '24

There are no practical stable C++ ABI. Qt tries hard by their extensive usage of PIMPL, but applications still break from time to time on Qt upgrades. It's a futile effort.

5

u/not_a_novel_account Aug 29 '24

Again simply untrue, neither the C or C++ language standards say a word about ABI, their ABIs are governed by external standards. For GCC (and effectively all *nix compilers), that standard is SysV for C and Itanium for C++. These standards are unchanging and, for all intents and purposes, locked in, with billions of dollars of software relying upon that stability.

3

u/NotFromSkane Aug 29 '24

And the standards committees still take decisions based on whether or not it forces implementations to break ABI. It doesn't have to be in the doc to be a factor

-1

u/SnooCompliments7914 Aug 29 '24

Note I said "practical". There are more than the compiler to maintain a stable ABI. And in real world, it breaks a lot more often than C ABIs.

→ More replies (2)

1

u/ArdiMaster Aug 29 '24

Rust code can’t be (easily?) called from C by default. Rust developers need to put in some extra work to make their code consumable to C. If the Rust developer chooses not to put in that effort for whatever reason, C developers can’t use their code.

→ More replies (11)

1

u/0xdeadf001 Aug 31 '24

And the C/C++ community feels like everything that's ported to Rust is taken away from them and they will never be able to use it.

People should not view themselves as "a Rust developer" or "a C++ developer". They should view themselves as developers. Nothing is "taken away" by moving something to a different language.

2

u/LvS Aug 31 '24

How do I link my C++ program against a library that is now no longer a C++ library but a Rust crate?

1

u/0xdeadf001 Aug 31 '24

We don't go burn down the old C++ code -- it still exists.

If you do want to call into the Rust code, there are a lot of different options for integrating code. It's a limitation, but it's not unique to Rust. For example, Python devs do a lot of integration with C/C++ codebases, such as numpy or torch.

The days when you could (or should) write everything in a single language are long gone. Some languages are better suited for certain purposes than others -- you use the right tool for the job.

Also, a lot of integration points are at network interfaces or data storage formats. In those cases, it doesn't matter what language was used to generate a file, or to send a network packet, etc. It's all just data.

2

u/LvS Sep 01 '24

It seems very much like we are burning down the old C++ code. There are many projects out their trying to replace C/C++ code with Rust code, including in the Linux kernel.

And sure, everybody - Python, Rust, you name it - integrates with C/C++ codebases, but there's a distinct lack of integration with Rust codebases.

1

u/mrtruthiness Sep 01 '24

Rust and C++ have the same name-mangling issues. To prevent Rust name-mangling one needs an 'extern "C"' declaration.

https://docs.rust-embedded.org/book/interoperability/rust-with-c.html

→ More replies (10)