Skip to content

Commit

Permalink
rewrite no-alloc-shim to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Aug 14, 2024
1 parent 5e04cef commit b85bedc
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ run-make/libtest-junit/Makefile
run-make/libtest-thread-limit/Makefile
run-make/macos-deployment-target/Makefile
run-make/native-link-modifier-bundle/Makefile
run-make/no-alloc-shim/Makefile
run-make/reproducible-build/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile
run-make/split-debuginfo/Makefile
Expand Down
4 changes: 2 additions & 2 deletions tests/run-make/min-global-align/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This tests ensure that global variables respect the target minimum alignment.
// This test checks that global variables respect the target minimum alignment.
// The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have
// type-alignment of 1, but some targets require greater global alignment.
// See https://github.com/rust-lang/rust/pull/44440

//@ only-linux
// Reason: this test is target-independent, considering compilation is targeted
// Reason: this test is specific to linux, considering compilation is targeted
// towards linux architectures only.

use run_make_support::{assert_count_is, llvm_components_contain, rfs, rustc};
Expand Down
24 changes: 0 additions & 24 deletions tests/run-make/no-alloc-shim/Makefile

This file was deleted.

55 changes: 55 additions & 0 deletions tests/run-make/no-alloc-shim/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// This test checks the compatibility of the interaction between `--emit obj` and
// `#[global_allocator]`, as it is now possible to invoke the latter without the
// allocator shim since #86844. As this feature is unstable, it should fail if
// --cfg check_feature_gate is passed.
// See https://github.com/rust-lang/rust/pull/86844

//@ ignore-cross-compile
// Reason: the compiled binary is executed

//@ ignore-msvc
//FIXME(Oneirical): Getting this to work on MSVC requires passing libcmt.lib to CC,
// which is not trivial to do.
// Tracking issue: https://github.com/rust-lang/rust/issues/128602
// Discussion: https://github.com/rust-lang/rust/pull/128407#discussion_r1702439172

use run_make_support::{cc, cwd, has_extension, has_prefix, run, rustc, shallow_find_files};

fn main() {
rustc().input("foo.rs").crate_type("bin").emit("obj").panic("abort").run();
let libdir = rustc().print("target-libdir").run().stdout_utf8();
let libdir = libdir.trim();

let alloc_libs = shallow_find_files(&libdir, |path| {
has_prefix(path, "liballoc-") && has_extension(path, "rlib")
});
let core_libs = shallow_find_files(&libdir, |path| {
has_prefix(path, "libcore-") && has_extension(path, "rlib")
});
let compiler_builtins_libs = shallow_find_files(libdir, |path| {
has_prefix(path, "libcompiler_builtins") && has_extension(path, "rlib")
});

cc().input("foo.o")
.out_exe("foo")
.args(&alloc_libs)
.args(&core_libs)
.args(&compiler_builtins_libs)
.run();
run("foo");

// Check that linking without __rust_no_alloc_shim_is_unstable defined fails
rustc()
.input("foo.rs")
.crate_type("bin")
.emit("obj")
.panic("abort")
.cfg("check_feature_gate")
.run();
cc().input("foo.o")
.out_exe("foo")
.args(&alloc_libs)
.args(&core_libs)
.args(&compiler_builtins_libs)
.run_fail();
}

0 comments on commit b85bedc

Please sign in to comment.