Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ pub use crate::external_deps::rustdoc::{Rustdoc, bare_rustdoc, rustdoc};
// Path-related helpers.
pub use crate::path_helpers::{
build_root, cwd, filename_contains, filename_not_in_denylist, has_extension, has_prefix,
has_suffix, not_contains, path, shallow_find_directories, shallow_find_files, source_root,
has_suffix, minicore_path, not_contains, path, shallow_find_directories, shallow_find_files,
source_root,
};
// Convenience helpers for running binaries and other commands.
pub use crate::run::{cmd, run, run_fail, run_with_args};
Expand Down
6 changes: 6 additions & 0 deletions src/tools/run-make-support/src/path_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ pub fn build_root() -> PathBuf {
env_var("BUILD_ROOT").into()
}

/// Path to minicore.
#[must_use]
pub fn minicore_path() -> PathBuf {
source_root().join("tests/auxiliary/minicore.rs")
}

/// Browse the directory `path` non-recursively and return all files which respect the parameters
/// outlined by `closure`.
#[track_caller]
Expand Down
11 changes: 11 additions & 0 deletions tests/auxiliary/minicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ pub mod mem {
pub const fn align_of<T>() -> usize;
}

pub mod ptr {
#[inline]
#[rustc_diagnostic_item = "ptr_write_volatile"]
pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
#[rustc_intrinsic]
pub unsafe fn volatile_store<T>(dst: *mut T, val: T);

unsafe { volatile_store(dst, src) };
}
}

#[lang = "c_void"]
#[repr(u8)]
pub enum c_void {
Expand Down
32 changes: 2 additions & 30 deletions tests/run-make/avr-rjmp-offset/avr-rjmp-offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#![no_main]
#![allow(internal_features)]

use minicore::ptr;
extern crate minicore;
use minicore::*;

#[no_mangle]
pub fn main() -> ! {
Expand All @@ -21,32 +22,3 @@ pub fn main() -> ! {
unsafe { ptr::write_volatile(port_b, 2) };
}
}

// FIXME: replace with proper minicore once available (#130693)
mod minicore {
#[lang = "pointee_sized"]
pub trait PointeeSized {}

#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}

#[lang = "sized"]
pub trait Sized: MetaSized {}

#[lang = "copy"]
pub trait Copy {}
impl Copy for u32 {}
impl Copy for &u32 {}
impl<T: PointeeSized> Copy for *mut T {}

pub mod ptr {
#[inline]
#[rustc_diagnostic_item = "ptr_write_volatile"]
pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
#[rustc_intrinsic]
pub unsafe fn volatile_store<T>(dst: *mut T, val: T);

unsafe { volatile_store(dst, src) };
}
}
}
12 changes: 11 additions & 1 deletion tests/run-make/avr-rjmp-offset/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@
// crashes... so I'm going to disable this test for windows for now.
//@ ignore-windows-gnu

use run_make_support::{llvm_objdump, rustc};
use run_make_support::{llvm_objdump, minicore_path, path, rustc};

fn main() {
rustc()
.input(minicore_path())
.crate_name("minicore")
.crate_type("rlib")
.target("avr-none")
.target_cpu("avr")
.output("libminicore.rlib")
.run();

rustc()
.input("avr-rjmp-offsets.rs")
.opt_level("s")
Expand All @@ -36,6 +45,7 @@ fn main() {
.linker("rust-lld")
.link_arg("--entry=main")
.output("compiled")
.extern_("minicore", path("libminicore.rlib"))
.run();

let disassembly = llvm_objdump().disassemble().input("compiled").run().stdout_utf8();
Expand Down
10 changes: 5 additions & 5 deletions tests/run-make/thumb-interworking/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//@ needs-llvm-components: arm
//@ needs-rust-lld
use run_make_support::{llvm_filecheck, llvm_objdump, path, rfs, run, rustc, source_root};
use run_make_support::{
llvm_filecheck, llvm_objdump, minicore_path, path, rfs, run, rustc, source_root,
};

// Test a thumb target calling arm functions. Doing so requires switching from thumb mode to arm
// mode, calling the arm code, then switching back to thumb mode. Depending on the thumb version,
Expand All @@ -26,20 +28,18 @@ fn main() {

fn helper(prefix: &str, target: &str) {
rustc()
.input(source_root().join("tests/auxiliary/minicore.rs"))
.input(minicore_path())
.crate_name("minicore")
.crate_type("rlib")
.target(target)
.output("libminicore.rlib")
.run();
let minicore = path("libminicore.rlib");

rustc()
.input("main.rs")
.panic("abort")
.link_arg("-Tlink.ld")
.arg("--extern")
.arg(format!("minicore={}", minicore.display()))
.extern_("minicore", path("libminicore.rlib"))
.target(target)
.output(prefix)
.run();
Expand Down
21 changes: 3 additions & 18 deletions tests/run-make/wasm-unexpected-features/foo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#![needs_allocator]
#![allow(internal_features)]

extern crate minicore;
use minicore::*;

#[rustc_std_internal_symbol]
unsafe fn __rust_alloc(_size: usize, _align: usize) -> *mut u8 {
0 as *mut u8
Expand All @@ -23,21 +26,3 @@ extern "C" fn init() {
__rust_alloc_error_handler(0, 0);
}
}

mod minicore {
#[lang = "pointee_sized"]
pub trait PointeeSized {}

#[lang = "meta_sized"]
pub trait MetaSized: PointeeSized {}

#[lang = "sized"]
pub trait Sized: MetaSized {}

#[lang = "copy"]
pub trait Copy {}
impl Copy for u8 {}

#[lang = "drop_in_place"]
fn drop_in_place<T>(_: *mut T) {}
}
15 changes: 12 additions & 3 deletions tests/run-make/wasm-unexpected-features/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
//@ only-wasm32-wasip1

//@ needs-rust-lld
use std::path::Path;

use run_make_support::{rfs, rustc, wasmparser};
use run_make_support::{minicore_path, path, rfs, rustc, wasmparser};

fn main() {
rustc()
.input(minicore_path())
.crate_name("minicore")
.crate_type("rlib")
.target("wasm32-wasip1")
.target_cpu("mvp")
.output("libminicore.rlib")
.run();

rustc()
.input("foo.rs")
.target("wasm32-wasip1")
Expand All @@ -13,6 +21,7 @@ fn main() {
.lto("fat")
.linker_plugin_lto("on")
.link_arg("--import-memory")
.extern_("minicore", path("libminicore.rlib"))
.run();
verify_features(Path::new("foo.wasm"));
}
Expand Down
Loading