Rust 1.25 Moves to LLVM 6

综合技术 2018-04-03 阅读原文

Rust 1.25
upgrades its LLVM 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 is motivated by a number of benefits
, such as assorted bug fixes, including SIMD-related compilation errors, but mostly by the fact it allows to keep up with LLVM’s upstream 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

annotation s:

struct Number(i32);

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

struct Align16(i32);

assert_eq!(std::mem::align_of::(), 16);
assert_eq!(std::mem::size_of::(), 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

, 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.




Making Terminal Applications in Rust with Termion This post will walk through the basics of implementing a terminal (TTY) application for experienced and new beginners to...
Mehul Patel – Dive Into Rust at ORDINATEUR’1... The event is focused on introducing and teaching the state of art system programming language Rust to local programmers...
llvm学习笔记(4) 一般操作数 寄存器以外的一般的操作数由Operand描述,它定义如下: 593 class Operand : DAGOperand { ...
Building a JS Interpreter in Rust Part 1 So I’ve decided to have a go at building a JS interpreter in Rust. I’ve wanted to do this for a while for a couple of r...
Writing a GPU-Accelerated Path Tracer in Rust R... Well, it’s that time again. This is the start of a second series of articles on raytracing in Rust following on from...