News for hackers. Stuff that matters.
Re:Announcing Rust 1.6 by haberman on Thursday January 21, 2016 @05:34PM (#10949035)
Since this release is focused on stabilizing libcore for embedded use, it seems a good time to ask a question that's been on my mind.

C11 (and C++11) defined a memory model and atomic operations for shared-state lock-free concurrency. But that model and the atomic operations aren't being used by Linux, because they didn't match up with the semantics of the operations that Linux uses. (See https://lwn.net/Articles/586838/ and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p012...).

I'm curious what Rust says about this. Does Rust have a memory model like C11/C++11? I'm curious whether Rust (and C11/C++11 for that matter) will evolve to have primitives like what the Linux kernel currently defines and uses.

Re:Announcing Rust 1.6 by steveklabnik on Thursday January 21, 2016 @05:37PM (#10949060)
We do not have a formal spec yet, and so do not technically have a memory model like C or C++ do. However, since we're built on LLVM, we do have some semantics that are pretty much based on it. Our atomics stuff is pretty much LLVM's. A lot of the work going into forming said models is trying to determine how much of LLVM we've let pollute into the language in the meantime and where it's feasible to diverge.

https://github.com/rust-lang/rfcs/issues/1447 is a good thread if you care about this topic.

Re:Announcing Rust 1.6 by johnbender on Thursday January 21, 2016 @06:55PM (#10949567)
http://plv.mpi-sws.org/rustbelt/

As part of defining the Rust semantics they will certainly tackle the question of the memory model. Dreyer and company have a track record of providing semantics and reasoning principles for weak memory models (like C11).

You might have to wait a while for a rigorous semantics though.

Re:Announcing Rust 1.6 by hellofunk on Friday January 22, 2016 @07:04AM (#10952230)
I'm curious if what you mean is that C++11 has a standard spec for the memory model you describe, but if Linux doesn't use it, then Linux does not actually adhere to the C++11 standard? Does that mean that Linux C++11 compilers are non-standard in general?
Re:Announcing Rust 1.6 by haberman on Friday January 22, 2016 @02:30PM (#10955012)
Let me clarify first that when I say "Linux" in this post, I'm specifically referring to the Linux kernel, not user-space software that runs on Linux.

The Linux kernel is written in C, but uses lots of GCC-specific features and inline assembly to address things that aren't covered by the C standard. Among these, the Linux kernel has its own set of atomic types and memory barriers. It documents them here: https://www.kernel.org/doc/Documentation/memory-barriers.txt

So even if Linux is being compiled on a conforming C11 compiler (the Linux kernel is written in C, not C++), it uses its own atomic primitives instead of the ones provided by the language. Hope that helps.

Re:Announcing Rust 1.6 by Manishearth on Friday January 22, 2016 @09:14AM (#10952776)
I don't think there are any (modern) C++ compilers out there which follow the standard 100% and perfectly. ICBW.
Re:Announcing Rust 1.6 by hellofunk on Friday January 22, 2016 @10:01AM (#10953033)
Re:Announcing Rust 1.6 by Manishearth on Friday January 22, 2016 @12:36PM (#10954220)
That's a list of features. My point was that there are some slight variations induced by optimizations or otherwise which are against the spec.
Re:Announcing Rust 1.6 by hellofunk on Friday January 22, 2016 @01:47PM (#10954703)
I think you are confusing specification with implementation. The C++ standard does not outline how a compiler implements a feature, just how it should behave to match the standard. There are several compilers that 100% adhere to the full standard, including the guarantees specified by the standard in the form of memory and time complexity (optimization).
Re:Announcing Rust 1.6 by Manishearth on Friday January 22, 2016 @04:51PM (#10955824)
Oh, I know that specification != implementation, but IIRC both clang and GCC have certain behaviour which do not conform to the standard. But I can't find these right now, so I'll drop it here :)