about summary refs log tree commit diff
path: root/tests/run-make/share-generics-dylib/rmake.rs
blob: ae9e51abffd7af2cc266f8c2f24cabe89ac41b7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//@ ignore-cross-compile
//@ needs-dynamic-linking
//@ needs-crate-type: dylib

// This test makes sure all generic instances get re-exported from Rust dylibs for use by
// `-Zshare-generics`. There are two rlibs (`instance_provider_a` and `instance_provider_b`)
// which both provide an instance of `Cell<i32>::set`. There is `instance_user_dylib` which is
// supposed to re-export both these instances, and then there are `instance_user_a_rlib` and
// `instance_user_b_rlib` which each rely on a specific instance to be available.
//
// In the end everything is linked together into `linked_leaf`. If `instance_user_dylib` does
// not export both then we'll get an `undefined reference` error for one of the instances.
//
// This is regression test for https://github.com/rust-lang/rust/issues/67276.

use run_make_support::rustc;

fn main() {
    compile("rlib", "instance_provider_a.rs");
    compile("rlib", "instance_provider_b.rs");
    compile("dylib", "instance_user_dylib.rs");
    compile("rlib", "instance_user_a_rlib.rs");
    compile("rlib", "instance_user_b_rlib.rs");
    compile("bin", "linked_leaf.rs");
}

fn compile(crate_type: &str, input: &str) {
    rustc()
        .input(input)
        .crate_type(crate_type)
        .args(&["-Cprefer-dynamic", "-Zshare-generics=yes", "-Csymbol-mangling-version=v0"])
        .codegen_units(1)
        .run();
}