mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Merge commit '370c397ec9169809e5ad270079712e0043514240' into sync_cg_clif-2022-03-20
This commit is contained in:
commit
ef4ce72919
@ -4,9 +4,9 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.53"
|
||||
version = "1.0.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
|
||||
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
|
||||
|
||||
[[package]]
|
||||
name = "ar"
|
||||
@ -15,9 +15,9 @@ source = "git+https://github.com/bjorn3/rust-ar.git?branch=do_not_remove_cg_clif
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
@ -33,18 +33,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-bforest"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71447555acc6c875c52c407d572fc1327dc5c34cba72b4b2e7ad048aa4e4fd19"
|
||||
checksum = "d16922317bd7dd104d509a373887822caa0242fc1def00de66abb538db221db4"
|
||||
dependencies = [
|
||||
"cranelift-entity",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec9a10261891a7a919b0d4f6aa73582e88441d9a8f6173c88efbe4a5a362ea67"
|
||||
checksum = "8b80bf40380256307b68a3dcbe1b91cac92a533e212b5b635abc3e4525781a0a"
|
||||
dependencies = [
|
||||
"cranelift-bforest",
|
||||
"cranelift-codegen-meta",
|
||||
@ -59,30 +59,30 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-meta"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "815755d76fcbcf6e17ab888545b28ab775f917cb12ce0797e60cd41a2288692c"
|
||||
checksum = "703d0ed7d3bc6c7a814ca12858175bf4e93167a3584127858c686e4b5dd6e432"
|
||||
dependencies = [
|
||||
"cranelift-codegen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-codegen-shared"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23ea92f2a67335a2e4d3c9c65624c3b14ae287d595b0650822c41824febab66b"
|
||||
checksum = "80f52311e1c90de12dcf8c4b9999c6ebfd1ed360373e88c357160936844511f6"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-entity"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd25847875e388c500ad3624b4d2e14067955c93185194a7222246a25b91c975"
|
||||
checksum = "66bc82ef522c1f643baf7d4d40b7c52643ee4549d8960b0e6a047daacb83f897"
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-frontend"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "308bcfb7eb47bdf5ff6e1ace262af4ed39ec19f204c751fffb037e0e82a0c8bf"
|
||||
checksum = "3cc35e4251864b17515845ba47447bca88fec9ca1a4186b19fe42526e36140e8"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"log",
|
||||
@ -92,9 +92,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-jit"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f560b3a314b8d15facf411e5d29b917c3e787a2bbc3fcdc5183bc0c5b7d4fe01"
|
||||
checksum = "93c66d594ad3bfe4e58b1fbd8d17877a7c6564a5f2d6f78cbbf4b0182af1927f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cranelift-codegen",
|
||||
@ -110,9 +110,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-module"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a57aba9e603d694d1430ff38bd914bae23ef9c2e44b25a65e318905807e654c"
|
||||
checksum = "bf356697c40232aa09e1e3fb8a350ee894e849ccecc4eac56ff0570a4575c325"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cranelift-codegen",
|
||||
@ -120,9 +120,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-native"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12cdc799aee673be2317e631d4569a1ba0a7e77a07a7ce45557086d2e02e9514"
|
||||
checksum = "b882b2251c9845d509d92aebfdb6c8bb3b3b48e207ac951f21fbd20cfe7f90b3"
|
||||
dependencies = [
|
||||
"cranelift-codegen",
|
||||
"libc",
|
||||
@ -131,9 +131,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cranelift-object"
|
||||
version = "0.81.0"
|
||||
version = "0.82.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "502a7333836052fcdf4425d7f7a21264d99f862d32b9c3a0e47cd920487a9b60"
|
||||
checksum = "2d3f1a88e654e567d2591169239ed157ab290811a729a6468f53999c01001263"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cranelift-codegen",
|
||||
@ -145,9 +145,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.3.1"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3"
|
||||
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
@ -179,9 +179,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.116"
|
||||
version = "0.2.119"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74"
|
||||
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
@ -228,6 +228,12 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
||||
|
||||
[[package]]
|
||||
name = "regalloc"
|
||||
version = "0.0.34"
|
||||
@ -272,6 +278,7 @@ dependencies = [
|
||||
"indexmap",
|
||||
"libloading",
|
||||
"object",
|
||||
"once_cell",
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
]
|
||||
@ -284,9 +291,9 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.12.2"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff"
|
||||
checksum = "d7fa7e55043acb85fca6b3c01485a2eeb6b69c5d21002e273c79e465f43b7ac1"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
|
@ -8,12 +8,12 @@ crate-type = ["dylib"]
|
||||
|
||||
[dependencies]
|
||||
# These have to be in sync with each other
|
||||
cranelift-codegen = { version = "0.81.0", features = ["unwind", "all-arch"] }
|
||||
cranelift-frontend = "0.81.0"
|
||||
cranelift-module = "0.81.0"
|
||||
cranelift-native = "0.81.0"
|
||||
cranelift-jit = { version = "0.81.0", optional = true }
|
||||
cranelift-object = "0.81.0"
|
||||
cranelift-codegen = { version = "0.82.1", features = ["unwind", "all-arch"] }
|
||||
cranelift-frontend = "0.82.1"
|
||||
cranelift-module = "0.82.1"
|
||||
cranelift-native = "0.82.1"
|
||||
cranelift-jit = { version = "0.82.1", optional = true }
|
||||
cranelift-object = "0.82.1"
|
||||
target-lexicon = "0.12.0"
|
||||
gimli = { version = "0.26.0", default-features = false, features = ["write"]}
|
||||
object = { version = "0.27.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
|
||||
@ -21,6 +21,7 @@ object = { version = "0.27.0", default-features = false, features = ["std", "rea
|
||||
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
|
||||
indexmap = "1.8.0"
|
||||
libloading = { version = "0.6.0", optional = true }
|
||||
once_cell = "1.10.0"
|
||||
smallvec = "1.6.1"
|
||||
|
||||
[patch.crates-io]
|
||||
|
@ -56,7 +56,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "compiler_builtins"
|
||||
version = "0.1.70"
|
||||
version = "0.1.71"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "163437f05ca8f29d7e9128ea728dedf5eb620e445fbca273641d3a3050305f23"
|
||||
dependencies = [
|
||||
"rustc-std-workspace-core",
|
||||
]
|
||||
@ -132,9 +134,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.119"
|
||||
version = "0.2.121"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
|
||||
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
|
||||
dependencies = [
|
||||
"rustc-std-workspace-core",
|
||||
]
|
||||
|
@ -14,7 +14,6 @@ compiler_builtins = { version = "0.1.39", default-features = false, features = [
|
||||
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
|
||||
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }
|
||||
rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" }
|
||||
compiler_builtins = { path = "./compiler-builtins" }
|
||||
|
||||
[profile.dev]
|
||||
lto = "off"
|
||||
@ -23,3 +22,14 @@ lto = "off"
|
||||
debug = true
|
||||
incremental = true
|
||||
lto = "off"
|
||||
|
||||
# Mandatory for correctly compiling compiler-builtins
|
||||
[profile.dev.package.compiler_builtins]
|
||||
debug-assertions = false
|
||||
overflow-checks = false
|
||||
codegen-units = 10000
|
||||
|
||||
[profile.release.package.compiler_builtins]
|
||||
debug-assertions = false
|
||||
overflow-checks = false
|
||||
codegen-units = 10000
|
||||
|
@ -14,29 +14,33 @@ pub(crate) fn prepare() {
|
||||
eprintln!("[INSTALL] hyperfine");
|
||||
Command::new("cargo").arg("install").arg("hyperfine").spawn().unwrap().wait().unwrap();
|
||||
|
||||
clone_repo(
|
||||
clone_repo_shallow_github(
|
||||
"rand",
|
||||
"rust-random",
|
||||
"rand",
|
||||
"https://github.com/rust-random/rand.git",
|
||||
"0f933f9c7176e53b2a3c7952ded484e1783f0bf1",
|
||||
);
|
||||
apply_patches("rand", Path::new("rand"));
|
||||
|
||||
clone_repo(
|
||||
clone_repo_shallow_github(
|
||||
"regex",
|
||||
"rust-lang",
|
||||
"regex",
|
||||
"https://github.com/rust-lang/regex.git",
|
||||
"341f207c1071f7290e3f228c710817c280c8dca1",
|
||||
);
|
||||
|
||||
clone_repo(
|
||||
clone_repo_shallow_github(
|
||||
"portable-simd",
|
||||
"rust-lang",
|
||||
"portable-simd",
|
||||
"https://github.com/rust-lang/portable-simd",
|
||||
"b8d6b6844602f80af79cd96401339ec594d472d8",
|
||||
);
|
||||
apply_patches("portable-simd", Path::new("portable-simd"));
|
||||
|
||||
clone_repo(
|
||||
clone_repo_shallow_github(
|
||||
"simple-raytracer",
|
||||
"ebobby",
|
||||
"simple-raytracer",
|
||||
"https://github.com/ebobby/simple-raytracer",
|
||||
"804a7a21b9e673a482797aa289a18ed480e4d813",
|
||||
);
|
||||
|
||||
@ -74,29 +78,12 @@ fn prepare_sysroot() {
|
||||
git_init_cmd.arg("init").arg("-q").current_dir(&sysroot_src);
|
||||
spawn_and_wait(git_init_cmd);
|
||||
|
||||
let mut git_add_cmd = Command::new("git");
|
||||
git_add_cmd.arg("add").arg(".").current_dir(&sysroot_src);
|
||||
spawn_and_wait(git_add_cmd);
|
||||
|
||||
let mut git_commit_cmd = Command::new("git");
|
||||
git_commit_cmd
|
||||
.arg("commit")
|
||||
.arg("-m")
|
||||
.arg("Initial commit")
|
||||
.arg("-q")
|
||||
.current_dir(&sysroot_src);
|
||||
spawn_and_wait(git_commit_cmd);
|
||||
init_git_repo(&sysroot_src);
|
||||
|
||||
apply_patches("sysroot", &sysroot_src);
|
||||
|
||||
clone_repo(
|
||||
"build_sysroot/compiler-builtins",
|
||||
"https://github.com/rust-lang/compiler-builtins.git",
|
||||
"0.1.70",
|
||||
);
|
||||
apply_patches("compiler-builtins", Path::new("build_sysroot/compiler-builtins"));
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn clone_repo(target_dir: &str, repo: &str, rev: &str) {
|
||||
eprintln!("[CLONE] {}", repo);
|
||||
// Ignore exit code as the repo may already have been checked out
|
||||
@ -111,6 +98,57 @@ fn clone_repo(target_dir: &str, repo: &str, rev: &str) {
|
||||
spawn_and_wait(checkout_cmd);
|
||||
}
|
||||
|
||||
fn clone_repo_shallow_github(target_dir: &str, username: &str, repo: &str, rev: &str) {
|
||||
if cfg!(windows) {
|
||||
// Older windows doesn't have tar or curl by default. Fall back to using git.
|
||||
clone_repo(target_dir, &format!("https://github.com/{}/{}.git", username, repo), rev);
|
||||
return;
|
||||
}
|
||||
|
||||
let archive_url = format!("https://github.com/{}/{}/archive/{}.tar.gz", username, repo, rev);
|
||||
let archive_file = format!("{}.tar.gz", rev);
|
||||
let archive_dir = format!("{}-{}", repo, rev);
|
||||
|
||||
eprintln!("[DOWNLOAD] {}/{} from {}", username, repo, archive_url);
|
||||
|
||||
// Remove previous results if they exists
|
||||
let _ = std::fs::remove_file(&archive_file);
|
||||
let _ = std::fs::remove_dir_all(&archive_dir);
|
||||
let _ = std::fs::remove_dir_all(target_dir);
|
||||
|
||||
// Download zip archive
|
||||
let mut download_cmd = Command::new("curl");
|
||||
download_cmd.arg("--location").arg("--output").arg(&archive_file).arg(archive_url);
|
||||
spawn_and_wait(download_cmd);
|
||||
|
||||
// Unpack tar archive
|
||||
let mut unpack_cmd = Command::new("tar");
|
||||
unpack_cmd.arg("xf").arg(&archive_file);
|
||||
spawn_and_wait(unpack_cmd);
|
||||
|
||||
// Rename unpacked dir to the expected name
|
||||
std::fs::rename(archive_dir, target_dir).unwrap();
|
||||
|
||||
init_git_repo(Path::new(target_dir));
|
||||
|
||||
// Cleanup
|
||||
std::fs::remove_file(archive_file).unwrap();
|
||||
}
|
||||
|
||||
fn init_git_repo(repo_dir: &Path) {
|
||||
let mut git_init_cmd = Command::new("git");
|
||||
git_init_cmd.arg("init").arg("-q").current_dir(repo_dir);
|
||||
spawn_and_wait(git_init_cmd);
|
||||
|
||||
let mut git_add_cmd = Command::new("git");
|
||||
git_add_cmd.arg("add").arg(".").current_dir(repo_dir);
|
||||
spawn_and_wait(git_add_cmd);
|
||||
|
||||
let mut git_commit_cmd = Command::new("git");
|
||||
git_commit_cmd.arg("commit").arg("-m").arg("Initial commit").arg("-q").current_dir(repo_dir);
|
||||
spawn_and_wait(git_commit_cmd);
|
||||
}
|
||||
|
||||
fn get_patches(crate_name: &str) -> Vec<OsString> {
|
||||
let mut patches: Vec<_> = fs::read_dir("patches")
|
||||
.unwrap()
|
||||
|
@ -8,33 +8,21 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
#![no_std]
|
||||
#![feature(allocator_api, rustc_private)]
|
||||
#![cfg_attr(any(unix, target_os = "redox"), feature(libc))]
|
||||
|
||||
// The minimum alignment guaranteed by the architecture. This value is used to
|
||||
// add fast paths for low alignment values.
|
||||
#[cfg(all(any(target_arch = "x86",
|
||||
target_arch = "arm",
|
||||
target_arch = "mips",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "powerpc64")))]
|
||||
const MIN_ALIGN: usize = 8;
|
||||
#[cfg(all(any(target_arch = "x86_64",
|
||||
target_arch = "aarch64",
|
||||
target_arch = "mips64",
|
||||
target_arch = "s390x",
|
||||
target_arch = "sparc64")))]
|
||||
const MIN_ALIGN: usize = 16;
|
||||
|
||||
pub struct System;
|
||||
|
||||
#[cfg(any(windows, unix, target_os = "redox"))]
|
||||
mod realloc_fallback {
|
||||
use core::alloc::{GlobalAlloc, Layout};
|
||||
use core::cmp;
|
||||
use core::ptr;
|
||||
impl super::System {
|
||||
pub(crate) unsafe fn realloc_fallback(&self, ptr: *mut u8, old_layout: Layout,
|
||||
new_size: usize) -> *mut u8 {
|
||||
pub(crate) unsafe fn realloc_fallback(
|
||||
&self,
|
||||
ptr: *mut u8,
|
||||
old_layout: Layout,
|
||||
new_size: usize,
|
||||
) -> *mut u8 {
|
||||
// Docs for GlobalAlloc::realloc require this to be valid:
|
||||
let new_layout = Layout::from_size_align_unchecked(new_size, old_layout.align());
|
||||
let new_ptr = GlobalAlloc::alloc(self, new_layout);
|
||||
@ -49,97 +37,47 @@ mod realloc_fallback {
|
||||
}
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
mod platform {
|
||||
extern crate libc;
|
||||
use core::ptr;
|
||||
use MIN_ALIGN;
|
||||
use System;
|
||||
use core::alloc::{GlobalAlloc, Layout};
|
||||
use core::ffi::c_void;
|
||||
use core::ptr;
|
||||
use System;
|
||||
extern "C" {
|
||||
fn posix_memalign(memptr: *mut *mut c_void, align: usize, size: usize) -> i32;
|
||||
fn free(p: *mut c_void);
|
||||
}
|
||||
unsafe impl GlobalAlloc for System {
|
||||
#[inline]
|
||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
|
||||
libc::malloc(layout.size()) as *mut u8
|
||||
} else {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
if layout.align() > (1 << 31) {
|
||||
return ptr::null_mut()
|
||||
}
|
||||
}
|
||||
aligned_malloc(&layout)
|
||||
}
|
||||
aligned_malloc(&layout)
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
|
||||
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
|
||||
libc::calloc(layout.size(), 1) as *mut u8
|
||||
} else {
|
||||
let ptr = self.alloc(layout.clone());
|
||||
if !ptr.is_null() {
|
||||
ptr::write_bytes(ptr, 0, layout.size());
|
||||
}
|
||||
ptr
|
||||
let ptr = self.alloc(layout.clone());
|
||||
if !ptr.is_null() {
|
||||
ptr::write_bytes(ptr, 0, layout.size());
|
||||
}
|
||||
ptr
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
|
||||
libc::free(ptr as *mut libc::c_void)
|
||||
free(ptr as *mut c_void)
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
|
||||
if layout.align() <= MIN_ALIGN && layout.align() <= new_size {
|
||||
libc::realloc(ptr as *mut libc::c_void, new_size) as *mut u8
|
||||
} else {
|
||||
self.realloc_fallback(ptr, layout, new_size)
|
||||
}
|
||||
self.realloc_fallback(ptr, layout, new_size)
|
||||
}
|
||||
}
|
||||
#[cfg(any(target_os = "android",
|
||||
target_os = "hermit",
|
||||
target_os = "redox",
|
||||
target_os = "solaris"))]
|
||||
#[inline]
|
||||
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
|
||||
// On android we currently target API level 9 which unfortunately
|
||||
// doesn't have the `posix_memalign` API used below. Instead we use
|
||||
// `memalign`, but this unfortunately has the property on some systems
|
||||
// where the memory returned cannot be deallocated by `free`!
|
||||
//
|
||||
// Upon closer inspection, however, this appears to work just fine with
|
||||
// Android, so for this platform we should be fine to call `memalign`
|
||||
// (which is present in API level 9). Some helpful references could
|
||||
// possibly be chromium using memalign [1], attempts at documenting that
|
||||
// memalign + free is ok [2] [3], or the current source of chromium
|
||||
// which still uses memalign on android [4].
|
||||
//
|
||||
// [1]: https://codereview.chromium.org/10796020/
|
||||
// [2]: https://code.google.com/p/android/issues/detail?id=35391
|
||||
// [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579
|
||||
// [4]: https://chromium.googlesource.com/chromium/src/base/+/master/
|
||||
// /memory/aligned_memory.cc
|
||||
libc::memalign(layout.align(), layout.size()) as *mut u8
|
||||
}
|
||||
#[cfg(not(any(target_os = "android",
|
||||
target_os = "hermit",
|
||||
target_os = "redox",
|
||||
target_os = "solaris")))]
|
||||
#[inline]
|
||||
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
|
||||
let mut out = ptr::null_mut();
|
||||
let ret = libc::posix_memalign(&mut out, layout.align(), layout.size());
|
||||
if ret != 0 {
|
||||
ptr::null_mut()
|
||||
} else {
|
||||
out as *mut u8
|
||||
}
|
||||
let ret = posix_memalign(&mut out, layout.align(), layout.size());
|
||||
if ret != 0 { ptr::null_mut() } else { out as *mut u8 }
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
#[allow(nonstandard_style)]
|
||||
mod platform {
|
||||
use MIN_ALIGN;
|
||||
use System;
|
||||
use core::alloc::{GlobalAlloc, Layout};
|
||||
use System;
|
||||
type LPVOID = *mut u8;
|
||||
type HANDLE = LPVOID;
|
||||
type SIZE_T = usize;
|
||||
@ -165,18 +103,9 @@ mod platform {
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn allocate_with_flags(layout: Layout, flags: DWORD) -> *mut u8 {
|
||||
let ptr = if layout.align() <= MIN_ALIGN {
|
||||
HeapAlloc(GetProcessHeap(), flags, layout.size())
|
||||
} else {
|
||||
let size = layout.size() + layout.align();
|
||||
let ptr = HeapAlloc(GetProcessHeap(), flags, size);
|
||||
if ptr.is_null() {
|
||||
ptr
|
||||
} else {
|
||||
align_ptr(ptr, layout.align())
|
||||
}
|
||||
};
|
||||
ptr as *mut u8
|
||||
let size = layout.size() + layout.align();
|
||||
let ptr = HeapAlloc(GetProcessHeap(), flags, size);
|
||||
(if ptr.is_null() { ptr } else { align_ptr(ptr, layout.align()) }) as *mut u8
|
||||
}
|
||||
unsafe impl GlobalAlloc for System {
|
||||
#[inline]
|
||||
@ -189,24 +118,13 @@ mod platform {
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
|
||||
if layout.align() <= MIN_ALIGN {
|
||||
let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID);
|
||||
debug_assert!(err != 0, "Failed to free heap memory: {}",
|
||||
GetLastError());
|
||||
} else {
|
||||
let header = get_header(ptr);
|
||||
let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
|
||||
debug_assert!(err != 0, "Failed to free heap memory: {}",
|
||||
GetLastError());
|
||||
}
|
||||
let header = get_header(ptr);
|
||||
let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
|
||||
debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
|
||||
if layout.align() <= MIN_ALIGN {
|
||||
HeapReAlloc(GetProcessHeap(), 0, ptr as LPVOID, new_size) as *mut u8
|
||||
} else {
|
||||
self.realloc_fallback(ptr, layout, new_size)
|
||||
}
|
||||
self.realloc_fallback(ptr, layout, new_size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Adapted from rustc run-pass test suite
|
||||
|
||||
#![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::{
|
||||
ops::{Deref, CoerceUnsized, DispatchFromDyn},
|
||||
|
@ -1,7 +1,14 @@
|
||||
#![feature(
|
||||
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
|
||||
untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits,
|
||||
thread_local,
|
||||
no_core,
|
||||
lang_items,
|
||||
intrinsics,
|
||||
unboxed_closures,
|
||||
extern_types,
|
||||
decl_macro,
|
||||
rustc_attrs,
|
||||
transparent_unions,
|
||||
auto_traits,
|
||||
thread_local
|
||||
)]
|
||||
#![no_core]
|
||||
#![allow(dead_code)]
|
||||
@ -55,6 +62,7 @@ unsafe impl Copy for i16 {}
|
||||
unsafe impl Copy for i32 {}
|
||||
unsafe impl Copy for isize {}
|
||||
unsafe impl Copy for f32 {}
|
||||
unsafe impl Copy for f64 {}
|
||||
unsafe impl Copy for char {}
|
||||
unsafe impl<'a, T: ?Sized> Copy for &'a T {}
|
||||
unsafe impl<T: ?Sized> Copy for *const T {}
|
||||
@ -483,8 +491,17 @@ pub trait Deref {
|
||||
fn deref(&self) -> &Self::Target;
|
||||
}
|
||||
|
||||
pub struct Unique<T: ?Sized> {
|
||||
pub pointer: *const T,
|
||||
pub _marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
|
||||
|
||||
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
|
||||
|
||||
#[lang = "owned_box"]
|
||||
pub struct Box<T: ?Sized>(*mut T);
|
||||
pub struct Box<T: ?Sized>(Unique<T>, ());
|
||||
|
||||
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
|
||||
|
||||
@ -508,8 +525,8 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
|
||||
}
|
||||
|
||||
#[lang = "box_free"]
|
||||
unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
|
||||
libc::free(ptr as *mut u8);
|
||||
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, alloc: ()) {
|
||||
libc::free(ptr.pointer as *mut u8);
|
||||
}
|
||||
|
||||
#[lang = "drop"]
|
||||
|
@ -7,10 +7,6 @@ extern crate mini_core;
|
||||
use mini_core::*;
|
||||
use mini_core::libc::*;
|
||||
|
||||
unsafe extern "C" fn my_puts(s: *const i8) {
|
||||
puts(s);
|
||||
}
|
||||
|
||||
macro_rules! assert {
|
||||
($e:expr) => {
|
||||
if !$e {
|
||||
@ -105,12 +101,6 @@ fn start<T: Termination + 'static>(
|
||||
static mut NUM: u8 = 6 * 7;
|
||||
static NUM_REF: &'static u8 = unsafe { &NUM };
|
||||
|
||||
struct Unique<T: ?Sized> {
|
||||
pointer: *const T,
|
||||
_marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
|
||||
|
||||
unsafe fn zeroed<T>() -> T {
|
||||
let mut uninit = MaybeUninit { uninit: () };
|
||||
|
@ -1,48 +0,0 @@
|
||||
From 1d574bf5e32d51641dcacaf8ef777e95b44f6f2a Mon Sep 17 00:00:00 2001
|
||||
From: bjorn3 <bjorn3@users.noreply.github.com>
|
||||
Date: Thu, 18 Feb 2021 18:30:55 +0100
|
||||
Subject: [PATCH] Disable 128bit atomic operations
|
||||
|
||||
Cranelift doesn't support them yet
|
||||
---
|
||||
src/mem/mod.rs | 12 ------------
|
||||
1 file changed, 12 deletions(-)
|
||||
|
||||
diff --git a/src/mem/mod.rs b/src/mem/mod.rs
|
||||
index 107762c..2d1ae10 100644
|
||||
--- a/src/mem/mod.rs
|
||||
+++ b/src/mem/mod.rs
|
||||
@@ -137,10 +137,6 @@ intrinsics! {
|
||||
pub unsafe extern "C" fn __llvm_memcpy_element_unordered_atomic_8(dest: *mut u64, src: *const u64, bytes: usize) -> () {
|
||||
memcpy_element_unordered_atomic(dest, src, bytes);
|
||||
}
|
||||
- #[cfg(target_has_atomic_load_store = "128")]
|
||||
- pub unsafe extern "C" fn __llvm_memcpy_element_unordered_atomic_16(dest: *mut u128, src: *const u128, bytes: usize) -> () {
|
||||
- memcpy_element_unordered_atomic(dest, src, bytes);
|
||||
- }
|
||||
|
||||
#[cfg(target_has_atomic_load_store = "8")]
|
||||
pub unsafe extern "C" fn __llvm_memmove_element_unordered_atomic_1(dest: *mut u8, src: *const u8, bytes: usize) -> () {
|
||||
@@ -158,10 +154,6 @@ intrinsics! {
|
||||
pub unsafe extern "C" fn __llvm_memmove_element_unordered_atomic_8(dest: *mut u64, src: *const u64, bytes: usize) -> () {
|
||||
memmove_element_unordered_atomic(dest, src, bytes);
|
||||
}
|
||||
- #[cfg(target_has_atomic_load_store = "128")]
|
||||
- pub unsafe extern "C" fn __llvm_memmove_element_unordered_atomic_16(dest: *mut u128, src: *const u128, bytes: usize) -> () {
|
||||
- memmove_element_unordered_atomic(dest, src, bytes);
|
||||
- }
|
||||
|
||||
#[cfg(target_has_atomic_load_store = "8")]
|
||||
pub unsafe extern "C" fn __llvm_memset_element_unordered_atomic_1(s: *mut u8, c: u8, bytes: usize) -> () {
|
||||
@@ -179,8 +171,4 @@ intrinsics! {
|
||||
pub unsafe extern "C" fn __llvm_memset_element_unordered_atomic_8(s: *mut u64, c: u8, bytes: usize) -> () {
|
||||
memset_element_unordered_atomic(s, c, bytes);
|
||||
}
|
||||
- #[cfg(target_has_atomic_load_store = "128")]
|
||||
- pub unsafe extern "C" fn __llvm_memset_element_unordered_atomic_16(s: *mut u128, c: u8, bytes: usize) -> () {
|
||||
- memset_element_unordered_atomic(s, c, bytes);
|
||||
- }
|
||||
}
|
||||
--
|
||||
2.26.2.7.g19db9cfb68
|
||||
|
@ -1,23 +0,0 @@
|
||||
From 9c5663e36391fa20becf84f3af2e82afa5bb720b Mon Sep 17 00:00:00 2001
|
||||
From: bjorn3 <bjorn3@users.noreply.github.com>
|
||||
Date: Sat, 15 Aug 2020 19:56:03 +0200
|
||||
Subject: [PATCH] [rand] Enable c2-chacha simd feature
|
||||
|
||||
---
|
||||
rand_chacha/Cargo.toml | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/rand_chacha/Cargo.toml b/rand_chacha/Cargo.toml
|
||||
index 9190b7f..872cca2 100644
|
||||
--- a/rand_chacha/Cargo.toml
|
||||
+++ b/rand_chacha/Cargo.toml
|
||||
@@ -24,5 +24,5 @@ ppv-lite86 = { version = "0.2.8", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
-std = ["ppv-lite86/std"]
|
||||
+std = ["ppv-lite86/std", "ppv-lite86/simd"]
|
||||
simd = [] # deprecated
|
||||
--
|
||||
2.20.1
|
||||
|
@ -4,27 +4,18 @@ Date: Sat, 15 Aug 2020 20:04:38 +0200
|
||||
Subject: [PATCH] [rand] Disable failing test
|
||||
|
||||
---
|
||||
src/distributions/uniform.rs | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
src/distributions/uniform.rs | 1 +
|
||||
1 file changed, 1 insertion(+), 0 deletions(-)
|
||||
|
||||
diff --git a/src/distributions/uniform.rs b/src/distributions/uniform.rs
|
||||
index 480b859..c80bb6f 100644
|
||||
--- a/src/distributions/uniform.rs
|
||||
+++ b/src/distributions/uniform.rs
|
||||
@@ -1085,7 +1085,7 @@ mod tests {
|
||||
_ => panic!("`UniformDurationMode` was not serialized/deserialized correctly")
|
||||
}
|
||||
}
|
||||
-
|
||||
+
|
||||
#[test]
|
||||
#[cfg(feature = "serde1")]
|
||||
fn test_uniform_serialization() {
|
||||
@@ -1314,6 +1314,7 @@ mod tests {
|
||||
not(target_arch = "wasm32"),
|
||||
not(target_arch = "asmjs")
|
||||
))]
|
||||
+ #[ignore] // FIXME
|
||||
+ #[ignore] // Requires unwinding
|
||||
fn test_float_assertions() {
|
||||
use super::SampleUniform;
|
||||
use std::panic::catch_unwind;
|
||||
|
@ -18,7 +18,7 @@ new file mode 100644
|
||||
index 0000000..46fd999
|
||||
--- /dev/null
|
||||
+++ b/library/core/tests/Cargo.toml
|
||||
@@ -0,0 +1,8 @@
|
||||
@@ -0,0 +1,11 @@
|
||||
+[package]
|
||||
+name = "core"
|
||||
+version = "0.0.0"
|
||||
@ -27,18 +27,9 @@ index 0000000..46fd999
|
||||
+[lib]
|
||||
+name = "coretests"
|
||||
+path = "lib.rs"
|
||||
diff --git a/library/core/tests/num/flt2dec/mod.rs b/library/core/tests/num/flt2dec/mod.rs
|
||||
index a35897e..f0bf645 100644
|
||||
--- a/library/core/tests/num/flt2dec/mod.rs
|
||||
+++ b/library/core/tests/num/flt2dec/mod.rs
|
||||
@@ -13,7 +13,6 @@ mod strategy {
|
||||
mod dragon;
|
||||
mod grisu;
|
||||
}
|
||||
-mod random;
|
||||
|
||||
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
|
||||
match decode(v).1 {
|
||||
+
|
||||
+[dependencies]
|
||||
+rand = "0.7"
|
||||
diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs
|
||||
index 1a6be3a..42dbd59 100644
|
||||
--- a/library/core/tests/ptr.rs
|
||||
@ -59,25 +50,5 @@ index 1a6be3a..42dbd59 100644
|
||||
|
||||
#[test]
|
||||
fn write_unaligned_drop() {
|
||||
diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs
|
||||
index 6609bc3..241b497 100644
|
||||
--- a/library/core/tests/slice.rs
|
||||
+++ b/library/core/tests/slice.rs
|
||||
@@ -1209,6 +1209,7 @@ fn brute_force_rotate_test_1() {
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
#[test]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn sort_unstable() {
|
||||
@@ -1394,6 +1395,7 @@ fn partition_at_index() {
|
||||
v.select_nth_unstable(0);
|
||||
assert!(v == [0xDEADBEEF]);
|
||||
}
|
||||
+*/
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "index 0 greater than length of slice")]
|
||||
--
|
||||
2.21.0 (Apple Git-122)
|
||||
|
@ -1,30 +1,48 @@
|
||||
From 0ffdd8eda8df364391c8ac6e1ce92c73ba9254d4 Mon Sep 17 00:00:00 2001
|
||||
From eb703e627e7a84f1cd8d0d87f0f69da1f0acf765 Mon Sep 17 00:00:00 2001
|
||||
From: bjorn3 <bjorn3@users.noreply.github.com>
|
||||
Date: Fri, 3 Dec 2021 12:16:30 +0100
|
||||
Subject: [PATCH] Disable long running tests
|
||||
|
||||
---
|
||||
library/core/tests/slice.rs | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
library/core/tests/slice.rs | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs
|
||||
index 2c8f00a..44847ee 100644
|
||||
index 8402833..84592e0 100644
|
||||
--- a/library/core/tests/slice.rs
|
||||
+++ b/library/core/tests/slice.rs
|
||||
@@ -2332,7 +2332,8 @@ macro_rules! empty_max_mut {
|
||||
};
|
||||
@@ -1809,6 +1809,7 @@ fn sort_unstable() {
|
||||
assert!(v == [0xDEADBEEF]);
|
||||
}
|
||||
|
||||
+/*
|
||||
#[cfg(not(miri))] // Comparing usize::MAX many elements takes forever in Miri (and in rustc without optimizations)
|
||||
take_tests! {
|
||||
slice: &[(); usize::MAX], method: take,
|
||||
(take_in_bounds_max_range_to, (..usize::MAX), Some(EMPTY_MAX), &[(); 0]),
|
||||
@@ -2345,3 +2347,4 @@ take_tests! {
|
||||
#[test]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg_attr(miri, ignore)] // Miri is too slow
|
||||
@@ -1914,6 +1915,7 @@ fn select_nth_unstable() {
|
||||
v.select_nth_unstable(0);
|
||||
assert!(v == [0xDEADBEEF]);
|
||||
}
|
||||
+*/
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "index 0 greater than length of slice")]
|
||||
@@ -2462,6 +2462,7 @@ take_tests! {
|
||||
#[cfg(not(miri))] // unused in Miri
|
||||
const EMPTY_MAX: &'static [()] = &[(); usize::MAX];
|
||||
|
||||
+/*
|
||||
// can't be a constant due to const mutability rules
|
||||
#[cfg(not(miri))] // unused in Miri
|
||||
macro_rules! empty_max_mut {
|
||||
@@ -2485,6 +2486,7 @@ take_tests! {
|
||||
(take_mut_oob_max_range_to_inclusive, (..=usize::MAX), None, empty_max_mut!()),
|
||||
(take_mut_in_bounds_max_range_from, (usize::MAX..), Some(&mut [] as _), empty_max_mut!()),
|
||||
}
|
||||
+*/
|
||||
|
||||
#[test]
|
||||
fn test_slice_from_ptr_range() {
|
||||
--
|
||||
2.26.2.7.g19db9cfb68
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2022-02-23"
|
||||
channel = "nightly-2022-03-19"
|
||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
||||
|
@ -12,18 +12,6 @@ git checkout -- .
|
||||
git checkout "$(rustc -V | cut -d' ' -f3 | tr -d '(')"
|
||||
|
||||
git apply - <<EOF
|
||||
diff --git a/Cargo.toml b/Cargo.toml
|
||||
index 5bd1147cad5..10d68a2ff14 100644
|
||||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -111,5 +111,7 @@ rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' }
|
||||
rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' }
|
||||
rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' }
|
||||
|
||||
+compiler_builtins = { path = "../build_sysroot/compiler-builtins" }
|
||||
+
|
||||
[patch."https://github.com/rust-lang/rust-clippy"]
|
||||
clippy_lints = { path = "src/tools/clippy/clippy_lints" }
|
||||
diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml
|
||||
index d95b5b7f17f..00b6f0e3635 100644
|
||||
--- a/library/alloc/Cargo.toml
|
||||
@ -38,9 +26,43 @@ index d95b5b7f17f..00b6f0e3635 100644
|
||||
[dev-dependencies]
|
||||
rand = "0.7"
|
||||
rand_xorshift = "0.2"
|
||||
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
|
||||
index 887d27fd6dca4..2c2239f2b83d1 100644
|
||||
--- a/src/tools/compiletest/src/header.rs
|
||||
+++ b/src/tools/compiletest/src/header.rs
|
||||
@@ -806,8 +806,8 @@ pub fn make_test_description<R: Read>(
|
||||
cfg: Option<&str>,
|
||||
) -> test::TestDesc {
|
||||
let mut ignore = false;
|
||||
#[cfg(not(bootstrap))]
|
||||
- let ignore_message: Option<String> = None;
|
||||
+ let ignore_message: Option<&str> = None;
|
||||
let mut should_fail = false;
|
||||
|
||||
let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some();
|
||||
|
||||
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
|
||||
index 8431aa7b818..a3ff7e68ce5 100644
|
||||
--- a/src/tools/compiletest/src/runtest.rs
|
||||
+++ b/src/tools/compiletest/src/runtest.rs
|
||||
@@ -3489,11 +3489,7 @@ fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> S
|
||||
.join("library");
|
||||
normalize_path(&src_dir, "$(echo '$SRC_DIR')");
|
||||
|
||||
- if let Some(virtual_rust_source_base_dir) =
|
||||
- option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").map(PathBuf::from)
|
||||
- {
|
||||
- normalize_path(&virtual_rust_source_base_dir.join("library"), "$(echo '$SRC_DIR')");
|
||||
- }
|
||||
+ normalize_path(&Path::new("$(cd ../build_sysroot/sysroot_src/library; pwd)"), "$(echo '$SRC_DIR')");
|
||||
|
||||
// Paths into the build directory
|
||||
let test_build_dir = &self.config.build_base;
|
||||
EOF
|
||||
|
||||
cat > config.toml <<EOF
|
||||
changelog-seen = 2
|
||||
|
||||
[llvm]
|
||||
ninja = false
|
||||
|
||||
|
@ -10,99 +10,111 @@ pushd rust
|
||||
|
||||
command -v rg >/dev/null 2>&1 || cargo install ripgrep
|
||||
|
||||
rm -r src/test/ui/{extern/,panics/,unsized-locals/,lto/,simd*,linkage*,unwind-*.rs} || true
|
||||
for test in $(rg --files-with-matches "asm!|catch_unwind|should_panic|lto|// needs-asm-support" src/test/ui); do
|
||||
rm -r src/test/ui/{extern/,unsized-locals/,lto/,linkage*} || true
|
||||
for test in $(rg --files-with-matches "asm!|lto|// needs-asm-support|// needs-unwind" src/test/{ui,incremental}); do
|
||||
rm $test
|
||||
done
|
||||
|
||||
for test in $(rg -i --files-with-matches "//(\[\w+\])?~|// error-pattern:|// build-fail|// run-fail|-Cllvm-args" src/test/ui); do
|
||||
for test in $(rg -i --files-with-matches "//(\[\w+\])?~[^\|]*\s*ERR|// error-pattern:|// build-fail|// run-fail|-Cllvm-args" src/test/ui); do
|
||||
rm $test
|
||||
done
|
||||
|
||||
git checkout -- src/test/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed
|
||||
|
||||
# these all depend on unwinding support
|
||||
rm src/test/ui/backtrace.rs
|
||||
rm src/test/ui/array-slice-vec/box-of-array-of-drop-*.rs
|
||||
rm src/test/ui/array-slice-vec/slice-panic-*.rs
|
||||
rm src/test/ui/array-slice-vec/nested-vec-3.rs
|
||||
rm src/test/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs
|
||||
rm src/test/ui/issues/issue-26655.rs
|
||||
rm src/test/ui/issues/issue-29485.rs
|
||||
rm src/test/ui/issues/issue-30018-panic.rs
|
||||
rm src/test/ui/process/multi-panic.rs
|
||||
rm src/test/ui/sepcomp/sepcomp-unwind.rs
|
||||
rm src/test/ui/structs-enums/unit-like-struct-drop-run.rs
|
||||
rm src/test/ui/drop/terminate-in-initializer.rs
|
||||
rm src/test/ui/threads-sendsync/task-stderr.rs
|
||||
rm src/test/ui/numbers-arithmetic/int-abs-overflow.rs
|
||||
rm src/test/ui/drop/drop-trait-enum.rs
|
||||
rm src/test/ui/numbers-arithmetic/issue-8460.rs
|
||||
rm src/test/ui/runtime/rt-explody-panic-payloads.rs
|
||||
rm src/test/incremental/change_crate_dep_kind.rs
|
||||
rm src/test/ui/threads-sendsync/unwind-resource.rs
|
||||
# missing features
|
||||
# ================
|
||||
|
||||
rm src/test/ui/issues/issue-28950.rs # depends on stack size optimizations
|
||||
rm src/test/ui/codegen/init-large-type.rs # same
|
||||
rm src/test/ui/sse2.rs # cpuid not supported, so sse2 not detected
|
||||
rm src/test/ui/issues/issue-33992.rs # unsupported linkages
|
||||
rm src/test/ui/issues/issue-51947.rs # same
|
||||
rm src/test/incremental/hashes/function_interfaces.rs # same
|
||||
rm src/test/incremental/hashes/statics.rs # same
|
||||
rm src/test/ui/numbers-arithmetic/saturating-float-casts.rs # intrinsic gives different but valid result
|
||||
rm src/test/ui/mir/mir_misc_casts.rs # depends on deduplication of constants
|
||||
rm src/test/ui/mir/mir_raw_fat_ptr.rs # same
|
||||
rm src/test/ui/consts/issue-33537.rs # same
|
||||
# requires stack unwinding
|
||||
rm src/test/ui/backtrace.rs
|
||||
rm src/test/ui/process/multi-panic.rs
|
||||
rm src/test/ui/numbers-arithmetic/issue-8460.rs
|
||||
rm src/test/incremental/change_crate_dep_kind.rs
|
||||
rm src/test/incremental/issue-80691-bad-eval-cache.rs # -Cpanic=abort causes abort instead of exit(101)
|
||||
rm src/test/ui/panic-while-printing.rs
|
||||
rm src/test/ui/test-attrs/test-panic-while-printing.rs
|
||||
rm src/test/ui/test-attrs/test-type.rs
|
||||
|
||||
# requires compiling with -Cpanic=unwind
|
||||
rm src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs # "Cannot run dynamic test fn out-of-process"
|
||||
rm src/test/ui/async-await/async-fn-size-moved-locals.rs # -Cpanic=abort shrinks some generator by one byte
|
||||
rm src/test/ui/async-await/async-fn-size-uninit-locals.rs # same
|
||||
rm src/test/ui/generator/size-moved-locals.rs # same
|
||||
rm src/test/ui/fn/dyn-fn-alignment.rs # wants a 256 byte alignment
|
||||
rm src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs # "Cannot run dynamic test fn out-of-process"
|
||||
|
||||
# vendor intrinsics
|
||||
rm src/test/ui/sse2.rs # cpuid not supported, so sse2 not detected
|
||||
rm src/test/ui/intrinsics/const-eval-select-x86_64.rs # requires x86_64 vendor intrinsics
|
||||
rm src/test/ui/simd/array-type.rs # "Index argument for `simd_insert` is not a constant"
|
||||
rm src/test/ui/simd/intrinsic/generic-bitmask-pass.rs # simd_bitmask unimplemented
|
||||
rm src/test/ui/simd/intrinsic/generic-as.rs # simd_as unimplemented
|
||||
rm src/test/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs # simd_saturating_add unimplemented
|
||||
rm src/test/ui/simd/intrinsic/float-math-pass.rs # simd_fcos unimplemented
|
||||
rm src/test/ui/simd/intrinsic/generic-gather-pass.rs # simd_gather unimplemented
|
||||
rm src/test/ui/simd/intrinsic/generic-select-pass.rs # simd_select_bitmask unimplemented
|
||||
rm src/test/ui/simd/issue-85915-simd-ptrs.rs # simd_gather unimplemented
|
||||
rm src/test/ui/simd/issue-89193.rs # simd_gather unimplemented
|
||||
rm src/test/ui/simd/simd-bitmask.rs # simd_bitmask unimplemented
|
||||
|
||||
# exotic linkages
|
||||
rm src/test/ui/issues/issue-33992.rs # unsupported linkages
|
||||
rm src/test/incremental/hashes/function_interfaces.rs # same
|
||||
rm src/test/incremental/hashes/statics.rs # same
|
||||
|
||||
# variadic arguments
|
||||
rm src/test/ui/abi/mir/mir_codegen_calls_variadic.rs # requires float varargs
|
||||
rm src/test/ui/abi/variadic-ffi.rs # requires callee side vararg support
|
||||
|
||||
# unsized locals
|
||||
rm -r src/test/run-pass-valgrind/unsized-locals
|
||||
|
||||
# misc unimplemented things
|
||||
rm src/test/ui/intrinsics/intrinsic-nearby.rs # unimplemented nearbyintf32 and nearbyintf64 intrinsics
|
||||
rm src/test/ui/target-feature/missing-plusminus.rs # error not implemented
|
||||
rm src/test/ui/fn/dyn-fn-alignment.rs # wants a 256 byte alignment
|
||||
rm -r src/test/run-make/emit-named-files # requires full --emit support
|
||||
|
||||
rm src/test/incremental/hashes/inline_asm.rs # inline asm
|
||||
rm src/test/incremental/issue-72386.rs # same
|
||||
rm src/test/incremental/lto.rs # requires lto
|
||||
rm src/test/incremental/dirty_clean.rs # TODO
|
||||
# optimization tests
|
||||
# ==================
|
||||
rm src/test/ui/issues/issue-28950.rs # depends on stack size optimizations
|
||||
rm src/test/ui/codegen/init-large-type.rs # same
|
||||
rm -r src/test/run-make/fmt-write-bloat/ # tests an optimization
|
||||
|
||||
# backend specific tests
|
||||
# ======================
|
||||
rm src/test/incremental/thinlto/cgu_invalidated_when_import_{added,removed}.rs # requires LLVM
|
||||
rm src/test/ui/abi/stack-protector.rs # requires stack protector support
|
||||
|
||||
# giving different but possibly correct results
|
||||
# =============================================
|
||||
rm src/test/ui/numbers-arithmetic/saturating-float-casts.rs # intrinsic gives different but valid result
|
||||
rm src/test/ui/simd/intrinsic/float-minmax-pass.rs # same
|
||||
rm src/test/ui/mir/mir_misc_casts.rs # depends on deduplication of constants
|
||||
rm src/test/ui/mir/mir_raw_fat_ptr.rs # same
|
||||
rm src/test/ui/consts/issue-33537.rs # same
|
||||
|
||||
# doesn't work due to the way the rustc test suite is invoked.
|
||||
# should work when using ./x.py test the way it is intended
|
||||
# ============================================================
|
||||
rm -r src/test/run-make/emit-shared-files # requires the rustdoc executable in build/bin/
|
||||
rm -r src/test/run-make/unstable-flag-required # same
|
||||
rm -r src/test/run-make/rustdoc-* # same
|
||||
rm -r src/test/run-make/emit-named-files # requires full --emit support
|
||||
|
||||
rm -r src/test/run-pass-valgrind/unsized-locals
|
||||
|
||||
rm src/test/ui/json-bom-plus-crlf-multifile.rs # differing warning
|
||||
rm src/test/ui/json-bom-plus-crlf.rs # same
|
||||
rm src/test/ui/intrinsics/const-eval-select-x86_64.rs # same
|
||||
rm src/test/ui/match/issue-82392.rs # differing error
|
||||
rm src/test/ui/consts/min_const_fn/address_of_const.rs # same
|
||||
rm src/test/ui/consts/issue-miri-1910.rs # same
|
||||
rm src/test/ui/generic-associated-types/bugs/issue-80626.rs # same
|
||||
rm src/test/ui/generic-associated-types/bugs/issue-89008.rs # same
|
||||
rm src/test/ui/type-alias-impl-trait/cross_crate_ice*.rs # requires removed aux dep
|
||||
|
||||
# genuine bugs
|
||||
# ============
|
||||
rm src/test/ui/allocator/no_std-alloc-error-handler-default.rs # missing rust_oom definition
|
||||
rm src/test/ui/cfg/cfg-panic.rs
|
||||
rm -r src/test/ui/hygiene/
|
||||
|
||||
rm -r src/test/ui/polymorphization/ # polymorphization not yet supported
|
||||
rm src/test/codegen-units/polymorphization/unused_type_parameters.rs # same
|
||||
|
||||
rm -r src/test/run-make/fmt-write-bloat/ # tests an optimization
|
||||
rm src/test/ui/abi/mir/mir_codegen_calls_variadic.rs # requires float varargs
|
||||
rm src/test/ui/abi/variadic-ffi.rs # requires callee side vararg support
|
||||
|
||||
rm src/test/ui/command/command-current-dir.rs # can't find libstd.so
|
||||
|
||||
rm src/test/ui/abi/stack-protector.rs # requires stack protector support
|
||||
|
||||
rm src/test/incremental/issue-80691-bad-eval-cache.rs # wrong exit code
|
||||
rm src/test/incremental/spike-neg1.rs # errors out for some reason
|
||||
rm src/test/incremental/spike-neg2.rs # same
|
||||
rm src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs # gives a stackoverflow before the backend runs
|
||||
rm src/test/ui/mir/ssa-analysis-regression-50041.rs # produces ICE
|
||||
|
||||
rm src/test/incremental/thinlto/cgu_invalidated_when_import_{added,removed}.rs # requires LLVM
|
||||
rm src/test/ui/simd/intrinsic/generic-reduction-pass.rs # simd_reduce_add_unordered doesn't accept an accumulator for integer vectors
|
||||
|
||||
# bugs in the test suite
|
||||
# ======================
|
||||
rm src/test/ui/unsafe/union.rs # has UB caught by cg_clif. see rust-lang/rust#95075
|
||||
|
||||
echo "[TEST] rustc test suite"
|
||||
RUST_TEST_NOCAPTURE=1 COMPILETEST_FORCE_STAGE0=1 ./x.py test --stage 0 src/test/{codegen-units,run-make,run-pass-valgrind,ui,incremental}
|
||||
|
@ -57,7 +57,6 @@ function base_sysroot_tests() {
|
||||
fi
|
||||
|
||||
echo "[AOT] dst_field_align"
|
||||
# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
|
||||
$MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target "$TARGET_TRIPLE"
|
||||
$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
|
||||
|
||||
|
@ -94,6 +94,9 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
|
||||
let sig = Signature { params, returns, call_conv: self.target_config.default_call_conv };
|
||||
let func_id = self.module.declare_function(name, Linkage::Import, &sig).unwrap();
|
||||
let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func);
|
||||
if self.clif_comments.enabled() {
|
||||
self.add_comment(func_ref, format!("{:?}", name));
|
||||
}
|
||||
let call_inst = self.bcx.ins().call(func_ref, args);
|
||||
if self.clif_comments.enabled() {
|
||||
self.add_comment(call_inst, format!("easy_call {}", name));
|
||||
@ -367,7 +370,10 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
||||
.map(|inst| fx.tcx.codegen_fn_attrs(inst.def_id()).flags.contains(CodegenFnAttrFlags::COLD))
|
||||
.unwrap_or(false);
|
||||
if is_cold {
|
||||
// FIXME Mark current_block block as cold once Cranelift supports it
|
||||
fx.bcx.set_cold_block(fx.bcx.current_block().unwrap());
|
||||
if let Some((_place, destination_block)) = destination {
|
||||
fx.bcx.set_cold_block(fx.get_block(destination_block));
|
||||
}
|
||||
}
|
||||
|
||||
// Unpack arguments tuple for closures
|
||||
@ -501,7 +507,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
||||
let ret_block = fx.get_block(dest);
|
||||
fx.bcx.ins().jump(ret_block, &[]);
|
||||
} else {
|
||||
trap_unreachable(fx, "[corruption] Diverging function returned");
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ use rustc_ast::InlineAsmOptions;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::layout::FnAbiOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
|
||||
use indexmap::IndexSet;
|
||||
|
||||
@ -25,7 +26,10 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||
let mir = tcx.instance_mir(instance.def);
|
||||
let _mir_guard = crate::PrintOnPanic(|| {
|
||||
let mut buf = Vec::new();
|
||||
rustc_middle::mir::write_mir_pretty(tcx, Some(instance.def_id()), &mut buf).unwrap();
|
||||
with_no_trimmed_paths!({
|
||||
rustc_middle::mir::pretty::write_mir_fn(tcx, mir, &mut |_, _| Ok(()), &mut buf)
|
||||
.unwrap();
|
||||
});
|
||||
String::from_utf8_lossy(&buf).into_owned()
|
||||
});
|
||||
|
||||
@ -90,7 +94,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||
} else if arg_uninhabited {
|
||||
fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]);
|
||||
fx.bcx.switch_to_block(fx.block_map[START_BLOCK]);
|
||||
crate::trap::trap_unreachable(&mut fx, "function has uninhabited argument");
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
} else {
|
||||
tcx.sess.time("codegen clif ir", || {
|
||||
tcx.sess
|
||||
@ -258,7 +262,9 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
||||
|
||||
if fx.clif_comments.enabled() {
|
||||
let mut terminator_head = "\n".to_string();
|
||||
bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap();
|
||||
with_no_trimmed_paths!({
|
||||
bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap();
|
||||
});
|
||||
let inst = fx.bcx.func.layout.last_inst(block).unwrap();
|
||||
fx.add_comment(inst, terminator_head);
|
||||
}
|
||||
@ -303,7 +309,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
||||
|
||||
let target = fx.get_block(*target);
|
||||
let failure = fx.bcx.create_block();
|
||||
// FIXME Mark failure block as cold once Cranelift supports it
|
||||
fx.bcx.set_cold_block(failure);
|
||||
|
||||
if *expected {
|
||||
fx.bcx.ins().brz(cond, failure, &[]);
|
||||
@ -424,18 +430,16 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
||||
fx.bcx.ins().jump(destination_block, &[]);
|
||||
}
|
||||
None => {
|
||||
crate::trap::trap_unreachable(
|
||||
fx,
|
||||
"[corruption] Returned from noreturn inline asm",
|
||||
);
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
}
|
||||
}
|
||||
TerminatorKind::Resume | TerminatorKind::Abort => {
|
||||
trap_unreachable(fx, "[corruption] Unwinding bb reached.");
|
||||
// FIXME implement unwinding
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
TerminatorKind::Unreachable => {
|
||||
trap_unreachable(fx, "[corruption] Hit unreachable code.");
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
TerminatorKind::Yield { .. }
|
||||
| TerminatorKind::FalseEdge { .. }
|
||||
@ -813,7 +817,14 @@ pub(crate) fn codegen_place<'tcx>(
|
||||
for elem in place.projection {
|
||||
match elem {
|
||||
PlaceElem::Deref => {
|
||||
cplace = cplace.place_deref(fx);
|
||||
if cplace.layout().ty.is_box() {
|
||||
cplace = cplace
|
||||
.place_field(fx, Field::new(0)) // Box<T> -> Unique<T>
|
||||
.place_field(fx, Field::new(0)) // Unique<T> -> *const T
|
||||
.place_deref(fx);
|
||||
} else {
|
||||
cplace = cplace.place_deref(fx);
|
||||
}
|
||||
}
|
||||
PlaceElem::Field(field, _ty) => {
|
||||
cplace = cplace.place_field(fx, field);
|
||||
@ -918,5 +929,5 @@ pub(crate) fn codegen_panic_inner<'tcx>(
|
||||
args,
|
||||
);
|
||||
|
||||
crate::trap::trap_unreachable(fx, "panic lang item returned");
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(rustc_private, once_cell)]
|
||||
#![feature(rustc_private)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![warn(unused_lifetimes)]
|
||||
#![warn(unreachable_pub)]
|
||||
@ -9,19 +9,21 @@ extern crate rustc_interface;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_target;
|
||||
|
||||
use std::lazy::SyncLazy;
|
||||
use std::panic;
|
||||
|
||||
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
|
||||
use rustc_interface::interface;
|
||||
use rustc_session::config::ErrorOutputType;
|
||||
use rustc_session::config::{ErrorOutputType, TrimmedDefPaths};
|
||||
use rustc_session::early_error;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
// FIXME use std::lazy::SyncLazy once it stabilizes
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
const BUG_REPORT_URL: &str = "https://github.com/bjorn3/rustc_codegen_cranelift/issues/new";
|
||||
|
||||
static DEFAULT_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
|
||||
SyncLazy::new(|| {
|
||||
static DEFAULT_HOOK: Lazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
|
||||
Lazy::new(|| {
|
||||
let hook = panic::take_hook();
|
||||
panic::set_hook(Box::new(|info| {
|
||||
// Invoke the default handler, which prints the actual panic message and optionally a backtrace
|
||||
@ -53,6 +55,8 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks {
|
||||
config.opts.maybe_sysroot = Some(config.opts.maybe_sysroot.clone().unwrap_or_else(|| {
|
||||
std::env::current_exe().unwrap().parent().unwrap().parent().unwrap().to_owned()
|
||||
}));
|
||||
|
||||
config.opts.trimmed_def_paths = TrimmedDefPaths::GoodPath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +65,7 @@ fn main() {
|
||||
let start_rss = get_resident_set_size();
|
||||
rustc_driver::init_rustc_env_logger();
|
||||
let mut callbacks = CraneliftPassesCallbacks::default();
|
||||
SyncLazy::force(&DEFAULT_HOOK); // Install ice hook
|
||||
Lazy::force(&DEFAULT_HOOK); // Install ice hook
|
||||
let exit_code = rustc_driver::catch_with_exit_code(|| {
|
||||
let args = std::env::args_os()
|
||||
.enumerate()
|
||||
|
@ -1,16 +1,18 @@
|
||||
macro builtin_functions($register:ident; $(fn $name:ident($($arg_name:ident: $arg_ty:ty),*) -> $ret_ty:ty;)*) {
|
||||
#[cfg(feature = "jit")]
|
||||
#[allow(improper_ctypes)]
|
||||
extern "C" {
|
||||
$(fn $name($($arg_name: $arg_ty),*) -> $ret_ty;)*
|
||||
}
|
||||
|
||||
#[cfg(feature = "jit")]
|
||||
pub(crate) fn $register(builder: &mut cranelift_jit::JITBuilder) {
|
||||
for (name, val) in [$((stringify!($name), $name as *const u8)),*] {
|
||||
builder.symbol(name, val);
|
||||
macro_rules! builtin_functions {
|
||||
($register:ident; $(fn $name:ident($($arg_name:ident: $arg_ty:ty),*) -> $ret_ty:ty;)*) => {
|
||||
#[cfg(feature = "jit")]
|
||||
#[allow(improper_ctypes)]
|
||||
extern "C" {
|
||||
$(fn $name($($arg_name: $arg_ty),*) -> $ret_ty;)*
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "jit")]
|
||||
pub(crate) fn $register(builder: &mut cranelift_jit::JITBuilder) {
|
||||
for (name, val) in [$((stringify!($name), $name as *const u8)),*] {
|
||||
builder.symbol(name, val);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
builtin_functions! {
|
||||
|
@ -110,7 +110,6 @@ impl<'tcx> DebugContext<'tcx> {
|
||||
|
||||
entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id)));
|
||||
entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(loc.line as u64));
|
||||
// FIXME: probably omit this
|
||||
entry.set(gimli::DW_AT_decl_column, AttributeValue::Udata(loc.col.to_usize() as u64));
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,8 @@ impl UnwindContext {
|
||||
|
||||
#[cfg(all(feature = "jit", not(windows)))]
|
||||
pub(crate) unsafe fn register_jit(self, jit_module: &cranelift_jit::JITModule) {
|
||||
use std::mem::ManuallyDrop;
|
||||
|
||||
let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(self.endian));
|
||||
self.frame_table.write_eh_frame(&mut eh_frame).unwrap();
|
||||
|
||||
@ -95,17 +97,16 @@ impl UnwindContext {
|
||||
|
||||
// FIXME support unregistering unwind tables once cranelift-jit supports deallocating
|
||||
// individual functions
|
||||
#[allow(unused_variables)]
|
||||
let (eh_frame, eh_frame_len, _) = Vec::into_raw_parts(eh_frame);
|
||||
let eh_frame = ManuallyDrop::new(eh_frame);
|
||||
|
||||
// =======================================================================
|
||||
// Everything after this line up to the end of the file is loosly based on
|
||||
// Everything after this line up to the end of the file is loosely based on
|
||||
// https://github.com/bytecodealliance/wasmtime/blob/4471a82b0c540ff48960eca6757ccce5b1b5c3e4/crates/jit/src/unwind/systemv.rs
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
// On macOS, `__register_frame` takes a pointer to a single FDE
|
||||
let start = eh_frame;
|
||||
let end = start.add(eh_frame_len);
|
||||
let start = eh_frame.as_ptr();
|
||||
let end = start.add(eh_frame.len());
|
||||
let mut current = start;
|
||||
|
||||
// Walk all of the entries in the frame table and register them
|
||||
@ -124,7 +125,7 @@ impl UnwindContext {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
// On other platforms, `__register_frame` will walk the FDEs until an entry of length 0
|
||||
__register_frame(eh_frame);
|
||||
__register_frame(eh_frame.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,11 +68,10 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
|
||||
let layout = value.layout();
|
||||
|
||||
if layout.abi == Abi::Uninhabited {
|
||||
return trap_unreachable_ret_value(
|
||||
fx,
|
||||
dest_layout,
|
||||
"[panic] Tried to get discriminant for uninhabited type.",
|
||||
);
|
||||
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
||||
fx.bcx.ins().trapnz(true_, TrapCode::UnreachableCodeReached);
|
||||
// Return a dummy value
|
||||
return CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout);
|
||||
}
|
||||
|
||||
let (tag_scalar, tag_field, tag_encoding) = match &layout.variants {
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::CString;
|
||||
use std::lazy::SyncOnceCell;
|
||||
use std::os::raw::{c_char, c_int};
|
||||
use std::sync::{mpsc, Mutex};
|
||||
|
||||
@ -14,6 +13,9 @@ use rustc_span::Symbol;
|
||||
|
||||
use cranelift_jit::{JITBuilder, JITModule};
|
||||
|
||||
// FIXME use std::lazy::SyncOnceCell once it stabilizes
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
use crate::{prelude::*, BackendConfig};
|
||||
use crate::{CodegenCx, CodegenMode};
|
||||
|
||||
@ -27,8 +29,7 @@ thread_local! {
|
||||
}
|
||||
|
||||
/// The Sender owned by the rustc thread
|
||||
static GLOBAL_MESSAGE_SENDER: SyncOnceCell<Mutex<mpsc::Sender<UnsafeMessage>>> =
|
||||
SyncOnceCell::new();
|
||||
static GLOBAL_MESSAGE_SENDER: OnceCell<Mutex<mpsc::Sender<UnsafeMessage>>> = OnceCell::new();
|
||||
|
||||
/// A message that is sent from the jitted runtime to the rustc thread.
|
||||
/// Senders are responsible for upholding `Send` semantics.
|
||||
|
@ -126,12 +126,9 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
|
||||
};
|
||||
}
|
||||
|
||||
if let Some((_, dest)) = destination {
|
||||
let ret_block = fx.get_block(dest);
|
||||
fx.bcx.ins().jump(ret_block, &[]);
|
||||
} else {
|
||||
trap_unreachable(fx, "[corruption] Diverging intrinsic returned.");
|
||||
}
|
||||
let dest = destination.expect("all llvm intrinsics used by stdlib should return").1;
|
||||
let ret_block = fx.get_block(dest);
|
||||
fx.bcx.ins().jump(ret_block, &[]);
|
||||
}
|
||||
|
||||
// llvm.x86.avx2.vperm2i128
|
||||
|
@ -1,46 +1,32 @@
|
||||
//! Codegen of intrinsics. This includes `extern "rust-intrinsic"`, `extern "platform-intrinsic"`
|
||||
//! and LLVM intrinsics that have symbol names starting with `llvm.`.
|
||||
|
||||
mod cpuid;
|
||||
mod llvm;
|
||||
mod simd;
|
||||
|
||||
pub(crate) use cpuid::codegen_cpuid_call;
|
||||
pub(crate) use llvm::codegen_llvm_intrinsic_call;
|
||||
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
||||
use crate::prelude::*;
|
||||
use cranelift_codegen::ir::AtomicRmwOp;
|
||||
|
||||
macro intrinsic_pat {
|
||||
macro_rules! intrinsic_pat {
|
||||
(_) => {
|
||||
_
|
||||
},
|
||||
};
|
||||
($name:ident) => {
|
||||
sym::$name
|
||||
},
|
||||
};
|
||||
(kw.$name:ident) => {
|
||||
kw::$name
|
||||
},
|
||||
};
|
||||
($name:literal) => {
|
||||
$name
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
macro intrinsic_arg {
|
||||
(o $fx:expr, $arg:ident) => {},
|
||||
macro_rules! intrinsic_arg {
|
||||
(o $fx:expr, $arg:ident) => {};
|
||||
(c $fx:expr, $arg:ident) => {
|
||||
let $arg = codegen_operand($fx, $arg);
|
||||
},
|
||||
};
|
||||
(v $fx:expr, $arg:ident) => {
|
||||
let $arg = codegen_operand($fx, $arg).load_scalar($fx);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro intrinsic_match {
|
||||
macro_rules! intrinsic_match {
|
||||
($fx:expr, $intrinsic:expr, $args:expr,
|
||||
_ => $unknown:block;
|
||||
$(
|
||||
@ -62,6 +48,20 @@ macro intrinsic_match {
|
||||
}
|
||||
}
|
||||
|
||||
mod cpuid;
|
||||
mod llvm;
|
||||
mod simd;
|
||||
|
||||
pub(crate) use cpuid::codegen_cpuid_call;
|
||||
pub(crate) use llvm::codegen_llvm_intrinsic_call;
|
||||
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
|
||||
use crate::prelude::*;
|
||||
use cranelift_codegen::ir::AtomicRmwOp;
|
||||
|
||||
fn report_atomic_type_validation_error<'tcx>(
|
||||
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
||||
intrinsic: Symbol,
|
||||
@ -229,7 +229,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
|
||||
// Insert non returning intrinsics here
|
||||
match intrinsic {
|
||||
sym::abort => {
|
||||
trap_abort(fx, "Called intrinsic::abort.");
|
||||
fx.bcx.ins().trap(TrapCode::User(0));
|
||||
}
|
||||
sym::transmute => {
|
||||
crate::base::codegen_panic(fx, "Transmuting to uninhabited type.", span);
|
||||
@ -749,6 +749,18 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
_ if intrinsic.as_str().starts_with("atomic_load"), (v ptr) {
|
||||
let ty = substs.type_at(0);
|
||||
match ty.kind() {
|
||||
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
|
||||
// FIXME implement 128bit atomics
|
||||
if fx.tcx.is_compiler_builtins(LOCAL_CRATE) {
|
||||
// special case for compiler-builtins to avoid having to patch it
|
||||
crate::trap::trap_unimplemented(fx, "128bit atomics not yet supported");
|
||||
let ret_block = fx.get_block(destination.unwrap().1);
|
||||
fx.bcx.ins().jump(ret_block, &[]);
|
||||
return;
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(span, "128bit atomics not yet supported");
|
||||
}
|
||||
}
|
||||
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
|
||||
_ => {
|
||||
report_atomic_type_validation_error(fx, intrinsic, span, ty);
|
||||
@ -765,6 +777,18 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
_ if intrinsic.as_str().starts_with("atomic_store"), (v ptr, c val) {
|
||||
let ty = substs.type_at(0);
|
||||
match ty.kind() {
|
||||
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
|
||||
// FIXME implement 128bit atomics
|
||||
if fx.tcx.is_compiler_builtins(LOCAL_CRATE) {
|
||||
// special case for compiler-builtins to avoid having to patch it
|
||||
crate::trap::trap_unimplemented(fx, "128bit atomics not yet supported");
|
||||
let ret_block = fx.get_block(destination.unwrap().1);
|
||||
fx.bcx.ins().jump(ret_block, &[]);
|
||||
return;
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(span, "128bit atomics not yet supported");
|
||||
}
|
||||
}
|
||||
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
|
||||
_ => {
|
||||
report_atomic_type_validation_error(fx, intrinsic, span, ty);
|
||||
@ -1115,10 +1139,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
};
|
||||
}
|
||||
|
||||
if let Some((_, dest)) = destination {
|
||||
let ret_block = fx.get_block(dest);
|
||||
fx.bcx.ins().jump(ret_block, &[]);
|
||||
} else {
|
||||
trap_unreachable(fx, "[corruption] Diverging intrinsic returned.");
|
||||
}
|
||||
let ret_block = fx.get_block(destination.unwrap().1);
|
||||
fx.bcx.ins().jump(ret_block, &[]);
|
||||
}
|
||||
|
@ -409,6 +409,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
};
|
||||
|
||||
simd_reduce_add_ordered | simd_reduce_add_unordered, (c v, v acc) {
|
||||
// FIXME there must be no acc param for integer vectors
|
||||
if !v.layout().ty.is_simd() {
|
||||
report_simd_type_validation_error(fx, intrinsic, span, v.layout().ty);
|
||||
return;
|
||||
@ -424,6 +425,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
};
|
||||
|
||||
simd_reduce_mul_ordered | simd_reduce_mul_unordered, (c v, v acc) {
|
||||
// FIXME there must be no acc param for integer vectors
|
||||
if !v.layout().ty.is_simd() {
|
||||
report_simd_type_validation_error(fx, intrinsic, span, v.layout().ty);
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![feature(rustc_private, decl_macro)]
|
||||
#![cfg_attr(feature = "jit", feature(never_type, vec_into_raw_parts, once_cell))]
|
||||
#![feature(rustc_private)]
|
||||
// Note: please avoid adding other feature gates where possible
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![warn(unused_lifetimes)]
|
||||
#![warn(unreachable_pub)]
|
||||
@ -105,7 +105,6 @@ mod prelude {
|
||||
pub(crate) use crate::common::*;
|
||||
pub(crate) use crate::debuginfo::{DebugContext, UnwindContext};
|
||||
pub(crate) use crate::pointer::Pointer;
|
||||
pub(crate) use crate::trap::*;
|
||||
pub(crate) use crate::value_and_place::{CPlace, CPlaceInner, CValue};
|
||||
}
|
||||
|
||||
@ -196,7 +195,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
CodegenMode::Aot => driver::aot::run_aot(tcx, config, metadata, need_metadata_module),
|
||||
CodegenMode::Jit | CodegenMode::JitLazy => {
|
||||
#[cfg(feature = "jit")]
|
||||
let _: ! = driver::jit::run_jit(tcx, config);
|
||||
driver::jit::run_jit(tcx, config);
|
||||
|
||||
#[cfg(not(feature = "jit"))]
|
||||
tcx.sess.fatal("jit support was disabled when compiling rustc_codegen_cranelift");
|
||||
@ -301,7 +300,10 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::Tar
|
||||
}
|
||||
};
|
||||
|
||||
isa_builder.finish(flags)
|
||||
match isa_builder.finish(flags) {
|
||||
Ok(target_isa) => target_isa,
|
||||
Err(err) => sess.fatal(&format!("failed to build TargetIsa: {}", err)),
|
||||
}
|
||||
}
|
||||
|
||||
/// This is the entrypoint for a hot plugged rustc_codegen_cranelift
|
||||
|
@ -25,12 +25,6 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, '_>, msg: &str) {
|
||||
fx.bcx.ins().call(puts, &[msg_ptr]);
|
||||
}
|
||||
|
||||
/// Trap code: user1
|
||||
pub(crate) fn trap_abort(fx: &mut FunctionCx<'_, '_, '_>, msg: impl AsRef<str>) {
|
||||
codegen_print(fx, msg.as_ref());
|
||||
fx.bcx.ins().trap(TrapCode::User(1));
|
||||
}
|
||||
|
||||
/// Use this for example when a function call should never return. This will fill the current block,
|
||||
/// so you can **not** add instructions to it afterwards.
|
||||
///
|
||||
@ -39,21 +33,6 @@ pub(crate) fn trap_unreachable(fx: &mut FunctionCx<'_, '_, '_>, msg: impl AsRef<
|
||||
codegen_print(fx, msg.as_ref());
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
|
||||
/// Like `trap_unreachable` but returns a fake value of the specified type.
|
||||
///
|
||||
/// Trap code: user65535
|
||||
pub(crate) fn trap_unreachable_ret_value<'tcx>(
|
||||
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
||||
dest_layout: TyAndLayout<'tcx>,
|
||||
msg: impl AsRef<str>,
|
||||
) -> CValue<'tcx> {
|
||||
codegen_print(fx, msg.as_ref());
|
||||
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
||||
fx.bcx.ins().trapnz(true_, TrapCode::UnreachableCodeReached);
|
||||
CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout)
|
||||
}
|
||||
|
||||
/// Use this when something is unimplemented, but `libcore` or `libstd` requires it to codegen.
|
||||
/// Unlike `trap_unreachable` this will not fill the current block, so you **must** add instructions
|
||||
/// to it afterwards.
|
||||
|
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
#![allow()] /*This line is ignored by bash
|
||||
#![deny(unsafe_code)] /*This line is ignored by bash
|
||||
# This block is ignored by rustc
|
||||
set -e
|
||||
echo "[BUILD] y.rs" 1>&2
|
||||
rustc $0 -o ${0/.rs/.bin} -g
|
||||
rustc $0 -o ${0/.rs/.bin} -Cdebuginfo=1
|
||||
exec ${0/.rs/.bin} $@
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user