|
| 1 | +// Testing various mixings of rlibs and dylibs. Makes sure that it's possible to |
| 2 | +// link an rlib to a dylib. The dependency tree among the file looks like: |
| 3 | +// |
| 4 | +// foo |
| 5 | +// / \ |
| 6 | +// bar1 bar2 |
| 7 | +// / \ / |
| 8 | +// baz baz2 |
| 9 | +// |
| 10 | +// This is generally testing the permutations of the foo/bar1/bar2 layer against |
| 11 | +// the baz/baz2 layer |
| 12 | + |
| 13 | +//@ ignore-cross-compile |
| 14 | + |
| 15 | +use run_make_support::{rustc, tmp_dir}; |
| 16 | +use std::fs; |
| 17 | + |
| 18 | +fn test_with_teardown(rustc_calls: impl Fn()) { |
| 19 | + rustc_calls(); |
| 20 | + //FIXME(Oneirical): This should be replaced with the run-make-support fs wrappers. |
| 21 | + fs::remove_dir_all(tmp_dir()).unwrap(); |
| 22 | + fs::create_dir(tmp_dir()).unwrap(); |
| 23 | +} |
| 24 | + |
| 25 | +fn main() { |
| 26 | + test_with_teardown(|| { |
| 27 | + // Building just baz |
| 28 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 29 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 30 | + rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); |
| 31 | + rustc().crate_type("bin").input("baz.rs").run(); |
| 32 | + }); |
| 33 | + test_with_teardown(|| { |
| 34 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 35 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 36 | + rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run(); |
| 37 | + rustc().crate_type("bin").input("baz.rs").run(); |
| 38 | + }); |
| 39 | + test_with_teardown(|| { |
| 40 | + // Building baz2 |
| 41 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 42 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 43 | + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
| 44 | + rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1); |
| 45 | + rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1); |
| 46 | + }); |
| 47 | + test_with_teardown(|| { |
| 48 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 49 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 50 | + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
| 51 | + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
| 52 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 53 | + }); |
| 54 | + test_with_teardown(|| { |
| 55 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 56 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 57 | + rustc().crate_type("rlib").input("bar2.rs").run(); |
| 58 | + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
| 59 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 60 | + }); |
| 61 | + test_with_teardown(|| { |
| 62 | + rustc().crate_type("rlib").input("foo.rs").run(); |
| 63 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 64 | + rustc().crate_type("rlib").input("bar2.rs").run(); |
| 65 | + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
| 66 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 67 | + }); |
| 68 | + test_with_teardown(|| { |
| 69 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 70 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 71 | + rustc().crate_type("rlib").input("bar2.rs").run(); |
| 72 | + rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run(); |
| 73 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 74 | + }); |
| 75 | + test_with_teardown(|| { |
| 76 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 77 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 78 | + rustc().crate_type("rlib").input("bar2.rs").run(); |
| 79 | + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
| 80 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 81 | + }); |
| 82 | + test_with_teardown(|| { |
| 83 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 84 | + rustc().crate_type("rlib").input("bar1.rs").run(); |
| 85 | + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
| 86 | + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
| 87 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 88 | + }); |
| 89 | + rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 90 | + rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run(); |
| 91 | + rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run(); |
| 92 | + rustc().crate_type("dylib,rlib").input("baz2.rs").run(); |
| 93 | + rustc().crate_type("bin").input("baz2.rs").run(); |
| 94 | +} |
0 commit comments