BT

Rust 1.25 Moves to LLVM 6

| by Sergio De Simone Follow 14 Followers on Apr 02, 2018. Estimated reading time: 2 minutes |

Rust 1.25 upgrades to LLVM 6, adds support for nested import groups in use statements, custom struct alignment, and library stabilizations. This latest Rust release does not include, though, much awaited features such as impl Trait, stable SIMD support, and 128-bit integers.

The update to LLVM 6 (a collection of modular and reusable compiler and toolchain technologies) is motivated by a number of benefits, such as assorted bug fixes, including SIMD-related compilation errors, but mostly it allows the project to keep up with LLVM’s upstream WebAssembly (Wasm) backend more easily, so new Wasm features can be supported quickly. This has an important exception for the Emscripted-powered JavaScript backend, which is using a locked up LLVM 4 version. According to Rust developer Steve Klabnik, LLVM 6 does not necessarily bring any performance improvements in the general case, and it will depend on the exact code whether it will provide faster or slower compilation.

The new use statement syntax allows developers to specify nested import groups, aiming to make the code more readable and concise. For example, the following set of imports:

use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};

can now be written as:

use std::{fs::File, io::Read, path::{Path, PathBuf}};

Additionally, you can set the alignment of Rust 1.25 structs using #[repr(align(x))] annotation s:

struct Number(i32);

assert_eq!(std::mem::align_of::<Number>(), 4);
assert_eq!(std::mem::size_of::<Number>(), 4);

#[repr(align(16))]
struct Align16(i32);

assert_eq!(std::mem::align_of::<Align16>(), 16);
assert_eq!(std::mem::size_of::<Align16>(), 16);

This feature can be useful when using hardware with specific alignment requirements, for better interoperability with C code, e.g. to make it easier to correctly pass a struct that some C code expects to be aligned in a given manner, and for advanced cases such as statically allocating page tables in a kernel.

On the library front, the most significant change is the introduction of std::ptr::NonNull, which is like *mut T but with the guarantee of being non-zero and covariant. Its use is mostly appropriate when building data structures with unsafe code.

As it stands, Rust 1.25 is not the Rust big release many developers are waiting for, since it does not include major features that the Rust team has been working on for quite some time, including impl Trait (which should allow for improved performance, simpler generics syntax and diagnostics), 128-bit integers, stable SIMD library support, and others. The good news, according to Klabnik, is they are likely going to land in the next two releases, 1.26 and 1.27.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT