Migrate min-global-align and no-alloc-shim run-make tests to rmake by Oneirical · Pull Request #128407 · rust-lang/rust (original) (raw)

I was able to get this test to pass on msvc by adding libcmt.lib as Chris mentioned, but also had to pass compiler-builtins:

use run_make_support::{ cc, cwd, extra_c_flags, 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().args(extra_c_flags())
    .input("foo.o")
    .out_exe("foo")
    .arg("/link")
    .args(&alloc_libs)
    .args(&core_libs)
    .args(&compiler_builtins_libs)
    .arg("libcmt.lib")
    .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().args(extra_c_flags())
    .input("foo.o")
    .out_exe("foo")
    .arg("/link")
    .args(&alloc_libs)
    .args(&core_libs)
    .args(&compiler_builtins_libs)
    .arg("libcmt.lib")
    .run_fail();

}

Not super sure about what's the best thing to do w.r.t. having to pass libcmt.lib.