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 Jul 30, 2024
1 parent c9d378c commit 4c26950
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 25 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 @@ -31,7 +31,6 @@ run-make/long-linker-command-lines/Makefile
run-make/macos-deployment-target/Makefile
run-make/native-link-modifier-bundle/Makefile
run-make/native-link-modifier-whole-archive/Makefile
run-make/no-alloc-shim/Makefile
run-make/no-builtins-attribute/Makefile
run-make/pdb-buildinfo-cl-cmd/Makefile
run-make/pgo-gen-lto/Makefile
Expand Down
24 changes: 0 additions & 24 deletions tests/run-make/no-alloc-shim/Makefile

This file was deleted.

36 changes: 36 additions & 0 deletions tests/run-make/no-alloc-shim/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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

//FIXME(Oneirical): ignore-msvc FIXME(bjorn3) can't figure out how to link with the MSVC toolchain

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")
});
cc().input("foo.o").out_exe("foo").args(&alloc_libs).args(&core_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).run_fail();
}

0 comments on commit 4c26950

Please sign in to comment.