Skip to content

Commit

Permalink
Rewrite lto-readonly-lib to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jun 6, 2024
1 parent 6574fc4 commit 486a640
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 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 @@ -129,7 +129,6 @@ run-make/lto-dylib-dep/Makefile
run-make/lto-empty/Makefile
run-make/lto-linkage-used-attr/Makefile
run-make/lto-no-link-whole-rlib/Makefile
run-make/lto-readonly-lib/Makefile
run-make/lto-smoke-c/Makefile
run-make/macos-deployment-target/Makefile
run-make/macos-fat-archive/Makefile
Expand Down
6 changes: 3 additions & 3 deletions tests/run-make/ls-metadata/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use run_make_support::fs_wrapper;
use run_make_support::{rmake_out_path, rustc};

fn main() {
rustc().input("foo.rs");
rustc().arg("-Zls=root").input(rmake_out_path("foo"));
rustc().input("foo.rs").run();
rustc().arg("-Zls=root").input(rmake_out_path("foo")).run();
fs_wrapper::create_file(rmake_out_path("bar"));
rustc().arg("-Zls=root").input(rmake_out_path("bar"));
rustc().arg("-Zls=root").input(rmake_out_path("bar")).run();
}
13 changes: 0 additions & 13 deletions tests/run-make/lto-readonly-lib/Makefile

This file was deleted.

25 changes: 25 additions & 0 deletions tests/run-make/lto-readonly-lib/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// When the compiler is performing link time optimization, it will
// need to copy the original rlib file, set the copy's permissions to read/write,
// and modify that copy - even if the original
// file is read-only. This test creates a read-only rlib, and checks that
// compilation with LTO succeeds.
// See https://github.com/rust-lang/rust/pull/17619

//@ ignore-cross-compile

use run_make_support::fs_wrapper;
use run_make_support::{rmake_out_dir, run, rustc};

fn main() {
rustc().input("lib.rs").run();
let entries = fs_wrapper::read_dir(rmake_out_dir());
for entry in entries {
if entry.path().extension().and_then(|s| s.to_str()) == Some("rlib") {
let mut perms = fs_wrapper::metadata(entry.path()).permissions();
perms.set_readonly(true);
fs_wrapper::set_permissions(entry.path(), perms);
}
}
rustc().input("main.rs").arg("-Clto").run();
run("main");
}

0 comments on commit 486a640

Please sign in to comment.