authorbors <bors@rust-lang.org> 2023-04-03 01:34:05 UTC
committerbors <bors@rust-lang.org> 2023-04-03 01:34:05 UTC
log33289132ecc1805250f63801fded10fceb2300d8
treecc866d6632d1ee2b47ca3064045164c2092cc015
parenta93bcdc30771340dfff914a1cf48556886ad33a6
parentc45037b95641f22ec53a39bd13e2535d4d1605bd

Auto merge of #109770 - jyn514:run-make-fulldeps, r=Mark-Simulacrum

Move almost all run-make-fulldeps tests to run-make They pass fine, and this avoids having to build the compiler twice. There are few enough tests left that I think it should be possible to get rid of this test suite altogether, but I expect this PR to fail at least a few times in bors and want to get it merged before tackling further changes. cc https://github.com/rust-lang/rust/pull/83775 Fixes https://github.com/rust-lang/rust/issues/66085. Fixes https://github.com/rust-lang/rust/issues/83773.

1466 files changed, 9507 insertions(+), 9376 deletions(-)

tests/run-make-fulldeps/a-b-a-linker-guard/Makefile deleted-15
...@@ -1,15 +0,0 @@
1include ../tools.mk
2
3# Test that if we build `b` against a version of `a` that has one set
4# of types, it will not run with a dylib that has a different set of
5# types.
6
7# NOTE(eddyb) this test only works with the `legacy` mangling,
8# and will probably get removed once `legacy` is gone.
9
10all:
11 $(RUSTC) a.rs --cfg x -C prefer-dynamic -Z unstable-options -C symbol-mangling-version=legacy
12 $(RUSTC) b.rs -C prefer-dynamic -Z unstable-options -C symbol-mangling-version=legacy
13 $(call RUN,b)
14 $(RUSTC) a.rs --cfg y -C prefer-dynamic -Z unstable-options -C symbol-mangling-version=legacy
15 $(call FAIL,b)
tests/run-make-fulldeps/a-b-a-linker-guard/a.rs deleted-8
...@@ -1,8 +0,0 @@
1#![crate_name = "a"]
2#![crate_type = "dylib"]
3
4#[cfg(x)]
5pub fn foo(x: u32) { }
6
7#[cfg(y)]
8pub fn foo(x: i32) { }
tests/run-make-fulldeps/a-b-a-linker-guard/b.rs deleted-7
...@@ -1,7 +0,0 @@
1#![crate_name = "b"]
2
3extern crate a;
4
5fn main() {
6 a::foo(22_u32);
7}
tests/run-make-fulldeps/alloc-no-oom-handling/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_global_oom_handling
tests/run-make-fulldeps/alloc-no-rc/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_rc
tests/run-make-fulldeps/alloc-no-sync/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_sync
tests/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3# Test that -A warnings makes the 'empty trait list for derive' warning go away
4OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" )
5
6all: foo
7 test -z '$(OUT)'
8
9# This is just to make sure the above command actually succeeds
10foo:
11 $(RUSTC) foo.rs -A warnings
tests/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1#[derive()]
2#[derive(Copy, Clone)]
3pub struct Foo;
4
5pub fn main() { }
tests/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile deleted-15
...@@ -1,15 +0,0 @@
1include ../tools.mk
2
3# Test that -A warnings makes the 'empty trait list for derive' warning go away
4DEP=$(shell $(RUSTC) bar.rs)
5OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" )
6
7all: foo bar
8 test -z '$(OUT)'
9
10# These are just to ensure that the above commands actually work
11bar:
12 $(RUSTC) bar.rs
13
14foo: bar
15 $(RUSTC) foo.rs -A warnings
tests/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1#![crate_type = "lib"]
2#![feature(staged_api)]
3#![unstable(feature = "unstable_test_feature", issue = "none")]
4
5pub fn baz() {}
tests/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1#![feature(unstable_test_feature)]
2
3extern crate bar;
4
5pub fn main() { bar::baz() }
tests/run-make-fulldeps/archive-duplicate-names/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3all:
4 mkdir $(TMPDIR)/a
5 mkdir $(TMPDIR)/b
6 $(call COMPILE_OBJ,$(TMPDIR)/a/foo.o,foo.c)
7 $(call COMPILE_OBJ,$(TMPDIR)/b/foo.o,bar.c)
8 $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o
9 $(RUSTC) foo.rs
10 $(RUSTC) bar.rs
11 $(call RUN,bar)
tests/run-make-fulldeps/archive-duplicate-names/bar.c deleted-1
...@@ -1 +0,0 @@
1void bar() {}
tests/run-make-fulldeps/archive-duplicate-names/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::baz();
5}
tests/run-make-fulldeps/archive-duplicate-names/foo.c deleted-1
...@@ -1 +0,0 @@
1void foo() {}
tests/run-make-fulldeps/archive-duplicate-names/foo.rs deleted-14
...@@ -1,14 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {
5 fn foo();
6 fn bar();
7}
8
9pub fn baz() {
10 unsafe {
11 foo();
12 bar();
13 }
14}
tests/run-make-fulldeps/arguments-non-c-like-enum/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --crate-type=staticlib nonclike.rs
5 $(CC) test.c $(call STATICLIB,nonclike) $(call OUT_EXE,test) \
6 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
7 $(call RUN,test)
tests/run-make-fulldeps/arguments-non-c-like-enum/nonclike.rs deleted-31
...@@ -1,31 +0,0 @@
1#[repr(C, u8)]
2pub enum TT {
3 AA(u64, u64),
4 BB,
5}
6
7#[no_mangle]
8pub extern "C" fn tt_add(a: TT, b: TT) -> u64 {
9 match (a, b) {
10 (TT::AA(a1, b1), TT::AA(a2, b2)) => a1 + a2 + b1 + b2,
11 (TT::AA(a1, b1), TT::BB) => a1 + b1,
12 (TT::BB, TT::AA(a1, b1)) => a1 + b1,
13 _ => 0,
14 }
15}
16
17#[repr(C, u8)]
18pub enum T {
19 A(u64),
20 B,
21}
22
23#[no_mangle]
24pub extern "C" fn t_add(a: T, b: T) -> u64 {
25 match (a, b) {
26 (T::A(a), T::A(b)) => a + b,
27 (T::A(a), T::B) => a,
28 (T::B, T::A(b)) => b,
29 _ => 0,
30 }
31}
tests/run-make-fulldeps/arguments-non-c-like-enum/test.c deleted-66
...@@ -1,66 +0,0 @@
1#include <stdint.h>
2#include <assert.h>
3
4#include <stdio.h>
5
6/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
7 * type in nonclike.rs . */
8enum TT_Tag {
9 AA,
10 BB,
11};
12typedef uint8_t TT_Tag;
13
14typedef struct {
15 uint64_t _0;
16 uint64_t _1;
17} AA_Body;
18
19typedef struct {
20 TT_Tag tag;
21 union {
22 AA_Body aa;
23 };
24} TT;
25
26/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
27 * in nonclike.rs . */
28enum T_Tag {
29 A,
30 B,
31};
32typedef uint8_t T_Tag;
33
34typedef struct {
35 uint64_t _0;
36} A_Body;
37
38typedef struct {
39 T_Tag tag;
40 union {
41 A_Body a;
42 };
43} T;
44
45/* These symbols are defined by the Rust staticlib built from
46 * nonclike.rs. */
47extern uint64_t t_add(T a, T b);
48extern uint64_t tt_add(TT a, TT b);
49
50int main(int argc, char *argv[]) {
51 (void)argc; (void)argv;
52
53 /* This example works. */
54 TT xx = { .tag = AA, .aa = { ._0 = 1, ._1 = 2 } };
55 TT yy = { .tag = AA, .aa = { ._0 = 10, ._1 = 20 } };
56 uint64_t rr = tt_add(xx, yy);
57 assert(33 == rr);
58
59 /* This one used to return an incorrect result (see issue #68190). */
60 T x = { .tag = A, .a = { ._0 = 1 } };
61 T y = { .tag = A, .a = { ._0 = 10 } };
62 uint64_t r = t_add(x, y);
63 assert(11 == r);
64
65 return 0;
66}
tests/run-make-fulldeps/atomic-lock-free/Makefile deleted-48
...@@ -1,48 +0,0 @@
1include ../tools.mk
2
3# This tests ensure that atomic types are never lowered into runtime library calls that are not
4# guaranteed to be lock-free.
5
6all:
7ifeq ($(UNAME),Linux)
8ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
9 $(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs
10 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
11 $(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs
12 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
13endif
14ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm)
15 $(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs
16 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
17 $(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs
18 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
19 $(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs
20 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
21 $(RUSTC) --target=thumbv7neon-unknown-linux-gnueabihf atomic_lock_free.rs
22 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
23endif
24ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64)
25 $(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs
26 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
27endif
28ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips)
29 $(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs
30 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
31 $(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs
32 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
33endif
34ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc)
35 $(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs
36 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
37 $(RUSTC) --target=powerpc-unknown-linux-gnuspe atomic_lock_free.rs
38 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
39 $(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs
40 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
41 $(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs
42 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
43endif
44ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz)
45 $(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs
46 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
47endif
48endif
tests/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs deleted-66
...@@ -1,66 +0,0 @@
1#![feature(no_core, intrinsics, lang_items)]
2#![crate_type="rlib"]
3#![no_core]
4
5extern "rust-intrinsic" {
6 fn atomic_xadd_seqcst<T>(dst: *mut T, src: T) -> T;
7}
8
9#[lang = "sized"]
10trait Sized {}
11#[lang = "copy"]
12trait Copy {}
13#[lang = "freeze"]
14trait Freeze {}
15
16impl<T: ?Sized> Copy for *mut T {}
17
18#[cfg(target_has_atomic = "8")]
19pub unsafe fn atomic_u8(x: *mut u8) {
20 atomic_xadd_seqcst(x, 1);
21 atomic_xadd_seqcst(x, 1);
22}
23#[cfg(target_has_atomic = "8")]
24pub unsafe fn atomic_i8(x: *mut i8) {
25 atomic_xadd_seqcst(x, 1);
26}
27#[cfg(target_has_atomic = "16")]
28pub unsafe fn atomic_u16(x: *mut u16) {
29 atomic_xadd_seqcst(x, 1);
30}
31#[cfg(target_has_atomic = "16")]
32pub unsafe fn atomic_i16(x: *mut i16) {
33 atomic_xadd_seqcst(x, 1);
34}
35#[cfg(target_has_atomic = "32")]
36pub unsafe fn atomic_u32(x: *mut u32) {
37 atomic_xadd_seqcst(x, 1);
38}
39#[cfg(target_has_atomic = "32")]
40pub unsafe fn atomic_i32(x: *mut i32) {
41 atomic_xadd_seqcst(x, 1);
42}
43#[cfg(target_has_atomic = "64")]
44pub unsafe fn atomic_u64(x: *mut u64) {
45 atomic_xadd_seqcst(x, 1);
46}
47#[cfg(target_has_atomic = "64")]
48pub unsafe fn atomic_i64(x: *mut i64) {
49 atomic_xadd_seqcst(x, 1);
50}
51#[cfg(target_has_atomic = "128")]
52pub unsafe fn atomic_u128(x: *mut u128) {
53 atomic_xadd_seqcst(x, 1);
54}
55#[cfg(target_has_atomic = "128")]
56pub unsafe fn atomic_i128(x: *mut i128) {
57 atomic_xadd_seqcst(x, 1);
58}
59#[cfg(target_has_atomic = "ptr")]
60pub unsafe fn atomic_usize(x: *mut usize) {
61 atomic_xadd_seqcst(x, 1);
62}
63#[cfg(target_has_atomic = "ptr")]
64pub unsafe fn atomic_isize(x: *mut isize) {
65 atomic_xadd_seqcst(x, 1);
66}
tests/run-make-fulldeps/bare-outfile/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 cp foo.rs $(TMPDIR)
5 cd $(TMPDIR) && $(RUSTC) -o foo foo.rs
6 $(call RUN,foo)
tests/run-make-fulldeps/bare-outfile/foo.rs deleted-2
...@@ -1,2 +0,0 @@
1fn main() {
2}
tests/run-make-fulldeps/c-dynamic-dylib/Makefile deleted-12
...@@ -1,12 +0,0 @@
1include ../tools.mk
2
3# ignore-macos
4#
5# This hits an assertion in the linker on older versions of osx apparently
6
7all: $(call DYLIB,cfoo)
8 $(RUSTC) foo.rs -C prefer-dynamic
9 $(RUSTC) bar.rs
10 $(call RUN,bar)
11 $(call REMOVE_DYLIBS,cfoo)
12 $(call FAIL,bar)
tests/run-make-fulldeps/c-dynamic-dylib/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::rsfoo();
5}
tests/run-make-fulldeps/c-dynamic-dylib/cfoo.c deleted-4
...@@ -1,4 +0,0 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int foo() { return 0; }
tests/run-make-fulldeps/c-dynamic-dylib/foo.rs deleted-10
...@@ -1,10 +0,0 @@
1#![crate_type = "dylib"]
2
3#[link(name = "cfoo")]
4extern "C" {
5 fn foo();
6}
7
8pub fn rsfoo() {
9 unsafe { foo() }
10}
tests/run-make-fulldeps/c-dynamic-rlib/Makefile deleted-15
...@@ -1,15 +0,0 @@
1include ../tools.mk
2
3# ignore-macos
4#
5# This hits an assertion in the linker on older versions of osx apparently
6
7# This overrides the LD_LIBRARY_PATH for RUN
8TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR)
9
10all: $(call DYLIB,cfoo)
11 $(RUSTC) foo.rs
12 $(RUSTC) bar.rs
13 $(call RUN,bar)
14 $(call REMOVE_DYLIBS,cfoo)
15 $(call FAIL,bar)
tests/run-make-fulldeps/c-dynamic-rlib/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::rsfoo();
5}
tests/run-make-fulldeps/c-dynamic-rlib/cfoo.c deleted-4
...@@ -1,4 +0,0 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int foo() { return 0; }
tests/run-make-fulldeps/c-dynamic-rlib/foo.rs deleted-10
...@@ -1,10 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "cfoo")]
4extern "C" {
5 fn foo();
6}
7
8pub fn rsfoo() {
9 unsafe { foo() }
10}
tests/run-make-fulldeps/c-link-to-rust-dylib/Makefile deleted-17
...@@ -1,17 +0,0 @@
1include ../tools.mk
2
3all: $(TMPDIR)/$(call BIN,bar)
4 $(call RUN,bar)
5 $(call REMOVE_DYLIBS,foo)
6 $(call FAIL,bar)
7
8ifdef IS_MSVC
9$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo)
10 $(CC) bar.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,bar)
11else
12$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo)
13 $(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -L $(TMPDIR)
14endif
15
16$(call DYLIB,foo): foo.rs
17 $(RUSTC) foo.rs
tests/run-make-fulldeps/c-link-to-rust-dylib/bar.c deleted-6
...@@ -1,6 +0,0 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make-fulldeps/c-link-to-rust-dylib/foo.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "dylib"]
2
3#[no_mangle]
4pub extern "C" fn foo() {}
tests/run-make-fulldeps/c-link-to-rust-staticlib/Makefile deleted-12
...@@ -1,12 +0,0 @@
1include ../tools.mk
2
3# ignore-freebsd
4# FIXME
5
6all:
7 $(RUSTC) foo.rs
8 $(CC) bar.c $(call STATICLIB,foo) $(call OUT_EXE,bar) \
9 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
10 $(call RUN,bar)
11 rm $(call STATICLIB,foo)
12 $(call RUN,bar)
tests/run-make-fulldeps/c-link-to-rust-staticlib/bar.c deleted-6
...@@ -1,6 +0,0 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "staticlib"]
2
3#[no_mangle]
4pub extern "C" fn foo() {}
tests/run-make-fulldeps/c-link-to-rust-va-list-fn/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) checkrust.rs
5 $(CC) test.c $(call STATICLIB,checkrust) $(call OUT_EXE,test) $(EXTRACFLAGS)
6 $(call RUN,test)
tests/run-make-fulldeps/c-link-to-rust-va-list-fn/checkrust.rs deleted-148
...@@ -1,148 +0,0 @@
1#![crate_type = "staticlib"]
2#![feature(c_variadic)]
3#![feature(rustc_private)]
4
5extern crate libc;
6
7use libc::{c_char, c_double, c_int, c_long, c_longlong};
8use std::ffi::VaList;
9use std::ffi::{CString, CStr};
10
11macro_rules! continue_if {
12 ($cond:expr) => {
13 if !($cond) {
14 return 0xff;
15 }
16 }
17}
18
19unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool {
20 let cstr0 = CStr::from_ptr(ptr);
21 match CString::new(val) {
22 Ok(cstr1) => &*cstr1 == cstr0,
23 Err(_) => false,
24 }
25}
26
27#[no_mangle]
28pub unsafe extern "C" fn check_list_0(mut ap: VaList) -> usize {
29 continue_if!(ap.arg::<c_longlong>() == 1);
30 continue_if!(ap.arg::<c_int>() == 2);
31 continue_if!(ap.arg::<c_longlong>() == 3);
32 0
33}
34
35#[no_mangle]
36pub unsafe extern "C" fn check_list_1(mut ap: VaList) -> usize {
37 continue_if!(ap.arg::<c_int>() == -1);
38 continue_if!(ap.arg::<c_char>() == 'A' as c_char);
39 continue_if!(ap.arg::<c_char>() == '4' as c_char);
40 continue_if!(ap.arg::<c_char>() == ';' as c_char);
41 continue_if!(ap.arg::<c_int>() == 0x32);
42 continue_if!(ap.arg::<c_int>() == 0x10000001);
43 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Valid!"));
44 0
45}
46
47#[no_mangle]
48pub unsafe extern "C" fn check_list_2(mut ap: VaList) -> usize {
49 continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor());
50 continue_if!(ap.arg::<c_long>() == 12);
51 continue_if!(ap.arg::<c_char>() == 'a' as c_char);
52 continue_if!(ap.arg::<c_double>().floor() == 6.18f64.floor());
53 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Hello"));
54 continue_if!(ap.arg::<c_int>() == 42);
55 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "World"));
56 0
57}
58
59#[no_mangle]
60pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize {
61 continue_if!(ap.arg::<c_double>().floor() == 6.28f64.floor());
62 continue_if!(ap.arg::<c_int>() == 16);
63 continue_if!(ap.arg::<c_char>() == 'A' as c_char);
64 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!"));
65 ap.with_copy(|mut ap| {
66 if compare_c_str(ap.arg::<*const c_char>(), "Correct") {
67 0
68 } else {
69 0xff
70 }
71 })
72}
73
74#[no_mangle]
75pub unsafe extern "C" fn check_varargs_0(_: c_int, mut ap: ...) -> usize {
76 continue_if!(ap.arg::<c_int>() == 42);
77 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Hello, World!"));
78 0
79}
80
81#[no_mangle]
82pub unsafe extern "C" fn check_varargs_1(_: c_int, mut ap: ...) -> usize {
83 continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor());
84 continue_if!(ap.arg::<c_long>() == 12);
85 continue_if!(ap.arg::<c_char>() == 'A' as c_char);
86 continue_if!(ap.arg::<c_longlong>() == 1);
87 0
88}
89
90#[no_mangle]
91pub unsafe extern "C" fn check_varargs_2(_: c_int, _ap: ...) -> usize {
92 0
93}
94
95#[no_mangle]
96pub unsafe extern "C" fn check_varargs_3(_: c_int, mut ap: ...) -> usize {
97 continue_if!(ap.arg::<c_int>() == 1);
98 continue_if!(ap.arg::<c_int>() == 2);
99 continue_if!(ap.arg::<c_int>() == 3);
100 continue_if!(ap.arg::<c_int>() == 4);
101 continue_if!(ap.arg::<c_int>() == 5);
102 continue_if!(ap.arg::<c_int>() == 6);
103 continue_if!(ap.arg::<c_int>() == 7);
104 continue_if!(ap.arg::<c_int>() == 8);
105 continue_if!(ap.arg::<c_int>() == 9);
106 continue_if!(ap.arg::<c_int>() == 10);
107 0
108}
109
110#[no_mangle]
111pub unsafe extern "C" fn check_varargs_4(_: c_double, mut ap: ...) -> usize {
112 continue_if!(ap.arg::<c_double>() == 1.0);
113 continue_if!(ap.arg::<c_double>() == 2.0);
114 continue_if!(ap.arg::<c_double>() == 3.0);
115 continue_if!(ap.arg::<c_double>() == 4.0);
116 continue_if!(ap.arg::<c_double>() == 5.0);
117 continue_if!(ap.arg::<c_double>() == 6.0);
118 continue_if!(ap.arg::<c_double>() == 7.0);
119 continue_if!(ap.arg::<c_double>() == 8.0);
120 continue_if!(ap.arg::<c_double>() == 9.0);
121 continue_if!(ap.arg::<c_double>() == 10.0);
122 0
123}
124
125#[no_mangle]
126pub unsafe extern "C" fn check_varargs_5(_: c_int, mut ap: ...) -> usize {
127 continue_if!(ap.arg::<c_double>() == 1.0);
128 continue_if!(ap.arg::<c_int>() == 1);
129 continue_if!(ap.arg::<c_double>() == 2.0);
130 continue_if!(ap.arg::<c_int>() == 2);
131 continue_if!(ap.arg::<c_double>() == 3.0);
132 continue_if!(ap.arg::<c_int>() == 3);
133 continue_if!(ap.arg::<c_double>() == 4.0);
134 continue_if!(ap.arg::<c_int>() == 4);
135 continue_if!(ap.arg::<c_int>() == 5);
136 continue_if!(ap.arg::<c_double>() == 5.0);
137 continue_if!(ap.arg::<c_int>() == 6);
138 continue_if!(ap.arg::<c_double>() == 6.0);
139 continue_if!(ap.arg::<c_int>() == 7);
140 continue_if!(ap.arg::<c_double>() == 7.0);
141 continue_if!(ap.arg::<c_int>() == 8);
142 continue_if!(ap.arg::<c_double>() == 8.0);
143 continue_if!(ap.arg::<c_int>() == 9);
144 continue_if!(ap.arg::<c_double>() == 9.0);
145 continue_if!(ap.arg::<c_int>() == 10);
146 continue_if!(ap.arg::<c_double>() == 10.0);
147 0
148}
tests/run-make-fulldeps/c-link-to-rust-va-list-fn/test.c deleted-50
...@@ -1,50 +0,0 @@
1#include <stdarg.h>
2#include <assert.h>
3#include <stdint.h>
4#include <stdlib.h>
5#include <stdio.h>
6
7extern size_t check_list_0(va_list ap);
8extern size_t check_list_1(va_list ap);
9extern size_t check_list_2(va_list ap);
10extern size_t check_list_copy_0(va_list ap);
11extern size_t check_varargs_0(int fixed, ...);
12extern size_t check_varargs_1(int fixed, ...);
13extern size_t check_varargs_2(int fixed, ...);
14extern size_t check_varargs_3(int fixed, ...);
15extern size_t check_varargs_4(double fixed, ...);
16extern size_t check_varargs_5(int fixed, ...);
17
18int test_rust(size_t (*fn)(va_list), ...) {
19 size_t ret = 0;
20 va_list ap;
21 va_start(ap, fn);
22 ret = fn(ap);
23 va_end(ap);
24 return ret;
25}
26
27int main(int argc, char* argv[]) {
28 assert(test_rust(check_list_0, 0x01LL, 0x02, 0x03LL) == 0);
29
30 assert(test_rust(check_list_1, -1, 'A', '4', ';', 0x32, 0x10000001, "Valid!") == 0);
31
32 assert(test_rust(check_list_2, 3.14, 12l, 'a', 6.28, "Hello", 42, "World") == 0);
33
34 assert(test_rust(check_list_copy_0, 6.28, 16, 'A', "Skip Me!", "Correct") == 0);
35
36 assert(check_varargs_0(0, 42, "Hello, World!") == 0);
37
38 assert(check_varargs_1(0, 3.14, 12l, 'A', 0x1LL) == 0);
39
40 assert(check_varargs_2(0, "All", "of", "these", "are", "ignored", ".") == 0);
41
42 assert(check_varargs_3(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) == 0);
43
44 assert(check_varargs_4(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0) == 0);
45
46 assert(check_varargs_5(0, 1.0, 1, 2.0, 2, 3.0, 3, 4.0, 4, 5, 5.0, 6, 6.0, 7, 7.0, 8, 8.0,
47 9, 9.0, 10, 10.0) == 0);
48
49 return 0;
50}
tests/run-make-fulldeps/c-static-dylib/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,cfoo)
4 $(RUSTC) foo.rs -C prefer-dynamic
5 $(RUSTC) bar.rs
6 rm $(call NATIVE_STATICLIB,cfoo)
7 $(call RUN,bar)
8 $(call REMOVE_DYLIBS,foo)
9 $(call FAIL,bar)
tests/run-make-fulldeps/c-static-dylib/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::rsfoo();
5}
tests/run-make-fulldeps/c-static-dylib/cfoo.c deleted-1
...@@ -1 +0,0 @@
1int foo() { return 0; }
tests/run-make-fulldeps/c-static-dylib/foo.rs deleted-10
...@@ -1,10 +0,0 @@
1#![crate_type = "dylib"]
2
3#[link(name = "cfoo", kind = "static")]
4extern "C" {
5 fn foo();
6}
7
8pub fn rsfoo() {
9 unsafe { foo() }
10}
tests/run-make-fulldeps/c-static-rlib/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,cfoo)
4 $(RUSTC) foo.rs
5 $(RUSTC) bar.rs
6 $(call REMOVE_RLIBS,foo)
7 rm $(call NATIVE_STATICLIB,cfoo)
8 $(call RUN,bar)
tests/run-make-fulldeps/c-static-rlib/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::rsfoo();
5}
tests/run-make-fulldeps/c-static-rlib/cfoo.c deleted-1
...@@ -1 +0,0 @@
1int foo() { return 0; }
tests/run-make-fulldeps/c-static-rlib/foo.rs deleted-10
...@@ -1,10 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "cfoo", kind = "static")]
4extern "C" {
5 fn foo();
6}
7
8pub fn rsfoo() {
9 unsafe { foo() }
10}
tests/run-make-fulldeps/c-unwind-abi-catch-lib-panic/Makefile deleted-30
...@@ -1,30 +0,0 @@
1include ../tools.mk
2
3all: archive
4 # Compile `main.rs`, which will link into our library, and run it.
5 $(RUSTC) main.rs
6 $(call RUN,main)
7
8ifdef IS_MSVC
9archive: add.o panic.o
10 # Now, create an archive using these two objects.
11 $(AR) crus $(TMPDIR)/add.lib $(TMPDIR)/add.o $(TMPDIR)/panic.o
12else
13archive: add.o panic.o
14 # Now, create an archive using these two objects.
15 $(AR) crus $(TMPDIR)/libadd.a $(TMPDIR)/add.o $(TMPDIR)/panic.o
16endif
17
18# Compile `panic.rs` into an object file.
19#
20# Note that we invoke `rustc` directly, so we may emit an object rather
21# than an archive. We'll do that later.
22panic.o:
23 $(BARE_RUSTC) $(RUSTFLAGS) \
24 --out-dir $(TMPDIR) \
25 --emit=obj panic.rs
26
27# Compile `add.c` into an object file.
28add.o:
29 $(call COMPILE_OBJ,$(TMPDIR)/add.o,add.c)
30
tests/run-make-fulldeps/c-unwind-abi-catch-lib-panic/add.c deleted-12
...@@ -1,12 +0,0 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4
5// An external function, defined in Rust.
6extern void panic_if_greater_than_10(unsigned x);
7
8unsigned add_small_numbers(unsigned a, unsigned b) {
9 unsigned c = a + b;
10 panic_if_greater_than_10(c);
11 return c;
12}
tests/run-make-fulldeps/c-unwind-abi-catch-lib-panic/main.rs deleted-35
...@@ -1,35 +0,0 @@
1//! A test for calling `C-unwind` functions across foreign function boundaries.
2//!
3//! This test triggers a panic in a Rust library that our foreign function invokes. This shows
4//! that we can unwind through the C code in that library, and catch the underlying panic.
5#![feature(c_unwind)]
6
7use std::panic::{catch_unwind, AssertUnwindSafe};
8
9fn main() {
10 // Call `add_small_numbers`, passing arguments that will NOT trigger a panic.
11 let (a, b) = (9, 1);
12 let c = unsafe { add_small_numbers(a, b) };
13 assert_eq!(c, 10);
14
15 // Call `add_small_numbers`, passing arguments that will trigger a panic, and catch it.
16 let caught_unwind = catch_unwind(AssertUnwindSafe(|| {
17 let (a, b) = (10, 1);
18 let _c = unsafe { add_small_numbers(a, b) };
19 unreachable!("should have unwound instead of returned");
20 }));
21
22 // Assert that we did indeed panic, then unwrap and downcast the panic into the sum.
23 assert!(caught_unwind.is_err());
24 let panic_obj = caught_unwind.unwrap_err();
25 let msg = panic_obj.downcast_ref::<String>().unwrap();
26 assert_eq!(msg, "11");
27}
28
29#[link(name = "add", kind = "static")]
30extern "C-unwind" {
31 /// An external function, defined in C.
32 ///
33 /// Returns the sum of two numbers, or panics if the sum is greater than 10.
34 fn add_small_numbers(a: u32, b: u32) -> u32;
35}
tests/run-make-fulldeps/c-unwind-abi-catch-lib-panic/panic.rs deleted-12
...@@ -1,12 +0,0 @@
1#![crate_type = "staticlib"]
2#![feature(c_unwind)]
3
4/// This function will panic if `x` is greater than 10.
5///
6/// This function is called by `add_small_numbers`.
7#[no_mangle]
8pub extern "C-unwind" fn panic_if_greater_than_10(x: u32) {
9 if x > 10 {
10 panic!("{}", x); // That is too big!
11 }
12}
tests/run-make-fulldeps/c-unwind-abi-catch-panic/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,add)
4 $(RUSTC) main.rs
5 $(call RUN,main) || exit 1
tests/run-make-fulldeps/c-unwind-abi-catch-panic/add.c deleted-12
...@@ -1,12 +0,0 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4
5// An external function, defined in Rust.
6extern void panic_if_greater_than_10(unsigned x);
7
8unsigned add_small_numbers(unsigned a, unsigned b) {
9 unsigned c = a + b;
10 panic_if_greater_than_10(c);
11 return c;
12}
tests/run-make-fulldeps/c-unwind-abi-catch-panic/main.rs deleted-44
...@@ -1,44 +0,0 @@
1//! A test for calling `C-unwind` functions across foreign function boundaries.
2//!
3//! This test triggers a panic when calling a foreign function that calls *back* into Rust.
4#![feature(c_unwind)]
5
6use std::panic::{catch_unwind, AssertUnwindSafe};
7
8fn main() {
9 // Call `add_small_numbers`, passing arguments that will NOT trigger a panic.
10 let (a, b) = (9, 1);
11 let c = unsafe { add_small_numbers(a, b) };
12 assert_eq!(c, 10);
13
14 // Call `add_small_numbers`, passing arguments that will trigger a panic, and catch it.
15 let caught_unwind = catch_unwind(AssertUnwindSafe(|| {
16 let (a, b) = (10, 1);
17 let _c = unsafe { add_small_numbers(a, b) };
18 unreachable!("should have unwound instead of returned");
19 }));
20
21 // Assert that we did indeed panic, then unwrap and downcast the panic into the sum.
22 assert!(caught_unwind.is_err());
23 let panic_obj = caught_unwind.unwrap_err();
24 let msg = panic_obj.downcast_ref::<String>().unwrap();
25 assert_eq!(msg, "11");
26}
27
28#[link(name = "add", kind = "static")]
29extern "C-unwind" {
30 /// An external function, defined in C.
31 ///
32 /// Returns the sum of two numbers, or panics if the sum is greater than 10.
33 fn add_small_numbers(a: u32, b: u32) -> u32;
34}
35
36/// This function will panic if `x` is greater than 10.
37///
38/// This function is called by `add_small_numbers`.
39#[no_mangle]
40pub extern "C-unwind" fn panic_if_greater_than_10(x: u32) {
41 if x > 10 {
42 panic!("{}", x); // That is too big!
43 }
44}
tests/run-make-fulldeps/cat-and-grep-sanity-check/Makefile deleted-46
...@@ -1,46 +0,0 @@
1include ../tools.mk
2
3all:
4 echo a | $(CGREP) a
5 ! echo b | $(CGREP) a
6 echo xyz | $(CGREP) x y z
7 ! echo abc | $(CGREP) b c d
8 printf "x\ny\nz" | $(CGREP) x y z
9
10 echo AbCd | $(CGREP) -i a b C D
11 ! echo AbCd | $(CGREP) a b C D
12
13 true | $(CGREP) -v nothing
14 ! echo nothing | $(CGREP) -v nothing
15 ! echo xyz | $(CGREP) -v w x y
16 ! echo xyz | $(CGREP) -v x y z
17 echo xyz | $(CGREP) -v a b c
18
19 ! echo 'foo bar baz' | $(CGREP) 'foo baz'
20 echo 'foo bar baz' | $(CGREP) foo baz
21 echo 'x a `b` c y z' | $(CGREP) 'a `b` c'
22
23 echo baaac | $(CGREP) -e 'ba*c'
24 echo bc | $(CGREP) -e 'ba*c'
25 ! echo aaac | $(CGREP) -e 'ba*c'
26
27 echo aaa | $(CGREP) -e 'a+'
28 ! echo bbb | $(CGREP) -e 'a+'
29
30 echo abc | $(CGREP) -e 'a|e|i|o|u'
31 ! echo fgh | $(CGREP) -e 'a|e|i|o|u'
32 echo abc | $(CGREP) -e '[aeiou]'
33 ! echo fgh | $(CGREP) -e '[aeiou]'
34 ! echo abc | $(CGREP) -e '[^aeiou]{3}'
35 echo fgh | $(CGREP) -e '[^aeiou]{3}'
36 echo ab cd ef gh | $(CGREP) -e '\bcd\b'
37 ! echo abcdefgh | $(CGREP) -e '\bcd\b'
38 echo xyz | $(CGREP) -e '...'
39 ! echo xy | $(CGREP) -e '...'
40 ! echo xyz | $(CGREP) -e '\.\.\.'
41 echo ... | $(CGREP) -e '\.\.\.'
42
43 echo foo bar baz | $(CGREP) -e 'foo.*baz'
44 ! echo foo bar baz | $(CGREP) -ve 'foo.*baz'
45 ! echo foo bar baz | $(CGREP) -e 'baz.*foo'
46 echo foo bar baz | $(CGREP) -ve 'baz.*foo'
tests/run-make-fulldeps/cdylib-dylib-linkage/Makefile deleted-27
...@@ -1,27 +0,0 @@
1include ../tools.mk
2
3TARGET_SYSROOT := $(shell $(RUSTC) --print sysroot)/lib/rustlib/$(TARGET)/lib
4
5ifdef IS_MSVC
6LIBSTD := $(wildcard $(TARGET_SYSROOT)/libstd-*.dll.lib)
7else
8LIBSTD := $(wildcard $(TARGET_SYSROOT)/$(call DYLIB_GLOB,std))
9STD := $(basename $(patsubst lib%,%, $(notdir $(LIBSTD))))
10endif
11
12all: $(call RUN_BINFILE,foo)
13 $(call RUN,foo)
14
15ifdef IS_MSVC
16CLIBS := $(TMPDIR)/foo.dll.lib $(TMPDIR)/bar.dll.lib $(LIBSTD)
17$(call RUN_BINFILE,foo): $(call DYLIB,foo)
18 $(CC) $(CFLAGS) foo.c $(CLIBS) $(call OUT_EXE,foo)
19else
20CLIBS := -lfoo -lbar -l$(STD) -L $(TMPDIR) -L $(TARGET_SYSROOT)
21$(call RUN_BINFILE,foo): $(call DYLIB,foo)
22 $(CC) $(CFLAGS) foo.c $(CLIBS) -o $(call RUN_BINFILE,foo)
23endif
24
25$(call DYLIB,foo):
26 $(RUSTC) -C prefer-dynamic bar.rs
27 $(RUSTC) foo.rs
tests/run-make-fulldeps/cdylib-dylib-linkage/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1#![crate_type = "dylib"]
2
3pub fn bar() {
4 println!("hello!");
5}
tests/run-make-fulldeps/cdylib-dylib-linkage/foo.c deleted-10
...@@ -1,10 +0,0 @@
1#include <assert.h>
2
3extern void foo();
4extern unsigned bar(unsigned a, unsigned b);
5
6int main() {
7 foo();
8 assert(bar(1, 2) == 3);
9 return 0;
10}
tests/run-make-fulldeps/cdylib-dylib-linkage/foo.rs deleted-13
...@@ -1,13 +0,0 @@
1#![crate_type = "cdylib"]
2
3extern crate bar;
4
5#[no_mangle]
6pub extern "C" fn foo() {
7 bar::bar();
8}
9
10#[no_mangle]
11pub extern "C" fn bar(a: u32, b: u32) -> u32 {
12 a + b
13}
tests/run-make-fulldeps/cdylib-fewer-symbols/Makefile deleted-12
...@@ -1,12 +0,0 @@
1# Test that allocator-related symbols don't show up as exported from a cdylib as
2# they're internal to Rust and not part of the public ABI.
3
4include ../tools.mk
5
6# ignore-windows
7# FIXME: The __rdl_ and __rust_ symbol still remains, no matter using MSVC or GNU
8# See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753
9
10all:
11 $(RUSTC) foo.rs
12 nm -g "$(call DYLIB,foo)" | $(CGREP) -v __rdl_ __rde_ __rg_ __rust_
tests/run-make-fulldeps/cdylib-fewer-symbols/foo.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_type = "cdylib"]
2
3#[no_mangle]
4pub extern "C" fn foo() -> u32 {
5 3
6}
tests/run-make-fulldeps/cdylib/Makefile deleted-19
...@@ -1,19 +0,0 @@
1include ../tools.mk
2
3all: $(call RUN_BINFILE,foo)
4 $(call RUN,foo)
5 rm $(call DYLIB,foo)
6 $(RUSTC) foo.rs -C lto
7 $(call RUN,foo)
8
9ifdef IS_MSVC
10$(call RUN_BINFILE,foo): $(call DYLIB,foo)
11 $(CC) $(CFLAGS) foo.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,foo)
12else
13$(call RUN_BINFILE,foo): $(call DYLIB,foo)
14 $(CC) $(CFLAGS) foo.c -lfoo -o $(call RUN_BINFILE,foo) -L $(TMPDIR)
15endif
16
17$(call DYLIB,foo):
18 $(RUSTC) bar.rs
19 $(RUSTC) foo.rs
tests/run-make-fulldeps/cdylib/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1#![crate_type = "rlib"]
2
3pub fn bar() {
4 println!("hello!");
5}
tests/run-make-fulldeps/cdylib/foo.c deleted-10
...@@ -1,10 +0,0 @@
1#include <assert.h>
2
3extern void foo();
4extern unsigned bar(unsigned a, unsigned b);
5
6int main() {
7 foo();
8 assert(bar(1, 2) == 3);
9 return 0;
10}
tests/run-make-fulldeps/cdylib/foo.rs deleted-13
...@@ -1,13 +0,0 @@
1#![crate_type = "cdylib"]
2
3extern crate bar;
4
5#[no_mangle]
6pub extern "C" fn foo() {
7 bar::bar();
8}
9
10#[no_mangle]
11pub extern "C" fn bar(a: u32, b: u32) -> u32 {
12 a + b
13}
tests/run-make-fulldeps/codegen-options-parsing/Makefile deleted-31
...@@ -1,31 +0,0 @@
1include ../tools.mk
2
3all:
4 #Option taking a number
5 $(RUSTC) -C codegen-units dummy.rs 2>&1 | \
6 $(CGREP) 'codegen option `codegen-units` requires a number'
7 $(RUSTC) -C codegen-units= dummy.rs 2>&1 | \
8 $(CGREP) 'incorrect value `` for codegen option `codegen-units` - a number was expected'
9 $(RUSTC) -C codegen-units=foo dummy.rs 2>&1 | \
10 $(CGREP) 'incorrect value `foo` for codegen option `codegen-units` - a number was expected'
11 $(RUSTC) -C codegen-units=1 dummy.rs
12 #Option taking a string
13 $(RUSTC) -C extra-filename dummy.rs 2>&1 | \
14 $(CGREP) 'codegen option `extra-filename` requires a string'
15 $(RUSTC) -C extra-filename= dummy.rs 2>&1
16 $(RUSTC) -C extra-filename=foo dummy.rs 2>&1
17 #Option taking no argument
18 $(RUSTC) -C lto= dummy.rs 2>&1 | \
19 $(CGREP) 'codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted'
20 $(RUSTC) -C lto=1 dummy.rs 2>&1 | \
21 $(CGREP) 'codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted'
22 $(RUSTC) -C lto=foo dummy.rs 2>&1 | \
23 $(CGREP) 'codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted'
24 $(RUSTC) -C lto dummy.rs
25
26 # Should not link dead code...
27 $(RUSTC) --print link-args dummy.rs 2>&1 | \
28 $(CGREP) -e '--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF'
29 # ... unless you specifically ask to keep it
30 $(RUSTC) --print link-args -C link-dead-code dummy.rs 2>&1 | \
31 $(CGREP) -ve '--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF'
tests/run-make-fulldeps/codegen-options-parsing/dummy.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/compile-stdin/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 echo 'fn main(){}' | $(RUSTC) -
5 $(call RUN,rust_out)
tests/run-make-fulldeps/compiler-lookup-paths-2/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all:
4 mkdir -p $(TMPDIR)/a $(TMPDIR)/b
5 $(RUSTC) a.rs && mv $(TMPDIR)/liba.rlib $(TMPDIR)/a
6 $(RUSTC) b.rs -L $(TMPDIR)/a && mv $(TMPDIR)/libb.rlib $(TMPDIR)/b
7 $(RUSTC) c.rs -L crate=$(TMPDIR)/b -L dependency=$(TMPDIR)/a \
8 && exit 1 || exit 0
tests/run-make-fulldeps/compiler-lookup-paths-2/a.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "lib"]
tests/run-make-fulldeps/compiler-lookup-paths-2/b.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "lib"]
2extern crate a;
tests/run-make-fulldeps/compiler-lookup-paths-2/c.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "lib"]
2extern crate b;
3extern crate a;
tests/run-make-fulldeps/compiler-lookup-paths/Makefile deleted-38
...@@ -1,38 +0,0 @@
1include ../tools.mk
2
3all: $(TMPDIR)/libnative.a
4 mkdir -p $(TMPDIR)/crate
5 mkdir -p $(TMPDIR)/native
6 mv $(TMPDIR)/libnative.a $(TMPDIR)/native
7 $(RUSTC) a.rs
8 mv $(TMPDIR)/liba.rlib $(TMPDIR)/crate
9 $(RUSTC) b.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0
10 $(RUSTC) b.rs -L dependency=$(TMPDIR)/crate && exit 1 || exit 0
11 $(RUSTC) b.rs -L crate=$(TMPDIR)/crate
12 $(RUSTC) b.rs -L all=$(TMPDIR)/crate
13 $(RUSTC) c.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0
14 $(RUSTC) c.rs -L crate=$(TMPDIR)/crate && exit 1 || exit 0
15 $(RUSTC) c.rs -L dependency=$(TMPDIR)/crate
16 $(RUSTC) c.rs -L all=$(TMPDIR)/crate
17 $(RUSTC) d.rs -L dependency=$(TMPDIR)/native && exit 1 || exit 0
18 $(RUSTC) d.rs -L crate=$(TMPDIR)/native && exit 1 || exit 0
19 $(RUSTC) d.rs -L native=$(TMPDIR)/native
20 $(RUSTC) d.rs -L all=$(TMPDIR)/native
21 # Deduplication tests:
22 # Same hash, no errors.
23 mkdir -p $(TMPDIR)/e1
24 mkdir -p $(TMPDIR)/e2
25 $(RUSTC) e.rs -o $(TMPDIR)/e1/libe.rlib
26 $(RUSTC) e.rs -o $(TMPDIR)/e2/libe.rlib
27 $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2
28 $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2
29 $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2
30 # Different hash, errors.
31 $(RUSTC) e2.rs -o $(TMPDIR)/e2/libe.rlib
32 $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0
33 $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0
34 $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 && exit 1 || exit 0
35 # Native/dependency paths don't cause errors.
36 $(RUSTC) f.rs -L native=$(TMPDIR)/e1 -L $(TMPDIR)/e2
37 $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L $(TMPDIR)/e2
38 $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2
tests/run-make-fulldeps/compiler-lookup-paths/a.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "lib"]
tests/run-make-fulldeps/compiler-lookup-paths/b.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "lib"]
2extern crate a;
tests/run-make-fulldeps/compiler-lookup-paths/c.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "lib"]
2extern crate b;
tests/run-make-fulldeps/compiler-lookup-paths/d.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "native", kind = "static")]
4extern "C" {}
tests/run-make-fulldeps/compiler-lookup-paths/e.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_name = "e"]
2#![crate_type = "rlib"]
tests/run-make-fulldeps/compiler-lookup-paths/e2.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_name = "e"]
2#![crate_type = "rlib"]
3
4pub fn f() {}
tests/run-make-fulldeps/compiler-lookup-paths/f.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "rlib"]
2extern crate e;
tests/run-make-fulldeps/compiler-lookup-paths/native.c deleted-1
...@@ -1 +0,0 @@
1// intentionally empty
tests/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# only-windows-gnu
4
5all:
6 $(CXX) foo.cpp -c -o $(TMPDIR)/foo.o
7 $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o
8 $(RUSTC) foo.rs -lfoo -lstdc++
9 $(call RUN,foo)
tests/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp deleted-4
...@@ -1,4 +0,0 @@
1extern "C" void foo() {
2 int *a = new int(3);
3 delete a;
4}
tests/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs deleted-10
...@@ -1,10 +0,0 @@
1extern "C" {
2 fn foo();
3}
4
5pub fn main() {
6 unsafe {
7 foo();
8 }
9 assert_eq!(7f32.powi(3), 343f32);
10}
tests/run-make-fulldeps/core-no-fp-fmt-parse/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/core/src/lib.rs --cfg no_fp_fmt_parse
tests/run-make-fulldeps/crate-data-smoke/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3all:
4 [ `$(RUSTC) --print crate-name crate.rs` = "foo" ]
5 [ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ]
6 [ `$(RUSTC) --print file-names --crate-type=lib \
7 --test crate.rs` = "$(call BIN,foo)" ]
8 [ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ]
9 $(RUSTC) --print file-names lib.rs
10 $(RUSTC) --print file-names rlib.rs
tests/run-make-fulldeps/crate-data-smoke/crate.rs deleted-7
...@@ -1,7 +0,0 @@
1#![crate_name = "foo"]
2
3// Querying about the crate metadata should *not* parse the entire crate, it
4// only needs the crate attributes (which are guaranteed to be at the top) be
5// sure that if we have an error like a missing module that we can still query
6// about the crate id.
7mod error;
tests/run-make-fulldeps/crate-data-smoke/lib.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_name = "mylib"]
2#![crate_type = "lib"]
tests/run-make-fulldeps/crate-data-smoke/rlib.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_name = "mylib"]
2#![crate_type = "rlib"]
tests/run-make-fulldeps/crate-hash-rustc-version/Makefile deleted-37
...@@ -1,37 +0,0 @@
1include ../../run-make-fulldeps/tools.mk
2
3# Ensure that crates compiled with different rustc versions cannot
4# be dynamically linked.
5
6FLAGS := -Cprefer-dynamic -Zsymbol-mangling-version=v0
7UNAME := $(shell uname)
8ifeq ($(UNAME),Linux)
9 EXT=".so"
10 NM_CMD := nm -D
11endif
12ifeq ($(UNAME),Darwin)
13 EXT=".dylib"
14 NM_CMD := nm
15endif
16
17ifndef NM_CMD
18all:
19 exit 0
20else
21all:
22 # a.rs is a dylib
23 $(RUSTC) a.rs --crate-type=dylib $(FLAGS)
24 # Write symbols to disk.
25 $(NM_CMD) $(call DYLIB,a) > $(TMPDIR)/symbolsbefore
26 # b.rs is a binary
27 $(RUSTC) b.rs --extern a=$(TMPDIR)/liba$(EXT) --crate-type=bin -Crpath $(FLAGS)
28 $(call RUN,b)
29 # Now re-compile a.rs with another rustc version
30 RUSTC_FORCE_RUSTC_VERSION=deadfeed $(RUSTC) a.rs --crate-type=dylib $(FLAGS)
31 # After compiling with a different rustc version, write symbols to disk again.
32 $(NM_CMD) $(call DYLIB,a) > $(TMPDIR)/symbolsafter
33 # As a sanity check, test if the symbols changed:
34 # If the symbols are identical, there's been an error.
35 if diff $(TMPDIR)/symbolsbefore $(TMPDIR)/symbolsafter; then exit 1; fi
36 $(call FAIL,b)
37endif
tests/run-make-fulldeps/crate-hash-rustc-version/a.rs deleted-4
...@@ -1,4 +0,0 @@
1pub fn foo(mut x: String) -> String {
2 x.push_str(", world!");
3 x
4}
tests/run-make-fulldeps/crate-hash-rustc-version/b.rs deleted-8
...@@ -1,8 +0,0 @@
1extern crate a;
2
3use a::foo;
4
5fn main() {
6 let x = String::from("Hello");
7 println!("{}", foo(x));
8}
tests/run-make-fulldeps/crate-name-priority/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs
5 rm $(TMPDIR)/$(call BIN,foo)
6 $(RUSTC) foo.rs --crate-name bar
7 rm $(TMPDIR)/$(call BIN,bar)
8 $(RUSTC) foo1.rs
9 rm $(TMPDIR)/$(call BIN,foo)
10 $(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1)
11 rm $(TMPDIR)/$(call BIN,bar1)
tests/run-make-fulldeps/crate-name-priority/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/crate-name-priority/foo1.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_name = "foo"]
2
3fn main() {}
tests/run-make-fulldeps/cross-lang-lto-clang/Makefile deleted-25
...@@ -1,25 +0,0 @@
1# needs-matching-clang
2
3# This test makes sure that cross-language inlining actually works by checking
4# the generated machine code.
5
6include ../tools.mk
7
8all: cpp-executable rust-executable
9
10cpp-executable:
11 $(RUSTC) -Clinker-plugin-lto=on -o $(TMPDIR)/librustlib-xlto.a -Copt-level=2 -Ccodegen-units=1 ./rustlib.rs
12 $(CLANG) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lrustlib-xlto -o $(TMPDIR)/cmain ./cmain.c -O3
13 # Make sure we don't find a call instruction to the function we expect to
14 # always be inlined.
15 "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -v -e "call.*rust_always_inlined"
16 # As a sanity check, make sure we do find a call instruction to a
17 # non-inlined function
18 "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -e "call.*rust_never_inlined"
19
20rust-executable:
21 $(CLANG) ./clib.c -flto=thin -c -o $(TMPDIR)/clib.o -O2
22 (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
23 $(RUSTC) -Clinker-plugin-lto=on -L$(TMPDIR) -Copt-level=2 -Clinker=$(CLANG) -Clink-arg=-fuse-ld=lld ./main.rs -o $(TMPDIR)/rsmain
24 "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -e "call.*c_never_inlined"
25 "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -v -e "call.*c_always_inlined"
tests/run-make-fulldeps/cross-lang-lto-clang/clib.c deleted-9
...@@ -1,9 +0,0 @@
1#include <stdint.h>
2
3uint32_t c_always_inlined() {
4 return 1234;
5}
6
7__attribute__((noinline)) uint32_t c_never_inlined() {
8 return 12345;
9}
tests/run-make-fulldeps/cross-lang-lto-clang/cmain.c deleted-12
...@@ -1,12 +0,0 @@
1#include <stdint.h>
2
3// A trivial function defined in Rust, returning a constant value. This should
4// always be inlined.
5uint32_t rust_always_inlined();
6
7
8uint32_t rust_never_inlined();
9
10int main(int argc, char** argv) {
11 return rust_never_inlined() + rust_always_inlined();
12}
tests/run-make-fulldeps/cross-lang-lto-clang/main.rs deleted-11
...@@ -1,11 +0,0 @@
1#[link(name = "xyz")]
2extern "C" {
3 fn c_always_inlined() -> u32;
4 fn c_never_inlined() -> u32;
5}
6
7fn main() {
8 unsafe {
9 println!("blub: {}", c_always_inlined() + c_never_inlined());
10 }
11}
tests/run-make-fulldeps/cross-lang-lto-clang/rustlib.rs deleted-12
...@@ -1,12 +0,0 @@
1#![crate_type="staticlib"]
2
3#[no_mangle]
4pub extern "C" fn rust_always_inlined() -> u32 {
5 42
6}
7
8#[no_mangle]
9#[inline(never)]
10pub extern "C" fn rust_never_inlined() -> u32 {
11 421
12}
tests/run-make-fulldeps/cross-lang-lto-pgo-smoketest/Makefile deleted-87
...@@ -1,87 +0,0 @@
1# needs-matching-clang
2
3# This test makes sure that cross-language inlining can be used in conjunction
4# with profile-guided optimization. The test only tests that the whole workflow
5# can be executed without anything crashing. It does not test whether PGO or
6# xLTO have any specific effect on the generated code.
7
8include ../tools.mk
9
10COMMON_FLAGS=-Copt-level=3 -Ccodegen-units=1
11
12# LLVM doesn't support instrumenting binaries that use SEH:
13# https://bugs.llvm.org/show_bug.cgi?id=41279
14#
15# Things work fine with -Cpanic=abort though.
16ifdef IS_MSVC
17COMMON_FLAGS+= -Cpanic=abort
18endif
19
20all: cpp-executable rust-executable
21
22cpp-executable:
23 $(RUSTC) -Clinker-plugin-lto=on \
24 -Cprofile-generate="$(TMPDIR)"/cpp-profdata \
25 -o "$(TMPDIR)"/librustlib-xlto.a \
26 $(COMMON_FLAGS) \
27 ./rustlib.rs
28 $(CLANG) -flto=thin \
29 -fprofile-generate="$(TMPDIR)"/cpp-profdata \
30 -fuse-ld=lld \
31 -L "$(TMPDIR)" \
32 -lrustlib-xlto \
33 -o "$(TMPDIR)"/cmain \
34 -O3 \
35 ./cmain.c
36 $(TMPDIR)/cmain
37 # Postprocess the profiling data so it can be used by the compiler
38 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
39 -o "$(TMPDIR)"/cpp-profdata/merged.profdata \
40 "$(TMPDIR)"/cpp-profdata/default_*.profraw
41 $(RUSTC) -Clinker-plugin-lto=on \
42 -Cprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \
43 -o "$(TMPDIR)"/librustlib-xlto.a \
44 $(COMMON_FLAGS) \
45 ./rustlib.rs
46 $(CLANG) -flto=thin \
47 -fprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \
48 -fuse-ld=lld \
49 -L "$(TMPDIR)" \
50 -lrustlib-xlto \
51 -o "$(TMPDIR)"/cmain \
52 -O3 \
53 ./cmain.c
54
55rust-executable:
56 exit
57 $(CLANG) ./clib.c -fprofile-generate="$(TMPDIR)"/rs-profdata -flto=thin -c -o $(TMPDIR)/clib.o -O3
58 (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
59 $(RUSTC) -Clinker-plugin-lto=on \
60 -Cprofile-generate="$(TMPDIR)"/rs-profdata \
61 -L$(TMPDIR) \
62 $(COMMON_FLAGS) \
63 -Clinker=$(CLANG) \
64 -Clink-arg=-fuse-ld=lld \
65 -o $(TMPDIR)/rsmain \
66 ./main.rs
67 $(TMPDIR)/rsmain
68 # Postprocess the profiling data so it can be used by the compiler
69 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
70 -o "$(TMPDIR)"/rs-profdata/merged.profdata \
71 "$(TMPDIR)"/rs-profdata/default_*.profraw
72 $(CLANG) ./clib.c \
73 -fprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \
74 -flto=thin \
75 -c \
76 -o $(TMPDIR)/clib.o \
77 -O3
78 rm "$(TMPDIR)"/libxyz.a
79 (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
80 $(RUSTC) -Clinker-plugin-lto=on \
81 -Cprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \
82 -L$(TMPDIR) \
83 $(COMMON_FLAGS) \
84 -Clinker=$(CLANG) \
85 -Clink-arg=-fuse-ld=lld \
86 -o $(TMPDIR)/rsmain \
87 ./main.rs
tests/run-make-fulldeps/cross-lang-lto-pgo-smoketest/clib.c deleted-9
...@@ -1,9 +0,0 @@
1#include <stdint.h>
2
3uint32_t c_always_inlined() {
4 return 1234;
5}
6
7__attribute__((noinline)) uint32_t c_never_inlined() {
8 return 12345;
9}
tests/run-make-fulldeps/cross-lang-lto-pgo-smoketest/cmain.c deleted-12
...@@ -1,12 +0,0 @@
1#include <stdint.h>
2
3// A trivial function defined in Rust, returning a constant value. This should
4// always be inlined.
5uint32_t rust_always_inlined();
6
7
8uint32_t rust_never_inlined();
9
10int main(int argc, char** argv) {
11 return (rust_never_inlined() + rust_always_inlined()) * 0;
12}
tests/run-make-fulldeps/cross-lang-lto-pgo-smoketest/main.rs deleted-11
...@@ -1,11 +0,0 @@
1#[link(name = "xyz")]
2extern "C" {
3 fn c_always_inlined() -> u32;
4 fn c_never_inlined() -> u32;
5}
6
7fn main() {
8 unsafe {
9 println!("blub: {}", c_always_inlined() + c_never_inlined());
10 }
11}
tests/run-make-fulldeps/cross-lang-lto-pgo-smoketest/rustlib.rs deleted-12
...@@ -1,12 +0,0 @@
1#![crate_type="staticlib"]
2
3#[no_mangle]
4pub extern "C" fn rust_always_inlined() -> u32 {
5 42
6}
7
8#[no_mangle]
9#[inline(never)]
10pub extern "C" fn rust_never_inlined() -> u32 {
11 421
12}
tests/run-make-fulldeps/cross-lang-lto-upstream-rlibs/Makefile deleted-32
...@@ -1,32 +0,0 @@
1include ../tools.mk
2
3# ignore windows due to libLLVM being present in PATH and the PATH and library path being the same
4# (so fixing it is harder). See #57765 for context
5ifndef IS_WINDOWS
6
7# This test makes sure that we don't loose upstream object files when compiling
8# staticlibs with -C linker-plugin-lto
9
10all: staticlib.rs upstream.rs
11 $(RUSTC) upstream.rs -C linker-plugin-lto -Ccodegen-units=1
12
13 # Check No LTO
14 $(RUSTC) staticlib.rs -C linker-plugin-lto -Ccodegen-units=1 -L. -o $(TMPDIR)/staticlib.a
15 (cd $(TMPDIR); "$(LLVM_BIN_DIR)"/llvm-ar x ./staticlib.a)
16 # Make sure the upstream object file was included
17 ls $(TMPDIR)/upstream.*.rcgu.o
18
19 # Cleanup
20 rm $(TMPDIR)/*
21
22 # Check ThinLTO
23 $(RUSTC) upstream.rs -C linker-plugin-lto -Ccodegen-units=1 -Clto=thin
24 $(RUSTC) staticlib.rs -C linker-plugin-lto -Ccodegen-units=1 -Clto=thin -L. -o $(TMPDIR)/staticlib.a
25 (cd $(TMPDIR); "$(LLVM_BIN_DIR)"/llvm-ar x ./staticlib.a)
26 ls $(TMPDIR)/upstream.*.rcgu.o
27
28else
29
30all:
31
32endif
tests/run-make-fulldeps/cross-lang-lto-upstream-rlibs/staticlib.rs deleted-8
...@@ -1,8 +0,0 @@
1#![crate_type="staticlib"]
2
3extern crate upstream;
4
5#[no_mangle]
6pub extern "C" fn bar() {
7 upstream::foo();
8}
tests/run-make-fulldeps/cross-lang-lto-upstream-rlibs/upstream.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "rlib"]
2
3pub fn foo() {}
tests/run-make-fulldeps/cross-lang-lto/Makefile deleted-57
...@@ -1,57 +0,0 @@
1
2include ../tools.mk
3
4# ignore windows due to libLLVM being present in PATH and the PATH and library path being the same
5# (so fixing it is harder). See #57765 for context
6ifndef IS_WINDOWS
7
8# This test makes sure that the object files we generate are actually
9# LLVM bitcode files (as used by linker LTO plugins) when compiling with
10# -Clinker-plugin-lto.
11
12# this only succeeds for bitcode files
13ASSERT_IS_BITCODE_OBJ=("$(LLVM_BIN_DIR)"/llvm-bcanalyzer $(1))
14EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; "$(LLVM_BIN_DIR)"/llvm-ar x $(1))
15
16BUILD_LIB=$(RUSTC) lib.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1
17BUILD_EXE=$(RUSTC) main.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1 --emit=obj
18
19all: staticlib staticlib-fat-lto staticlib-thin-lto rlib exe cdylib rdylib
20
21staticlib: lib.rs
22 $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib.a
23 $(call EXTRACT_OBJS, liblib.a)
24 for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
25
26staticlib-fat-lto: lib.rs
27 $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-fat-lto.a -Clto=fat
28 $(call EXTRACT_OBJS, liblib-fat-lto.a)
29 for file in $(TMPDIR)/liblib-fat-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
30
31staticlib-thin-lto: lib.rs
32 $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-thin-lto.a -Clto=thin
33 $(call EXTRACT_OBJS, liblib-thin-lto.a)
34 for file in $(TMPDIR)/liblib-thin-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
35
36rlib: lib.rs
37 $(BUILD_LIB) --crate-type=rlib -o $(TMPDIR)/liblib.rlib
38 $(call EXTRACT_OBJS, liblib.rlib)
39 for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
40
41cdylib: lib.rs
42 $(BUILD_LIB) --crate-type=cdylib --emit=obj -o $(TMPDIR)/cdylib.o
43 $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/cdylib.o)
44
45rdylib: lib.rs
46 $(BUILD_LIB) --crate-type=dylib --emit=obj -o $(TMPDIR)/rdylib.o
47 $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/rdylib.o)
48
49exe: lib.rs
50 $(BUILD_EXE) -o $(TMPDIR)/exe.o
51 $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/exe.o)
52
53else
54
55all:
56
57endif
tests/run-make-fulldeps/cross-lang-lto/lib.rs deleted-4
...@@ -1,4 +0,0 @@
1#[no_mangle]
2pub extern "C" fn foo() {
3 println!("abc");
4}
tests/run-make-fulldeps/cross-lang-lto/main.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 println!("Hello World");
3}
tests/run-make-fulldeps/debug-assertions/Makefile deleted-25
...@@ -1,25 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) debug.rs -C debug-assertions=no
5 $(call RUN,debug) good
6 $(RUSTC) debug.rs -C opt-level=0
7 $(call RUN,debug) bad
8 $(RUSTC) debug.rs -C opt-level=1
9 $(call RUN,debug) good
10 $(RUSTC) debug.rs -C opt-level=2
11 $(call RUN,debug) good
12 $(RUSTC) debug.rs -C opt-level=3
13 $(call RUN,debug) good
14 $(RUSTC) debug.rs -C opt-level=s
15 $(call RUN,debug) good
16 $(RUSTC) debug.rs -C opt-level=z
17 $(call RUN,debug) good
18 $(RUSTC) debug.rs -O
19 $(call RUN,debug) good
20 $(RUSTC) debug.rs
21 $(call RUN,debug) bad
22 $(RUSTC) debug.rs -C debug-assertions=yes -O
23 $(call RUN,debug) bad
24 $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1
25 $(call RUN,debug) bad
tests/run-make-fulldeps/debug-assertions/debug.rs deleted-33
...@@ -1,33 +0,0 @@
1#![feature(rustc_attrs)]
2#![deny(warnings)]
3
4use std::env;
5use std::thread;
6
7fn main() {
8 let should_fail = env::args().nth(1) == Some("bad".to_string());
9
10 assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail);
11 assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail);
12 assert_eq!(thread::spawn(overflow).join().is_err(), should_fail);
13}
14
15fn debug_assert_eq() {
16 let mut hit1 = false;
17 let mut hit2 = false;
18 debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 });
19 assert!(!hit1);
20 assert!(!hit2);
21}
22
23fn debug_assert() {
24 let mut hit = false;
25 debug_assert!({ hit = true; false });
26 assert!(!hit);
27}
28
29fn overflow() {
30 fn add(a: u8, b: u8) -> u8 { a + b }
31
32 add(200u8, 200u8);
33}
tests/run-make-fulldeps/dep-info-doesnt-run-much/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --emit dep-info
tests/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1// We're only emitting dep info, so we shouldn't be running static analysis to
2// figure out that this program is erroneous.
3fn main() {
4 let a: u8 = "a";
5}
tests/run-make-fulldeps/dep-info-spaces/Makefile deleted-19
...@@ -1,19 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4# ignore-freebsd
5# FIXME: (windows: see `../dep-info/Makefile`)
6
7all:
8 cp lib.rs $(TMPDIR)/
9 cp 'foo foo.rs' $(TMPDIR)/
10 cp bar.rs $(TMPDIR)/
11 $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs
12 sleep 1
13 touch $(TMPDIR)/'foo foo.rs'
14 -rm -f $(TMPDIR)/done
15 $(MAKE) -drf Makefile.foo
16 rm $(TMPDIR)/done
17 pwd
18 $(MAKE) -drf Makefile.foo
19 rm $(TMPDIR)/done && exit 1 || exit 0
tests/run-make-fulldeps/dep-info-spaces/Makefile.foo deleted-7
...@@ -1,7 +0,0 @@
1LIB := $(shell $(RUSTC) --print file-names --crate-type=lib $(TMPDIR)/lib.rs)
2
3$(TMPDIR)/$(LIB):
4 $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs
5 touch $(TMPDIR)/done
6
7-include $(TMPDIR)/lib.d
tests/run-make-fulldeps/dep-info-spaces/bar.rs deleted-1
...@@ -1 +0,0 @@
1pub fn bar() {}
tests/run-make-fulldeps/dep-info-spaces/foo foo.rs deleted-1
...@@ -1 +0,0 @@
1pub fn foo() {}
tests/run-make-fulldeps/dep-info-spaces/lib.rs deleted-4
...@@ -1,4 +0,0 @@
1#[path="foo foo.rs"]
2pub mod foo;
3
4pub mod bar;
tests/run-make-fulldeps/dep-info/Makefile deleted-25
...@@ -1,25 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4# ignore-freebsd
5# FIXME: on windows `rustc --dep-info` produces Makefile dependency with
6# windows native paths (e.g. `c:\path\to\libfoo.a`)
7# but msys make seems to fail to recognize such paths, so test fails.
8
9all:
10 cp *.rs $(TMPDIR)
11 $(RUSTC) --emit dep-info,link --crate-type=lib $(TMPDIR)/lib.rs
12 sleep 2
13 touch $(TMPDIR)/foo.rs
14 -rm -f $(TMPDIR)/done
15 $(MAKE) -drf Makefile.foo
16 sleep 2
17 rm $(TMPDIR)/done
18 pwd
19 $(MAKE) -drf Makefile.foo
20 rm $(TMPDIR)/done && exit 1 || exit 0
21
22 # When a source file is deleted `make` should still work
23 rm $(TMPDIR)/bar.rs
24 cp $(TMPDIR)/lib2.rs $(TMPDIR)/lib.rs
25 $(MAKE) -drf Makefile.foo
tests/run-make-fulldeps/dep-info/Makefile.foo deleted-7
...@@ -1,7 +0,0 @@
1LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs)
2
3$(TMPDIR)/$(LIB):
4 $(RUSTC) --emit dep-info,link --crate-type=lib lib.rs
5 touch $(TMPDIR)/done
6
7-include $(TMPDIR)/foo.d
tests/run-make-fulldeps/dep-info/bar.rs deleted-1
...@@ -1 +0,0 @@
1pub fn bar() {}
tests/run-make-fulldeps/dep-info/foo.rs deleted-1
...@@ -1 +0,0 @@
1pub fn foo() {}
tests/run-make-fulldeps/dep-info/lib.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_name = "foo"]
2
3pub mod foo;
4pub mod bar;
tests/run-make-fulldeps/dep-info/lib2.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_name = "foo"]
2
3pub mod foo;
tests/run-make-fulldeps/doctests-keep-binaries/Makefile deleted-21
...@@ -1,21 +0,0 @@
1include ../../run-make-fulldeps/tools.mk
2
3# Check that valid binaries are persisted by running them, regardless of whether the --run or --no-run option is used.
4
5all: run no_run
6
7run:
8 mkdir -p $(TMPDIR)/doctests
9 $(RUSTC) --crate-type rlib t.rs
10 $(RUSTDOC) -Zunstable-options --test --persist-doctests $(TMPDIR)/doctests --extern t=$(TMPDIR)/libt.rlib t.rs
11 $(TMPDIR)/doctests/t_rs_2_0/rust_out
12 $(TMPDIR)/doctests/t_rs_8_0/rust_out
13 rm -rf $(TMPDIR)/doctests
14
15no_run:
16 mkdir -p $(TMPDIR)/doctests
17 $(RUSTC) --crate-type rlib t.rs
18 $(RUSTDOC) -Zunstable-options --test --persist-doctests $(TMPDIR)/doctests --extern t=$(TMPDIR)/libt.rlib t.rs --no-run
19 $(TMPDIR)/doctests/t_rs_2_0/rust_out
20 $(TMPDIR)/doctests/t_rs_8_0/rust_out
21 rm -rf $(TMPDIR)/doctests
tests/run-make-fulldeps/doctests-keep-binaries/t.rs deleted-11
...@@ -1,11 +0,0 @@
1/// Fungle the foople.
2/// ```
3/// t::foople();
4/// ```
5pub fn foople() {}
6
7/// Flomble the florp
8/// ```
9/// t::florp();
10/// ```
11pub fn florp() {}
tests/run-make-fulldeps/duplicate-output-flavors/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --crate-type=rlib foo.rs
5 $(RUSTC) --crate-type=rlib,rlib foo.rs
tests/run-make-fulldeps/duplicate-output-flavors/foo.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "rlib"]
tests/run-make-fulldeps/dylib-chain/Makefile deleted-12
...@@ -1,12 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) m1.rs -C prefer-dynamic
5 $(RUSTC) m2.rs -C prefer-dynamic
6 $(RUSTC) m3.rs -C prefer-dynamic
7 $(RUSTC) m4.rs
8 $(call RUN,m4)
9 $(call REMOVE_DYLIBS,m1)
10 $(call REMOVE_DYLIBS,m2)
11 $(call REMOVE_DYLIBS,m3)
12 $(call FAIL,m4)
tests/run-make-fulldeps/dylib-chain/m1.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "dylib"]
2pub fn m1() {}
tests/run-make-fulldeps/dylib-chain/m2.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "dylib"]
2extern crate m1;
3
4pub fn m2() { m1::m1() }
tests/run-make-fulldeps/dylib-chain/m3.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "dylib"]
2extern crate m2;
3
4pub fn m3() { m2::m2() }
tests/run-make-fulldeps/dylib-chain/m4.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate m3;
2
3fn main() { m3::m3() }
tests/run-make-fulldeps/emit-stack-sizes/Makefile deleted-12
...@@ -1,12 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4# ignore-macos
5#
6# This feature only works when the output object format is ELF so we ignore
7# macOS and Windows
8
9# check that the .stack_sizes section is generated
10all:
11 $(RUSTC) -C opt-level=3 -Z emit-stack-sizes --emit=obj foo.rs
12 size -A $(TMPDIR)/foo.o | $(CGREP) .stack_sizes
tests/run-make-fulldeps/emit-stack-sizes/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "lib"]
2
3pub fn foo() {}
tests/run-make-fulldeps/emit/Makefile deleted-21
...@@ -1,21 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
5 $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
6 $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
7 $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
8 $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
9 $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
10 $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
11 $(call RUN,test-26235) || exit 1
12 $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
13 $(call RUN,test-26235) || exit 1
14 $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
15 $(call RUN,test-26235) || exit 1
16 $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
17 $(call RUN,test-26235) || exit 1
18 $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
19 $(call RUN,test-26235) || exit 1
20 $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
21 $(call RUN,test-26235) || exit 1
tests/run-make-fulldeps/emit/test-24876.rs deleted-9
...@@ -1,9 +0,0 @@
1// Checks for issue #24876
2
3fn main() {
4 let mut v = 0;
5 for i in 0..0 {
6 v += i;
7 }
8 println!("{}", v)
9}
tests/run-make-fulldeps/emit/test-26235.rs deleted-46
...@@ -1,46 +0,0 @@
1// Checks for issue #26235
2
3fn main() {
4 use std::thread;
5
6 type Key = u32;
7 const NUM_THREADS: usize = 2;
8
9 #[derive(Clone,Copy)]
10 struct Stats<S> {
11 upsert: S,
12 delete: S,
13 insert: S,
14 update: S
15 };
16
17 impl<S> Stats<S> where S: Copy {
18 fn dot<B, F, T>(self, s: Stats<T>, f: F) -> Stats<B> where F: Fn(S, T) -> B {
19 let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self;
20 let Stats { upsert: u2, delete: d2, insert: i2, update: p2 } = s;
21 Stats { upsert: f(u1, u2), delete: f(d1, d2), insert: f(i1, i2), update: f(p1, p2) }
22 }
23
24 fn new(init: S) -> Self {
25 Stats { upsert: init, delete: init, insert: init, update: init }
26 }
27 }
28
29 fn make_threads() -> Vec<thread::JoinHandle<()>> {
30 let mut t = Vec::with_capacity(NUM_THREADS);
31 for _ in 0..NUM_THREADS {
32 t.push(thread::spawn(move || {}));
33 }
34 t
35 }
36
37 let stats = [Stats::new(0); NUM_THREADS];
38 make_threads();
39
40 {
41 let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold(
42 Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y)));
43 println!("upserts: {}, deletes: {}, inserts: {}, updates: {}",
44 upsert, delete, insert, update);
45 }
46}
tests/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --crate-type staticlib
5 $(RUSTC) bar.rs 2>&1 | $(CGREP) "found staticlib"
tests/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::foo();
5}
tests/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs deleted-1
...@@ -1 +0,0 @@
1pub fn foo() {}
tests/run-make-fulldeps/error-writing-dependencies/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all:
4 # Let's get a nice error message
5 $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \
6 $(CGREP) "error writing dependencies"
7 # Make sure the filename shows up
8 $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | $(CGREP) "baz"
tests/run-make-fulldeps/error-writing-dependencies/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/exit-code/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) success.rs; [ $$? -eq 0 ]
5 $(RUSTC) --invalid-arg-foo; [ $$? -eq 1 ]
6 $(RUSTC) compile-error.rs; [ $$? -eq 1 ]
7 $(RUSTC) -Ztreat-err-as-bug compile-error.rs; [ $$? -eq 101 ]
8 $(RUSTDOC) -o $(TMPDIR)/exit-code success.rs; [ $$? -eq 0 ]
9 $(RUSTDOC) --invalid-arg-foo; [ $$? -eq 1 ]
10 $(RUSTDOC) compile-error.rs; [ $$? -eq 1 ]
11 $(RUSTDOC) lint-failure.rs; [ $$? -eq 1 ]
tests/run-make-fulldeps/exit-code/compile-error.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 compile_error!("kaboom");
3}
tests/run-make-fulldeps/exit-code/lint-failure.rs deleted-6
...@@ -1,6 +0,0 @@
1#![deny(broken_intra_doc_links)]
2
3/// [intradoc::failure]
4pub fn main() {
5 println!("Hello, world!");
6}
tests/run-make-fulldeps/exit-code/success.rs deleted-4
...@@ -1,4 +0,0 @@
1/// Main function
2fn main() {
3 println!("Hello, world!");
4}
tests/run-make-fulldeps/extern-diff-internal-name/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) lib.rs
5 $(RUSTC) test.rs --extern foo=$(TMPDIR)/libbar.rlib
tests/run-make-fulldeps/extern-diff-internal-name/lib.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_name = "bar"]
2#![crate_type = "rlib"]
tests/run-make-fulldeps/extern-diff-internal-name/test.rs deleted-5
...@@ -1,5 +0,0 @@
1#[macro_use]
2extern crate foo;
3
4fn main() {
5}
tests/run-make-fulldeps/extern-flag-disambiguates/Makefile deleted-25
...@@ -1,25 +0,0 @@
1include ../tools.mk
2
3# Attempt to build this dependency tree:
4#
5# A.1 A.2
6# |\ |
7# | \ |
8# B \ C
9# \ | /
10# \|/
11# D
12#
13# Note that A.1 and A.2 are crates with the same name.
14
15all:
16 $(RUSTC) -C metadata=1 -C extra-filename=-1 a.rs
17 $(RUSTC) -C metadata=2 -C extra-filename=-2 a.rs
18 $(RUSTC) b.rs --extern a=$(TMPDIR)/liba-1.rlib
19 $(RUSTC) c.rs --extern a=$(TMPDIR)/liba-2.rlib
20 @echo before
21 $(RUSTC) --cfg before d.rs --extern a=$(TMPDIR)/liba-1.rlib
22 $(call RUN,d)
23 @echo after
24 $(RUSTC) --cfg after d.rs --extern a=$(TMPDIR)/liba-1.rlib
25 $(call RUN,d)
tests/run-make-fulldeps/extern-flag-disambiguates/a.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_name = "a"]
2#![crate_type = "rlib"]
3
4static FOO: usize = 3;
5
6pub fn token() -> &'static usize { &FOO }
tests/run-make-fulldeps/extern-flag-disambiguates/b.rs deleted-9
...@@ -1,9 +0,0 @@
1#![crate_name = "b"]
2#![crate_type = "rlib"]
3
4extern crate a;
5
6static FOO: usize = 3;
7
8pub fn token() -> &'static usize { &FOO }
9pub fn a_token() -> &'static usize { a::token() }
tests/run-make-fulldeps/extern-flag-disambiguates/c.rs deleted-9
...@@ -1,9 +0,0 @@
1#![crate_name = "c"]
2#![crate_type = "rlib"]
3
4extern crate a;
5
6static FOO: usize = 3;
7
8pub fn token() -> &'static usize { &FOO }
9pub fn a_token() -> &'static usize { a::token() }
tests/run-make-fulldeps/extern-flag-disambiguates/d.rs deleted-11
...@@ -1,11 +0,0 @@
1#[cfg(before)] extern crate a;
2extern crate b;
3extern crate c;
4#[cfg(after)] extern crate a;
5
6fn t(a: &'static usize) -> usize { a as *const _ as usize }
7
8fn main() {
9 assert_eq!(t(a::token()), t(b::a_token()));
10 assert!(t(a::token()) != t(c::a_token()));
11}
tests/run-make-fulldeps/extern-flag-fun/Makefile deleted-19
...@@ -1,19 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) bar.rs --crate-type=rlib
5 $(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a
6 $(RUSTC) bar-alt.rs --crate-type=rlib
7 $(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0
8 $(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0
9 $(RUSTC) foo.rs \
10 --extern bar=$(TMPDIR)/libbar.rlib \
11 --extern bar=$(TMPDIR)/libbar-alt.rlib \
12 && exit 1 || exit 0
13 $(RUSTC) foo.rs \
14 --extern bar=$(TMPDIR)/libbar.rlib \
15 --extern bar=$(TMPDIR)/libbar-a.rlib
16 $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib
17 # Try to be sneaky and load a private crate from with a non-private name.
18 $(RUSTC) rustc.rs -Zforce-unstable-if-unmarked --crate-type=rlib
19 $(RUSTC) gated_unstable.rs --extern alloc=$(TMPDIR)/librustc.rlib 2>&1 | $(CGREP) 'rustc_private'
tests/run-make-fulldeps/extern-flag-fun/bar-alt.rs deleted-1
...@@ -1 +0,0 @@
1pub fn f() {}
tests/run-make-fulldeps/extern-flag-fun/bar.rs deleted-1
...@@ -1 +0,0 @@
1// intentionally empty
tests/run-make-fulldeps/extern-flag-fun/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate bar;
2
3fn main() {}
tests/run-make-fulldeps/extern-flag-fun/gated_unstable.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate alloc;
2
3fn main() {}
tests/run-make-fulldeps/extern-flag-fun/rustc.rs deleted-1
...@@ -1 +0,0 @@
1pub fn foo() {}
tests/run-make-fulldeps/extern-flag-pathless/Makefile deleted-18
...@@ -1,18 +0,0 @@
1include ../tools.mk
2
3# Test mixing pathless --extern with paths.
4
5all:
6 $(RUSTC) bar-static.rs --crate-name=bar --crate-type=rlib
7 $(RUSTC) bar-dynamic.rs --crate-name=bar --crate-type=dylib -C prefer-dynamic
8 # rlib preferred over dylib
9 $(RUSTC) foo.rs --extern bar
10 $(call RUN,foo) | $(CGREP) 'static'
11 $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar
12 $(call RUN,foo) | $(CGREP) 'static'
13 # explicit --extern overrides pathless
14 $(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar
15 $(call RUN,foo) | $(CGREP) 'dynamic'
16 # prefer-dynamic does what it says
17 $(RUSTC) foo.rs --extern bar -C prefer-dynamic
18 $(call RUN,foo) | $(CGREP) 'dynamic'
tests/run-make-fulldeps/extern-flag-pathless/bar-dynamic.rs deleted-3
...@@ -1,3 +0,0 @@
1pub fn f() {
2 println!("dynamic");
3}
tests/run-make-fulldeps/extern-flag-pathless/bar-static.rs deleted-3
...@@ -1,3 +0,0 @@
1pub fn f() {
2 println!("static");
3}
tests/run-make-fulldeps/extern-flag-pathless/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 bar::f();
3}
tests/run-make-fulldeps/extern-flag-rename-transitive/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs
5 $(RUSTC) bar.rs
6 $(RUSTC) baz.rs --extern a=$(TMPDIR)/libfoo.rlib
7
tests/run-make-fulldeps/extern-flag-rename-transitive/bar.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "rlib"]
2
3extern crate foo;
tests/run-make-fulldeps/extern-flag-rename-transitive/baz.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "rlib"]
2
3extern crate a;
4extern crate bar;
tests/run-make-fulldeps/extern-flag-rename-transitive/foo.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "rlib"]
tests/run-make-fulldeps/extern-fn-generic/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,test)
4 $(RUSTC) testcrate.rs
5 $(RUSTC) test.rs
6 $(call RUN,test) || exit 1
tests/run-make-fulldeps/extern-fn-generic/test.c deleted-16
...@@ -1,16 +0,0 @@
1#include <stdint.h>
2
3typedef struct TestStruct {
4 uint8_t x;
5 int32_t y;
6} TestStruct;
7
8typedef int callback(TestStruct s);
9
10uint32_t call(callback *c) {
11 TestStruct s;
12 s.x = 'a';
13 s.y = 3;
14
15 return c(s);
16}
tests/run-make-fulldeps/extern-fn-generic/test.rs deleted-20
...@@ -1,20 +0,0 @@
1extern crate testcrate;
2
3extern "C" fn bar<T>(ts: testcrate::TestStruct<T>) -> T {
4 ts.y
5}
6
7#[link(name = "test", kind = "static")]
8extern "C" {
9 fn call(c: extern "C" fn(testcrate::TestStruct<i32>) -> i32) -> i32;
10}
11
12fn main() {
13 // Let's test calling it cross crate
14 let back = unsafe { testcrate::call(testcrate::foo::<i32>) };
15 assert_eq!(3, back);
16
17 // And just within this crate
18 let back = unsafe { call(bar::<i32>) };
19 assert_eq!(3, back);
20}
tests/run-make-fulldeps/extern-fn-generic/testcrate.rs deleted-16
...@@ -1,16 +0,0 @@
1#![crate_type = "lib"]
2
3#[repr(C)]
4pub struct TestStruct<T> {
5 pub x: u8,
6 pub y: T,
7}
8
9pub extern "C" fn foo<T>(ts: TestStruct<T>) -> T {
10 ts.y
11}
12
13#[link(name = "test", kind = "static")]
14extern "C" {
15 pub fn call(c: extern "C" fn(TestStruct<i32>) -> i32) -> i32;
16}
tests/run-make-fulldeps/extern-fn-mangle/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,test)
4 $(RUSTC) test.rs
5 $(call RUN,test) || exit 1
tests/run-make-fulldeps/extern-fn-mangle/test.c deleted-8
...@@ -1,8 +0,0 @@
1#include <stdint.h>
2
3uint32_t foo();
4uint32_t bar();
5
6uint32_t add() {
7 return foo() + bar();
8}
tests/run-make-fulldeps/extern-fn-mangle/test.rs deleted-19
...@@ -1,19 +0,0 @@
1#[no_mangle]
2pub extern "C" fn foo() -> i32 {
3 3
4}
5
6#[no_mangle]
7pub extern "C" fn bar() -> i32 {
8 5
9}
10
11#[link(name = "test", kind = "static")]
12extern "C" {
13 fn add() -> i32;
14}
15
16fn main() {
17 let back = unsafe { add() };
18 assert_eq!(8, back);
19}
tests/run-make-fulldeps/extern-fn-reachable/Makefile deleted-25
...@@ -1,25 +0,0 @@
1include ../tools.mk
2
3# ignore-windows-msvc
4
5NM=nm -D
6
7ifeq ($(UNAME),Darwin)
8NM=nm -gU
9endif
10
11ifdef IS_WINDOWS
12NM=nm -g
13endif
14
15# This overrides the LD_LIBRARY_PATH for RUN
16TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR)
17
18all:
19 $(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so -C prefer-dynamic
20
21 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun1)" -eq "1" ]
22 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun2)" -eq "1" ]
23 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun3)" -eq "1" ]
24 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun4)" -eq "1" ]
25 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun5)" -eq "1" ]
tests/run-make-fulldeps/extern-fn-reachable/dylib.rs deleted-14
...@@ -1,14 +0,0 @@
1#![crate_type = "dylib"]
2#![allow(dead_code)]
3
4#[no_mangle] pub extern "C" fn fun1() {}
5#[no_mangle] extern "C" fn fun2() {}
6
7mod foo {
8 #[no_mangle] pub extern "C" fn fun3() {}
9}
10pub mod bar {
11 #[no_mangle] pub extern "C" fn fun4() {}
12}
13
14#[no_mangle] pub fn fun5() {}
tests/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,test)
4 $(RUSTC) test.rs
5 $(call RUN,test) || exit 1
tests/run-make-fulldeps/extern-fn-struct-passing-abi/test.c deleted-314
...@@ -1,314 +0,0 @@
1#include <assert.h>
2#include <stdint.h>
3
4struct Rect {
5 int32_t a;
6 int32_t b;
7 int32_t c;
8 int32_t d;
9};
10
11struct BiggerRect {
12 struct Rect s;
13 int32_t a;
14 int32_t b;
15};
16
17struct FloatRect {
18 int32_t a;
19 int32_t b;
20 double c;
21};
22
23struct Huge {
24 int32_t a;
25 int32_t b;
26 int32_t c;
27 int32_t d;
28 int32_t e;
29};
30
31struct FloatPoint {
32 double x;
33 double y;
34};
35
36struct FloatOne {
37 double x;
38};
39
40struct IntOdd {
41 int8_t a;
42 int8_t b;
43 int8_t c;
44};
45
46// System V x86_64 ABI:
47// a, b, c, d, e should be in registers
48// s should be byval pointer
49//
50// Win64 ABI:
51// a, b, c, d should be in registers
52// e should be on the stack
53// s should be byval pointer
54void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Rect s) {
55 assert(a == 1);
56 assert(b == 2);
57 assert(c == 3);
58 assert(d == 4);
59 assert(e == 5);
60 assert(s.a == 553);
61 assert(s.b == 554);
62 assert(s.c == 555);
63 assert(s.d == 556);
64}
65
66// System V x86_64 ABI:
67// a, b, c, d, e, f should be in registers
68// s should be byval pointer on the stack
69//
70// Win64 ABI:
71// a, b, c, d should be in registers
72// e, f should be on the stack
73// s should be byval pointer on the stack
74void byval_many_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e,
75 int32_t f, struct Rect s) {
76 assert(a == 1);
77 assert(b == 2);
78 assert(c == 3);
79 assert(d == 4);
80 assert(e == 5);
81 assert(f == 6);
82 assert(s.a == 553);
83 assert(s.b == 554);
84 assert(s.c == 555);
85 assert(s.d == 556);
86}
87
88// System V x86_64 ABI:
89// a, b, c, d, e, f, g should be in sse registers
90// s should be split across 2 registers
91// t should be byval pointer
92//
93// Win64 ABI:
94// a, b, c, d should be in sse registers
95// e, f, g should be on the stack
96// s should be on the stack (treated as 2 i64's)
97// t should be on the stack (treated as an i64 and a double)
98void byval_rect_floats(float a, float b, double c, float d, float e,
99 float f, double g, struct Rect s, struct FloatRect t) {
100 assert(a == 1.);
101 assert(b == 2.);
102 assert(c == 3.);
103 assert(d == 4.);
104 assert(e == 5.);
105 assert(f == 6.);
106 assert(g == 7.);
107 assert(s.a == 553);
108 assert(s.b == 554);
109 assert(s.c == 555);
110 assert(s.d == 556);
111 assert(t.a == 3489);
112 assert(t.b == 3490);
113 assert(t.c == 8.);
114}
115
116// System V x86_64 ABI:
117// a, b, d, e, f should be in registers
118// c passed via sse registers
119// s should be byval pointer
120//
121// Win64 ABI:
122// a, b, d should be in registers
123// c passed via sse registers
124// e, f should be on the stack
125// s should be byval pointer
126void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d,
127 int32_t e, int32_t f, struct Rect s) {
128 assert(a == 1);
129 assert(b == 2);
130 assert(c == 3.);
131 assert(d == 4);
132 assert(e == 5);
133 assert(f == 6);
134 assert(s.a == 553);
135 assert(s.b == 554);
136 assert(s.c == 555);
137 assert(s.d == 556);
138}
139
140// System V x86_64 ABI:
141// a, b, d, e, f should be byval pointer (on the stack)
142// g passed via register (fixes #41375)
143//
144// Win64 ABI:
145// a, b, d, e, f, g should be byval pointer
146void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c,
147 struct Huge d, struct Huge e, struct Huge f,
148 struct Rect g) {
149 assert(g.a == 123);
150 assert(g.b == 456);
151 assert(g.c == 789);
152 assert(g.d == 420);
153}
154
155// System V x86_64 & Win64 ABI:
156// a, b should be in registers
157// s should be split across 2 integer registers
158void split_rect(int32_t a, int32_t b, struct Rect s) {
159 assert(a == 1);
160 assert(b == 2);
161 assert(s.a == 553);
162 assert(s.b == 554);
163 assert(s.c == 555);
164 assert(s.d == 556);
165}
166
167// System V x86_64 & Win64 ABI:
168// a, b should be in sse registers
169// s should be split across integer & sse registers
170void split_rect_floats(float a, float b, struct FloatRect s) {
171 assert(a == 1.);
172 assert(b == 2.);
173 assert(s.a == 3489);
174 assert(s.b == 3490);
175 assert(s.c == 8.);
176}
177
178// System V x86_64 ABI:
179// a, b, d, f should be in registers
180// c, e passed via sse registers
181// s should be split across 2 registers
182//
183// Win64 ABI:
184// a, b, d should be in registers
185// c passed via sse registers
186// e, f should be on the stack
187// s should be on the stack (treated as 2 i64's)
188void split_rect_with_floats(int32_t a, int32_t b, float c,
189 int32_t d, float e, int32_t f, struct Rect s) {
190 assert(a == 1);
191 assert(b == 2);
192 assert(c == 3.);
193 assert(d == 4);
194 assert(e == 5.);
195 assert(f == 6);
196 assert(s.a == 553);
197 assert(s.b == 554);
198 assert(s.c == 555);
199 assert(s.d == 556);
200}
201
202// System V x86_64 & Win64 ABI:
203// a, b, c should be in registers
204// s should be split across 2 registers
205// t should be a byval pointer
206void split_and_byval_rect(int32_t a, int32_t b, int32_t c, struct Rect s, struct Rect t) {
207 assert(a == 1);
208 assert(b == 2);
209 assert(c == 3);
210 assert(s.a == 553);
211 assert(s.b == 554);
212 assert(s.c == 555);
213 assert(s.d == 556);
214 assert(t.a == 553);
215 assert(t.b == 554);
216 assert(t.c == 555);
217 assert(t.d == 556);
218}
219
220// System V x86_64 & Win64 ABI:
221// a, b should in registers
222// s and return should be split across 2 registers
223struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) {
224 assert(a == 1);
225 assert(b == 2);
226 assert(s.a == 553);
227 assert(s.b == 554);
228 assert(s.c == 555);
229 assert(s.d == 556);
230 return s;
231}
232
233// System V x86_64 & Win64 ABI:
234// a, b, c, d should be in registers
235// return should be in a hidden sret pointer
236// s should be a byval pointer
237struct BiggerRect sret_byval_struct(int32_t a, int32_t b, int32_t c, int32_t d, struct Rect s) {
238 assert(a == 1);
239 assert(b == 2);
240 assert(c == 3);
241 assert(d == 4);
242 assert(s.a == 553);
243 assert(s.b == 554);
244 assert(s.c == 555);
245 assert(s.d == 556);
246
247 struct BiggerRect t;
248 t.s = s; t.a = 27834; t.b = 7657;
249 return t;
250}
251
252// System V x86_64 & Win64 ABI:
253// a, b should be in registers
254// return should be in a hidden sret pointer
255// s should be split across 2 registers
256struct BiggerRect sret_split_struct(int32_t a, int32_t b, struct Rect s) {
257 assert(a == 1);
258 assert(b == 2);
259 assert(s.a == 553);
260 assert(s.b == 554);
261 assert(s.c == 555);
262 assert(s.d == 556);
263
264 struct BiggerRect t;
265 t.s = s; t.a = 27834; t.b = 7657;
266 return t;
267}
268
269// System V x86_64 & Win64 ABI:
270// s should be byval pointer (since sizeof(s) > 16)
271// return should in a hidden sret pointer
272struct Huge huge_struct(struct Huge s) {
273 assert(s.a == 5647);
274 assert(s.b == 5648);
275 assert(s.c == 5649);
276 assert(s.d == 5650);
277 assert(s.e == 5651);
278
279 return s;
280}
281
282// System V x86_64 ABI:
283// p should be in registers
284// return should be in registers
285//
286// Win64 ABI and 64-bit PowerPC ELFv1 ABI:
287// p should be a byval pointer
288// return should be in a hidden sret pointer
289struct FloatPoint float_point(struct FloatPoint p) {
290 assert(p.x == 5.);
291 assert(p.y == -3.);
292
293 return p;
294}
295
296// 64-bit PowerPC ELFv1 ABI:
297// f1 should be in a register
298// return should be in a hidden sret pointer
299struct FloatOne float_one(struct FloatOne f1) {
300 assert(f1.x == 7.);
301
302 return f1;
303}
304
305// 64-bit PowerPC ELFv1 ABI:
306// i should be in the least-significant bits of a register
307// return should be in a hidden sret pointer
308struct IntOdd int_odd(struct IntOdd i) {
309 assert(i.a == 1);
310 assert(i.b == 2);
311 assert(i.c == 3);
312
313 return i;
314}
tests/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs deleted-138
...@@ -1,138 +0,0 @@
1// Passing structs via FFI should work regardless of whether
2// they get passed in multiple registers, byval pointers or the stack
3
4#[derive(Clone, Copy, Debug, PartialEq)]
5#[repr(C)]
6struct Rect {
7 a: i32,
8 b: i32,
9 c: i32,
10 d: i32,
11}
12
13#[derive(Clone, Copy, Debug, PartialEq)]
14#[repr(C)]
15struct BiggerRect {
16 s: Rect,
17 a: i32,
18 b: i32,
19}
20
21#[derive(Clone, Copy, Debug, PartialEq)]
22#[repr(C)]
23struct FloatRect {
24 a: i32,
25 b: i32,
26 c: f64,
27}
28
29#[derive(Clone, Copy, Debug, PartialEq)]
30#[repr(C)]
31struct Huge {
32 a: i32,
33 b: i32,
34 c: i32,
35 d: i32,
36 e: i32,
37}
38
39#[derive(Clone, Copy, Debug, PartialEq)]
40#[repr(C)]
41struct FloatPoint {
42 x: f64,
43 y: f64,
44}
45
46#[derive(Clone, Copy, Debug, PartialEq)]
47#[repr(C)]
48struct FloatOne {
49 x: f64,
50}
51
52#[derive(Clone, Copy, Debug, PartialEq)]
53#[repr(C)]
54struct IntOdd {
55 a: i8,
56 b: i8,
57 c: i8,
58}
59
60#[link(name = "test", kind = "static")]
61extern "C" {
62 fn byval_rect(a: i32, b: i32, c: i32, d: i32, e: i32, s: Rect);
63
64 fn byval_many_rect(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, s: Rect);
65
66 fn byval_rect_floats(
67 a: f32,
68 b: f32,
69 c: f64,
70 d: f32,
71 e: f32,
72 f: f32,
73 g: f64,
74 s: Rect,
75 t: FloatRect,
76 );
77
78 fn byval_rect_with_float(a: i32, b: i32, c: f32, d: i32, e: i32, f: i32, s: Rect);
79
80 fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect);
81
82 fn split_rect(a: i32, b: i32, s: Rect);
83
84 fn split_rect_floats(a: f32, b: f32, s: FloatRect);
85
86 fn split_rect_with_floats(a: i32, b: i32, c: f32, d: i32, e: f32, f: i32, s: Rect);
87
88 fn split_and_byval_rect(a: i32, b: i32, c: i32, s: Rect, t: Rect);
89
90 fn split_ret_byval_struct(a: i32, b: i32, s: Rect) -> Rect;
91
92 fn sret_byval_struct(a: i32, b: i32, c: i32, d: i32, s: Rect) -> BiggerRect;
93
94 fn sret_split_struct(a: i32, b: i32, s: Rect) -> BiggerRect;
95
96 fn huge_struct(s: Huge) -> Huge;
97
98 fn float_point(p: FloatPoint) -> FloatPoint;
99
100 fn float_one(f: FloatOne) -> FloatOne;
101
102 fn int_odd(i: IntOdd) -> IntOdd;
103}
104
105fn main() {
106 let s = Rect { a: 553, b: 554, c: 555, d: 556 };
107 let t = BiggerRect { s: s, a: 27834, b: 7657 };
108 let u = FloatRect { a: 3489, b: 3490, c: 8. };
109 let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 };
110 let p = FloatPoint { x: 5., y: -3. };
111 let f1 = FloatOne { x: 7. };
112 let i = IntOdd { a: 1, b: 2, c: 3 };
113
114 unsafe {
115 byval_rect(1, 2, 3, 4, 5, s);
116 byval_many_rect(1, 2, 3, 4, 5, 6, s);
117 byval_rect_floats(1., 2., 3., 4., 5., 6., 7., s, u);
118 byval_rect_with_float(1, 2, 3.0, 4, 5, 6, s);
119 byval_rect_with_many_huge(v, v, v, v, v, v, Rect { a: 123, b: 456, c: 789, d: 420 });
120 split_rect(1, 2, s);
121 split_rect_floats(1., 2., u);
122 split_rect_with_floats(1, 2, 3.0, 4, 5.0, 6, s);
123 split_and_byval_rect(1, 2, 3, s, s);
124 split_rect(1, 2, s);
125 assert_eq!(huge_struct(v), v);
126 assert_eq!(split_ret_byval_struct(1, 2, s), s);
127 assert_eq!(sret_byval_struct(1, 2, 3, 4, s), t);
128 assert_eq!(sret_split_struct(1, 2, s), t);
129 assert_eq!(float_point(p), p);
130 assert_eq!(int_odd(i), i);
131
132 // MSVC/GCC/Clang are not consistent in the ABI of single-float aggregates.
133 // x86_64: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82028
134 // i686: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82041
135 #[cfg(not(all(windows, target_env = "gnu")))]
136 assert_eq!(float_one(f1), f1);
137 }
138}
tests/run-make-fulldeps/extern-fn-with-extern-types/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,ctest)
4 $(RUSTC) test.rs
5 $(call RUN,test) || exit 1
tests/run-make-fulldeps/extern-fn-with-extern-types/ctest.c deleted-16
...@@ -1,16 +0,0 @@
1#include <stdio.h>
2#include <stdint.h>
3
4typedef struct data {
5 uint32_t magic;
6} data;
7
8data* data_create(uint32_t magic) {
9 static data d;
10 d.magic = magic;
11 return &d;
12}
13
14uint32_t data_get(data* p) {
15 return p->magic;
16}
tests/run-make-fulldeps/extern-fn-with-extern-types/test.rs deleted-17
...@@ -1,17 +0,0 @@
1#![feature(extern_types)]
2
3#[link(name = "ctest", kind = "static")]
4extern "C" {
5 type data;
6
7 fn data_create(magic: u32) -> *mut data;
8 fn data_get(data: *mut data) -> u32;
9}
10
11const MAGIC: u32 = 0xdeadbeef;
12fn main() {
13 unsafe {
14 let data = data_create(MAGIC);
15 assert_eq!(data_get(data), MAGIC);
16 }
17}
tests/run-make-fulldeps/extern-fn-with-packed-struct/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,test)
4 $(RUSTC) test.rs
5 $(call RUN,test) || exit 1
tests/run-make-fulldeps/extern-fn-with-packed-struct/test.c deleted-26
...@@ -1,26 +0,0 @@
1// Pragma needed cause of gcc bug on windows: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
2
3#include <assert.h>
4
5#ifdef _MSC_VER
6#pragma pack(push,1)
7struct Foo {
8 char a;
9 short b;
10 char c;
11};
12#else
13#pragma pack(1)
14struct __attribute__((packed)) Foo {
15 char a;
16 short b;
17 char c;
18};
19#endif
20
21struct Foo foo(struct Foo foo) {
22 assert(foo.a == 1);
23 assert(foo.b == 2);
24 assert(foo.c == 3);
25 return foo;
26}
tests/run-make-fulldeps/extern-fn-with-packed-struct/test.rs deleted-20
...@@ -1,20 +0,0 @@
1#[repr(C, packed)]
2#[derive(Copy, Clone, Debug, PartialEq)]
3struct Foo {
4 a: i8,
5 b: i16,
6 c: i8,
7}
8
9#[link(name = "test", kind = "static")]
10extern "C" {
11 fn foo(f: Foo) -> Foo;
12}
13
14fn main() {
15 unsafe {
16 let a = Foo { a: 1, b: 2, c: 3 };
17 let b = foo(a);
18 assert_eq!(a, b);
19 }
20}
tests/run-make-fulldeps/extern-fn-with-union/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,ctest)
4 $(RUSTC) testcrate.rs
5 $(RUSTC) test.rs
6 $(call RUN,test) || exit 1
tests/run-make-fulldeps/extern-fn-with-union/ctest.c deleted-10
...@@ -1,10 +0,0 @@
1#include <stdio.h>
2#include <stdint.h>
3
4typedef union TestUnion {
5 uint64_t bits;
6} TestUnion;
7
8uint64_t give_back(TestUnion tu) {
9 return tu.bits;
10}
tests/run-make-fulldeps/extern-fn-with-union/test.rs deleted-19
...@@ -1,19 +0,0 @@
1extern crate testcrate;
2
3use std::mem;
4
5extern "C" {
6 fn give_back(tu: testcrate::TestUnion) -> u64;
7}
8
9fn main() {
10 let magic: u64 = 0xDEADBEEF;
11
12 // Let's test calling it cross crate
13 let back = unsafe { testcrate::give_back(mem::transmute(magic)) };
14 assert_eq!(magic, back);
15
16 // And just within this crate
17 let back = unsafe { give_back(mem::transmute(magic)) };
18 assert_eq!(magic, back);
19}
tests/run-make-fulldeps/extern-fn-with-union/testcrate.rs deleted-11
...@@ -1,11 +0,0 @@
1#![crate_type = "lib"]
2
3#[repr(C)]
4pub struct TestUnion {
5 _val: u64,
6}
7
8#[link(name = "ctest", kind = "static")]
9extern "C" {
10 pub fn give_back(tu: TestUnion) -> u64;
11}
tests/run-make-fulldeps/extern-multiple-copies/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo1.rs
5 $(RUSTC) foo2.rs
6 mkdir $(TMPDIR)/foo
7 cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib
8 $(RUSTC) bar.rs --extern foo1=$(TMPDIR)/libfoo1.rlib -L $(TMPDIR)/foo
tests/run-make-fulldeps/extern-multiple-copies/bar.rs deleted-6
...@@ -1,6 +0,0 @@
1extern crate foo2; // foo2 first to exhibit the bug
2extern crate foo1;
3
4fn main() {
5 /* ... */
6}
tests/run-make-fulldeps/extern-multiple-copies/foo1.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "rlib"]
tests/run-make-fulldeps/extern-multiple-copies/foo2.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "rlib"]
tests/run-make-fulldeps/extern-multiple-copies2/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo1.rs
5 $(RUSTC) foo2.rs
6 mkdir $(TMPDIR)/foo
7 cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib
8 $(RUSTC) bar.rs \
9 --extern foo1=$(TMPDIR)/foo/libfoo1.rlib \
10 --extern foo2=$(TMPDIR)/libfoo2.rlib
tests/run-make-fulldeps/extern-multiple-copies2/bar.rs deleted-8
...@@ -1,8 +0,0 @@
1#[macro_use]
2extern crate foo2; // foo2 first to exhibit the bug
3#[macro_use]
4extern crate foo1;
5
6fn main() {
7 foo2::foo2(foo1::A);
8}
tests/run-make-fulldeps/extern-multiple-copies2/foo1.rs deleted-7
...@@ -1,7 +0,0 @@
1#![crate_type = "rlib"]
2
3pub struct A;
4
5pub fn foo1(a: A) {
6 drop(a);
7}
tests/run-make-fulldeps/extern-multiple-copies2/foo2.rs deleted-8
...@@ -1,8 +0,0 @@
1#![crate_type = "rlib"]
2
3#[macro_use]
4extern crate foo1;
5
6pub fn foo2(a: foo1::A) {
7 foo1::foo1(a);
8}
tests/run-make-fulldeps/extern-overrides-distribution/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) libc.rs -Cmetadata=foo
5 $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib
tests/run-make-fulldeps/extern-overrides-distribution/libc.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "lib"]
2
3pub fn foo() {}
tests/run-make-fulldeps/extern-overrides-distribution/main.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate libc;
2
3fn main() {
4 libc::foo();
5}
tests/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -C extra-filename=bar foo.rs -C save-temps
5 rm $(TMPDIR)/foobar.foo*0.rcgu.o
6 rm $(TMPDIR)/$(call BIN,foobar)
tests/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/foreign-double-unwind/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3all: foo
4 $(call RUN,foo) | $(CGREP) -v unreachable
5
6foo: foo.rs $(call NATIVE_STATICLIB,foo)
7 $(RUSTC) $< -lfoo $(EXTRARSCXXFLAGS)
8
9$(TMPDIR)/libfoo.o: foo.cpp
10 $(call COMPILE_OBJ_CXX,$@,$<)
tests/run-make-fulldeps/foreign-double-unwind/foo.cpp deleted-33
...@@ -1,33 +0,0 @@
1#include <cstdio>
2#include <exception>
3
4void println(const char* s) {
5 puts(s);
6 fflush(stdout);
7}
8
9struct outer_exception {};
10struct inner_exception {};
11
12extern "C" {
13 void throw_cxx_exception() {
14 if (std::uncaught_exception()) {
15 println("throwing inner C++ exception");
16 throw inner_exception();
17 } else {
18 println("throwing outer C++ exception");
19 throw outer_exception();
20 }
21 }
22
23 void cxx_catch_callback(void (*cb)()) {
24 try {
25 cb();
26 println("unreachable: callback returns");
27 } catch (outer_exception) {
28 println("unreachable: caught outer exception in catch (...)");
29 } catch (inner_exception) {
30 println("unreachable: caught inner exception in catch (...)");
31 }
32 }
33}
tests/run-make-fulldeps/foreign-double-unwind/foo.rs deleted-26
...@@ -1,26 +0,0 @@
1// Tests that C++ double unwinding through Rust code will be properly guarded
2// against instead of exhibiting undefined behaviour.
3
4#![feature(c_unwind)]
5
6extern "C-unwind" {
7 fn throw_cxx_exception();
8 fn cxx_catch_callback(cb: extern "C-unwind" fn());
9}
10
11struct ThrowOnDrop;
12
13impl Drop for ThrowOnDrop {
14 fn drop(&mut self) {
15 unsafe { throw_cxx_exception() };
16 }
17}
18
19extern "C-unwind" fn test_double_unwind() {
20 let _a = ThrowOnDrop;
21 let _b = ThrowOnDrop;
22}
23
24fn main() {
25 unsafe { cxx_catch_callback(test_double_unwind) };
26}
tests/run-make-fulldeps/foreign-exceptions/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3all: foo
4 $(call RUN,foo)
5
6foo: foo.rs $(call NATIVE_STATICLIB,foo)
7 $(RUSTC) $< -lfoo $(EXTRARSCXXFLAGS)
8
9$(TMPDIR)/libfoo.o: foo.cpp
10 $(call COMPILE_OBJ_CXX,$@,$<)
tests/run-make-fulldeps/foreign-exceptions/foo.cpp deleted-60
...@@ -1,60 +0,0 @@
1#include <assert.h>
2#include <stddef.h>
3#include <stdio.h>
4
5void println(const char* s) {
6 puts(s);
7 fflush(stdout);
8}
9
10struct exception {};
11struct rust_panic {};
12
13struct drop_check {
14 bool* ok;
15 ~drop_check() {
16 println("~drop_check");
17
18 if (ok)
19 *ok = true;
20 }
21};
22
23extern "C" {
24 void rust_catch_callback(void (*cb)(), bool* rust_ok);
25
26 void throw_cxx_exception() {
27 println("throwing C++ exception");
28 throw exception();
29 }
30
31 void test_cxx_exception() {
32 bool rust_ok = false;
33 try {
34 rust_catch_callback(throw_cxx_exception, &rust_ok);
35 assert(false && "unreachable");
36 } catch (exception e) {
37 println("caught C++ exception");
38 assert(rust_ok);
39 return;
40 }
41 assert(false && "did not catch thrown C++ exception");
42 }
43
44 void cxx_catch_callback(void (*cb)(), bool* cxx_ok) {
45 drop_check x;
46 x.ok = NULL;
47 try {
48 cb();
49 } catch (rust_panic e) {
50 assert(false && "shouldn't be able to catch a rust panic");
51 } catch (...) {
52 println("caught foreign exception in catch (...)");
53 // Foreign exceptions are caught by catch (...). We only set the ok
54 // flag if we successfully caught the panic. The destructor of
55 // drop_check will then set the flag to true if it is executed.
56 x.ok = cxx_ok;
57 throw;
58 }
59 }
60}
tests/run-make-fulldeps/foreign-exceptions/foo.rs deleted-59
...@@ -1,59 +0,0 @@
1// Tests that C++ exceptions can unwind through Rust code run destructors and
2// are caught by catch_unwind. Also tests that Rust panics can unwind through
3// C++ code.
4
5#![feature(c_unwind)]
6
7use std::panic::{catch_unwind, AssertUnwindSafe};
8
9struct DropCheck<'a>(&'a mut bool);
10impl<'a> Drop for DropCheck<'a> {
11 fn drop(&mut self) {
12 println!("DropCheck::drop");
13 *self.0 = true;
14 }
15}
16
17extern "C" {
18 fn test_cxx_exception();
19}
20
21extern "C-unwind" {
22 fn cxx_catch_callback(cb: extern "C-unwind" fn(), ok: *mut bool);
23}
24
25#[no_mangle]
26extern "C-unwind" fn rust_catch_callback(cb: extern "C-unwind" fn(), rust_ok: &mut bool) {
27 let _drop = DropCheck(rust_ok);
28 cb();
29 unreachable!("should have unwound instead of returned");
30}
31
32fn test_rust_panic() {
33 extern "C-unwind" fn callback() {
34 println!("throwing rust panic");
35 panic!(1234i32);
36 }
37
38 let mut dropped = false;
39 let mut cxx_ok = false;
40 let caught_unwind = catch_unwind(AssertUnwindSafe(|| {
41 let _drop = DropCheck(&mut dropped);
42 unsafe {
43 cxx_catch_callback(callback, &mut cxx_ok);
44 }
45 unreachable!("should have unwound instead of returned");
46 }));
47 println!("caught rust panic");
48 assert!(dropped);
49 assert!(caught_unwind.is_err());
50 let panic_obj = caught_unwind.unwrap_err();
51 let panic_int = *panic_obj.downcast_ref::<i32>().unwrap();
52 assert_eq!(panic_int, 1234);
53 assert!(cxx_ok);
54}
55
56fn main() {
57 unsafe { test_cxx_exception() };
58 test_rust_panic();
59}
tests/run-make-fulldeps/foreign-rust-exceptions/Makefile deleted-11
...@@ -1,11 +0,0 @@
1# ignore-i686-pc-windows-gnu
2
3# This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder
4# so cross-DLL unwinding does not work.
5
6include ../tools.mk
7
8all:
9 $(RUSTC) bar.rs --crate-type=cdylib
10 $(RUSTC) foo.rs
11 $(call RUN,foo) 2>&1 | $(CGREP) "Rust cannot catch foreign exceptions"
tests/run-make-fulldeps/foreign-rust-exceptions/bar.rs deleted-7
...@@ -1,7 +0,0 @@
1#![crate_type = "cdylib"]
2#![feature(c_unwind)]
3
4#[no_mangle]
5extern "C-unwind" fn panic() {
6 panic!();
7}
tests/run-make-fulldeps/foreign-rust-exceptions/foo.rs deleted-13
...@@ -1,13 +0,0 @@
1#![feature(c_unwind)]
2
3#[cfg_attr(not(windows), link(name = "bar"))]
4#[cfg_attr(windows, link(name = "bar.dll"))]
5extern "C-unwind" {
6 fn panic();
7}
8
9fn main() {
10 let _ = std::panic::catch_unwind(|| {
11 unsafe { panic() };
12 });
13}
tests/run-make-fulldeps/fpic/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4# ignore-macos
5
6# Test for #39529.
7# `-z text` causes ld to error if there are any non-PIC sections
8
9all:
10 $(RUSTC) hello.rs -C link-args=-Wl,-z,text
tests/run-make-fulldeps/fpic/hello.rs deleted-1
...@@ -1 +0,0 @@
1fn main() { }
tests/run-make-fulldeps/glibc-staticlib-args/Makefile deleted-12
...@@ -1,12 +0,0 @@
1# only-gnu
2# only-linux
3
4include ../tools.mk
5
6# This ensures that std::env::args works in a library called from C on glibc Linux.
7
8all:
9 $(RUSTC) --crate-type=staticlib library.rs
10 $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) \
11 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
12 $(call RUN,program)
tests/run-make-fulldeps/glibc-staticlib-args/library.rs deleted-4
...@@ -1,4 +0,0 @@
1#[no_mangle]
2pub extern "C" fn args_check() {
3 assert_ne!(std::env::args_os().count(), 0);
4}
tests/run-make-fulldeps/glibc-staticlib-args/program.c deleted-6
...@@ -1,6 +0,0 @@
1void args_check();
2
3int main() {
4 args_check();
5 return 0;
6}
tests/run-make-fulldeps/hir-tree/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3# Test that hir-tree output doesn't crash and includes
4# the string constant we would expect to see.
5
6all:
7 $(RUSTC) -o $(TMPDIR)/input.hir -Z unpretty=hir-tree input.rs
8 $(CGREP) '"Hello, Rustaceans!\n"' < $(TMPDIR)/input.hir
tests/run-make-fulldeps/hir-tree/input.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 println!("Hello, Rustaceans!");
3}
tests/run-make-fulldeps/hotplug_codegen_backend/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../tools.mk1include ../../run-make/tools.mk
22
3# ignore-stage13# ignore-stage1
44
tests/run-make-fulldeps/include_bytes_deps/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3# ignore-freebsd
4
5all:
6 $(RUSTC) --emit dep-info main.rs
7 $(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d
tests/run-make-fulldeps/include_bytes_deps/input.bin deleted-1
...@@ -1 +0,0 @@
1Hello world!
tests/run-make-fulldeps/include_bytes_deps/input.md deleted-1
...@@ -1 +0,0 @@
1# Hello, world!
tests/run-make-fulldeps/include_bytes_deps/input.txt deleted-1
...@@ -1 +0,0 @@
1Hello world!
tests/run-make-fulldeps/include_bytes_deps/main.rs deleted-10
...@@ -1,10 +0,0 @@
1#[doc = include_str!("input.md")]
2pub struct SomeStruct;
3
4pub fn main() {
5 const INPUT_TXT: &'static str = include_str!("input.txt");
6 const INPUT_BIN: &'static [u8] = include_bytes!("input.bin");
7
8 println!("{}", INPUT_TXT);
9 println!("{:?}", INPUT_BIN);
10}
tests/run-make-fulldeps/incr-add-rust-src-component/Makefile deleted-44
...@@ -1,44 +0,0 @@
1include ../tools.mk
2
3# rust-lang/rust#70924: Test that if we add rust-src component in between two
4# incremental compiles, the compiler does not ICE on the second.
5
6# This test uses `ln -s` rather than copying to save testing time, but its
7# usage doesn't work on windows. So ignore windows.
8
9# ignore-windows
10
11SYSROOT:=$(shell $(RUSTC) --print sysroot)
12FAKEROOT=$(TMPDIR)/fakeroot
13INCR=$(TMPDIR)/incr
14
15# Make a local copy of the sysroot; then remove the rust-src part of it, if
16# present, for the *first* build. Then put in a facsimile of the rust-src
17# component for the second build, in order to expose the ICE from issue #70924.
18#
19# Note that it is much easier to just do `cp -a $(SYSROOT)/* $(FAKEROOT)` as a
20# first step, but I am concerned that would be too expensive in a unit test
21# compared to making symbolic links.
22#
23# Anyway, the pattern you'll see here is: For every prefix in
24# root/lib/rustlib/src, link all of prefix parent content, then remove the
25# prefix, then loop on the next prefix. This way, we basically create a copy of
26# the context around root/lib/rustlib/src, and can freely add/remove the src
27# component itself.
28all:
29 mkdir $(FAKEROOT)
30 ln -s $(SYSROOT)/* $(FAKEROOT)
31 rm -f $(FAKEROOT)/lib
32 mkdir $(FAKEROOT)/lib
33 ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
34 rm -f $(FAKEROOT)/lib/rustlib
35 mkdir $(FAKEROOT)/lib/rustlib
36 ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
37 rm -f $(FAKEROOT)/lib/rustlib/src
38 mkdir $(FAKEROOT)/lib/rustlib/src
39 ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
40 rm -f $(FAKEROOT)/lib/rustlib/src/rust
41 $(RUSTC) --sysroot $(FAKEROOT) -C incremental=$(INCR) main.rs
42 mkdir -p $(FAKEROOT)/lib/rustlib/src/rust/src/libstd
43 touch $(FAKEROOT)/lib/rustlib/src/rust/src/libstd/lib.rs
44 $(RUSTC) --sysroot $(FAKEROOT) -C incremental=$(INCR) main.rs
tests/run-make-fulldeps/incr-add-rust-src-component/main.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 println!("Hello World");
3}
tests/run-make-fulldeps/inline-always-many-cgu/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2
5 if cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b'; then \
6 echo "found call instruction when one wasn't expected"; \
7 exit 1; \
8 fi
tests/run-make-fulldeps/inline-always-many-cgu/foo.rs deleted-15
...@@ -1,15 +0,0 @@
1#![crate_type = "lib"]
2
3pub mod a {
4 #[inline(always)]
5 pub fn foo() {
6 }
7
8 pub fn bar() {
9 }
10}
11
12#[no_mangle]
13pub fn bar() {
14 a::foo();
15}
tests/run-make-fulldeps/interdependent-c-libraries/Makefile deleted-14
...@@ -1,14 +0,0 @@
1include ../tools.mk
2
3# The rust crate foo will link to the native library foo, while the rust crate
4# bar will link to the native library bar. There is also a dependency between
5# the native library bar to the natibe library foo.
6#
7# This test ensures that the ordering of -lfoo and -lbar on the command line is
8# correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo'
9# library will be stripped out, and the linkage will fail.
10
11all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar)
12 $(RUSTC) foo.rs
13 $(RUSTC) bar.rs
14 $(RUSTC) main.rs --print link-args
tests/run-make-fulldeps/interdependent-c-libraries/bar.c deleted-3
...@@ -1,3 +0,0 @@
1void foo();
2
3void bar() { foo(); }
tests/run-make-fulldeps/interdependent-c-libraries/bar.rs deleted-14
...@@ -1,14 +0,0 @@
1#![crate_type = "rlib"]
2
3extern crate foo;
4
5#[link(name = "bar", kind = "static")]
6extern "C" {
7 fn bar();
8}
9
10pub fn doit() {
11 unsafe {
12 bar();
13 }
14}
tests/run-make-fulldeps/interdependent-c-libraries/foo.c deleted-1
...@@ -1 +0,0 @@
1void foo() {}
tests/run-make-fulldeps/interdependent-c-libraries/foo.rs deleted-12
...@@ -1,12 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {
5 fn foo();
6}
7
8pub fn doit() {
9 unsafe {
10 foo();
11 }
12}
tests/run-make-fulldeps/interdependent-c-libraries/main.rs deleted-6
...@@ -1,6 +0,0 @@
1extern crate foo;
2extern crate bar;
3
4fn main() {
5 bar::doit();
6}
tests/run-make-fulldeps/intrinsic-unreachable/Makefile deleted-12
...@@ -1,12 +0,0 @@
1include ../tools.mk
2
3# needs-asm-support
4# ignore-windows-msvc
5#
6# Because of Windows exception handling, the code is not necessarily any shorter.
7# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466
8
9all:
10 $(RUSTC) -O --emit asm exit-ret.rs
11 $(RUSTC) -O --emit asm exit-unreachable.rs
12 test `wc -l < $(TMPDIR)/exit-unreachable.s` -lt `wc -l < $(TMPDIR)/exit-ret.s`
tests/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs deleted-14
...@@ -1,14 +0,0 @@
1#![crate_type="lib"]
2use std::arch::asm;
3
4#[deny(unreachable_code)]
5pub fn exit(n: usize) -> i32 {
6 unsafe {
7 // Pretend this asm is an exit() syscall.
8 asm!("/*{0}*/", in(reg) n);
9 }
10 // This return value is just here to generate some extra code for a return
11 // value, making it easier for the test script to detect whether the
12 // compiler deleted it.
13 42
14}
tests/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs deleted-18
...@@ -1,18 +0,0 @@
1#![feature(core_intrinsics)]
2#![crate_type="lib"]
3use std::arch::asm;
4
5use std::intrinsics;
6
7#[allow(unreachable_code)]
8pub fn exit(n: usize) -> i32 {
9 unsafe {
10 // Pretend this asm is an exit() syscall.
11 asm!("/*{0}*/", in(reg) n);
12 intrinsics::unreachable()
13 }
14 // This return value is just here to generate some extra code for a return
15 // value, making it easier for the test script to detect whether the
16 // compiler deleted it.
17 42
18}
tests/run-make-fulldeps/invalid-library/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 touch $(TMPDIR)/lib.rmeta
5 $(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/lib.rmeta
6 $(RUSTC) foo.rs 2>&1 | $(CGREP) "found invalid metadata"
tests/run-make-fulldeps/invalid-library/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate foo;
2
3fn main() {}
tests/run-make-fulldeps/invalid-staticlib/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 touch $(TMPDIR)/libfoo.a
5 echo | $(RUSTC) - --crate-type=rlib -lstatic=foo 2>&1 | $(CGREP) "failed to add native library"
tests/run-make-fulldeps/issue-11908/Makefile deleted-21
...@@ -1,21 +0,0 @@
1# This test ensures that if you have the same rlib or dylib at two locations
2# in the same path that you don't hit an assertion in the compiler.
3#
4# Note that this relies on `liburl` to be in the path somewhere else,
5# and then our aux-built libraries will collide with liburl (they have
6# the same version listed)
7
8include ../tools.mk
9
10all:
11 mkdir $(TMPDIR)/other
12 $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic
13 mv $(call DYLIB,foo) $(TMPDIR)/other
14 $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic
15 $(RUSTC) bar.rs -L $(TMPDIR)/other
16 rm -rf $(TMPDIR)
17 mkdir -p $(TMPDIR)/other
18 $(RUSTC) foo.rs --crate-type=rlib
19 mv $(TMPDIR)/libfoo.rlib $(TMPDIR)/other
20 $(RUSTC) foo.rs --crate-type=rlib
21 $(RUSTC) bar.rs -L $(TMPDIR)/other
tests/run-make-fulldeps/issue-11908/bar.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate foo;
2
3fn main() {}
tests/run-make-fulldeps/issue-11908/foo.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_name = "foo"]
tests/run-make-fulldeps/issue-14500/Makefile deleted-13
...@@ -1,13 +0,0 @@
1include ../tools.mk
2
3# Test to make sure that reachable extern fns are always available in final
4# productcs, including when LTO is used. In this test, the `foo` crate has a
5# reahable symbol, and is a dependency of the `bar` crate. When the `bar` crate
6# is compiled with LTO, it shouldn't strip the symbol from `foo`, and that's the
7# only way that `foo.c` will successfully compile.
8
9all:
10 $(RUSTC) foo.rs --crate-type=rlib
11 $(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a
12 $(CC) foo.c $(TMPDIR)/libbar.a $(EXTRACFLAGS) $(call OUT_EXE,foo)
13 $(call RUN,foo)
tests/run-make-fulldeps/issue-14500/bar.rs deleted-1
...@@ -1 +0,0 @@
1extern crate foo;
tests/run-make-fulldeps/issue-14500/foo.c deleted-7
...@@ -1,7 +0,0 @@
1extern void foo();
2extern char FOO_STATIC;
3
4int main() {
5 foo();
6 return (int)FOO_STATIC;
7}
tests/run-make-fulldeps/issue-14500/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1#[no_mangle]
2pub extern "C" fn foo() {}
3
4#[no_mangle]
5pub static FOO_STATIC: u8 = 0;
tests/run-make-fulldeps/issue-14698/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 TMP=fake TMPDIR=fake $(RUSTC) foo.rs 2>&1 | $(CGREP) "couldn't create a temp dir:"
tests/run-make-fulldeps/issue-14698/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/issue-15460/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,foo)
4 $(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic
5 $(RUSTC) bar.rs
6 $(call RUN,bar)
tests/run-make-fulldeps/issue-15460/bar.rs deleted-4
...@@ -1,4 +0,0 @@
1extern crate foo;
2fn main() {
3 unsafe { foo::foo() }
4}
tests/run-make-fulldeps/issue-15460/foo.c deleted-6
...@@ -1,6 +0,0 @@
1// ignore-license
2
3#ifdef _WIN32
4__declspec(dllexport)
5#endif
6void foo() {}
tests/run-make-fulldeps/issue-15460/foo.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_type = "dylib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {
5 pub fn foo();
6}
tests/run-make-fulldeps/issue-18943/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3# Regression test for ICE #18943 when compiling as lib
4
5all:
6 $(RUSTC) foo.rs --crate-type lib
7 $(call REMOVE_RLIBS,foo) && exit 0 || exit 1
tests/run-make-fulldeps/issue-18943/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1trait Foo { }
2
3trait Bar { }
4
5impl<'a> Foo for Bar + 'a { }
tests/run-make-fulldeps/issue-19371/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../tools.mk1include ../../run-make/tools.mk
22
3# This test ensures that rustc compile_input can be called twice in one task3# This test ensures that rustc compile_input can be called twice in one task
4# without causing a panic.4# without causing a panic.
tests/run-make-fulldeps/issue-20626/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3# Test output to be four
4# The original error only occurred when printing, not when comparing using assert!
5
6all:
7 $(RUSTC) foo.rs -O
8 [ `$(call RUN,foo)` = "4" ]
tests/run-make-fulldeps/issue-20626/foo.rs deleted-13
...@@ -1,13 +0,0 @@
1fn identity(a: &u32) -> &u32 { a }
2
3fn print_foo(f: &fn(&u32) -> &u32, x: &u32) {
4 print!("{}", (*f)(x));
5}
6
7fn main() {
8 let x = &4;
9 let f: fn(&u32) -> &u32 = identity;
10
11 // Didn't print 4 on optimized builds
12 print_foo(&f, x);
13}
tests/run-make-fulldeps/issue-22131/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all: foo.rs
4 $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs
5 $(RUSTDOC) --test --cfg 'feature="bar"' \
6 -L $(TMPDIR) foo.rs |\
7 $(CGREP) 'foo.rs - foo (line 1) ... ok'
tests/run-make-fulldeps/issue-22131/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1/// ```rust
2/// assert_eq!(foo::foo(), 1);
3/// ```
4#[cfg(feature = "bar")]
5pub fn foo() -> i32 { 1 }
tests/run-make-fulldeps/issue-24445/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3# only-linux
4
5all:
6 $(RUSTC) foo.rs
7 $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo
8 $(call RUN,foo)
9 $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo
10 $(call RUN,foo)
tests/run-make-fulldeps/issue-24445/foo.c deleted-6
...@@ -1,6 +0,0 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make-fulldeps/issue-24445/foo.rs deleted-15
...@@ -1,15 +0,0 @@
1#![crate_type = "staticlib"]
2
3struct Destroy;
4impl Drop for Destroy {
5 fn drop(&mut self) { println!("drop"); }
6}
7
8thread_local! {
9 static X: Destroy = Destroy
10}
11
12#[no_mangle]
13pub extern "C" fn foo() {
14 X.with(|_| ());
15}
tests/run-make-fulldeps/issue-25581/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,test)
4 $(RUSTC) test.rs
5 $(call RUN,test) || exit 1
tests/run-make-fulldeps/issue-25581/test.c deleted-15
...@@ -1,15 +0,0 @@
1#include <stddef.h>
2#include <stdint.h>
3
4struct ByteSlice {
5 uint8_t *data;
6 size_t len;
7};
8
9size_t slice_len(struct ByteSlice bs) {
10 return bs.len;
11}
12
13uint8_t slice_elem(struct ByteSlice bs, size_t idx) {
14 return bs.data[idx];
15}
tests/run-make-fulldeps/issue-25581/test.rs deleted-18
...@@ -1,18 +0,0 @@
1#[link(name = "test", kind = "static")]
2extern "C" {
3 fn slice_len(s: &[u8]) -> usize;
4 fn slice_elem(s: &[u8], idx: usize) -> u8;
5}
6
7fn main() {
8 let data = [1, 2, 3, 4, 5];
9
10 unsafe {
11 assert_eq!(data.len(), slice_len(&data) as usize);
12 assert_eq!(data[0], slice_elem(&data, 0));
13 assert_eq!(data[1], slice_elem(&data, 1));
14 assert_eq!(data[2], slice_elem(&data, 2));
15 assert_eq!(data[3], slice_elem(&data, 3));
16 assert_eq!(data[4], slice_elem(&data, 4));
17 }
18}
tests/run-make-fulldeps/issue-26006/Makefile deleted-16
...@@ -1,16 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4
5OUT := $(TMPDIR)/out
6
7all: time
8
9time: libc
10 mkdir -p $(OUT)/time $(OUT)/time/deps
11 ln -sf $(OUT)/libc/liblibc.rlib $(OUT)/time/deps/
12 $(RUSTC) in/time/lib.rs -Ldependency=$(OUT)/time/deps/
13
14libc:
15 mkdir -p $(OUT)/libc
16 $(RUSTC) in/libc/lib.rs --crate-name=libc -Cmetadata=foo -o $(OUT)/libc/liblibc.rlib
tests/run-make-fulldeps/issue-26006/in/libc/lib.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type="rlib"]
2
3pub fn something(){}
tests/run-make-fulldeps/issue-26006/in/time/lib.rs deleted-4
...@@ -1,4 +0,0 @@
1#![feature(rustc_private)]
2extern crate libc;
3
4fn main(){}
tests/run-make-fulldeps/issue-26092/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3# This test ensures that rustc does not panic with `-o ""` option.
4
5all:
6 $(RUSTC) -o "" blank.rs 2>&1 | $(CGREP) -i 'panic' && exit 1 || exit 0
tests/run-make-fulldeps/issue-26092/blank.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/issue-28595/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,a) $(call NATIVE_STATICLIB,b)
4 $(RUSTC) a.rs
5 $(RUSTC) b.rs
6 $(call RUN,b)
tests/run-make-fulldeps/issue-28595/a.c deleted-1
...@@ -1 +0,0 @@
1void a(void) {}
tests/run-make-fulldeps/issue-28595/a.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "a", kind = "static")]
4extern "C" {
5 pub fn a();
6}
tests/run-make-fulldeps/issue-28595/b.c deleted-5
...@@ -1,5 +0,0 @@
1extern void a(void);
2
3void b(void) {
4 a();
5}
tests/run-make-fulldeps/issue-28595/b.rs deleted-12
...@@ -1,12 +0,0 @@
1extern crate a;
2
3#[link(name = "b", kind = "static")]
4extern "C" {
5 pub fn b();
6}
7
8fn main() {
9 unsafe {
10 b();
11 }
12}
tests/run-make-fulldeps/issue-28766/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -O foo.rs
5 $(RUSTC) -O -L $(TMPDIR) main.rs
tests/run-make-fulldeps/issue-28766/foo.rs deleted-8
...@@ -1,8 +0,0 @@
1#![crate_type="lib"]
2pub struct Foo(());
3
4impl Foo {
5 pub fn new() -> Foo {
6 Foo(())
7 }
8}
tests/run-make-fulldeps/issue-28766/main.rs deleted-7
...@@ -1,7 +0,0 @@
1#![crate_type="lib"]
2extern crate foo;
3use foo::Foo;
4
5pub fn crash() -> Box<Foo> {
6 Box::new(Foo::new())
7}
tests/run-make-fulldeps/issue-30063/Makefile deleted-35
...@@ -1,35 +0,0 @@
1include ../tools.mk
2
3all:
4 rm -f $(TMPDIR)/foo-output
5 $(RUSTC) -C codegen-units=4 -o $(TMPDIR)/foo-output foo.rs
6 rm $(TMPDIR)/foo-output
7
8 rm -f $(TMPDIR)/asm-output
9 $(RUSTC) -C codegen-units=4 --emit=asm -o $(TMPDIR)/asm-output foo.rs
10 rm $(TMPDIR)/asm-output
11
12 rm -f $(TMPDIR)/bc-output
13 $(RUSTC) -C codegen-units=4 --emit=llvm-bc -o $(TMPDIR)/bc-output foo.rs
14 rm $(TMPDIR)/bc-output
15
16 rm -f $(TMPDIR)/ir-output
17 $(RUSTC) -C codegen-units=4 --emit=llvm-ir -o $(TMPDIR)/ir-output foo.rs
18 rm $(TMPDIR)/ir-output
19
20 rm -f $(TMPDIR)/link-output
21 $(RUSTC) -C codegen-units=4 --emit=link -o $(TMPDIR)/link-output foo.rs
22 rm $(TMPDIR)/link-output
23
24 rm -f $(TMPDIR)/obj-output
25 $(RUSTC) -C codegen-units=4 --emit=obj -o $(TMPDIR)/obj-output foo.rs
26 rm $(TMPDIR)/obj-output
27
28 rm -f $(TMPDIR)/dep-output
29 $(RUSTC) -C codegen-units=4 --emit=dep-info -o $(TMPDIR)/dep-output foo.rs
30 rm $(TMPDIR)/dep-output
31
32# # (This case doesn't work yet, and may be fundamentally wrong-headed anyway.)
33# rm -f $(TMPDIR)/multi-output
34# $(RUSTC) -C codegen-units=4 --emit=asm,obj -o $(TMPDIR)/multi-output foo.rs
35# rm $(TMPDIR)/multi-output
tests/run-make-fulldeps/issue-30063/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() { }
tests/run-make-fulldeps/issue-33329/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --target x86_64_unknown-linux-musl main.rs 2>&1 | $(CGREP) \
5 "error: Error loading target specification: Could not find specification for target"
tests/run-make-fulldeps/issue-33329/main.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/issue-35164/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) main.rs --error-format json 2>&1 | $(CGREP) -e '"byte_start":23\b' '"byte_end":29\b'
tests/run-make-fulldeps/issue-35164/main.rs deleted-5
...@@ -1,5 +0,0 @@
1mod submodule;
2
3fn main() {
4 submodule::foo();
5}
tests/run-make-fulldeps/issue-35164/submodule/mod.rs deleted-3
...@@ -1,3 +0,0 @@
1pub fn foo() {
2 let _MyFoo = 2;
3}
tests/run-make-fulldeps/issue-37839/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) a.rs && $(RUSTC) b.rs
5 $(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \
6 --out-dir=$(TMPDIR)
tests/run-make-fulldeps/issue-37839/a.rs deleted-2
...@@ -1,2 +0,0 @@
1#![allow(unused)]
2#![crate_type = "proc-macro"]
tests/run-make-fulldeps/issue-37839/b.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "lib"]
2#[macro_use] extern crate a;
tests/run-make-fulldeps/issue-37839/c.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "lib"]
2extern crate b;
tests/run-make-fulldeps/issue-37893/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) a.rs && $(RUSTC) b.rs && $(RUSTC) c.rs
tests/run-make-fulldeps/issue-37893/a.rs deleted-2
...@@ -1,2 +0,0 @@
1#![allow(unused)]
2#![crate_type = "proc-macro"]
tests/run-make-fulldeps/issue-37893/b.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "lib"]
2#[macro_use] extern crate a;
tests/run-make-fulldeps/issue-37893/c.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "staticlib"]
2extern crate b;
3extern crate a;
tests/run-make-fulldeps/issue-38237/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs; $(RUSTC) bar.rs
5 $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR)
tests/run-make-fulldeps/issue-38237/bar.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "lib"]
2
3#[derive(Debug)]
4pub struct S;
tests/run-make-fulldeps/issue-38237/baz.rs deleted-8
...@@ -1,8 +0,0 @@
1extern crate foo;
2extern crate bar;
3
4pub struct Bar;
5impl ::std::ops::Deref for Bar {
6 type Target = bar::S;
7 fn deref(&self) -> &Self::Target { unimplemented!() }
8}
tests/run-make-fulldeps/issue-38237/foo.rs deleted-9
...@@ -1,9 +0,0 @@
1#![crate_type = "proc-macro"]
2
3extern crate proc_macro;
4
5#[proc_macro_derive(A)]
6pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { ts }
7
8#[derive(Debug)]
9struct S;
tests/run-make-fulldeps/issue-40535/Makefile deleted-13
...@@ -1,13 +0,0 @@
1include ../tools.mk
2
3# The ICE occurred in the following situation:
4# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`)
5# * `bar` declares and depends on `extern crate baz`
6# * All crates built in metadata-only mode (`cargo check`)
7all:
8 # cc https://github.com/rust-lang/rust/issues/40623
9 $(RUSTC) baz.rs --emit=metadata
10 $(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta
11 $(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta 2>&1 | \
12 $(CGREP) -v "unexpectedly panicked"
13 # ^ Succeeds if it doesn't find the ICE message
tests/run-make-fulldeps/issue-40535/bar.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "lib"]
2
3extern crate baz;
tests/run-make-fulldeps/issue-40535/baz.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "lib"]
tests/run-make-fulldeps/issue-40535/foo.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "lib"]
2
3extern crate bar;
4extern crate baz;
tests/run-make-fulldeps/issue-46239/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) main.rs -C opt-level=1
5 $(call RUN,main)
tests/run-make-fulldeps/issue-46239/main.rs deleted-8
...@@ -1,8 +0,0 @@
1fn project<T>(x: &(T,)) -> &T { &x.0 }
2
3fn dummy() {}
4
5fn main() {
6 let f = (dummy as fn(),);
7 (*project(&f))();
8}
tests/run-make-fulldeps/issue-47551/Makefile deleted-9
...@@ -1,9 +0,0 @@
1# only-linux
2# ignore-32bit
3
4include ../tools.mk
5
6all:
7 $(RUSTC) eh_frame-terminator.rs
8 $(call RUN,eh_frame-terminator) | $(CGREP) '1122334455667788'
9 objdump --dwarf=frames $(TMPDIR)/eh_frame-terminator | $(CGREP) 'ZERO terminator'
tests/run-make-fulldeps/issue-47551/eh_frame-terminator.rs deleted-22
...@@ -1,22 +0,0 @@
1// run-pass
2
3#[derive(Clone, Copy)]
4struct Foo {
5 array: [u64; 10240],
6}
7
8impl Foo {
9 const fn new() -> Self {
10 Self {
11 array: [0x1122_3344_5566_7788; 10240]
12 }
13 }
14}
15
16static BAR: [Foo; 10240] = [Foo::new(); 10240];
17
18fn main() {
19 let bt = std::backtrace::Backtrace::force_capture();
20 println!("Hello, world! {:?}", bt);
21 println!("{:x}", BAR[0].array[0]);
22}
tests/run-make-fulldeps/issue-51671/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# ignore-windows-msvc
4
5all:
6 $(RUSTC) --emit=obj app.rs
7 nm $(TMPDIR)/app.o | $(CGREP) rust_begin_unwind
8 nm $(TMPDIR)/app.o | $(CGREP) rust_eh_personality
9 nm $(TMPDIR)/app.o | $(CGREP) __rg_oom
tests/run-make-fulldeps/issue-51671/app.rs deleted-20
...@@ -1,20 +0,0 @@
1#![crate_type = "bin"]
2#![feature(lang_items, alloc_error_handler)]
3#![no_main]
4#![no_std]
5
6use core::alloc::Layout;
7use core::panic::PanicInfo;
8
9#[panic_handler]
10fn panic(_: &PanicInfo) -> ! {
11 loop {}
12}
13
14#[lang = "eh_personality"]
15fn eh() {}
16
17#[alloc_error_handler]
18fn oom(_: Layout) -> ! {
19 loop {}
20}
tests/run-make-fulldeps/issue-53964/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) panic.rs
5 $(RUSTC) -C panic=abort --emit=obj app.rs -L $(TMPDIR)
tests/run-make-fulldeps/issue-53964/app.rs deleted-8
...@@ -1,8 +0,0 @@
1#![crate_type = "bin"]
2#![no_main]
3#![no_std]
4
5#![deny(unused_extern_crates)]
6
7// `panic` provides a `panic_handler` so it shouldn't trip the `unused_extern_crates` lint
8extern crate panic;
tests/run-make-fulldeps/issue-53964/panic.rs deleted-10
...@@ -1,10 +0,0 @@
1#![crate_type = "lib"]
2#![feature(panic_handler)]
3#![no_std]
4
5use core::panic::PanicInfo;
6
7#[panic_handler]
8fn panic(_: &PanicInfo) -> ! {
9 loop {}
10}
tests/run-make-fulldeps/issue-64153/Makefile deleted-26
...@@ -1,26 +0,0 @@
1include ../tools.mk
2
3# `llvm-objdump`'s output looks different on windows than on other platforms.
4# It should be enough to check on Unix platforms, so:
5# ignore-windows
6
7# Staticlibs don't include Rust object files from upstream crates if the same
8# code was already pulled into the lib via LTO. However, the bug described in
9# https://github.com/rust-lang/rust/issues/64153 lead to this exclusion not
10# working properly if the upstream crate was compiled with an explicit filename
11# (via `-o`).
12#
13# This test makes sure that functions defined in the upstream crates do not
14# appear twice in the final staticlib when listing all the symbols from it.
15
16all:
17 $(RUSTC) --crate-type rlib upstream.rs -o $(TMPDIR)/libupstream.rlib -Ccodegen-units=1
18 $(RUSTC) --crate-type staticlib downstream.rs -Clto -Ccodegen-units=1 -o $(TMPDIR)/libdownstream.a
19 # Dump all the symbols from the staticlib into `syms`
20 "$(LLVM_BIN_DIR)"/llvm-objdump -t $(TMPDIR)/libdownstream.a > $(TMPDIR)/syms
21 # Count the global instances of `issue64153_test_function`. There'll be 2
22 # if the `upstream` object file got erroneously included twice.
23 # The line we are testing for with the regex looks something like:
24 # 0000000000000000 g F .text.issue64153_test_function 00000023 issue64153_test_function
25 grep -c -e "[[:space:]]g[[:space:]]*F[[:space:]].*issue64153_test_function" $(TMPDIR)/syms > $(TMPDIR)/count
26 [ "$$(cat $(TMPDIR)/count)" -eq "1" ]
tests/run-make-fulldeps/issue-64153/downstream.rs deleted-6
...@@ -1,6 +0,0 @@
1extern crate upstream;
2
3#[no_mangle]
4pub extern "C" fn foo() {
5 print!("1 + 1 = {}", upstream::issue64153_test_function(1));
6}
tests/run-make-fulldeps/issue-64153/upstream.rs deleted-6
...@@ -1,6 +0,0 @@
1// Make this function extern "C", public, and no-mangle, so that it gets
2// exported from the downstream staticlib.
3#[no_mangle]
4pub extern "C" fn issue64153_test_function(x: u32) -> u32 {
5 x + 1
6}
tests/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/Makefile deleted-17
...@@ -1,17 +0,0 @@
1# Regression test for issue #68794
2#
3# Verify that no text relocations are accidentally introduced by linking a
4# minimal rust staticlib.
5#
6# The test links a rust static library into a shared library, and checks that
7# the linker doesn't have to flag the resulting file as containing TEXTRELs.
8
9include ../tools.mk
10
11# only-linux
12
13all:
14 $(RUSTC) foo.rs
15 $(CC) bar.c $(call STATICLIB,foo) -fPIC -shared -o $(call DYLIB,bar) \
16 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
17 readelf -d $(call DYLIB,bar) | grep TEXTREL; test $$? -eq 1
tests/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/bar.c deleted-6
...@@ -1,6 +0,0 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make-fulldeps/issue-68794-textrel-on-minimal-lib/foo.rs deleted-8
...@@ -1,8 +0,0 @@
1#![crate_type = "staticlib"]
2
3#[no_mangle]
4pub extern "C" fn foo(x: u32) {
5 // using the println! makes it so that enough code from the standard
6 // library is included (see issue #68794)
7 println!("foo: {}", x);
8}
tests/run-make-fulldeps/issue-69368/Makefile deleted-18
...@@ -1,18 +0,0 @@
1include ../tools.mk
2
3# Test that previously triggered a linker failure with root cause
4# similar to one found in the issue #69368.
5#
6# The crate that provides oom lang item is missing some other lang
7# items. Necessary to prevent the use of start-group / end-group.
8#
9# The weak lang items are defined in a separate compilation units,
10# so that linker could omit them if not used.
11#
12# The crates that need those weak lang items are dependencies of
13# crates that provide them.
14
15all:
16 $(RUSTC) a.rs
17 $(RUSTC) b.rs
18 $(RUSTC) c.rs
tests/run-make-fulldeps/issue-69368/a.rs deleted-26
...@@ -1,26 +0,0 @@
1#![crate_type = "rlib"]
2#![feature(lang_items)]
3#![feature(panic_unwind)]
4#![no_std]
5
6extern crate panic_unwind;
7
8#[panic_handler]
9pub fn panic_handler(_: &core::panic::PanicInfo) -> ! {
10 loop {}
11}
12
13#[no_mangle]
14extern "C" fn __rust_drop_panic() -> ! {
15 loop {}
16}
17
18#[no_mangle]
19extern "C" fn __rust_foreign_exception() -> ! {
20 loop {}
21}
22
23#[lang = "eh_personality"]
24fn eh_personality() {
25 loop {}
26}
tests/run-make-fulldeps/issue-69368/b.rs deleted-8
...@@ -1,8 +0,0 @@
1#![crate_type = "rlib"]
2#![feature(alloc_error_handler)]
3#![no_std]
4
5#[alloc_error_handler]
6pub fn error_handler(_: core::alloc::Layout) -> ! {
7 panic!();
8}
tests/run-make-fulldeps/issue-69368/c.rs deleted-34
...@@ -1,34 +0,0 @@
1#![crate_type = "bin"]
2#![feature(start)]
3#![no_std]
4
5extern crate alloc;
6extern crate a;
7extern crate b;
8
9use alloc::vec::Vec;
10use core::alloc::*;
11
12struct Allocator;
13
14unsafe impl GlobalAlloc for Allocator {
15 unsafe fn alloc(&self, _: Layout) -> *mut u8 {
16 loop {}
17 }
18
19 unsafe fn dealloc(&self, _: *mut u8, _: Layout) {
20 loop {}
21 }
22}
23
24#[global_allocator]
25static ALLOCATOR: Allocator = Allocator;
26
27#[start]
28fn main(argc: isize, _argv: *const *const u8) -> isize {
29 let mut v = Vec::new();
30 for i in 0..argc {
31 v.push(i);
32 }
33 v.iter().sum()
34}
tests/run-make-fulldeps/issue-7349/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3# Test to make sure that inner functions within a polymorphic outer function
4# don't get re-codegened when the outer function is monomorphized. The test
5# code monomorphizes the outer functions several times, but the magic constants
6# used in the inner functions should each appear only once in the generated IR.
7
8all:
9 $(RUSTC) foo.rs --emit=llvm-ir
10 [ "$$(grep -c 'ret i32 8675309' "$(TMPDIR)/foo.ll")" -eq "1" ]
11 [ "$$(grep -c 'ret i32 11235813' "$(TMPDIR)/foo.ll")" -eq "1" ]
tests/run-make-fulldeps/issue-7349/foo.rs deleted-22
...@@ -1,22 +0,0 @@
1fn outer<T>() {
2 #[allow(dead_code)]
3 fn inner() -> u32 {
4 8675309
5 }
6 inner();
7}
8
9extern "C" fn outer_foreign<T>() {
10 #[allow(dead_code)]
11 fn inner() -> u32 {
12 11235813
13 }
14 inner();
15}
16
17fn main() {
18 outer::<isize>();
19 outer::<usize>();
20 outer_foreign::<isize>();
21 outer_foreign::<usize>();
22}
tests/run-make-fulldeps/issue-83045/Makefile deleted-33
...@@ -1,33 +0,0 @@
1include ../../run-make-fulldeps/tools.mk
2
3# This test case creates a situation where the crate loader would run
4# into an ICE when confronted with an invalid setup where it cannot
5# find the dependency of a direct dependency.
6#
7# The test case makes sure that the compiler produces the expected
8# error message but does not ICE immediately after.
9#
10# See https://github.com/rust-lang/rust/issues/83045
11
12# This is a platform-independent issue, no need to waste time testing
13# everywhere.
14# only-x86_64
15# only-linux
16
17# NOTE: We use BARE_RUSTC below so that the compiler can't find liba.rlib
18# If we used RUSTC the additional '-L TMPDIR' option would allow rustc to
19# actually find the crate.
20#
21# We check that we get the expected error message
22# But that we do not get an ICE
23
24all:
25 $(RUSTC) --crate-name=a --crate-type=rlib a.rs --verbose
26 $(RUSTC) --crate-name=b --crate-type=rlib --extern a=$(TMPDIR)/liba.rlib b.rs --verbose
27 $(BARE_RUSTC) --out-dir $(TMPDIR) \
28 --extern b=$(TMPDIR)/libb.rlib \
29 --crate-type=rlib \
30 --edition=2018 \
31 c.rs 2>&1 | tee $(TMPDIR)/output.txt || exit 0
32 $(CGREP) E0519 < $(TMPDIR)/output.txt
33 $(CGREP) -v "internal compiler error" < $(TMPDIR)/output.txt
tests/run-make-fulldeps/issue-83045/a.rs deleted-1
...@@ -1 +0,0 @@
1// empty on purpose
tests/run-make-fulldeps/issue-83045/b.rs deleted-1
...@@ -1 +0,0 @@
1extern crate a;
tests/run-make-fulldeps/issue-83045/c.rs deleted-1
...@@ -1 +0,0 @@
1use b as _;
tests/run-make-fulldeps/issue-84395-lto-embed-bitcode/Makefile deleted-11
...@@ -1,11 +0,0 @@
1# needs-matching-clang
2
3# This test makes sure the embed bitcode in elf created with
4# lto-embed-bitcode=optimized is valid llvm BC module.
5
6include ../../run-make-fulldeps/tools.mk
7
8all:
9 $(RUSTC) test.rs --target $(TARGET) -Clink-arg=-fuse-ld=lld -Clinker-plugin-lto -Clinker=$(CLANG) -Clink-arg=-Wl,--plugin-opt=-lto-embed-bitcode=optimized -Zemit-thin-lto=no
10 $(LLVM_BIN_DIR)/objcopy --dump-section .llvmbc=$(TMPDIR)/test.bc $(TMPDIR)/test
11 $(LLVM_BIN_DIR)/llvm-dis $(TMPDIR)/test.bc
tests/run-make-fulldeps/issue-84395-lto-embed-bitcode/test.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 println!("Hello World!");
3}
tests/run-make-fulldeps/issue-97463-abi-param-passing/Makefile deleted-14
...@@ -1,14 +0,0 @@
1-include ../tools.mk
2
3# ignore-msvc
4
5# The issue exercised by this test, rust-lang/rust#97463, explicitly needs `-O`
6# flags (like `-O3`) to reproduce. Thus, we call $(CC) instead of nicer
7# alternatives provided by tools.mk like using `COMPILE_OBJ` or using a
8# `NATIVE_STATICLIB` dependency.
9
10all:
11 $(CC) -c -O3 -o $(TMPDIR)/bad.o bad.c
12 $(AR) rcs $(TMPDIR)/libbad.a $(TMPDIR)/bad.o
13 $(RUSTC) param_passing.rs -L$(TMPDIR) -lbad -C opt-level=3
14 $(call RUN,param_passing)
tests/run-make-fulldeps/issue-97463-abi-param-passing/bad.c deleted-24
...@@ -1,24 +0,0 @@
1#include <stdlib.h>
2#include <stdint.h>
3#include <stdio.h>
4
5
6struct bloc {
7 uint16_t a;
8 uint16_t b;
9 uint16_t c;
10};
11
12uint16_t c_read_value(uint32_t a, uint32_t b, uint32_t c) {
13 struct bloc *data = malloc(sizeof(struct bloc));
14
15 data->a = a & 0xFFFF;
16 data->b = b & 0xFFFF;
17 data->c = c & 0xFFFF;
18
19 printf("C struct: a = %u, b = %u, c = %u\n",
20 (unsigned) data->a, (unsigned) data->b, (unsigned) data->c);
21 printf("C function returns %u\n", (unsigned) data->b);
22
23 return data->b; /* leak data */
24}
tests/run-make-fulldeps/issue-97463-abi-param-passing/param_passing.rs deleted-38
...@@ -1,38 +0,0 @@
1// NOTE: Exposing the bug encoded in this test is sensitive to
2// LLVM optimization choices. See additional note below for an
3// example.
4
5#[link(name = "bad")]
6extern "C" {
7 pub fn c_read_value(a: u32, b: u32, c: u32) -> u16;
8}
9
10fn main() {
11 const C1: usize = 0x327b23c6;
12 const C2: usize = C1 & 0xFFFF;
13
14 let r1: usize = 0x0;
15 let r2: usize = C1;
16 let r3: usize = 0x0;
17 let value: u16 = unsafe { c_read_value(r1 as u32, r2 as u32, r3 as u32) };
18
19 // NOTE: as an example of the sensitivity of this test to optimization choices,
20 // uncommenting this block of code makes the bug go away on pnkfelix's machine.
21 // (But observing via `dbg!` doesn't hide the bug. At least sometimes.)
22 /*
23 println!("{}", value);
24 println!("{}", value as usize);
25 println!("{}", usize::from(value));
26 println!("{}", (value as usize) & 0xFFFF);
27 */
28
29 let d1 = value;
30 let d2 = value as usize;
31 let d3 = usize::from(value);
32 let d4 = (value as usize) & 0xFFFF;
33
34 let d = (&d1, &d2, &d3, &d4);
35 let d_ = (d1, d2, d3, d4);
36
37 assert_eq!(((&(C2 as u16), &C2, &C2, &C2), (C2 as u16, C2, C2, C2)), (d, d_));
38}
tests/run-make-fulldeps/issue64319/Makefile deleted-39
...@@ -1,39 +0,0 @@
1include ../../run-make-fulldeps/tools.mk
2
3# Different optimization levels imply different values for `-Zshare-generics`,
4# so try out a whole bunch of combinations to make sure everything is compatible
5all:
6 # First up, try some defaults
7 $(RUSTC) --crate-type rlib foo.rs
8 $(RUSTC) --crate-type dylib bar.rs -C opt-level=3
9
10 # Next try mixing up some things explicitly
11 $(RUSTC) --crate-type rlib foo.rs -Z share-generics=no
12 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
13 $(RUSTC) --crate-type rlib foo.rs -Z share-generics=no
14 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
15 $(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes
16 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
17 $(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes
18 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
19
20 # Now combine a whole bunch of options together
21 $(RUSTC) --crate-type rlib foo.rs
22 $(RUSTC) --crate-type dylib bar.rs
23 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
24 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
25 $(RUSTC) --crate-type dylib bar.rs -C opt-level=1
26 $(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=no
27 $(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=yes
28 $(RUSTC) --crate-type dylib bar.rs -C opt-level=2
29 $(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=no
30 $(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=yes
31 $(RUSTC) --crate-type dylib bar.rs -C opt-level=3
32 $(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=no
33 $(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=yes
34 $(RUSTC) --crate-type dylib bar.rs -C opt-level=s
35 $(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=no
36 $(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=yes
37 $(RUSTC) --crate-type dylib bar.rs -C opt-level=z
38 $(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=no
39 $(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=yes
tests/run-make-fulldeps/issue64319/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3pub fn bar() {
4 foo::foo();
5}
tests/run-make-fulldeps/issue64319/foo.rs deleted-9
...@@ -1,9 +0,0 @@
1pub fn foo() {
2 bar::<usize>();
3}
4
5pub fn bar<T>() {
6 baz();
7}
8
9fn baz() {}
tests/run-make-fulldeps/libs-through-symlinks/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4
5NAME := $(shell $(RUSTC) --print file-names foo.rs)
6
7all:
8 mkdir -p $(TMPDIR)/outdir
9 $(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME)
10 ln -nsf outdir/$(NAME) $(TMPDIR)
11 RUSTC_LOG=rustc_metadata::loader $(RUSTC) bar.rs
tests/run-make-fulldeps/libs-through-symlinks/bar.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate foo;
2
3fn main() {}
tests/run-make-fulldeps/libs-through-symlinks/foo.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "rlib"]
2#![crate_name = "foo"]
tests/run-make-fulldeps/libtest-json/Makefile deleted-18
...@@ -1,18 +0,0 @@
1include ../tools.mk
2
3# Test expected libtest's JSON output
4
5OUTPUT_FILE_DEFAULT := $(TMPDIR)/libtest-json-output-default.json
6OUTPUT_FILE_STDOUT_SUCCESS := $(TMPDIR)/libtest-json-output-stdout-success.json
7
8all: f.rs validate_json.py output-default.json output-stdout-success.json
9 $(RUSTC) --test f.rs
10 RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE_DEFAULT) || true
11 RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json --show-output > $(OUTPUT_FILE_STDOUT_SUCCESS) || true
12
13 cat $(OUTPUT_FILE_DEFAULT) | "$(PYTHON)" validate_json.py
14 cat $(OUTPUT_FILE_STDOUT_SUCCESS) | "$(PYTHON)" validate_json.py
15
16 # Normalize the actual output and compare to expected output file
17 cat $(OUTPUT_FILE_DEFAULT) | sed 's/"exec_time": [0-9.]*/"exec_time": $$TIME/' | diff output-default.json -
18 cat $(OUTPUT_FILE_STDOUT_SUCCESS) | sed 's/"exec_time": [0-9.]*/"exec_time": $$TIME/' | diff output-stdout-success.json -
tests/run-make-fulldeps/libtest-json/f.rs deleted-22
...@@ -1,22 +0,0 @@
1#[test]
2fn a() {
3 println!("print from successful test");
4 // Should pass
5}
6
7#[test]
8fn b() {
9 assert!(false);
10}
11
12#[test]
13#[should_panic]
14fn c() {
15 assert!(false);
16}
17
18#[test]
19#[ignore = "msg"]
20fn d() {
21 assert!(false);
22}
tests/run-make-fulldeps/libtest-json/output-default.json deleted-10
...@@ -1,10 +0,0 @@
1{ "type": "suite", "event": "started", "test_count": 4 }
2{ "type": "test", "event": "started", "name": "a" }
3{ "type": "test", "name": "a", "event": "ok" }
4{ "type": "test", "event": "started", "name": "b" }
5{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
6{ "type": "test", "event": "started", "name": "c" }
7{ "type": "test", "name": "c", "event": "ok" }
8{ "type": "test", "event": "started", "name": "d" }
9{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
10{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
tests/run-make-fulldeps/libtest-json/output-stdout-success.json deleted-10
...@@ -1,10 +0,0 @@
1{ "type": "suite", "event": "started", "test_count": 4 }
2{ "type": "test", "event": "started", "name": "a" }
3{ "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" }
4{ "type": "test", "event": "started", "name": "b" }
5{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
6{ "type": "test", "event": "started", "name": "c" }
7{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at 'assertion failed: false', f.rs:15:5\n" }
8{ "type": "test", "event": "started", "name": "d" }
9{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
10{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
tests/run-make-fulldeps/libtest-json/validate_json.py deleted-8
...@@ -1,8 +0,0 @@
1#!/usr/bin/env python
2
3import sys
4import json
5
6# Try to decode line in order to ensure it is a valid JSON document
7for line in sys.stdin:
8 json.loads(line)
tests/run-make-fulldeps/link-arg/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" --print link-args
3
4all:
5 $(RUSTC) $(RUSTC_FLAGS) empty.rs | $(CGREP) lfoo lbar
tests/run-make-fulldeps/link-arg/empty.rs deleted-1
...@@ -1 +0,0 @@
1fn main() { }
tests/run-make-fulldeps/link-args-order/Makefile deleted-10
...@@ -1,10 +0,0 @@
1# ignore-msvc
2
3include ../tools.mk
4
5RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args="d e" -C link-arg=f
6RUSTC_FLAGS_PRE = -C linker-flavor=ld -Z pre-link-arg=a -Z pre-link-args="b c" -Z pre-link-args="d e" -Z pre-link-arg=f
7
8all:
9 $(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
10 $(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
tests/run-make-fulldeps/link-args-order/empty.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/link-cfg/Makefile deleted-22
...@@ -1,22 +0,0 @@
1include ../tools.mk
2
3all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3)
4 ls $(TMPDIR)
5 $(BARE_RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static
6
7 $(RUSTC) no-deps.rs --cfg foo
8 $(call RUN,no-deps)
9 $(RUSTC) no-deps.rs --cfg bar
10 $(call RUN,no-deps)
11
12 $(RUSTC) dep.rs
13 $(RUSTC) with-deps.rs --cfg foo
14 $(call RUN,with-deps)
15 $(RUSTC) with-deps.rs --cfg bar
16 $(call RUN,with-deps)
17
18 $(RUSTC) dep-with-staticlib.rs
19 $(RUSTC) with-staticlib-deps.rs --cfg foo
20 $(call RUN,with-staticlib-deps)
21 $(RUSTC) with-staticlib-deps.rs --cfg bar
22 $(call RUN,with-staticlib-deps)
tests/run-make-fulldeps/link-cfg/dep-with-staticlib.rs deleted-8
...@@ -1,8 +0,0 @@
1#![feature(link_cfg)]
2#![crate_type = "rlib"]
3
4#[link(name = "return1", cfg(foo))]
5#[link(name = "return3", kind = "static", cfg(bar))]
6extern "C" {
7 pub fn my_function() -> i32;
8}
tests/run-make-fulldeps/link-cfg/dep.rs deleted-8
...@@ -1,8 +0,0 @@
1#![feature(link_cfg)]
2#![crate_type = "rlib"]
3
4#[link(name = "return1", cfg(foo))]
5#[link(name = "return2", cfg(bar))]
6extern "C" {
7 pub fn my_function() -> i32;
8}
tests/run-make-fulldeps/link-cfg/no-deps.rs deleted-20
...@@ -1,20 +0,0 @@
1#![feature(link_cfg)]
2
3#[link(name = "return1", cfg(foo))]
4#[link(name = "return2", cfg(bar))]
5extern "C" {
6 fn my_function() -> i32;
7}
8
9fn main() {
10 unsafe {
11 let v = my_function();
12 if cfg!(foo) {
13 assert_eq!(v, 1);
14 } else if cfg!(bar) {
15 assert_eq!(v, 2);
16 } else {
17 panic!("unknown");
18 }
19 }
20}
tests/run-make-fulldeps/link-cfg/return1.c deleted-6
...@@ -1,6 +0,0 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int my_function() {
5 return 1;
6}
tests/run-make-fulldeps/link-cfg/return2.c deleted-6
...@@ -1,6 +0,0 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int my_function() {
5 return 2;
6}
tests/run-make-fulldeps/link-cfg/return3.c deleted-6
...@@ -1,6 +0,0 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int my_function() {
5 return 3;
6}
tests/run-make-fulldeps/link-cfg/with-deps.rs deleted-14
...@@ -1,14 +0,0 @@
1extern crate dep;
2
3fn main() {
4 unsafe {
5 let v = dep::my_function();
6 if cfg!(foo) {
7 assert_eq!(v, 1);
8 } else if cfg!(bar) {
9 assert_eq!(v, 2);
10 } else {
11 panic!("unknown");
12 }
13 }
14}
tests/run-make-fulldeps/link-cfg/with-staticlib-deps.rs deleted-14
...@@ -1,14 +0,0 @@
1extern crate dep_with_staticlib;
2
3fn main() {
4 unsafe {
5 let v = dep_with_staticlib::my_function();
6 if cfg!(foo) {
7 assert_eq!(v, 1);
8 } else if cfg!(bar) {
9 assert_eq!(v, 3);
10 } else {
11 panic!("unknown");
12 }
13 }
14}
tests/run-make-fulldeps/link-dedup/Makefile deleted-12
...@@ -1,12 +0,0 @@
1# ignore-msvc
2
3include ../tools.mk
4
5all:
6 $(RUSTC) depa.rs
7 $(RUSTC) depb.rs
8 $(RUSTC) depc.rs
9 $(RUSTC) empty.rs --cfg bar 2>&1 | $(CGREP) '"-ltesta" "-ltestb" "-ltesta"'
10 $(RUSTC) empty.rs 2>&1 | $(CGREP) '"-ltesta"'
11 $(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltestb"'
12 $(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltesta" "-ltesta" "-ltesta"'
tests/run-make-fulldeps/link-dedup/depa.rs deleted-10
...@@ -1,10 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "testa")]
4extern "C" {}
5
6#[link(name = "testa")]
7extern "C" {}
8
9#[link(name = "testa")]
10extern "C" {}
tests/run-make-fulldeps/link-dedup/depb.rs deleted-8
...@@ -1,8 +0,0 @@
1#![feature(link_cfg)]
2#![crate_type = "rlib"]
3
4#[link(name = "testb", cfg(foo))]
5extern "C" {}
6
7#[link(name = "testb", cfg(bar))]
8extern "C" {}
tests/run-make-fulldeps/link-dedup/depc.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "testa")]
4extern "C" {}
tests/run-make-fulldeps/link-dedup/empty.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate depa;
2extern crate depb;
3extern crate depc;
4
5fn main() {}
tests/run-make-fulldeps/link-path-order/Makefile deleted-18
...@@ -1,18 +0,0 @@
1include ../tools.mk
2
3# Verifies that the -L arguments given to the linker is in the same order
4# as the -L arguments on the rustc command line.
5
6CORRECT_DIR=$(TMPDIR)/correct
7WRONG_DIR=$(TMPDIR)/wrong
8
9F := $(call NATIVE_STATICLIB_FILE,foo)
10
11all: $(call NATIVE_STATICLIB,correct) $(call NATIVE_STATICLIB,wrong)
12 mkdir -p $(CORRECT_DIR) $(WRONG_DIR)
13 mv $(call NATIVE_STATICLIB,correct) $(CORRECT_DIR)/$(F)
14 mv $(call NATIVE_STATICLIB,wrong) $(WRONG_DIR)/$(F)
15 $(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR)
16 $(call RUN,should_succeed)
17 $(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR)
18 $(call FAIL,should_fail)
tests/run-make-fulldeps/link-path-order/correct.c deleted-1
...@@ -1 +0,0 @@
1int should_return_one() { return 1; }
tests/run-make-fulldeps/link-path-order/main.rs deleted-16
...@@ -1,16 +0,0 @@
1#![feature(rustc_private)]
2
3extern crate libc;
4
5#[link(name = "foo", kind = "static")]
6extern "C" {
7 fn should_return_one() -> libc::c_int;
8}
9
10fn main() {
11 let result = unsafe { should_return_one() };
12
13 if result != 1 {
14 std::process::exit(255);
15 }
16}
tests/run-make-fulldeps/link-path-order/wrong.c deleted-1
...@@ -1 +0,0 @@
1int should_return_one() { return 0; }
tests/run-make-fulldeps/linkage-attr-on-static/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,foo)
4 $(RUSTC) bar.rs
5 $(call RUN,bar) || exit 1
tests/run-make-fulldeps/linkage-attr-on-static/bar.rs deleted-16
...@@ -1,16 +0,0 @@
1#![feature(linkage)]
2
3#[no_mangle]
4#[linkage = "external"]
5static BAZ: i32 = 21;
6
7#[link(name = "foo", kind = "static")]
8extern "C" {
9 fn what() -> i32;
10}
11
12fn main() {
13 unsafe {
14 assert_eq!(what(), BAZ);
15 }
16}
tests/run-make-fulldeps/linkage-attr-on-static/foo.c deleted-7
...@@ -1,7 +0,0 @@
1#include <stdint.h>
2
3extern int32_t BAZ;
4
5int32_t what() {
6 return BAZ;
7}
tests/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs -g
5 cp foo.bat $(TMPDIR)/
6 OUT_DIR="$(TMPDIR)" RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo)
tests/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat deleted-1
...@@ -1 +0,0 @@
1%MY_LINKER% %*
tests/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs deleted-101
...@@ -1,101 +0,0 @@
1// Like the `long-linker-command-lines` test this test attempts to blow
2// a command line limit for running the linker. Unlike that test, however,
3// this test is testing `cmd.exe` specifically rather than the OS.
4//
5// Unfortunately `cmd.exe` has a 8192 limit which is relatively small
6// in the grand scheme of things and anyone sripting rustc's linker
7// is probably using a `*.bat` script and is likely to hit this limit.
8//
9// This test uses a `foo.bat` script as the linker which just simply
10// delegates back to this program. The compiler should use a lower
11// limit for arguments before passing everything via `@`, which
12// means that everything should still succeed here.
13
14use std::env;
15use std::fs::{self, File};
16use std::io::{BufWriter, Write, Read};
17use std::path::PathBuf;
18use std::process::Command;
19
20fn main() {
21 if !cfg!(windows) {
22 return
23 }
24
25 let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
26 let ok = tmpdir.join("ok");
27 let not_ok = tmpdir.join("not_ok");
28 if env::var("YOU_ARE_A_LINKER").is_ok() {
29 match env::args_os().find(|a| a.to_string_lossy().contains("@")) {
30 Some(file) => {
31 let file = file.to_str().unwrap();
32 fs::copy(&file[1..], &ok).unwrap();
33 }
34 None => { File::create(&not_ok).unwrap(); }
35 }
36 return
37 }
38
39 let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
40 let me = env::current_exe().unwrap();
41 let bat = me.parent()
42 .unwrap()
43 .join("foo.bat");
44 let bat_linker = format!("linker={}", bat.display());
45 for i in (1..).map(|i| i * 10) {
46 println!("attempt: {}", i);
47
48 let file = tmpdir.join("bar.rs");
49 let mut f = BufWriter::new(File::create(&file).unwrap());
50 let mut lib_name = String::new();
51 for _ in 0..i {
52 lib_name.push_str("foo");
53 }
54 for j in 0..i {
55 writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap();
56 }
57 writeln!(f, "extern {{}}\nfn main() {{}}").unwrap();
58 f.into_inner().unwrap();
59
60 drop(fs::remove_file(&ok));
61 drop(fs::remove_file(&not_ok));
62 let status = Command::new(&rustc)
63 .arg(&file)
64 .arg("-C").arg(&bat_linker)
65 .arg("--out-dir").arg(&tmpdir)
66 .env("YOU_ARE_A_LINKER", "1")
67 .env("MY_LINKER", &me)
68 .status()
69 .unwrap();
70
71 if !status.success() {
72 panic!("rustc didn't succeed: {}", status);
73 }
74
75 if !ok.exists() {
76 assert!(not_ok.exists());
77 continue
78 }
79
80 let mut contents = Vec::new();
81 File::open(&ok).unwrap().read_to_end(&mut contents).unwrap();
82
83 for j in 0..i {
84 let exp = format!("{}{}", lib_name, j);
85 let exp = if cfg!(target_env = "msvc") {
86 let mut out = Vec::with_capacity(exp.len() * 2);
87 for c in exp.encode_utf16() {
88 // encode in little endian
89 out.push(c as u8);
90 out.push((c >> 8) as u8);
91 }
92 out
93 } else {
94 exp.into_bytes()
95 };
96 assert!(contents.windows(exp.len()).any(|w| w == &exp[..]));
97 }
98
99 break
100 }
101}
tests/run-make-fulldeps/long-linker-command-lines/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs -g -O
5 RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo)
tests/run-make-fulldeps/long-linker-command-lines/foo.rs deleted-106
...@@ -1,106 +0,0 @@
1// This is a test which attempts to blow out the system limit with how many
2// arguments can be passed to a process. This'll successively call rustc with
3// larger and larger argument lists in an attempt to find one that's way too
4// big for the system at hand. This file itself is then used as a "linker" to
5// detect when the process creation succeeds.
6//
7// Eventually we should see an argument that looks like `@` as we switch from
8// passing literal arguments to passing everything in the file.
9
10use std::collections::HashSet;
11use std::env;
12use std::fs::{self, File};
13use std::io::{BufWriter, Write};
14use std::path::{Path, PathBuf};
15use std::process::Command;
16
17fn write_test_case(file: &Path, n: usize) -> HashSet<String> {
18 let mut libs = HashSet::new();
19 let mut f = BufWriter::new(File::create(&file).unwrap());
20 let mut prefix = String::new();
21 for _ in 0..n {
22 prefix.push_str("foo");
23 }
24 for i in 0..n {
25 writeln!(f, "#[link(name = \"S{}{}S\")]", prefix, i).unwrap();
26 libs.insert(format!("{}{}", prefix, i));
27 }
28 writeln!(f, "extern \"C\" {{}}\nfn main() {{}}").unwrap();
29 f.into_inner().unwrap();
30
31 libs
32}
33
34fn read_linker_args(path: &Path) -> String {
35 let contents = fs::read(path).unwrap();
36 if cfg!(target_env = "msvc") {
37 let mut i = contents.chunks(2).map(|c| {
38 c[0] as u16 | ((c[1] as u16) << 8)
39 });
40 assert_eq!(i.next(), Some(0xfeff), "Expected UTF-16 BOM");
41 String::from_utf16(&i.collect::<Vec<u16>>()).unwrap()
42 } else {
43 String::from_utf8(contents).unwrap()
44 }
45}
46
47fn main() {
48 let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap());
49 let ok = tmpdir.join("ok");
50 if env::var("YOU_ARE_A_LINKER").is_ok() {
51 if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) {
52 let file = file.to_str().expect("non-utf8 file argument");
53 fs::copy(&file[1..], &ok).unwrap();
54 }
55 return
56 }
57
58 let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
59 let me_as_linker = format!("linker={}", env::current_exe().unwrap().display());
60 for i in (1..).map(|i| i * 100) {
61 println!("attempt: {}", i);
62 let file = tmpdir.join("bar.rs");
63 let mut expected_libs = write_test_case(&file, i);
64
65 drop(fs::remove_file(&ok));
66 let output = Command::new(&rustc)
67 .arg(&file)
68 .arg("-C").arg(&me_as_linker)
69 .arg("--out-dir").arg(&tmpdir)
70 .env("YOU_ARE_A_LINKER", "1")
71 .output()
72 .unwrap();
73
74 if !output.status.success() {
75 let stderr = String::from_utf8_lossy(&output.stderr);
76 panic!("status: {}\nstdout:\n{}\nstderr:\n{}",
77 output.status,
78 String::from_utf8_lossy(&output.stdout),
79 stderr.lines().map(|l| {
80 if l.len() > 200 {
81 format!("{}...\n", &l[..200])
82 } else {
83 format!("{}\n", l)
84 }
85 }).collect::<String>());
86 }
87
88 if !ok.exists() {
89 continue
90 }
91
92 let linker_args = read_linker_args(&ok);
93 for arg in linker_args.split('S') {
94 expected_libs.remove(arg);
95 }
96
97 assert!(
98 expected_libs.is_empty(),
99 "expected but missing libraries: {:#?}\nlinker arguments: \n{}",
100 expected_libs,
101 linker_args,
102 );
103
104 break
105 }
106}
tests/run-make-fulldeps/longjmp-across-rust/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,foo)
4 $(RUSTC) main.rs
5 $(call RUN,main)
tests/run-make-fulldeps/longjmp-across-rust/foo.c deleted-18
...@@ -1,18 +0,0 @@
1#include <assert.h>
2#include <setjmp.h>
3
4static jmp_buf ENV;
5
6extern void test_middle();
7
8void test_start(void(*f)()) {
9 if (setjmp(ENV) != 0)
10 return;
11 f();
12 assert(0);
13}
14
15void test_end() {
16 longjmp(ENV, 1);
17 assert(0);
18}
tests/run-make-fulldeps/longjmp-across-rust/main.rs deleted-29
...@@ -1,29 +0,0 @@
1#[link(name = "foo", kind = "static")]
2extern "C" {
3 fn test_start(f: extern "C" fn());
4 fn test_end();
5}
6
7fn main() {
8 unsafe {
9 test_start(test_middle);
10 }
11}
12
13struct A;
14
15impl Drop for A {
16 fn drop(&mut self) {}
17}
18
19extern "C" fn test_middle() {
20 let _a = A;
21 foo();
22}
23
24fn foo() {
25 let _a = A;
26 unsafe {
27 test_end();
28 }
29}
tests/run-make-fulldeps/ls-metadata/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs
5 $(RUSTC) -Z ls $(TMPDIR)/foo
6 touch $(TMPDIR)/bar
7 $(RUSTC) -Z ls $(TMPDIR)/bar
tests/run-make-fulldeps/ls-metadata/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/lto-dylib-dep/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3# Test that we don't run into an assertion when using a Rust dylib dependency
4# while compiling with full LTO.
5# See https://github.com/rust-lang/rust/issues/59137
6
7all:
8 $(RUSTC) a_dylib.rs --crate-type=dylib -C prefer-dynamic
9 $(RUSTC) main.rs -C lto
10 $(call RUN,main)
tests/run-make-fulldeps/lto-dylib-dep/a_dylib.rs deleted-3
...@@ -1,3 +0,0 @@
1pub fn foo() {
2 println!("bar");
3}
tests/run-make-fulldeps/lto-dylib-dep/main.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate a_dylib;
2
3fn main() {
4 a_dylib::foo();
5}
tests/run-make-fulldeps/lto-empty/Makefile deleted-12
...@@ -1,12 +0,0 @@
1include ../tools.mk
2
3all: cdylib-fat cdylib-thin
4
5cdylib-fat:
6 $(RUSTC) lib.rs -C lto=fat -C opt-level=3 -C incremental=$(TMPDIR)/inc-fat
7 $(RUSTC) lib.rs -C lto=fat -C opt-level=3 -C incremental=$(TMPDIR)/inc-fat
8
9cdylib-thin:
10 $(RUSTC) lib.rs -C lto=thin -C opt-level=3 -C incremental=$(TMPDIR)/inc-thin
11 $(RUSTC) lib.rs -C lto=thin -C opt-level=3 -C incremental=$(TMPDIR)/inc-thin
12
tests/run-make-fulldeps/lto-empty/lib.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "cdylib"]
tests/run-make-fulldeps/lto-no-link-whole-rlib/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar)
4 $(RUSTC) lib1.rs
5 $(RUSTC) lib2.rs
6 $(RUSTC) main.rs -Clto
7 $(call RUN,main)
8
tests/run-make-fulldeps/lto-no-link-whole-rlib/bar.c deleted-3
...@@ -1,3 +0,0 @@
1int foo() {
2 return 2;
3}
tests/run-make-fulldeps/lto-no-link-whole-rlib/foo.c deleted-3
...@@ -1,3 +0,0 @@
1int foo() {
2 return 1;
3}
tests/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs deleted-10
...@@ -1,10 +0,0 @@
1#![crate_type = "rlib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {
5 fn foo() -> i32;
6}
7
8pub fn foo1() -> i32 {
9 unsafe { foo() }
10}
tests/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs deleted-12
...@@ -1,12 +0,0 @@
1#![crate_type = "rlib"]
2
3extern crate lib1;
4
5#[link(name = "bar", kind = "static")]
6extern "C" {
7 fn foo() -> i32;
8}
9
10pub fn foo2() -> i32 {
11 unsafe { foo() }
12}
tests/run-make-fulldeps/lto-no-link-whole-rlib/main.rs deleted-7
...@@ -1,7 +0,0 @@
1extern crate lib1;
2extern crate lib2;
3
4fn main() {
5 assert_eq!(lib1::foo1(), 2);
6 assert_eq!(lib2::foo2(), 2);
7}
tests/run-make-fulldeps/lto-readonly-lib/Makefile deleted-12
...@@ -1,12 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) lib.rs
5
6 # the compiler needs to copy and modify the rlib file when performing
7 # LTO, so we should ensure that it can cope with the original rlib
8 # being read-only.
9 chmod 444 $(TMPDIR)/*.rlib
10
11 $(RUSTC) main.rs -C lto
12 $(call RUN,main)
tests/run-make-fulldeps/lto-readonly-lib/lib.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "rlib"]
tests/run-make-fulldeps/lto-readonly-lib/main.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate lib;
2
3fn main() {}
tests/run-make-fulldeps/lto-smoke-c/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3# Apparently older versions of GCC segfault if -g is passed...
4CC := $(CC:-g=)
5
6all:
7 $(RUSTC) foo.rs -C lto
8 $(CC) bar.c $(call STATICLIB,foo) \
9 $(call OUT_EXE,bar) \
10 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
11 $(call RUN,bar)
tests/run-make-fulldeps/lto-smoke-c/bar.c deleted-6
...@@ -1,6 +0,0 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make-fulldeps/lto-smoke-c/foo.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "staticlib"]
2
3#[no_mangle]
4pub extern "C" fn foo() {}
tests/run-make-fulldeps/lto-smoke/Makefile deleted-30
...@@ -1,30 +0,0 @@
1include ../tools.mk
2
3all: noparam bool_true bool_false thin fat
4
5noparam:
6 $(RUSTC) lib.rs
7 $(RUSTC) main.rs -C lto
8 $(call RUN,main)
9
10bool_true:
11 $(RUSTC) lib.rs
12 $(RUSTC) main.rs -C lto=yes
13 $(call RUN,main)
14
15
16bool_false:
17 $(RUSTC) lib.rs
18 $(RUSTC) main.rs -C lto=off
19 $(call RUN,main)
20
21thin:
22 $(RUSTC) lib.rs
23 $(RUSTC) main.rs -C lto=thin
24 $(call RUN,main)
25
26fat:
27 $(RUSTC) lib.rs
28 $(RUSTC) main.rs -C lto=fat
29 $(call RUN,main)
30
tests/run-make-fulldeps/lto-smoke/lib.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "rlib"]
tests/run-make-fulldeps/lto-smoke/main.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate lib;
2
3fn main() {}
tests/run-make-fulldeps/manual-crate-name/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --crate-name foo bar.rs
5 rm $(TMPDIR)/libfoo.rlib
tests/run-make-fulldeps/manual-crate-name/bar.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "rlib"]
tests/run-make-fulldeps/manual-link/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all: $(TMPDIR)/libbar.a
4 $(RUSTC) foo.rs -lstatic=bar
5 $(RUSTC) main.rs
6 $(call RUN,main)
tests/run-make-fulldeps/manual-link/bar.c deleted-1
...@@ -1 +0,0 @@
1void bar() {}
tests/run-make-fulldeps/manual-link/foo.c deleted-1
...@@ -1 +0,0 @@
1void bar() {}
tests/run-make-fulldeps/manual-link/foo.rs deleted-11
...@@ -1,11 +0,0 @@
1#![crate_type = "rlib"]
2
3extern "C" {
4 fn bar();
5}
6
7pub fn foo() {
8 unsafe {
9 bar();
10 }
11}
tests/run-make-fulldeps/manual-link/main.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::foo();
5}
tests/run-make-fulldeps/many-crates-but-no-match/Makefile deleted-35
...@@ -1,35 +0,0 @@
1include ../tools.mk
2
3# Modelled after ui/changing-crates.rs test, but this one puts
4# more than one (mismatching) candidate crate into the search path,
5# which did not appear directly expressible in UI testing infrastructure.
6#
7# Note that we move the built libraries into target direcrtories rather than
8# use the `--out-dir` option because the `../tools.mk` file already bakes a
9# use of `--out-dir` into the definition of $(RUSTC).
10
11A1=$(TMPDIR)/a1
12A2=$(TMPDIR)/a2
13A3=$(TMPDIR)/a3
14
15# A hack to match distinct lines of output from a single run.
16LOG=$(TMPDIR)/log.txt
17
18all:
19 mkdir -p $(A1) $(A2) $(A3)
20 $(RUSTC) --crate-type=rlib crateA1.rs
21 mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1)
22 $(RUSTC) --crate-type=rlib -L $(A1) crateB.rs
23 $(RUSTC) --crate-type=rlib crateA2.rs
24 mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2)
25 $(RUSTC) --crate-type=rlib crateA3.rs
26 mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3)
27 # Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match
28 $(RUSTC) -L $(A2) -L $(A3) crateC.rs >$(LOG) 2>&1 || true
29 $(CGREP) \
30 'found possibly newer version of crate `crateA` which `crateB` depends on' \
31 'note: perhaps that crate needs to be recompiled?' \
32 'crate `crateA`:' \
33 'crate `crateB`:' \
34 < $(LOG)
35 # the 'crate `crateA`' will match two entries.
tests/run-make-fulldeps/many-crates-but-no-match/crateA1.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_name="crateA"]
2
3// Base crate
4pub fn func<T>() {}
tests/run-make-fulldeps/many-crates-but-no-match/crateA2.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_name="crateA"]
2
3// Base crate
4pub fn func<T>() { println!("hello"); }
tests/run-make-fulldeps/many-crates-but-no-match/crateA3.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_name="crateA"]
2
3// Base crate
4pub fn foo<T>() { println!("world!"); }
tests/run-make-fulldeps/many-crates-but-no-match/crateB.rs deleted-1
...@@ -1 +0,0 @@
1extern crate crateA;
tests/run-make-fulldeps/many-crates-but-no-match/crateC.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate crateB;
2
3fn main() {}
tests/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs -C metadata=a -C extra-filename=-a
5 $(RUSTC) foo.rs -C metadata=b -C extra-filename=-b
6 $(RUSTC) bar.rs \
7 --extern foo1=$(TMPDIR)/libfoo-a.rlib \
8 --extern foo2=$(TMPDIR)/libfoo-b.rlib \
9 --print link-args
10 $(call RUN,bar)
tests/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs deleted-8
...@@ -1,8 +0,0 @@
1extern crate foo1;
2extern crate foo2;
3
4fn main() {
5 let a = foo1::foo();
6 let b = foo2::foo();
7 assert!(a as *const _ != b as *const _);
8}
tests/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_name = "foo"]
2#![crate_type = "rlib"]
3
4static FOO: usize = 3;
5
6pub fn foo() -> &'static usize { &FOO }
tests/run-make-fulldeps/min-global-align/Makefile deleted-22
...@@ -1,22 +0,0 @@
1include ../tools.mk
2
3# only-linux
4
5# This tests ensure that global variables respect the target minimum alignment.
6# The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have
7# type-alignment of 1, but some targets require greater global alignment.
8
9SRC = min_global_align.rs
10LL = $(TMPDIR)/min_global_align.ll
11
12all:
13# Most targets are happy with default alignment -- take i686 for example.
14ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
15 $(RUSTC) --target=i686-unknown-linux-gnu --emit=llvm-ir $(SRC)
16 [ "$$(grep -c 'align 1' "$(LL)")" -eq "3" ]
17endif
18# SystemZ requires even alignment for PC-relative addressing.
19ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz)
20 $(RUSTC) --target=s390x-unknown-linux-gnu --emit=llvm-ir $(SRC)
21 [ "$$(grep -c 'align 2' "$(LL)")" -eq "3" ]
22endif
tests/run-make-fulldeps/min-global-align/min_global_align.rs deleted-32
...@@ -1,32 +0,0 @@
1#![feature(no_core, lang_items)]
2#![crate_type = "rlib"]
3#![no_core]
4
5pub static STATIC_BOOL: bool = true;
6
7pub static mut STATIC_MUT_BOOL: bool = true;
8
9const CONST_BOOL: bool = true;
10pub static CONST_BOOL_REF: &'static bool = &CONST_BOOL;
11
12#[lang = "sized"]
13trait Sized {}
14
15#[lang = "copy"]
16trait Copy {}
17impl Copy for bool {}
18impl Copy for &bool {}
19
20#[lang = "freeze"]
21trait Freeze {}
22
23// No `UnsafeCell`, so everything is `Freeze`.
24impl<T: ?Sized> Freeze for T {}
25
26#[lang = "sync"]
27trait Sync {}
28impl Sync for bool {}
29impl Sync for &'static bool {}
30
31#[lang = "drop_in_place"]
32pub unsafe fn drop_in_place<T: ?Sized>(_: *mut T) {}
tests/run-make-fulldeps/mingw-export-call-convention/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# only-windows-gnu
4
5all:
6 $(RUSTC) foo.rs
7 # FIXME: we should make sure __stdcall calling convention is used here
8 # but that only works with LLD right now
9 nm -g "$(call IMPLIB,foo)" | $(CGREP) bar
tests/run-make-fulldeps/mingw-export-call-convention/foo.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "cdylib"]
2
3#[no_mangle]
4pub extern "system" fn bar() {}
tests/run-make-fulldeps/mismatching-target-triples/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3# Issue #10814
4#
5# these are no_std to avoid having to have the standard library or any
6# linkers/assemblers for the relevant platform
7
8all:
9 $(RUSTC) foo.rs --target=i686-unknown-linux-gnu
10 $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \
11 | $(CGREP) 'couldn'"'"'t find crate `foo` with expected target triple x86_64-unknown-linux-gnu'
tests/run-make-fulldeps/mismatching-target-triples/bar.rs deleted-3
...@@ -1,3 +0,0 @@
1#![feature(no_core)]
2#![no_core]
3extern crate foo;
tests/run-make-fulldeps/mismatching-target-triples/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1#![feature(no_core)]
2#![no_core]
3#![crate_type = "lib"]
tests/run-make-fulldeps/missing-crate-dependency/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --crate-type=rlib crateA.rs
5 $(RUSTC) --crate-type=rlib crateB.rs
6 $(call REMOVE_RLIBS,crateA)
7 # Ensure crateC fails to compile since dependency crateA is missing
8 $(RUSTC) crateC.rs 2>&1 | \
9 $(CGREP) 'can'"'"'t find crate for `crateA` which `crateB` depends on'
tests/run-make-fulldeps/missing-crate-dependency/crateA.rs deleted-2
...@@ -1,2 +0,0 @@
1// Base crate
2pub fn func() {}
tests/run-make-fulldeps/missing-crate-dependency/crateB.rs deleted-1
...@@ -1 +0,0 @@
1extern crate crateA;
tests/run-make-fulldeps/missing-crate-dependency/crateC.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate crateB;
2
3fn main() {}
tests/run-make-fulldeps/mixing-deps/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) both.rs -C prefer-dynamic
5 $(RUSTC) dylib.rs -C prefer-dynamic
6 $(RUSTC) prog.rs
7 $(call RUN,prog)
tests/run-make-fulldeps/mixing-deps/both.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "rlib"]
2#![crate_type = "dylib"]
3
4pub static foo: isize = 4;
tests/run-make-fulldeps/mixing-deps/dylib.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_type = "dylib"]
2extern crate both;
3
4use std::mem;
5
6pub fn addr() -> usize { unsafe { mem::transmute(&both::foo) } }
tests/run-make-fulldeps/mixing-deps/prog.rs deleted-9
...@@ -1,9 +0,0 @@
1extern crate dylib;
2extern crate both;
3
4use std::mem;
5
6fn main() {
7 assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) },
8 dylib::addr());
9}
tests/run-make-fulldeps/mixing-formats/Makefile deleted-74
...@@ -1,74 +0,0 @@
1include ../tools.mk
2
3# Testing various mixings of rlibs and dylibs. Makes sure that it's possible to
4# link an rlib to a dylib. The dependency tree among the file looks like:
5#
6# foo
7# / \
8# bar1 bar2
9# / \ /
10# baz baz2
11#
12# This is generally testing the permutations of the foo/bar1/bar2 layer against
13# the baz/baz2 layer
14
15all:
16 # Building just baz
17 $(RUSTC) --crate-type=rlib foo.rs
18 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
19 $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic
20 $(RUSTC) --crate-type=bin baz.rs
21 rm $(TMPDIR)/*
22 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
23 $(RUSTC) --crate-type=rlib bar1.rs
24 $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic
25 $(RUSTC) --crate-type=bin baz.rs
26 rm $(TMPDIR)/*
27 # Building baz2
28 $(RUSTC) --crate-type=rlib foo.rs
29 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
30 $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic
31 $(RUSTC) --crate-type=dylib baz2.rs && exit 1 || exit 0
32 $(RUSTC) --crate-type=bin baz2.rs && exit 1 || exit 0
33 rm $(TMPDIR)/*
34 $(RUSTC) --crate-type=rlib foo.rs
35 $(RUSTC) --crate-type=rlib bar1.rs
36 $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic
37 $(RUSTC) --crate-type=dylib,rlib baz2.rs
38 $(RUSTC) --crate-type=bin baz2.rs
39 rm $(TMPDIR)/*
40 $(RUSTC) --crate-type=rlib foo.rs
41 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
42 $(RUSTC) --crate-type=rlib bar2.rs
43 $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic
44 $(RUSTC) --crate-type=bin baz2.rs
45 rm $(TMPDIR)/*
46 $(RUSTC) --crate-type=rlib foo.rs
47 $(RUSTC) --crate-type=rlib bar1.rs
48 $(RUSTC) --crate-type=rlib bar2.rs
49 $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic
50 $(RUSTC) --crate-type=bin baz2.rs
51 rm $(TMPDIR)/*
52 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
53 $(RUSTC) --crate-type=rlib bar1.rs
54 $(RUSTC) --crate-type=rlib bar2.rs
55 $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic
56 $(RUSTC) --crate-type=bin baz2.rs
57 rm $(TMPDIR)/*
58 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
59 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
60 $(RUSTC) --crate-type=rlib bar2.rs
61 $(RUSTC) --crate-type=dylib,rlib baz2.rs
62 $(RUSTC) --crate-type=bin baz2.rs
63 rm $(TMPDIR)/*
64 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
65 $(RUSTC) --crate-type=rlib bar1.rs
66 $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic
67 $(RUSTC) --crate-type=dylib,rlib baz2.rs
68 $(RUSTC) --crate-type=bin baz2.rs
69 rm $(TMPDIR)/*
70 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
71 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
72 $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic
73 $(RUSTC) --crate-type=dylib,rlib baz2.rs
74 $(RUSTC) --crate-type=bin baz2.rs
tests/run-make-fulldeps/mixing-formats/bar1.rs deleted-1
...@@ -1 +0,0 @@
1extern crate foo;
tests/run-make-fulldeps/mixing-formats/bar2.rs deleted-1
...@@ -1 +0,0 @@
1extern crate foo;
tests/run-make-fulldeps/mixing-formats/baz.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate bar1;
2
3fn main() {}
tests/run-make-fulldeps/mixing-formats/baz2.rs deleted-4
...@@ -1,4 +0,0 @@
1extern crate bar1;
2extern crate bar2;
3
4fn main() {}
tests/run-make-fulldeps/mixing-formats/foo.rs deleted-1
...@@ -1 +0,0 @@
1// intentionally empty
tests/run-make-fulldeps/mixing-libs/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) rlib.rs
5 $(RUSTC) dylib.rs
6 $(RUSTC) rlib.rs --crate-type=dylib
7 $(RUSTC) dylib.rs
8 $(call REMOVE_DYLIBS,rlib)
9 $(RUSTC) prog.rs && exit 1 || exit 0
tests/run-make-fulldeps/mixing-libs/dylib.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "dylib"]
2extern crate rlib;
3
4pub fn dylib() { rlib::rlib() }
tests/run-make-fulldeps/mixing-libs/prog.rs deleted-7
...@@ -1,7 +0,0 @@
1extern crate dylib;
2extern crate rlib;
3
4fn main() {
5 dylib::dylib();
6 rlib::rlib();
7}
tests/run-make-fulldeps/mixing-libs/rlib.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "rlib"]
2pub fn rlib() {}
tests/run-make-fulldeps/msvc-opt-minsize/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs -Copt-level=z 2>&1
5 $(call RUN,foo)
tests/run-make-fulldeps/msvc-opt-minsize/foo.rs deleted-19
...@@ -1,19 +0,0 @@
1#![feature(test)]
2extern crate test;
3
4fn foo(x: i32, y: i32) -> i64 {
5 (x + y) as i64
6}
7
8#[inline(never)]
9fn bar() {
10 let _f = Box::new(0);
11 // This call used to trigger an LLVM bug in opt-level z where the base
12 // pointer gets corrupted, see issue #45034
13 let y: fn(i32, i32) -> i64 = test::black_box(foo);
14 test::black_box(y(1, 2));
15}
16
17fn main() {
18 bar();
19}
tests/run-make-fulldeps/multiple-emits/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out 2>&1
5 rm $(TMPDIR)/out.ll $(TMPDIR)/out.s
6 $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out2.ext 2>&1
7 rm $(TMPDIR)/out2.ll $(TMPDIR)/out2.s
tests/run-make-fulldeps/multiple-emits/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/no-builtins-lto/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3all:
4 # Compile a `#![no_builtins]` rlib crate
5 $(RUSTC) no_builtins.rs
6 # Build an executable that depends on that crate using LTO. The no_builtins crate doesn't
7 # participate in LTO, so its rlib must be explicitly linked into the final binary. Verify this by
8 # grepping the linker arguments.
9 $(RUSTC) main.rs -C lto --print link-args | $(CGREP) 'libno_builtins.rlib'
tests/run-make-fulldeps/no-builtins-lto/main.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate no_builtins;
2
3fn main() {}
tests/run-make-fulldeps/no-builtins-lto/no_builtins.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "lib"]
2#![no_builtins]
tests/run-make-fulldeps/no-duplicate-libs/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3ifdef IS_MSVC
4# FIXME(#27979)
5all:
6else
7all: $(call STATICLIB,foo) $(call STATICLIB,bar)
8 $(RUSTC) main.rs
9 $(call RUN,main)
10endif
tests/run-make-fulldeps/no-duplicate-libs/bar.c deleted-5
...@@ -1,5 +0,0 @@
1extern void foo();
2
3void bar() {
4 foo();
5}
tests/run-make-fulldeps/no-duplicate-libs/foo.c deleted-1
...@@ -1 +0,0 @@
1void foo() {}
tests/run-make-fulldeps/no-duplicate-libs/main.rs deleted-10
...@@ -1,10 +0,0 @@
1#[link(name = "foo")] // linker should drop this library, no symbols used
2#[link(name = "bar")] // symbol comes from this library
3#[link(name = "foo")] // now linker picks up `foo` b/c `bar` library needs it
4extern "C" {
5 fn bar();
6}
7
8fn main() {
9 unsafe { bar() }
10}
tests/run-make-fulldeps/no-intermediate-extras/Makefile deleted-7
...@@ -1,7 +0,0 @@
1# Regression test for issue #10973
2
3include ../tools.mk
4
5all:
6 $(RUSTC) --crate-type=rlib --test foo.rs
7 rm $(TMPDIR)/foo.bc && exit 1 || exit 0
tests/run-make-fulldeps/no-intermediate-extras/foo.rs deleted-1
...@@ -1 +0,0 @@
1// intentionally empty
tests/run-make-fulldeps/obey-crate-type-flag/Makefile deleted-13
...@@ -1,13 +0,0 @@
1include ../tools.mk
2
3# check that rustc builds all crate_type attributes
4# delete rlib
5# delete whatever dylib is made for this system
6# check that rustc only builds --crate-type flags, ignoring attributes
7# fail if an rlib was built
8all:
9 $(RUSTC) test.rs
10 $(call REMOVE_RLIBS,test)
11 $(call REMOVE_DYLIBS,test)
12 $(RUSTC) --crate-type dylib test.rs
13 $(call REMOVE_RLIBS,test) && exit 1 || exit 0
tests/run-make-fulldeps/obey-crate-type-flag/test.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "rlib"]
2#![crate_type = "dylib"]
tests/run-make-fulldeps/obtain-borrowck/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../tools.mk1include ../../run-make/tools.mk
22
3# This example shows how to implement a rustc driver that retrieves MIR bodies3# This example shows how to implement a rustc driver that retrieves MIR bodies
4# together with the borrow checker information.4# together with the borrow checker information.
tests/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 cp foo.rs $(TMPDIR)/foo.rs
5 mkdir $(TMPDIR)/foo
6 $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \
7 | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\""
tests/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/output-filename-overwrites-input/Makefile deleted-13
...@@ -1,13 +0,0 @@
1include ../tools.mk
2
3all:
4 cp foo.rs $(TMPDIR)/foo
5 $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \
6 | $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable"
7 cp bar.rs $(TMPDIR)/bar.rlib
8 $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \
9 | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable"
10 $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1
11 cp foo.rs $(TMPDIR)/foo.rs
12 $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \
13 | $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable"
tests/run-make-fulldeps/output-filename-overwrites-input/bar.rs deleted-1
...@@ -1 +0,0 @@
1#![crate_type = "lib"]
tests/run-make-fulldeps/output-filename-overwrites-input/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/output-type-permutations/Makefile deleted-146
...@@ -1,146 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib
5 $(call REMOVE_RLIBS,bar)
6 $(call REMOVE_DYLIBS,bar)
7 rm $(call STATICLIB,bar)
8 rm -f $(TMPDIR)/{lib,}bar.{dll.exp,dll.lib,pdb,dll.a}
9 # Check that $(TMPDIR) is empty.
10 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
11
12 $(RUSTC) foo.rs --crate-type=bin
13 rm $(TMPDIR)/$(call BIN,bar)
14 rm -f $(TMPDIR)/bar.pdb
15 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
16
17 $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link
18 rm $(TMPDIR)/bar.ll
19 rm $(TMPDIR)/bar.bc
20 rm $(TMPDIR)/bar.s
21 rm $(TMPDIR)/bar.o
22 rm $(TMPDIR)/$(call BIN,bar)
23 rm -f $(TMPDIR)/bar.pdb
24 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
25
26 $(RUSTC) foo.rs --emit asm -o $(TMPDIR)/foo
27 rm $(TMPDIR)/foo
28 $(RUSTC) foo.rs --emit asm=$(TMPDIR)/foo
29 rm $(TMPDIR)/foo
30 $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/foo
31 rm $(TMPDIR)/foo
32 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
33
34 $(RUSTC) foo.rs --emit llvm-bc -o $(TMPDIR)/foo
35 rm $(TMPDIR)/foo
36 $(RUSTC) foo.rs --emit llvm-bc=$(TMPDIR)/foo
37 rm $(TMPDIR)/foo
38 $(RUSTC) foo.rs --emit=llvm-bc=$(TMPDIR)/foo
39 rm $(TMPDIR)/foo
40 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
41
42 $(RUSTC) foo.rs --emit llvm-ir -o $(TMPDIR)/foo
43 rm $(TMPDIR)/foo
44 $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/foo
45 rm $(TMPDIR)/foo
46 $(RUSTC) foo.rs --emit=llvm-ir=$(TMPDIR)/foo
47 rm $(TMPDIR)/foo
48 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
49
50 $(RUSTC) foo.rs --emit obj -o $(TMPDIR)/foo
51 rm $(TMPDIR)/foo
52 $(RUSTC) foo.rs --emit obj=$(TMPDIR)/foo
53 rm $(TMPDIR)/foo
54 $(RUSTC) foo.rs --emit=obj=$(TMPDIR)/foo
55 rm $(TMPDIR)/foo
56 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
57
58 $(RUSTC) foo.rs --emit link -o $(TMPDIR)/$(call BIN,foo)
59 rm $(TMPDIR)/$(call BIN,foo)
60 $(RUSTC) foo.rs --emit link=$(TMPDIR)/$(call BIN,foo)
61 rm $(TMPDIR)/$(call BIN,foo)
62 $(RUSTC) foo.rs --emit=link=$(TMPDIR)/$(call BIN,foo)
63 rm $(TMPDIR)/$(call BIN,foo)
64 rm -f $(TMPDIR)/foo.pdb
65 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
66
67 $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo
68 rm $(TMPDIR)/foo
69 $(RUSTC) foo.rs --crate-type=rlib --emit link=$(TMPDIR)/foo
70 rm $(TMPDIR)/foo
71 $(RUSTC) foo.rs --crate-type=rlib --emit=link=$(TMPDIR)/foo
72 rm $(TMPDIR)/foo
73 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
74
75 $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/$(call BIN,foo)
76 rm $(TMPDIR)/$(call BIN,foo)
77 $(RUSTC) foo.rs --crate-type=dylib --emit link=$(TMPDIR)/$(call BIN,foo)
78 rm $(TMPDIR)/$(call BIN,foo)
79 $(RUSTC) foo.rs --crate-type=dylib --emit=link=$(TMPDIR)/$(call BIN,foo)
80 rm $(TMPDIR)/$(call BIN,foo)
81 rm -f $(TMPDIR)/{lib,}foo.{dll.exp,dll.lib,pdb,dll.a,exe.a}
82 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] || (ls -1 $(TMPDIR) && exit 1)
83
84 $(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo
85 rm $(TMPDIR)/foo
86 $(RUSTC) foo.rs --crate-type=staticlib --emit link=$(TMPDIR)/foo
87 rm $(TMPDIR)/foo
88 $(RUSTC) foo.rs --crate-type=staticlib --emit=link=$(TMPDIR)/foo
89 rm $(TMPDIR)/foo
90 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
91
92 $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/$(call BIN,foo)
93 rm $(TMPDIR)/$(call BIN,foo)
94 $(RUSTC) foo.rs --crate-type=bin --emit link=$(TMPDIR)/$(call BIN,foo)
95 rm $(TMPDIR)/$(call BIN,foo)
96 $(RUSTC) foo.rs --crate-type=bin --emit=link=$(TMPDIR)/$(call BIN,foo)
97 rm $(TMPDIR)/$(call BIN,foo)
98 rm -f $(TMPDIR)/foo.pdb
99 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
100
101 $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/ir \
102 --emit link \
103 --crate-type=rlib
104 rm $(TMPDIR)/ir
105 rm $(TMPDIR)/libbar.rlib
106 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
107
108 $(RUSTC) foo.rs --emit asm=$(TMPDIR)/asm \
109 --emit llvm-ir=$(TMPDIR)/ir \
110 --emit llvm-bc=$(TMPDIR)/bc \
111 --emit obj=$(TMPDIR)/obj \
112 --emit link=$(TMPDIR)/link \
113 --crate-type=staticlib
114 rm $(TMPDIR)/asm
115 rm $(TMPDIR)/ir
116 rm $(TMPDIR)/bc
117 rm $(TMPDIR)/obj
118 rm $(TMPDIR)/link
119 $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/asm \
120 --emit llvm-ir=$(TMPDIR)/ir \
121 --emit=llvm-bc=$(TMPDIR)/bc \
122 --emit obj=$(TMPDIR)/obj \
123 --emit=link=$(TMPDIR)/link \
124 --crate-type=staticlib
125 rm $(TMPDIR)/asm
126 rm $(TMPDIR)/ir
127 rm $(TMPDIR)/bc
128 rm $(TMPDIR)/obj
129 rm $(TMPDIR)/link
130 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
131
132 $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link --crate-type=staticlib
133 rm $(TMPDIR)/bar.ll
134 rm $(TMPDIR)/bar.s
135 rm $(TMPDIR)/bar.o
136 rm $(call STATICLIB,bar)
137 mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc
138 # Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later
139 # comparison.
140
141 $(RUSTC) foo.rs --emit=llvm-bc,link --crate-type=rlib
142 cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
143 rm $(TMPDIR)/bar.bc
144 rm $(TMPDIR)/foo.bc
145 $(call REMOVE_RLIBS,bar)
146 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
tests/run-make-fulldeps/output-type-permutations/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_name = "bar"]
2
3fn main() {}
tests/run-make-fulldeps/output-with-hyphens/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo-bar.rs --crate-type bin
5 [ -f $(TMPDIR)/$(call BIN,foo-bar) ]
6 $(RUSTC) foo-bar.rs --crate-type lib
7 [ -f $(TMPDIR)/libfoo_bar.rlib ]
tests/run-make-fulldeps/output-with-hyphens/foo-bar.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/override-aliased-flags/Makefile deleted-22
...@@ -1,22 +0,0 @@
1include ../tools.mk
2
3# FIXME: it would be good to check that it's actually the rightmost flags
4# that are used when multiple flags are specified, but I can't think of a
5# reliable way to check this.
6
7all:
8 # Test that `-O` and `-C opt-level` can be specified multiple times.
9 # The rightmost flag will be used over any previous flags.
10 $(RUSTC) -O -O main.rs
11 $(RUSTC) -O -C opt-level=0 main.rs
12 $(RUSTC) -C opt-level=0 -O main.rs
13 $(RUSTC) -C opt-level=0 -C opt-level=2 main.rs
14 $(RUSTC) -C opt-level=2 -C opt-level=0 main.rs
15
16 # Test that `-g` and `-C debuginfo` can be specified multiple times.
17 # The rightmost flag will be used over any previous flags.
18 $(RUSTC) -g -g main.rs
19 $(RUSTC) -g -C debuginfo=0 main.rs
20 $(RUSTC) -C debuginfo=0 -g main.rs
21 $(RUSTC) -C debuginfo=0 -C debuginfo=2 main.rs
22 $(RUSTC) -C debuginfo=2 -C debuginfo=0 main.rs
tests/run-make-fulldeps/override-aliased-flags/main.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/panic-impl-transitive/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../../run-make-fulldeps/tools.mk
2
3# NOTE we use --emit=llvm-ir to avoid running the linker (linking will fail because there's no main
4# in this crate)
5all:
6 $(RUSTC) panic-impl-provider.rs
7 $(RUSTC) panic-impl-consumer.rs -C panic=abort --emit=llvm-ir -L $(TMPDIR)
tests/run-make-fulldeps/panic-impl-transitive/panic-impl-consumer.rs deleted-5
...@@ -1,5 +0,0 @@
1#![no_std]
2#![no_main]
3
4// this crate provides the `panic_impl` lang item so we don't need to define it here
5extern crate panic_impl_provider;
tests/run-make-fulldeps/panic-impl-transitive/panic-impl-provider.rs deleted-9
...@@ -1,9 +0,0 @@
1#![crate_type = "rlib"]
2#![no_std]
3
4use core::panic::PanicInfo;
5
6#[panic_handler]
7fn panic(info: &PanicInfo) -> ! {
8 loop {}
9}
tests/run-make-fulldeps/pass-non-c-like-enum-to-c/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,test)
4 $(RUSTC) nonclike.rs -L$(TMPDIR) -ltest
5 $(call RUN,nonclike)
tests/run-make-fulldeps/pass-non-c-like-enum-to-c/nonclike.rs deleted-21
...@@ -1,21 +0,0 @@
1#[repr(C, u8)]
2pub enum TT {
3 AA(u64, u64),
4 BB,
5}
6
7#[repr(C,u8)]
8pub enum T {
9 A(u64),
10 B,
11}
12
13extern "C" {
14 pub fn t_add(a: T, b: T) -> u64;
15 pub fn tt_add(a: TT, b: TT) -> u64;
16}
17
18fn main() {
19 assert_eq!(33, unsafe { tt_add(TT::AA(1,2), TT::AA(10,20)) });
20 assert_eq!(11, unsafe { t_add(T::A(1), T::A(10)) });
21}
tests/run-make-fulldeps/pass-non-c-like-enum-to-c/test.c deleted-85
...@@ -1,85 +0,0 @@
1#include <stdint.h>
2
3/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
4 * type in nonclike.rs . */
5enum TT_Tag {
6 AA,
7 BB,
8};
9typedef uint8_t TT_Tag;
10
11typedef struct {
12 uint64_t _0;
13 uint64_t _1;
14} AA_Body;
15
16typedef struct {
17 TT_Tag tag;
18 union {
19 AA_Body aa;
20 };
21} TT;
22
23/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
24 * in nonclike.rs . */
25enum T_Tag {
26 A,
27 B,
28};
29typedef uint8_t T_Tag;
30
31typedef struct {
32 uint64_t _0;
33} A_Body;
34
35typedef struct {
36 T_Tag tag;
37 union {
38 A_Body a;
39 };
40} T;
41
42uint64_t tt_add(TT a, TT b) {
43 if (a.tag == AA && b.tag == AA) {
44 return a.aa._0 + a.aa._1 + b.aa._0 + b.aa._1;
45 } else if (a.tag == AA) {
46 return a.aa._0 + a.aa._1;
47 } else if (b.tag == BB) {
48 return b.aa._0 + b.aa._1;
49 } else {
50 return 0;
51 }
52}
53
54uint64_t t_add(T a, T b) {
55 if (a.tag == A && b.tag == A) {
56 return a.a._0 + b.a._0;
57 } else if (a.tag == AA) {
58 return a.a._0;
59 } else if (b.tag == BB) {
60 return b.a._0;
61 } else {
62 return 0;
63 }
64}
65
66TT tt_new(uint64_t a, uint64_t b) {
67 TT tt = {
68 .tag = AA,
69 .aa = {
70 ._0 = a,
71 ._1 = b,
72 },
73 };
74 return tt;
75}
76
77T t_new(uint64_t a) {
78 T t = {
79 .tag = A,
80 .a = {
81 ._0 = a,
82 },
83 };
84 return t;
85}
tests/run-make-fulldeps/pgo-branch-weights/Makefile deleted-34
...@@ -1,34 +0,0 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9# For some very small programs GNU ld seems to not properly handle
10# instrumentation sections correctly. Neither Gold nor LLD have that problem.
11ifeq ($(UNAME),Linux)
12ifneq (,$(findstring x86,$(TARGET)))
13COMMON_FLAGS=-Clink-args=-fuse-ld=gold
14endif
15endif
16
17
18all:
19 # We don't compile `opaque` with either optimizations or instrumentation.
20 $(RUSTC) $(COMMON_FLAGS) opaque.rs || exit 1
21 # Compile the test program with instrumentation
22 mkdir -p "$(TMPDIR)/prof_data_dir" || exit 1
23 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
24 -Cprofile-generate="$(TMPDIR)/prof_data_dir" -O -Ccodegen-units=1 || exit 1
25 $(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)/prof_data_dir" -O || exit 1
26 # The argument below generates to the expected branch weights
27 $(call RUN,main aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc) || exit 1
28 "$(LLVM_BIN_DIR)/llvm-profdata" merge \
29 -o "$(TMPDIR)/prof_data_dir/merged.profdata" \
30 "$(TMPDIR)/prof_data_dir" || exit 1
31 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
32 -Cprofile-use="$(TMPDIR)/prof_data_dir/merged.profdata" -O \
33 -Ccodegen-units=1 --emit=llvm-ir || exit 1
34 cat "$(TMPDIR)/interesting.ll" | "$(LLVM_FILECHECK)" filecheck-patterns.txt
tests/run-make-fulldeps/pgo-branch-weights/filecheck-patterns.txt deleted-24
...@@ -1,24 +0,0 @@
1
2# First, establish that certain !prof labels are attached to the expected
3# functions and branching instructions.
4
5CHECK: define void @function_called_twice(i32 {{.*}} !prof [[function_called_twice_id:![0-9]+]] {
6CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !prof [[branch_weights0:![0-9]+]]
7
8CHECK: define void @function_called_42_times(i32{{.*}} %c) {{.*}} !prof [[function_called_42_times_id:![0-9]+]] {
9CHECK: switch i32 %c, label {{.*}} [
10CHECK-NEXT: i32 97, label {{.*}}
11CHECK-NEXT: i32 98, label {{.*}}
12CHECK-NEXT: ], !prof [[branch_weights1:![0-9]+]]
13
14CHECK: define void @function_called_never(i32 {{.*}} !prof [[function_called_never_id:![0-9]+]] {
15
16
17
18# Now check that those !prof tags hold the expected counts
19
20CHECK: [[function_called_twice_id]] = !{!"function_entry_count", i64 2}
21CHECK: [[branch_weights0]] = !{!"branch_weights", i32 2, i32 0}
22CHECK: [[function_called_42_times_id]] = !{!"function_entry_count", i64 42}
23CHECK: [[branch_weights1]] = !{!"branch_weights", i32 2, i32 12, i32 28}
24CHECK: [[function_called_never_id]] = !{!"function_entry_count", i64 0}
tests/run-make-fulldeps/pgo-branch-weights/interesting.rs deleted-40
...@@ -1,40 +0,0 @@
1#![crate_name="interesting"]
2#![crate_type="rlib"]
3
4extern crate opaque;
5
6#[no_mangle]
7#[inline(never)]
8pub fn function_called_twice(c: char) {
9 if c == '2' {
10 // This branch is taken twice
11 opaque::f1();
12 } else {
13 // This branch is never taken
14 opaque::f2();
15 }
16}
17
18#[no_mangle]
19#[inline(never)]
20pub fn function_called_42_times(c: char) {
21 if c == 'a' {
22 // This branch is taken 12 times
23 opaque::f1();
24 } else {
25
26 if c == 'b' {
27 // This branch is taken 28 times
28 opaque::f2();
29 } else {
30 // This branch is taken 2 times
31 opaque::f3();
32 }
33 }
34}
35
36#[no_mangle]
37#[inline(never)]
38pub fn function_called_never(_: char) {
39 opaque::f1();
40}
tests/run-make-fulldeps/pgo-branch-weights/main.rs deleted-17
...@@ -1,17 +0,0 @@
1extern crate interesting;
2
3fn main() {
4 let arg = std::env::args().skip(1).next().unwrap();
5
6 for c in arg.chars() {
7 if c == '2' {
8 interesting::function_called_twice(c);
9 } else {
10 interesting::function_called_42_times(c);
11 }
12
13 if c == '0' {
14 interesting::function_called_never(c);
15 }
16 }
17}
tests/run-make-fulldeps/pgo-branch-weights/opaque.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_name="opaque"]
2#![crate_type="rlib"]
3
4pub fn f1() {}
5pub fn f2() {}
6pub fn f3() {}
tests/run-make-fulldeps/pgo-gen-lto/Makefile deleted-14
...@@ -1,14 +0,0 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9COMPILE_FLAGS=-Copt-level=3 -Clto=fat -Cprofile-generate="$(TMPDIR)"
10
11all:
12 $(RUSTC) $(COMPILE_FLAGS) test.rs
13 $(call RUN,test) || exit 1
14 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1)
tests/run-make-fulldeps/pgo-gen-lto/test.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile deleted-13
...@@ -1,13 +0,0 @@
1# needs-profiler-support
2
3include ../tools.mk
4
5COMPILE_FLAGS=-O -Ccodegen-units=1 -Cprofile-generate="$(TMPDIR)"
6
7all:
8 $(RUSTC) $(COMPILE_FLAGS) --emit=llvm-ir test.rs
9 # We expect symbols starting with "__llvm_profile_".
10 $(CGREP) "__llvm_profile_" < $(TMPDIR)/test.ll
11 # We do NOT expect the "__imp_" version of these symbols.
12 $(CGREP) -v "__imp___llvm_profile_" < $(TMPDIR)/test.ll # 64 bit
13 $(CGREP) -v "__imp____llvm_profile_" < $(TMPDIR)/test.ll # 32 bit
tests/run-make-fulldeps/pgo-gen-no-imp-symbols/test.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/pgo-gen/Makefile deleted-14
...@@ -1,14 +0,0 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9COMPILE_FLAGS=-g -Cprofile-generate="$(TMPDIR)"
10
11all:
12 $(RUSTC) $(COMPILE_FLAGS) test.rs
13 $(call RUN,test) || exit 1
14 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1)
tests/run-make-fulldeps/pgo-gen/test.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/pgo-indirect-call-promotion/Makefile deleted-26
...@@ -1,26 +0,0 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9all:
10 # We don't compile `opaque` with either optimizations or instrumentation.
11 # We don't compile `opaque` with either optimizations or instrumentation.
12 $(RUSTC) $(COMMON_FLAGS) opaque.rs
13 # Compile the test program with instrumentation
14 mkdir -p "$(TMPDIR)"/prof_data_dir
15 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
16 -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O -Ccodegen-units=1
17 $(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O
18 # The argument below generates to the expected branch weights
19 $(call RUN,main) || exit 1
20 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
21 -o "$(TMPDIR)"/prof_data_dir/merged.profdata \
22 "$(TMPDIR)"/prof_data_dir
23 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
24 -Cprofile-use="$(TMPDIR)"/prof_data_dir/merged.profdata -O \
25 -Ccodegen-units=1 --emit=llvm-ir
26 cat "$(TMPDIR)"/interesting.ll | "$(LLVM_FILECHECK)" filecheck-patterns.txt
tests/run-make-fulldeps/pgo-indirect-call-promotion/filecheck-patterns.txt deleted-16
...@@ -1,16 +0,0 @@
1CHECK: define void @call_a_bunch_of_functions({{.*}} {
2
3# Make sure that indirect call promotion inserted a check against the most
4# frequently called function.
5CHECK: %{{.*}} = icmp eq {{void \(\)\*|ptr}} %{{.*}}, @function_called_always
6
7# Check that the call to `function_called_always` was inlined, so that we
8# directly call `opaque_f1` from the upstream crate.
9CHECK: call void @opaque_f1()
10
11
12# Same checks as above, repeated for the trait object case
13
14CHECK: define void @call_a_bunch_of_trait_methods({{.*}}
15CHECK: %{{.*}} = icmp eq {{void \(\{\}\*\)\*|ptr}} %{{.*}}, {{.*}}@foo
16CHECK: tail call void @opaque_f2()
tests/run-make-fulldeps/pgo-indirect-call-promotion/interesting.rs deleted-56
...@@ -1,56 +0,0 @@
1#![crate_name="interesting"]
2#![crate_type="rlib"]
3
4extern crate opaque;
5
6#[no_mangle]
7pub fn function_called_always() {
8 opaque::opaque_f1();
9}
10
11#[no_mangle]
12pub fn function_called_never() {
13 opaque::opaque_f2();
14}
15
16#[no_mangle]
17pub fn call_a_bunch_of_functions(fns: &[fn()]) {
18
19 // Indirect call promotion transforms the below into something like
20 //
21 // for f in fns {
22 // if f == function_called_always {
23 // function_called_always()
24 // } else {
25 // f();
26 // }
27 // }
28 //
29 // where `function_called_always` actually gets inlined too.
30
31 for f in fns {
32 f();
33 }
34}
35
36
37pub trait Foo {
38 fn foo(&self);
39}
40
41impl Foo for u32 {
42
43 #[no_mangle]
44 fn foo(&self) {
45 opaque::opaque_f2();
46 }
47}
48
49#[no_mangle]
50pub fn call_a_bunch_of_trait_methods(trait_objects: &[&dyn Foo]) {
51
52 // Same as above, just with vtables in between
53 for x in trait_objects {
54 x.foo();
55 }
56}
tests/run-make-fulldeps/pgo-indirect-call-promotion/main.rs deleted-14
...@@ -1,14 +0,0 @@
1extern crate interesting;
2
3fn main() {
4 // function pointer case
5 let fns: Vec<_> = std::iter::repeat(interesting::function_called_always as fn())
6 .take(1000)
7 .collect();
8 interesting::call_a_bunch_of_functions(&fns[..]);
9
10 // Trait object case
11 let trait_objects = vec![0u32; 1000];
12 let trait_objects: Vec<_> = trait_objects.iter().map(|x| x as &dyn interesting::Foo).collect();
13 interesting::call_a_bunch_of_trait_methods(&trait_objects[..]);
14}
tests/run-make-fulldeps/pgo-indirect-call-promotion/opaque.rs deleted-7
...@@ -1,7 +0,0 @@
1#![crate_name="opaque"]
2#![crate_type="rlib"]
3
4#[no_mangle]
5pub fn opaque_f1() {}
6#[no_mangle]
7pub fn opaque_f2() {}
tests/run-make-fulldeps/pgo-use/Makefile deleted-46
...@@ -1,46 +0,0 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9# This test makes sure that PGO profiling data leads to cold functions being
10# marked as `cold` and hot functions with `inlinehint`.
11# The test program contains an `if` were actual execution only ever takes the
12# `else` branch. Accordingly, we expect the function that is never called to
13# be marked as cold.
14#
15# Disable the pre-inlining pass (i.e. a pass that does some inlining before
16# it adds the profiling instrumentation). Disabling this pass leads to
17# rather predictable IR which we need for this test to be stable.
18
19COMMON_FLAGS=-Copt-level=2 -Ccodegen-units=1 -Cllvm-args=-disable-preinline
20
21ifeq ($(UNAME),Darwin)
22# macOS does not have the `tac` command, but `tail -r` does the same thing
23TAC := tail -r
24else
25# some other platforms don't support the `-r` flag for `tail`, so use `tac`
26TAC := tac
27endif
28
29all:
30 # Compile the test program with instrumentation
31 $(RUSTC) $(COMMON_FLAGS) -Cprofile-generate="$(TMPDIR)" main.rs
32 # Run it in order to generate some profiling data
33 $(call RUN,main some-argument) || exit 1
34 # Postprocess the profiling data so it can be used by the compiler
35 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
36 -o "$(TMPDIR)"/merged.profdata \
37 "$(TMPDIR)"/default_*.profraw
38 # Compile the test program again, making use of the profiling data
39 $(RUSTC) $(COMMON_FLAGS) -Cprofile-use="$(TMPDIR)"/merged.profdata --emit=llvm-ir main.rs
40 # Check that the generate IR contains some things that we expect
41 #
42 # We feed the file into LLVM FileCheck tool *in reverse* so that we see the
43 # line with the function name before the line with the function attributes.
44 # FileCheck only supports checking that something matches on the next line,
45 # but not if something matches on the previous line.
46 $(TAC) "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck-patterns.txt
tests/run-make-fulldeps/pgo-use/filecheck-patterns.txt deleted-11
...@@ -1,11 +0,0 @@
1# Add a check that the IR contains some expected metadata
2CHECK: !{!"ProfileFormat", !"InstrProf"}
3CHECK: !"ProfileSummary"
4
5# Make sure that the hot function is marked with `inlinehint`
6CHECK: define {{.*}} @hot_function
7CHECK-NEXT: Function Attrs:{{.*}}inlinehint
8
9# Make sure that the cold function is marked with `cold`
10CHECK: define {{.*}} @cold_function
11CHECK-NEXT: Function Attrs:{{.*}}cold
tests/run-make-fulldeps/pgo-use/main.rs deleted-23
...@@ -1,23 +0,0 @@
1#[no_mangle]
2pub fn cold_function(c: u8) {
3 println!("cold {}", c);
4}
5
6#[no_mangle]
7pub fn hot_function(c: u8) {
8 std::env::set_var(format!("var{}", c), format!("hot {}", c));
9}
10
11fn main() {
12 let arg = std::env::args().skip(1).next().unwrap();
13
14 for i in 0 .. 1000_000 {
15 let some_value = arg.as_bytes()[i % arg.len()];
16 if some_value == b'!' {
17 // This branch is never taken at runtime
18 cold_function(some_value);
19 } else {
20 hot_function(some_value);
21 }
22 }
23}
tests/run-make-fulldeps/pointer-auth-link-with-c/Makefile deleted-14
...@@ -1,14 +0,0 @@
1include ../tools.mk
2
3# only-aarch64
4
5all:
6 $(COMPILE_OBJ) $(TMPDIR)/test.o test.c
7 $(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
8 $(RUSTC) -Z branch-protection=bti,pac-ret,leaf test.rs
9 $(call RUN,test)
10
11 $(COMPILE_OBJ) $(TMPDIR)/test.o test.c -mbranch-protection=bti+pac-ret+leaf
12 $(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
13 $(RUSTC) -Z branch-protection=bti,pac-ret,leaf test.rs
14 $(call RUN,test)
tests/run-make-fulldeps/pointer-auth-link-with-c/test.c deleted-1
...@@ -1 +0,0 @@
1int foo() { return 0; }
tests/run-make-fulldeps/pointer-auth-link-with-c/test.rs deleted-8
...@@ -1,8 +0,0 @@
1#[link(name = "test")]
2extern "C" {
3 fn foo() -> i32;
4}
5
6fn main() {
7 unsafe {foo();}
8}
tests/run-make-fulldeps/prefer-dylib/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib -C prefer-dynamic
5 $(RUSTC) foo.rs -C prefer-dynamic
6 $(call RUN,foo)
7 rm $(TMPDIR)/*bar*
8 $(call FAIL,foo)
tests/run-make-fulldeps/prefer-dylib/bar.rs deleted-1
...@@ -1 +0,0 @@
1pub fn bar() {}
tests/run-make-fulldeps/prefer-dylib/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate bar;
2
3fn main() {
4 bar::bar();
5}
tests/run-make-fulldeps/prefer-rlib/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib
5 ls $(TMPDIR)/$(call RLIB_GLOB,bar)
6 $(RUSTC) foo.rs
7 rm $(TMPDIR)/*bar*
8 $(call RUN,foo)
tests/run-make-fulldeps/prefer-rlib/bar.rs deleted-1
...@@ -1 +0,0 @@
1pub fn bar() {}
tests/run-make-fulldeps/prefer-rlib/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate bar;
2
3fn main() {
4 bar::bar();
5}
tests/run-make-fulldeps/pretty-expanded/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../tools.mk1include ../../run-make/tools.mk
22
3all:3all:
4 $(RUSTC) -o $(TMPDIR)/input.expanded.rs -Zunpretty=expanded input.rs4 $(RUSTC) -o $(TMPDIR)/input.expanded.rs -Zunpretty=expanded input.rs
tests/run-make-fulldeps/pretty-print-to-file/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -o $(TMPDIR)/input.out -Zunpretty=normal input.rs
5 diff -u $(TMPDIR)/input.out input.pp
tests/run-make-fulldeps/pretty-print-to-file/input.pp deleted-3
...@@ -1,3 +0,0 @@
1
2#[crate_type = "lib"]
3pub fn foo() -> i32 { 45 }
tests/run-make-fulldeps/pretty-print-to-file/input.rs deleted-5
...@@ -1,5 +0,0 @@
1#[crate_type="lib"]
2
3pub fn
4foo() -> i32
5{ 45 }
tests/run-make-fulldeps/print-calling-conventions/Makefile deleted-4
...@@ -1,4 +0,0 @@
1-include ../tools.mk
2
3all:
4 $(RUSTC) --print calling-conventions
tests/run-make-fulldeps/print-cfg/Makefile deleted-20
...@@ -1,20 +0,0 @@
1# needs-llvm-components: x86 arm
2
3include ../tools.mk
4
5all: default
6 $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows
7 $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64
8 $(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc
9 $(RUSTC) --target i686-apple-darwin --print cfg | $(CGREP) macos
10 $(RUSTC) --target i686-unknown-linux-gnu --print cfg | $(CGREP) gnu
11 $(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) target_abi=
12 $(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) eabihf
13
14ifdef IS_WINDOWS
15default:
16 $(RUSTC) --print cfg | $(CGREP) windows
17else
18default:
19 $(RUSTC) --print cfg | $(CGREP) unix
20endif
tests/run-make-fulldeps/print-target-list/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3# Checks that all the targets returned by `rustc --print target-list` are valid
4# target specifications
5all:
6 for target in $(shell $(BARE_RUSTC) --print target-list); do \
7 $(BARE_RUSTC) --target $$target --print sysroot; \
8 done
tests/run-make-fulldeps/profile/Makefile deleted-12
...@@ -1,12 +0,0 @@
1# needs-profiler-support
2
3include ../tools.mk
4
5all:
6 $(RUSTC) -g -Z profile test.rs
7 $(call RUN,test) || exit 1
8 [ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1)
9 [ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1)
10 $(RUSTC) -g -Z profile -Z profile-emit=$(TMPDIR)/abc/abc.gcda test.rs
11 $(call RUN,test) || exit 1
12 [ -e "$(TMPDIR)/abc/abc.gcda" ] || (echo "gcda file not emitted to defined path"; exit 1)
tests/run-make-fulldeps/profile/test.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/prune-link-args/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4
5# Notice the space in the end, this emulates the output of pkg-config
6RUSTC_FLAGS = -C link-args="-lc "
7
8all:
9 $(RUSTC) $(RUSTC_FLAGS) empty.rs
tests/run-make-fulldeps/prune-link-args/empty.rs deleted-1
...@@ -1 +0,0 @@
1fn main() { }
tests/run-make-fulldeps/redundant-libs/Makefile deleted-23
...@@ -1,23 +0,0 @@
1include ../tools.mk
2
3# ignore-windows-msvc
4
5# rustc will remove one of the two redundant references to foo below. Depending
6# on which one gets removed, we'll get a linker error on SOME platforms (like
7# Linux). On these platforms, when a library is referenced, the linker will
8# only pull in the symbols needed _at that point in time_. If a later library
9# depends on additional symbols from the library, they will not have been pulled
10# in, and you'll get undefined symbols errors.
11#
12# So in this example, we need to ensure that rustc keeps the _later_ reference
13# to foo, and not the former one.
14RUSTC_FLAGS = \
15 -l static=bar \
16 -l foo \
17 -l static=baz \
18 -l foo \
19 --print link-args
20
21all: $(call DYLIB,foo) $(call STATICLIB,bar) $(call STATICLIB,baz)
22 $(RUSTC) $(RUSTC_FLAGS) main.rs
23 $(call RUN,main)
tests/run-make-fulldeps/redundant-libs/bar.c deleted-1
...@@ -1 +0,0 @@
1void bar() {}
tests/run-make-fulldeps/redundant-libs/baz.c deleted-7
...@@ -1,7 +0,0 @@
1extern void foo1();
2extern void foo2();
3
4void baz() {
5 foo1();
6 foo2();
7}
tests/run-make-fulldeps/redundant-libs/foo.c deleted-2
...@@ -1,2 +0,0 @@
1void foo1() {}
2void foo2() {}
tests/run-make-fulldeps/redundant-libs/main.rs deleted-11
...@@ -1,11 +0,0 @@
1extern "C" {
2 fn bar();
3 fn baz();
4}
5
6fn main() {
7 unsafe {
8 bar();
9 baz();
10 }
11}
tests/run-make-fulldeps/relocation-model/Makefile deleted-19
...@@ -1,19 +0,0 @@
1include ../tools.mk
2
3all: others
4 $(RUSTC) -C relocation-model=dynamic-no-pic foo.rs
5 $(call RUN,foo)
6
7 $(RUSTC) -C relocation-model=default foo.rs
8 $(call RUN,foo)
9
10 $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj
11
12ifdef IS_MSVC
13# FIXME(#28026)
14others:
15else
16others:
17 $(RUSTC) -C relocation-model=static foo.rs
18 $(call RUN,foo)
19endif
tests/run-make-fulldeps/relocation-model/foo.rs deleted-1
...@@ -1 +0,0 @@
1pub fn main() {}
tests/run-make-fulldeps/relro-levels/Makefile deleted-21
...@@ -1,21 +0,0 @@
1include ../tools.mk
2
3# only-linux
4#
5# This tests the different -Zrelro-level values, and makes sure that they work properly.
6
7all:
8 # Ensure that binaries built with the full relro level links them with both
9 # RELRO and BIND_NOW for doing eager symbol resolving.
10 $(RUSTC) -Zrelro-level=full hello.rs
11 readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO
12 readelf -d $(TMPDIR)/hello | grep -q BIND_NOW
13
14 $(RUSTC) -Zrelro-level=partial hello.rs
15 readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO
16
17 # Ensure that we're *not* built with RELRO when setting it to off. We do
18 # not want to check for BIND_NOW however, as the linker might have that
19 # enabled by default.
20 $(RUSTC) -Zrelro-level=off hello.rs
21 ! readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO
tests/run-make-fulldeps/relro-levels/hello.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 println!("Hello, world!");
3}
tests/run-make-fulldeps/remap-path-prefix/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4
5# Checks if remapping works if the remap-from string contains path to the working directory plus more
6all:
7 $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux --crate-type=lib --emit=metadata auxiliary/lib.rs
8 grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
9 ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
tests/run-make-fulldeps/remap-path-prefix/auxiliary/lib.rs deleted-3
...@@ -1,3 +0,0 @@
1pub fn lib() {
2 panic!("calm");
3}
tests/run-make-fulldeps/reproducible-build-2/Makefile deleted-26
...@@ -1,26 +0,0 @@
1include ../tools.mk
2
3# ignore-musl
4# ignore-windows
5# Objects are reproducible but their path is not.
6
7all: \
8 fat_lto \
9 sysroot
10
11fat_lto:
12 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
13 $(RUSTC) reproducible-build-aux.rs
14 $(RUSTC) reproducible-build.rs -C lto=fat
15 cp $(TMPDIR)/reproducible-build $(TMPDIR)/reproducible-build-a
16 $(RUSTC) reproducible-build.rs -C lto=fat
17 cmp "$(TMPDIR)/reproducible-build-a" "$(TMPDIR)/reproducible-build" || exit 1
18
19sysroot:
20 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
21 $(RUSTC) reproducible-build-aux.rs
22 $(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(shell $(RUSTC) --print sysroot) --remap-path-prefix=$(shell $(RUSTC) --print sysroot)=/sysroot
23 cp -R $(shell $(RUSTC) --print sysroot) $(TMPDIR)/sysroot
24 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
25 $(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(TMPDIR)/sysroot --remap-path-prefix=$(TMPDIR)/sysroot=/sysroot
26 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
tests/run-make-fulldeps/reproducible-build-2/linker.rs deleted-44
...@@ -1,44 +0,0 @@
1use std::env;
2use std::path::Path;
3use std::fs::File;
4use std::io::{Read, Write};
5
6fn main() {
7 let mut dst = env::current_exe().unwrap();
8 dst.pop();
9 dst.push("linker-arguments1");
10 if dst.exists() {
11 dst.pop();
12 dst.push("linker-arguments2");
13 assert!(!dst.exists());
14 }
15
16 let mut out = String::new();
17 for arg in env::args().skip(1) {
18 let path = Path::new(&arg);
19 if !path.is_file() {
20 out.push_str(&arg);
21 out.push_str("\n");
22 continue
23 }
24
25 let mut contents = Vec::new();
26 File::open(path).unwrap().read_to_end(&mut contents).unwrap();
27
28 out.push_str(&format!("{}: {}\n", arg, hash(&contents)));
29 }
30
31 File::create(dst).unwrap().write_all(out.as_bytes()).unwrap();
32}
33
34// fnv hash for now
35fn hash(contents: &[u8]) -> u64 {
36 let mut hash = 0xcbf29ce484222325;
37
38 for byte in contents {
39 hash = hash ^ (*byte as u64);
40 hash = hash.wrapping_mul(0x100000001b3);
41 }
42
43 hash
44}
tests/run-make-fulldeps/reproducible-build-2/reproducible-build-aux.rs deleted-28
...@@ -1,28 +0,0 @@
1#![crate_type="lib"]
2
3pub static STATIC: i32 = 1234;
4
5pub struct Struct<T1, T2> {
6 _t1: std::marker::PhantomData<T1>,
7 _t2: std::marker::PhantomData<T2>,
8}
9
10pub fn regular_fn(_: i32) {}
11
12pub fn generic_fn<T1, T2>() {}
13
14impl<T1, T2> Drop for Struct<T1, T2> {
15 fn drop(&mut self) {}
16}
17
18pub enum Enum {
19 Variant1,
20 Variant2(u32),
21 Variant3 { x: u32 }
22}
23
24pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64);
25
26pub trait Trait<T1, T2> {
27 fn foo(&self);
28}
tests/run-make-fulldeps/reproducible-build-2/reproducible-build.rs deleted-116
...@@ -1,116 +0,0 @@
1// This test case makes sure that two identical invocations of the compiler
2// (i.e., same code base, same compile-flags, same compiler-versions, etc.)
3// produce the same output. In the past, symbol names of monomorphized functions
4// were not deterministic (which we want to avoid).
5//
6// The test tries to exercise as many different paths into symbol name
7// generation as possible:
8//
9// - regular functions
10// - generic functions
11// - methods
12// - statics
13// - closures
14// - enum variant constructors
15// - tuple struct constructors
16// - drop glue
17// - FnOnce adapters
18// - Trait object shims
19// - Fn Pointer shims
20
21#![allow(dead_code, warnings)]
22
23extern crate reproducible_build_aux;
24
25static STATIC: i32 = 1234;
26
27pub struct Struct<T1, T2> {
28 x: T1,
29 y: T2,
30}
31
32fn regular_fn(_: i32) {}
33
34fn generic_fn<T1, T2>() {}
35
36impl<T1, T2> Drop for Struct<T1, T2> {
37 fn drop(&mut self) {}
38}
39
40pub enum Enum {
41 Variant1,
42 Variant2(u32),
43 Variant3 { x: u32 }
44}
45
46struct TupleStruct(i8, i16, i32, i64);
47
48impl TupleStruct {
49 pub fn bar(&self) {}
50}
51
52trait Trait<T1, T2> {
53 fn foo(&self);
54}
55
56impl Trait<i32, u64> for u64 {
57 fn foo(&self) {}
58}
59
60impl reproducible_build_aux::Trait<char, String> for TupleStruct {
61 fn foo(&self) {}
62}
63
64fn main() {
65 regular_fn(STATIC);
66 generic_fn::<u32, char>();
67 generic_fn::<char, Struct<u32, u64>>();
68 generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
69
70 let dropped = Struct {
71 x: "",
72 y: 'a',
73 };
74
75 let _ = Enum::Variant1;
76 let _ = Enum::Variant2(0);
77 let _ = Enum::Variant3 { x: 0 };
78 let _ = TupleStruct(1, 2, 3, 4);
79
80 let closure = |x| {
81 x + 1i32
82 };
83
84 fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
85 f(STATIC)
86 }
87
88 println!("{}", inner(closure));
89
90 let object_shim: &Trait<i32, u64> = &0u64;
91 object_shim.foo();
92
93 fn with_fn_once_adapter<F: FnOnce(i32)>(f: F) {
94 f(0);
95 }
96
97 with_fn_once_adapter(|_:i32| { });
98
99 reproducible_build_aux::regular_fn(STATIC);
100 reproducible_build_aux::generic_fn::<u32, char>();
101 reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
102 reproducible_build_aux::generic_fn::<Struct<u64, u32>,
103 reproducible_build_aux::Struct<u32, u64>>();
104
105 let _ = reproducible_build_aux::Enum::Variant1;
106 let _ = reproducible_build_aux::Enum::Variant2(0);
107 let _ = reproducible_build_aux::Enum::Variant3 { x: 0 };
108 let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4);
109
110 let object_shim: &reproducible_build_aux::Trait<char, String> = &TupleStruct(0, 1, 2, 3);
111 object_shim.foo();
112
113 let pointer_shim: &Fn(i32) = &regular_fn;
114
115 TupleStruct(1, 2, 3, 4).bar();
116}
tests/run-make-fulldeps/reproducible-build/Makefile deleted-139
...@@ -1,139 +0,0 @@
1include ../tools.mk
2
3# ignore-musl
4# Objects are reproducible but their path is not.
5
6all: \
7 smoke \
8 debug \
9 opt \
10 link_paths \
11 remap_paths \
12 different_source_dirs_rlib \
13 remap_cwd_rlib \
14 remap_cwd_to_empty \
15 extern_flags
16
17# TODO: Builds of `bin` crate types are not deterministic with debuginfo=2 on
18# Windows.
19# See: https://github.com/rust-lang/rust/pull/87320#issuecomment-920105533
20# Issue: https://github.com/rust-lang/rust/issues/88982
21#
22# different_source_dirs_bin \
23# remap_cwd_bin \
24
25smoke:
26 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
27 $(RUSTC) linker.rs -O
28 $(RUSTC) reproducible-build-aux.rs
29 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker)
30 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker)
31 diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2"
32
33debug:
34 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
35 $(RUSTC) linker.rs -O
36 $(RUSTC) reproducible-build-aux.rs -g
37 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g
38 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g
39 diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2"
40
41opt:
42 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
43 $(RUSTC) linker.rs -O
44 $(RUSTC) reproducible-build-aux.rs -O
45 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O
46 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O
47 diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2"
48
49link_paths:
50 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
51 $(RUSTC) reproducible-build-aux.rs
52 $(RUSTC) reproducible-build.rs --crate-type rlib -L /b
53 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
54 $(RUSTC) reproducible-build.rs --crate-type rlib -L /a
55 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
56
57remap_paths:
58 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
59 $(RUSTC) reproducible-build-aux.rs
60 $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/a=/c
61 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
62 $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/b=/c
63 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
64
65different_source_dirs_bin:
66 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
67 $(RUSTC) reproducible-build-aux.rs
68 mkdir $(TMPDIR)/test
69 cp reproducible-build.rs $(TMPDIR)/test
70 $(RUSTC) reproducible-build.rs --crate-type bin --remap-path-prefix=$$PWD=/b
71 cp $(TMPDIR)/reproducible-build $(TMPDIR)/foo
72 (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \
73 --remap-path-prefix=$(TMPDIR)/test=/b \
74 --crate-type bin)
75 cmp "$(TMPDIR)/reproducible-build" "$(TMPDIR)/foo" || exit 1
76
77different_source_dirs_rlib:
78 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
79 $(RUSTC) reproducible-build-aux.rs
80 mkdir $(TMPDIR)/test
81 cp reproducible-build.rs $(TMPDIR)/test
82 $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=$$PWD=/b
83 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
84 (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \
85 --remap-path-prefix=$(TMPDIR)/test=/b \
86 --crate-type rlib)
87 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
88
89remap_cwd_bin:
90 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
91 $(RUSTC) reproducible-build-aux.rs
92 mkdir $(TMPDIR)/test
93 cp reproducible-build.rs $(TMPDIR)/test
94 $(RUSTC) reproducible-build.rs --crate-type bin -C debuginfo=2 \
95 -Z remap-cwd-prefix=.
96 cp $(TMPDIR)/reproducible-build $(TMPDIR)/first
97 (cd $(TMPDIR)/test && \
98 $(RUSTC) reproducible-build.rs --crate-type bin -C debuginfo=2 \
99 -Z remap-cwd-prefix=.)
100 cmp "$(TMPDIR)/first" "$(TMPDIR)/reproducible-build" || exit 1
101
102remap_cwd_rlib:
103 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
104 $(RUSTC) reproducible-build-aux.rs
105 mkdir $(TMPDIR)/test
106 cp reproducible-build.rs $(TMPDIR)/test
107 $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
108 -Z remap-cwd-prefix=.
109 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfirst.rlib
110 (cd $(TMPDIR)/test && \
111 $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
112 -Z remap-cwd-prefix=.)
113 cmp "$(TMPDIR)/libfirst.rlib" "$(TMPDIR)/libreproducible_build.rlib" || exit 1
114
115remap_cwd_to_empty:
116 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
117 $(RUSTC) reproducible-build-aux.rs
118 mkdir $(TMPDIR)/test
119 cp reproducible-build.rs $(TMPDIR)/test
120 $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
121 -Z remap-cwd-prefix=
122 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfirst.rlib
123 (cd $(TMPDIR)/test && \
124 $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
125 -Z remap-cwd-prefix=)
126 cmp "$(TMPDIR)/libfirst.rlib" "$(TMPDIR)/libreproducible_build.rlib" || exit 1
127
128extern_flags:
129 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
130 $(RUSTC) reproducible-build-aux.rs
131 $(RUSTC) reproducible-build.rs \
132 --extern reproducible_build_aux=$(TMPDIR)/libreproducible_build_aux.rlib \
133 --crate-type rlib
134 cp $(TMPDIR)/libreproducible_build_aux.rlib $(TMPDIR)/libbar.rlib
135 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
136 $(RUSTC) reproducible-build.rs \
137 --extern reproducible_build_aux=$(TMPDIR)/libbar.rlib \
138 --crate-type rlib
139 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
tests/run-make-fulldeps/reproducible-build/linker.rs deleted-50
...@@ -1,50 +0,0 @@
1use std::env;
2use std::path::Path;
3use std::fs::File;
4use std::io::{Read, Write};
5
6fn main() {
7 let mut dst = env::current_exe().unwrap();
8 dst.pop();
9 dst.push("linker-arguments1");
10 if dst.exists() {
11 dst.pop();
12 dst.push("linker-arguments2");
13 assert!(!dst.exists());
14 }
15
16 let mut out = String::new();
17 for arg in env::args().skip(1) {
18 let path = Path::new(&arg);
19 if !path.is_file() {
20 out.push_str(&arg);
21 out.push_str("\n");
22 continue
23 }
24
25 let mut contents = Vec::new();
26 File::open(path).unwrap().read_to_end(&mut contents).unwrap();
27
28 // This file is produced during linking in a temporary directory.
29 let arg = if arg.ends_with("/symbols.o") || arg.ends_with("\\symbols.o") {
30 "symbols.o"
31 } else {
32 &*arg
33 };
34 out.push_str(&format!("{}: {}\n", arg, hash(&contents)));
35 }
36
37 File::create(dst).unwrap().write_all(out.as_bytes()).unwrap();
38}
39
40// fnv hash for now
41fn hash(contents: &[u8]) -> u64 {
42 let mut hash = 0xcbf29ce484222325;
43
44 for byte in contents {
45 hash = hash ^ (*byte as u64);
46 hash = hash.wrapping_mul(0x100000001b3);
47 }
48
49 hash
50}
tests/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs deleted-28
...@@ -1,28 +0,0 @@
1#![crate_type="lib"]
2
3pub static STATIC: i32 = 1234;
4
5pub struct Struct<T1, T2> {
6 _t1: std::marker::PhantomData<T1>,
7 _t2: std::marker::PhantomData<T2>,
8}
9
10pub fn regular_fn(_: i32) {}
11
12pub fn generic_fn<T1, T2>() {}
13
14impl<T1, T2> Drop for Struct<T1, T2> {
15 fn drop(&mut self) {}
16}
17
18pub enum Enum {
19 Variant1,
20 Variant2(u32),
21 Variant3 { x: u32 }
22}
23
24pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64);
25
26pub trait Trait<T1, T2> {
27 fn foo(&self);
28}
tests/run-make-fulldeps/reproducible-build/reproducible-build.rs deleted-116
...@@ -1,116 +0,0 @@
1// This test case makes sure that two identical invocations of the compiler
2// (i.e., same code base, same compile-flags, same compiler-versions, etc.)
3// produce the same output. In the past, symbol names of monomorphized functions
4// were not deterministic (which we want to avoid).
5//
6// The test tries to exercise as many different paths into symbol name
7// generation as possible:
8//
9// - regular functions
10// - generic functions
11// - methods
12// - statics
13// - closures
14// - enum variant constructors
15// - tuple struct constructors
16// - drop glue
17// - FnOnce adapters
18// - Trait object shims
19// - Fn Pointer shims
20
21#![allow(dead_code, warnings)]
22
23extern crate reproducible_build_aux;
24
25static STATIC: i32 = 1234;
26
27pub struct Struct<T1, T2> {
28 x: T1,
29 y: T2,
30}
31
32fn regular_fn(_: i32) {}
33
34fn generic_fn<T1, T2>() {}
35
36impl<T1, T2> Drop for Struct<T1, T2> {
37 fn drop(&mut self) {}
38}
39
40pub enum Enum {
41 Variant1,
42 Variant2(u32),
43 Variant3 { x: u32 }
44}
45
46struct TupleStruct(i8, i16, i32, i64);
47
48impl TupleStruct {
49 pub fn bar(&self) {}
50}
51
52trait Trait<T1, T2> {
53 fn foo(&self);
54}
55
56impl Trait<i32, u64> for u64 {
57 fn foo(&self) {}
58}
59
60impl reproducible_build_aux::Trait<char, String> for TupleStruct {
61 fn foo(&self) {}
62}
63
64fn main() {
65 regular_fn(STATIC);
66 generic_fn::<u32, char>();
67 generic_fn::<char, Struct<u32, u64>>();
68 generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
69
70 let dropped = Struct {
71 x: "",
72 y: 'a',
73 };
74
75 let _ = Enum::Variant1;
76 let _ = Enum::Variant2(0);
77 let _ = Enum::Variant3 { x: 0 };
78 let _ = TupleStruct(1, 2, 3, 4);
79
80 let closure = |x| {
81 x + 1i32
82 };
83
84 fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
85 f(STATIC)
86 }
87
88 println!("{}", inner(closure));
89
90 let object_shim: &Trait<i32, u64> = &0u64;
91 object_shim.foo();
92
93 fn with_fn_once_adapter<F: FnOnce(i32)>(f: F) {
94 f(0);
95 }
96
97 with_fn_once_adapter(|_:i32| { });
98
99 reproducible_build_aux::regular_fn(STATIC);
100 reproducible_build_aux::generic_fn::<u32, char>();
101 reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
102 reproducible_build_aux::generic_fn::<Struct<u64, u32>,
103 reproducible_build_aux::Struct<u32, u64>>();
104
105 let _ = reproducible_build_aux::Enum::Variant1;
106 let _ = reproducible_build_aux::Enum::Variant2(0);
107 let _ = reproducible_build_aux::Enum::Variant3 { x: 0 };
108 let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4);
109
110 let object_shim: &reproducible_build_aux::Trait<char, String> = &TupleStruct(0, 1, 2, 3);
111 object_shim.foo();
112
113 let pointer_shim: &Fn(i32) = &regular_fn;
114
115 TupleStruct(1, 2, 3, 4).bar();
116}
tests/run-make-fulldeps/resolve-rename/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -C extra-filename=-hash foo.rs
5 $(RUSTC) bar.rs
6 mv $(TMPDIR)/libfoo-hash.rlib $(TMPDIR)/libfoo-another-hash.rlib
7 $(RUSTC) baz.rs
tests/run-make-fulldeps/resolve-rename/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1#![crate_type = "rlib"]
2
3extern crate foo;
4
5pub fn bar() { foo::foo() }
tests/run-make-fulldeps/resolve-rename/baz.rs deleted-5
...@@ -1,5 +0,0 @@
1#![crate_type = "rlib"]
2
3extern crate bar;
4
5pub fn baz() { bar::bar() }
tests/run-make-fulldeps/resolve-rename/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "rlib"]
2
3pub fn foo() {}
tests/run-make-fulldeps/return-non-c-like-enum-from-c/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,test)
4 $(RUSTC) nonclike.rs -L$(TMPDIR) -ltest
5 $(call RUN,nonclike)
tests/run-make-fulldeps/return-non-c-like-enum-from-c/nonclike.rs deleted-31
...@@ -1,31 +0,0 @@
1#[repr(C, u8)]
2pub enum TT {
3 AA(u64, u64),
4 BB,
5}
6
7#[repr(C,u8)]
8pub enum T {
9 A(u64),
10 B,
11}
12
13extern "C" {
14 pub fn t_new(a: u64) -> T;
15 pub fn tt_new(a: u64, b: u64) -> TT;
16}
17
18fn main() {
19 if let TT::AA(a, b) = unsafe { tt_new(10, 11) } {
20 assert_eq!(10, a);
21 assert_eq!(11, b);
22 } else {
23 panic!("expected TT::AA");
24 }
25
26 if let T::A(a) = unsafe { t_new(10) } {
27 assert_eq!(10, a);
28 } else {
29 panic!("expected T::A");
30 }
31}
tests/run-make-fulldeps/return-non-c-like-enum-from-c/test.c deleted-61
...@@ -1,61 +0,0 @@
1#include <stdint.h>
2
3/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
4 * type in nonclike.rs . */
5enum TT_Tag {
6 AA,
7 BB,
8};
9typedef uint8_t TT_Tag;
10
11typedef struct {
12 uint64_t _0;
13 uint64_t _1;
14} AA_Body;
15
16typedef struct {
17 TT_Tag tag;
18 union {
19 AA_Body aa;
20 };
21} TT;
22
23/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
24 * in nonclike.rs . */
25enum T_Tag {
26 A,
27 B,
28};
29typedef uint8_t T_Tag;
30
31typedef struct {
32 uint64_t _0;
33} A_Body;
34
35typedef struct {
36 T_Tag tag;
37 union {
38 A_Body a;
39 };
40} T;
41
42TT tt_new(uint64_t a, uint64_t b) {
43 TT tt = {
44 .tag = AA,
45 .aa = {
46 ._0 = a,
47 ._1 = b,
48 },
49 };
50 return tt;
51}
52
53T t_new(uint64_t a) {
54 T t = {
55 .tag = A,
56 .a = {
57 ._0 = a,
58 },
59 };
60 return t;
61}
tests/run-make-fulldeps/return-non-c-like-enum/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --crate-type=staticlib nonclike.rs
5 $(CC) test.c $(call STATICLIB,nonclike) $(call OUT_EXE,test) \
6 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
7 $(call RUN,test)
tests/run-make-fulldeps/return-non-c-like-enum/nonclike.rs deleted-21
...@@ -1,21 +0,0 @@
1#[repr(C, u8)]
2pub enum TT {
3 AA(u64, u64),
4 BB,
5}
6
7#[no_mangle]
8pub extern "C" fn tt_new(a: u64, b: u64) -> TT {
9 TT::AA(a, b)
10}
11
12#[repr(C,u8)]
13pub enum T {
14 A(u64),
15 B,
16}
17
18#[no_mangle]
19pub extern "C" fn t_new(a: u64) -> T {
20 T::A(a)
21}
tests/run-make-fulldeps/return-non-c-like-enum/test.c deleted-63
...@@ -1,63 +0,0 @@
1#include <stdint.h>
2#include <assert.h>
3
4/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
5 * type in nonclike.rs . */
6enum TT_Tag {
7 AA,
8 BB,
9};
10typedef uint8_t TT_Tag;
11
12typedef struct {
13 uint64_t _0;
14 uint64_t _1;
15} AA_Body;
16
17typedef struct {
18 TT_Tag tag;
19 union {
20 AA_Body aa;
21 };
22} TT;
23
24/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
25 * in nonclike.rs . */
26enum T_Tag {
27 A,
28 B,
29};
30typedef uint8_t T_Tag;
31
32typedef struct {
33 uint64_t _0;
34} A_Body;
35
36typedef struct {
37 T_Tag tag;
38 union {
39 A_Body a;
40 };
41} T;
42
43/* These symbols are defined by the Rust staticlib built from
44 * nonclike.rs. */
45extern TT tt_new(uint64_t a, uint64_t b);
46extern T t_new(uint64_t v);
47
48int main(int argc, char *argv[]) {
49 (void)argc; (void)argv;
50
51 /* This example works. */
52 TT tt = tt_new(10, 20);
53 assert(AA == tt.tag);
54 assert(10 == tt.aa._0);
55 assert(20 == tt.aa._1);
56
57 /* This one used to segfault (see issue #68190). */
58 T t = t_new(10);
59 assert(A == t.tag);
60 assert(10 == t.a._0);
61
62 return 0;
63}
tests/run-make-fulldeps/rlib-chain/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) m1.rs
5 $(RUSTC) m2.rs
6 $(RUSTC) m3.rs
7 $(RUSTC) m4.rs
8 $(call RUN,m4)
9 rm $(TMPDIR)/*lib
10 $(call RUN,m4)
tests/run-make-fulldeps/rlib-chain/m1.rs deleted-2
...@@ -1,2 +0,0 @@
1#![crate_type = "rlib"]
2pub fn m1() {}
tests/run-make-fulldeps/rlib-chain/m2.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "rlib"]
2extern crate m1;
3
4pub fn m2() { m1::m1() }
tests/run-make-fulldeps/rlib-chain/m3.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "rlib"]
2extern crate m2;
3
4pub fn m3() { m2::m2() }
tests/run-make-fulldeps/rlib-chain/m4.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate m3;
2
3fn main() { m3::m3() }
tests/run-make-fulldeps/rustdoc-determinism/Makefile deleted-16
...@@ -1,16 +0,0 @@
1include ../tools.mk
2
3# Assert that the search index is generated deterministically, regardless of the
4# order that crates are documented in.
5
6# ignore-windows
7# Uses `diff`.
8
9all:
10 $(RUSTDOC) foo.rs -o $(TMPDIR)/foo_first
11 $(RUSTDOC) bar.rs -o $(TMPDIR)/foo_first
12
13 $(RUSTDOC) bar.rs -o $(TMPDIR)/bar_first
14 $(RUSTDOC) foo.rs -o $(TMPDIR)/bar_first
15
16 diff $(TMPDIR)/foo_first/search-index.js $(TMPDIR)/bar_first/search-index.js
tests/run-make-fulldeps/rustdoc-determinism/bar.rs deleted-1
...@@ -1 +0,0 @@
1pub struct Bar;
tests/run-make-fulldeps/rustdoc-determinism/foo.rs deleted-1
...@@ -1 +0,0 @@
1pub struct Foo;
tests/run-make-fulldeps/rustdoc-error-lines/Makefile deleted-13
...@@ -1,13 +0,0 @@
1include ../tools.mk
2
3# Test that hir-tree output doesn't crash and includes
4# the string constant we would expect to see.
5
6all:
7 $(RUSTDOC) --test input.rs > $(TMPDIR)/output || true
8 $(CGREP) 'input.rs - foo (line 5)' < $(TMPDIR)/output
9 $(CGREP) 'input.rs:7:15' < $(TMPDIR)/output
10 $(CGREP) 'input.rs - bar (line 15)' < $(TMPDIR)/output
11 $(CGREP) 'input.rs:17:15' < $(TMPDIR)/output
12 $(CGREP) 'input.rs - bar (line 24)' < $(TMPDIR)/output
13 $(CGREP) 'input.rs:26:15' < $(TMPDIR)/output
tests/run-make-fulldeps/rustdoc-error-lines/input.rs deleted-28
...@@ -1,28 +0,0 @@
1// Test for #45868
2
3// random #![feature] to ensure that crate attrs
4// do not offset things
5/// ```rust
6/// #![feature(bool_to_option)]
7/// let x: char = 1;
8/// ```
9pub fn foo() {
10
11}
12
13/// Add some text around the test...
14///
15/// ```rust
16/// #![feature(bool_to_option)]
17/// let x: char = 1;
18/// ```
19///
20/// ...to make sure that the line number is still correct.
21///
22/// Let's also add a second test in the same doc comment.
23///
24/// ```rust
25/// #![feature(bool_to_option)]
26/// let x: char = 1;
27/// ```
28pub fn bar() {}
tests/run-make-fulldeps/rustdoc-io-error/Makefile deleted-20
...@@ -1,20 +0,0 @@
1include ../tools.mk
2
3# This test verifies that rustdoc doesn't ICE when it encounters an IO error
4# while generating files. Ideally this would be a rustdoc-ui test, so we could
5# verify the error message as well.
6
7# ignore-windows
8# The test uses `chmod`.
9
10OUTPUT_DIR := "$(TMPDIR)/rustdoc-io-error"
11
12# This test operates by creating a temporary directory and modifying its
13# permissions so that it is not writable. We have to take special care to set
14# the permissions back to normal so that it's able to be deleted later.
15all:
16 mkdir -p $(OUTPUT_DIR)
17 chmod u-w $(OUTPUT_DIR)
18 -$(shell $(RUSTDOC) -o $(OUTPUT_DIR) foo.rs)
19 chmod u+w $(OUTPUT_DIR)
20 exit $($(.SHELLSTATUS) -eq 1)
tests/run-make-fulldeps/rustdoc-io-error/foo.rs deleted-1
...@@ -1 +0,0 @@
1pub struct Foo;
tests/run-make-fulldeps/rustdoc-map-file/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTDOC) -Z unstable-options --generate-redirect-map foo.rs -o "$(TMPDIR)/out"
5 "$(PYTHON)" validate_json.py "$(TMPDIR)/out"
tests/run-make-fulldeps/rustdoc-map-file/expected.json deleted-5
...@@ -1,5 +0,0 @@
1{
2 "foo/macro.foo!.html": "foo/macro.foo.html",
3 "foo/private/struct.Quz.html": "foo/struct.Quz.html",
4 "foo/hidden/struct.Bar.html": "foo/struct.Bar.html"
5}
tests/run-make-fulldeps/rustdoc-map-file/foo.rs deleted-16
...@@ -1,16 +0,0 @@
1pub use private::Quz;
2pub use hidden::Bar;
3
4mod private {
5 pub struct Quz;
6}
7
8#[doc(hidden)]
9pub mod hidden {
10 pub struct Bar;
11}
12
13#[macro_export]
14macro_rules! foo {
15 () => {}
16}
tests/run-make-fulldeps/rustdoc-map-file/validate_json.py deleted-41
...@@ -1,41 +0,0 @@
1#!/usr/bin/env python
2
3import os
4import sys
5import json
6
7
8def find_redirect_map_file(folder, errors):
9 for root, dirs, files in os.walk(folder):
10 for name in files:
11 if not name.endswith("redirect-map.json"):
12 continue
13 with open(os.path.join(root, name)) as f:
14 data = json.load(f)
15 with open("expected.json") as f:
16 expected = json.load(f)
17 for key in expected:
18 if expected[key] != data.get(key):
19 errors.append("Expected `{}` for key `{}`, found: `{}`".format(
20 expected[key], key, data.get(key)))
21 else:
22 del data[key]
23 for key in data:
24 errors.append("Extra data not expected: key: `{}`, data: `{}`".format(
25 key, data[key]))
26 return True
27 return False
28
29
30if len(sys.argv) != 2:
31 print("Expected doc directory to check!")
32 sys.exit(1)
33
34errors = []
35if not find_redirect_map_file(sys.argv[1], errors):
36 print("Didn't find the map file in `{}`...".format(sys.argv[1]))
37 sys.exit(1)
38for err in errors:
39 print("=> {}".format(err))
40if len(errors) != 0:
41 sys.exit(1)
tests/run-make-fulldeps/rustdoc-output-path/Makefile deleted-4
...@@ -1,4 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTDOC) -o "$(TMPDIR)/foo/bar/doc" foo.rs
tests/run-make-fulldeps/rustdoc-output-path/foo.rs deleted-1
...@@ -1 +0,0 @@
1pub struct Foo;
tests/run-make-fulldeps/rustdoc-scrape-examples-macros/Makefile deleted-18
...@@ -1,18 +0,0 @@
1include ../../run-make-fulldeps/tools.mk
2
3OUTPUT_DIR := "$(TMPDIR)/rustdoc"
4DYLIB_NAME := $(shell echo | $(RUSTC) --crate-name foobar_macro --crate-type dylib --print file-names -)
5
6all:
7 $(RUSTC) src/proc.rs --crate-name foobar_macro --edition=2021 --crate-type proc-macro --emit=dep-info,link
8
9 $(RUSTC) src/lib.rs --crate-name foobar --edition=2021 --crate-type lib --emit=dep-info,link
10
11 $(RUSTDOC) examples/ex.rs --crate-name ex --crate-type bin --output $(OUTPUT_DIR) \
12 --extern foobar=$(TMPDIR)/libfoobar.rlib --extern foobar_macro=$(TMPDIR)/$(DYLIB_NAME) \
13 -Z unstable-options --scrape-examples-output-path $(TMPDIR)/ex.calls --scrape-examples-target-crate foobar
14
15 $(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
16 -Z unstable-options --with-examples $(TMPDIR)/ex.calls
17
18 $(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
tests/run-make-fulldeps/rustdoc-scrape-examples-macros/examples/ex.rs deleted-27
...@@ -1,27 +0,0 @@
1extern crate foobar;
2extern crate foobar_macro;
3
4use foobar::*;
5use foobar_macro::*;
6
7a_proc_macro!(); // no
8
9#[an_attr_macro]
10fn a() {
11 f(); // no
12}
13
14#[an_attr_macro(with_span)]
15fn b() {
16 f(); // yes
17}
18
19fn c() {
20 a_rules_macro!(f()); // yes
21}
22
23fn d() {
24 a_rules_macro!(()); // no
25}
26
27fn main(){}
tests/run-make-fulldeps/rustdoc-scrape-examples-macros/src/lib.rs deleted-12
...@@ -1,12 +0,0 @@
1// Scraped example should only include line numbers for items b and c in ex.rs
2// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '14'
3// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '15'
4// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '21'
5// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '22'
6
7pub fn f() {}
8
9#[macro_export]
10macro_rules! a_rules_macro {
11 ($e:expr) => { ($e, foobar::f()); }
12}
tests/run-make-fulldeps/rustdoc-scrape-examples-macros/src/proc.rs deleted-39
...@@ -1,39 +0,0 @@
1extern crate proc_macro;
2use proc_macro::*;
3
4#[proc_macro]
5pub fn a_proc_macro(_item: TokenStream) -> TokenStream {
6 "fn ex() { foobar::f(); }".parse().unwrap()
7}
8
9// inserts foobar::f() to the end of the function
10#[proc_macro_attribute]
11pub fn an_attr_macro(attr: TokenStream, item: TokenStream) -> TokenStream {
12 let new_call: TokenStream = "foobar::f();".parse().unwrap();
13
14 let mut tokens = item.into_iter();
15
16 let fn_tok = tokens.next().unwrap();
17 let ident_tok = tokens.next().unwrap();
18 let args_tok = tokens.next().unwrap();
19 let body = match tokens.next().unwrap() {
20 TokenTree::Group(g) => {
21 let new_g = Group::new(g.delimiter(), new_call);
22 let mut outer_g = Group::new(
23 g.delimiter(),
24 [TokenTree::Group(g.clone()), TokenTree::Group(new_g)].into_iter().collect(),
25 );
26
27 if attr.to_string() == "with_span" {
28 outer_g.set_span(g.span());
29 }
30
31 TokenTree::Group(outer_g)
32 }
33 _ => unreachable!(),
34 };
35
36 let tokens = vec![fn_tok, ident_tok, args_tok, body].into_iter().collect::<TokenStream>();
37
38 tokens
39}
tests/run-make-fulldeps/rustdoc-target-spec-json-path/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# Test that rustdoc will properly canonicalize the target spec json path just like rustc
4
5OUTPUT_DIR := "$(TMPDIR)/rustdoc-target-spec-json-path"
6
7all:
8 $(RUSTC) --crate-type lib dummy_core.rs --target target.json
9 $(RUSTDOC) -o $(OUTPUT_DIR) -L $(TMPDIR) my_crate.rs --target target.json
tests/run-make-fulldeps/rustdoc-target-spec-json-path/dummy_core.rs deleted-2
...@@ -1,2 +0,0 @@
1#![feature(no_core)]
2#![no_core]
tests/run-make-fulldeps/rustdoc-target-spec-json-path/my_crate.rs deleted-3
...@@ -1,3 +0,0 @@
1#![feature(no_core)]
2#![no_core]
3extern crate dummy_core;
tests/run-make-fulldeps/rustdoc-target-spec-json-path/target.json deleted-38
...@@ -1,38 +0,0 @@
1{
2 "arch": "x86_64",
3 "cpu": "x86-64",
4 "crt-static-respected": true,
5 "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
6 "dynamic-linking": true,
7 "env": "gnu",
8 "executables": true,
9 "has-elf-tls": true,
10 "has-rpath": true,
11 "linker-is-gnu": true,
12 "llvm-target": "x86_64-unknown-linux-gnu",
13 "max-atomic-width": 64,
14 "os": "linux",
15 "position-independent-executables": true,
16 "pre-link-args": {
17 "gcc": [
18 "-m64"
19 ]
20 },
21 "relro-level": "full",
22 "stack-probes": {
23 "kind": "inline-or-call",
24 "min-llvm-version-for-inline": [
25 11,
26 0,
27 1
28 ]
29 },
30 "supported-sanitizers": [
31 "address",
32 "leak",
33 "memory",
34 "thread"
35 ],
36 "target-family": "unix",
37 "target-pointer-width": "64"
38}
tests/run-make-fulldeps/rustdoc-themes/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3# Test that rustdoc will properly load in a theme file and display it in the theme selector.
4
5OUTPUT_DIR := "$(TMPDIR)/rustdoc-themes"
6
7all:
8 cp $(S)/src/librustdoc/html/static/css/themes/light.css $(TMPDIR)/test.css
9 $(RUSTDOC) -o $(OUTPUT_DIR) foo.rs --theme $(TMPDIR)/test.css
10 $(HTMLDOCCK) $(OUTPUT_DIR) foo.rs
tests/run-make-fulldeps/rustdoc-themes/foo.rs deleted-4
...@@ -1,4 +0,0 @@
1// @has test.css
2// @has foo/struct.Foo.html
3// @has - '//*[@id="rustdoc-vars"]/@data-themes' 'test'
4pub struct Foo;
tests/run-make-fulldeps/sanitizer-cdylib-link/Makefile deleted-16
...@@ -1,16 +0,0 @@
1# needs-sanitizer-support
2# needs-sanitizer-address
3
4include ../tools.mk
5
6LOG := $(TMPDIR)/log.txt
7
8# This test builds a shared object, then an executable that links it as a native
9# rust library (contrast to an rlib). The shared library and executable both
10# are compiled with address sanitizer, and we assert that a fault in the cdylib
11# is correctly detected.
12
13all:
14 $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) library.rs
15 $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
16 LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
tests/run-make-fulldeps/sanitizer-cdylib-link/library.rs deleted-5
...@@ -1,5 +0,0 @@
1#[no_mangle]
2pub extern "C" fn overflow() {
3 let xs = [0, 1, 2, 3];
4 let _y = unsafe { *xs.as_ptr().offset(4) };
5}
tests/run-make-fulldeps/sanitizer-cdylib-link/program.rs deleted-7
...@@ -1,7 +0,0 @@
1extern "C" {
2 fn overflow();
3}
4
5fn main() {
6 unsafe { overflow() }
7}
tests/run-make-fulldeps/sanitizer-dylib-link/Makefile deleted-16
...@@ -1,16 +0,0 @@
1# needs-sanitizer-support
2# needs-sanitizer-address
3
4include ../tools.mk
5
6LOG := $(TMPDIR)/log.txt
7
8# This test builds a shared object, then an executable that links it as a native
9# rust library (contrast to an rlib). The shared library and executable both
10# are compiled with address sanitizer, and we assert that a fault in the dylib
11# is correctly detected.
12
13all:
14 $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) library.rs
15 $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
16 LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
tests/run-make-fulldeps/sanitizer-dylib-link/library.rs deleted-5
...@@ -1,5 +0,0 @@
1#[no_mangle]
2pub extern "C" fn overflow() {
3 let xs = [0, 1, 2, 3];
4 let _y = unsafe { *xs.as_ptr().offset(4) };
5}
tests/run-make-fulldeps/sanitizer-dylib-link/program.rs deleted-7
...@@ -1,7 +0,0 @@
1extern "C" {
2 fn overflow();
3}
4
5fn main() {
6 unsafe { overflow() }
7}
tests/run-make-fulldeps/sanitizer-staticlib-link/Makefile deleted-20
...@@ -1,20 +0,0 @@
1# needs-sanitizer-support
2# needs-sanitizer-address
3
4include ../tools.mk
5
6# This test first builds a staticlib with AddressSanitizer and checks that
7# linking it to an executable fails due to the missing sanitizer runtime.
8# It then builds an executable linking to the staticlib and checks that
9# the fault in the staticlib is detected correctly.
10
11# Note that checking for the link failure actually checks two things at once:
12# 1) That the library has the sanitizer intrumentation
13# 2) and that library does not have the sanitizer runtime
14
15all:
16 $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs
17 ! $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS)
18 $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -L . program.rs
19 LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
20
tests/run-make-fulldeps/sanitizer-staticlib-link/library.rs deleted-5
...@@ -1,5 +0,0 @@
1#[no_mangle]
2pub extern "C" fn overflow() {
3 let xs = [0, 1, 2, 3];
4 let _y = unsafe { *xs.as_ptr().offset(4) };
5}
tests/run-make-fulldeps/sanitizer-staticlib-link/program.c deleted-6
...@@ -1,6 +0,0 @@
1void overflow();
2
3int main() {
4 overflow();
5 return 0;
6}
tests/run-make-fulldeps/sanitizer-staticlib-link/program.rs deleted-10
...@@ -1,10 +0,0 @@
1#[link(name = "library")]
2extern "C" {
3 fn overflow();
4}
5
6fn main() {
7 unsafe {
8 overflow();
9 }
10}
tests/run-make-fulldeps/separate-link-fail/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 echo 'fn main(){}' > $(TMPDIR)/main.rs
5 # Make sure that this fails
6 ! $(RUSTC) -Z link-only $(TMPDIR)/main.rs 2> $(TMPDIR)/stderr.txt
7 $(CGREP) "The input does not look like a .rlink file" < $(TMPDIR)/stderr.txt
tests/run-make-fulldeps/separate-link/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 echo 'fn main(){}' | $(RUSTC) -Z no-link -
5 $(RUSTC) -Z link-only $(TMPDIR)/rust_out.rlink
6 $(call RUN,rust_out)
tests/run-make-fulldeps/sepcomp-cci-copies/Makefile deleted-12
...@@ -1,12 +0,0 @@
1include ../tools.mk
2
3# Check that cross-crate inlined items are inlined in all compilation units
4# that refer to them, and not in any other compilation units.
5# Note that we have to pass `-C codegen-units=6` because up to two CGUs may be
6# created for each source module (see `rustc_const_eval::monomorphize::partitioning`).
7
8all:
9 $(RUSTC) cci_lib.rs
10 $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=6 \
11 -Z inline-in-all-cgus
12 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*cci_fn)" -eq "2" ]
tests/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_type = "rlib"]
2
3#[inline]
4pub fn cci_fn() -> usize {
5 1234
6}
tests/run-make-fulldeps/sepcomp-cci-copies/foo.rs deleted-25
...@@ -1,25 +0,0 @@
1extern crate cci_lib;
2use cci_lib::cci_fn;
3
4fn call1() -> usize {
5 cci_fn()
6}
7
8mod a {
9 use cci_lib::cci_fn;
10 pub fn call2() -> usize {
11 cci_fn()
12 }
13}
14
15mod b {
16 pub fn call3() -> usize {
17 0
18 }
19}
20
21fn main() {
22 call1();
23 a::call2();
24 b::call3();
25}
tests/run-make-fulldeps/sepcomp-inlining/Makefile deleted-15
...@@ -1,15 +0,0 @@
1include ../tools.mk
2
3# Test that #[inline] functions still get inlined across compilation unit
4# boundaries. Compilation should produce three IR files, but only the two
5# compilation units that have a usage of the #[inline] function should
6# contain a definition. Also, the non-#[inline] function should be defined
7# in only one compilation unit.
8
9all:
10 $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \
11 -Z inline-in-all-cgus
12 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ]
13 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ]
14 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ]
15 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c declare\ hidden\ i32\ .*normal)" -eq "2" ]
tests/run-make-fulldeps/sepcomp-inlining/foo.rs deleted-30
...@@ -1,30 +0,0 @@
1#![feature(start)]
2
3#[inline]
4fn inlined() -> u32 {
5 1234
6}
7
8fn normal() -> u32 {
9 2345
10}
11
12mod a {
13 pub fn f() -> u32 {
14 ::inlined() + ::normal()
15 }
16}
17
18mod b {
19 pub fn f() -> u32 {
20 ::inlined() + ::normal()
21 }
22}
23
24#[start]
25fn start(_: isize, _: *const *const u8) -> isize {
26 a::f();
27 b::f();
28
29 0
30}
tests/run-make-fulldeps/sepcomp-separate/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# Test that separate compilation actually puts code into separate compilation
4# units. `foo.rs` defines `magic_fn` in three different modules, which should
5# wind up in three different compilation units.
6
7all:
8 $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3
9 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*magic_fn)" -eq "3" ]
tests/run-make-fulldeps/sepcomp-separate/foo.rs deleted-21
...@@ -1,21 +0,0 @@
1fn magic_fn() -> usize {
2 1234
3}
4
5mod a {
6 pub fn magic_fn() -> usize {
7 2345
8 }
9}
10
11mod b {
12 pub fn magic_fn() -> usize {
13 3456
14 }
15}
16
17fn main() {
18 magic_fn();
19 a::magic_fn();
20 b::magic_fn();
21}
tests/run-make-fulldeps/share-generics-dylib/Makefile deleted-22
...@@ -1,22 +0,0 @@
1# This test makes sure all generic instances get re-exported from Rust dylibs for use by
2# `-Zshare-generics`. There are two rlibs (`instance_provider_a` and `instance_provider_b`)
3# which both provide an instance of `Cell<i32>::set`. There is `instance_user_dylib` which is
4# supposed to re-export both these instances, and then there are `instance_user_a_rlib` and
5# `instance_user_b_rlib` which each rely on a specific instance to be available.
6#
7# In the end everything is linked together into `linked_leaf`. If `instance_user_dylib` does
8# not export both then we'll get an `undefined reference` error for one of the instances.
9#
10# This is regression test for https://github.com/rust-lang/rust/issues/67276.
11
12include ../../run-make-fulldeps/tools.mk
13
14COMMON_ARGS=-Cprefer-dynamic -Zshare-generics=yes -Ccodegen-units=1 -Csymbol-mangling-version=v0
15
16all:
17 $(RUSTC) instance_provider_a.rs $(COMMON_ARGS) --crate-type=rlib
18 $(RUSTC) instance_provider_b.rs $(COMMON_ARGS) --crate-type=rlib
19 $(RUSTC) instance_user_dylib.rs $(COMMON_ARGS) --crate-type=dylib
20 $(RUSTC) instance_user_a_rlib.rs $(COMMON_ARGS) --crate-type=rlib
21 $(RUSTC) instance_user_b_rlib.rs $(COMMON_ARGS) --crate-type=rlib
22 $(RUSTC) linked_leaf.rs $(COMMON_ARGS) --crate-type=bin
tests/run-make-fulldeps/share-generics-dylib/instance_provider_a.rs deleted-6
...@@ -1,6 +0,0 @@
1use std::cell::Cell;
2
3pub fn foo() {
4 let a: Cell<i32> = Cell::new(1);
5 a.set(123);
6}
tests/run-make-fulldeps/share-generics-dylib/instance_provider_b.rs deleted-6
...@@ -1,6 +0,0 @@
1use std::cell::Cell;
2
3pub fn foo() {
4 let b: Cell<i32> = Cell::new(1);
5 b.set(123);
6}
tests/run-make-fulldeps/share-generics-dylib/instance_user_a_rlib.rs deleted-9
...@@ -1,9 +0,0 @@
1extern crate instance_provider_a as upstream;
2use std::cell::Cell;
3
4pub fn foo() {
5 upstream::foo();
6
7 let b: Cell<i32> = Cell::new(1);
8 b.set(123);
9}
tests/run-make-fulldeps/share-generics-dylib/instance_user_b_rlib.rs deleted-9
...@@ -1,9 +0,0 @@
1extern crate instance_provider_b as upstream;
2use std::cell::Cell;
3
4pub fn foo() {
5 upstream::foo();
6
7 let b: Cell<i32> = Cell::new(1);
8 b.set(123);
9}
tests/run-make-fulldeps/share-generics-dylib/instance_user_dylib.rs deleted-7
...@@ -1,7 +0,0 @@
1extern crate instance_provider_a;
2extern crate instance_provider_b;
3
4pub fn foo() {
5 instance_provider_a::foo();
6 instance_provider_b::foo();
7}
tests/run-make-fulldeps/share-generics-dylib/linked_leaf.rs deleted-15
...@@ -1,15 +0,0 @@
1extern crate instance_user_dylib;
2extern crate instance_user_a_rlib;
3extern crate instance_user_b_rlib;
4
5use std::cell::Cell;
6
7fn main() {
8
9 instance_user_a_rlib::foo();
10 instance_user_b_rlib::foo();
11 instance_user_dylib::foo();
12
13 let a: Cell<i32> = Cell::new(1);
14 a.set(123);
15}
tests/run-make-fulldeps/simd-ffi/Makefile deleted-47
...@@ -1,47 +0,0 @@
1include ../tools.mk
2
3TARGETS =
4ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm)
5# construct a fairly exhaustive list of platforms that we
6# support. These ones don't follow a pattern
7TARGETS += arm-linux-androideabi arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabi
8endif
9
10ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
11X86_ARCHS = i686 x86_64
12else
13X86_ARCHS =
14endif
15
16# these ones do, each OS lists the architectures it supports
17LINUX=$(filter aarch64 mips,$(LLVM_COMPONENTS)) $(X86_ARCHS)
18ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips)
19LINUX += mipsel
20endif
21
22WINDOWS=$(X86_ARCHS)
23# fails with: failed to get iphonesimulator SDK path: no such file or directory
24#IOS=i386 aarch64 armv7
25DARWIN=$(X86_ARCHS)
26
27$(foreach arch,$(LINUX),$(eval TARGETS += $(arch)-unknown-linux-gnu))
28$(foreach arch,$(WINDOWS),$(eval TARGETS += $(arch)-pc-windows-gnu))
29#$(foreach arch,$(IOS),$(eval TARGETS += $(arch)-apple-ios))
30$(foreach arch,$(DARWIN),$(eval TARGETS += $(arch)-apple-darwin))
31
32all: $(TARGETS)
33
34define MK_TARGETS
35# compile the rust file to the given target, but only to asm and IR
36# form, to avoid having to have an appropriate linker.
37#
38# we need some features because the integer SIMD instructions are not
39# enabled by-default for i686 and ARM; these features will be invalid
40# on some platforms, but LLVM just prints a warning so that's fine for
41# now.
42$(1): simd.rs
43 $$(RUSTC) --target=$(1) --emit=llvm-ir,asm simd.rs \
44 -C target-feature='+neon,+sse2' -C extra-filename=-$(1)
45endef
46
47$(foreach targetxxx,$(TARGETS),$(eval $(call MK_TARGETS,$(targetxxx))))
tests/run-make-fulldeps/simd-ffi/simd.rs deleted-82
...@@ -1,82 +0,0 @@
1// ensures that public symbols are not removed completely
2#![crate_type = "lib"]
3// we can compile to a variety of platforms, because we don't need
4// cross-compiled standard libraries.
5#![feature(no_core, auto_traits)]
6#![no_core]
7#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)]
8
9#[derive(Copy)]
10#[repr(simd)]
11pub struct f32x4(f32, f32, f32, f32);
12
13extern "C" {
14 #[link_name = "llvm.sqrt.v4f32"]
15 fn vsqrt(x: f32x4) -> f32x4;
16}
17
18pub fn foo(x: f32x4) -> f32x4 {
19 unsafe { vsqrt(x) }
20}
21
22#[derive(Copy)]
23#[repr(simd)]
24pub struct i32x4(i32, i32, i32, i32);
25
26extern "C" {
27 // _mm_sll_epi32
28 #[cfg(any(target_arch = "x86", target_arch = "x86-64"))]
29 #[link_name = "llvm.x86.sse2.psll.d"]
30 fn integer(a: i32x4, b: i32x4) -> i32x4;
31
32 // vmaxq_s32
33 #[cfg(target_arch = "arm")]
34 #[link_name = "llvm.arm.neon.vmaxs.v4i32"]
35 fn integer(a: i32x4, b: i32x4) -> i32x4;
36 // vmaxq_s32
37 #[cfg(target_arch = "aarch64")]
38 #[link_name = "llvm.aarch64.neon.maxs.v4i32"]
39 fn integer(a: i32x4, b: i32x4) -> i32x4;
40
41 // just some substitute foreign symbol, not an LLVM intrinsic; so
42 // we still get type checking, but not as detailed as (ab)using
43 // LLVM.
44 #[cfg(not(any(
45 target_arch = "x86",
46 target_arch = "x86-64",
47 target_arch = "arm",
48 target_arch = "aarch64"
49 )))]
50 fn integer(a: i32x4, b: i32x4) -> i32x4;
51}
52
53pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
54 unsafe { integer(a, b) }
55}
56
57#[lang = "sized"]
58pub trait Sized {}
59
60#[lang = "copy"]
61pub trait Copy {}
62
63impl Copy for f32 {}
64impl Copy for i32 {}
65
66pub mod marker {
67 pub use Copy;
68}
69
70#[lang = "freeze"]
71auto trait Freeze {}
72
73#[macro_export]
74#[rustc_builtin_macro]
75macro_rules! Copy {
76 () => {};
77}
78#[macro_export]
79#[rustc_builtin_macro]
80macro_rules! derive {
81 () => {};
82}
tests/run-make-fulldeps/simple-dylib/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2all:
3 $(RUSTC) bar.rs --crate-type=dylib -C prefer-dynamic
4 $(RUSTC) foo.rs
5 $(call RUN,foo)
tests/run-make-fulldeps/simple-dylib/bar.rs deleted-1
...@@ -1 +0,0 @@
1pub fn bar() {}
tests/run-make-fulldeps/simple-dylib/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate bar;
2
3fn main() {
4 bar::bar();
5}
tests/run-make-fulldeps/simple-rlib/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2all:
3 $(RUSTC) bar.rs --crate-type=rlib
4 $(RUSTC) foo.rs
5 $(call RUN,foo)
tests/run-make-fulldeps/simple-rlib/bar.rs deleted-1
...@@ -1 +0,0 @@
1pub fn bar() {}
tests/run-make-fulldeps/simple-rlib/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate bar;
2
3fn main() {
4 bar::bar();
5}
tests/run-make-fulldeps/split-debuginfo/Makefile deleted-308
...@@ -1,308 +0,0 @@
1include ../tools.mk
2
3all: off packed unpacked
4
5ifeq ($(UNAME),Darwin)
6# If disabled, don't run `dsymutil`.
7off:
8 rm -rf $(TMPDIR)/*.dSYM
9 $(RUSTC) foo.rs -g -C split-debuginfo=off
10 [ ! -d $(TMPDIR)/foo.dSYM ]
11
12# Packed by default, but only if debuginfo is requested
13packed:
14 rm -rf $(TMPDIR)/*.dSYM
15 $(RUSTC) foo.rs
16 [ ! -d $(TMPDIR)/foo.dSYM ]
17 rm -rf $(TMPDIR)/*.dSYM
18 $(RUSTC) foo.rs -g
19 [ -d $(TMPDIR)/foo.dSYM ]
20 rm -rf $(TMPDIR)/*.dSYM
21 $(RUSTC) foo.rs -g -C split-debuginfo=packed
22 [ -d $(TMPDIR)/foo.dSYM ]
23 rm -rf $(TMPDIR)/*.dSYM
24
25# Object files are preserved with unpacked and `dsymutil` isn't run
26unpacked:
27 $(RUSTC) foo.rs -g -C split-debuginfo=unpacked
28 ls $(TMPDIR)/*.o
29 [ ! -d $(TMPDIR)/foo.dSYM ]
30else
31ifdef IS_WINDOWS
32# Windows only supports packed debuginfo - nothing to test.
33off:
34packed:
35unpacked:
36else
37# Some non-Windows, non-Darwin platforms are not stable, and some are.
38ifeq ($(UNAME),Linux)
39 UNSTABLEOPTS :=
40else
41 UNSTABLEOPTS := -Zunstable-options
42endif
43
44# - Debuginfo in `.o` files
45# - `.o` deleted
46# - `.dwo` never created
47# - `.dwp` never created
48off:
49 $(RUSTC) foo.rs -g -C $(UNSTABLEOPTS) split-debuginfo=off
50 [ ! -f $(TMPDIR)/*.dwp ]
51 [ ! -f $(TMPDIR)/*.dwo ]
52 $(RUSTC) foo.rs -g
53 [ ! -f $(TMPDIR)/*.dwp ]
54 [ ! -f $(TMPDIR)/*.dwo ]
55
56packed: packed-split packed-single packed-lto packed-remapped packed-crosscrate
57
58# - Debuginfo in `.dwo` files
59# - `.o` deleted
60# - `.dwo` deleted
61# - `.dwp` present
62packed-split:
63 $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=packed -Zsplit-dwarf-kind=split
64 ls $(TMPDIR)/*.o && exit 1 || exit 0
65 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
66 rm $(TMPDIR)/foo.dwp
67 rm $(TMPDIR)/$(call BIN,foo)
68
69# - Debuginfo in `.o` files
70# - `.o` deleted
71# - `.dwo` never created
72# - `.dwp` present
73packed-single:
74 $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=packed -Zsplit-dwarf-kind=single
75 ls $(TMPDIR)/*.o && exit 1 || exit 0
76 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
77 rm $(TMPDIR)/foo.dwp
78 rm $(TMPDIR)/$(call BIN,foo)
79
80packed-lto: packed-lto-split packed-lto-single
81
82# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated
83# - `.o` never created
84# - `.dwo` never created
85# - `.dwp` never created
86packed-lto-split:
87 $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split \
88 --crate-type=rlib -Clinker-plugin-lto
89 ls $(TMPDIR)/*.o && exit 1 || exit 0
90 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
91 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
92 rm $(TMPDIR)/libbaz.rlib
93
94# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated
95# - `.o` never created
96# - `.dwo` never created
97# - `.dwp` never created
98packed-lto-single:
99 $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=packed -Zsplit-dwarf-kind=single \
100 --crate-type=rlib -Clinker-plugin-lto
101 ls $(TMPDIR)/*.o && exit 1 || exit 0
102 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
103 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
104 rm $(TMPDIR)/libbaz.rlib
105
106packed-remapped: packed-remapped-split packed-remapped-single
107
108# - Debuginfo in `.dwo` files
109# - `.o` and binary refer to remapped `.dwo` paths which do not exist
110# - `.o` deleted
111# - `.dwo` deleted
112# - `.dwp` present
113packed-remapped-split:
114 $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
115 -Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g
116 objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
117 ls $(TMPDIR)/*.o && exit 1 || exit 0
118 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
119 rm $(TMPDIR)/foo.dwp
120 rm $(TMPDIR)/$(call BIN,foo)
121
122# - Debuginfo in `.o` files
123# - `.o` and binary refer to remapped `.o` paths which do not exist
124# - `.o` deleted
125# - `.dwo` never created
126# - `.dwp` present
127packed-remapped-single:
128 $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
129 -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g
130 objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
131 ls $(TMPDIR)/*.o && exit 1 || exit 0
132 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
133 rm $(TMPDIR)/foo.dwp
134 rm $(TMPDIR)/$(call BIN,foo)
135
136packed-crosscrate: packed-crosscrate-split packed-crosscrate-single
137
138# - Debuginfo in `.dwo` files
139# - (bar) `.rlib` file created, contains `.dwo`
140# - (bar) `.o` deleted
141# - (bar) `.dwo` deleted
142# - (bar) `.dwp` never created
143# - (main) `.o` deleted
144# - (main) `.dwo` deleted
145# - (main) `.dwp` present
146packed-crosscrate-split:
147 $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=packed \
148 -Zsplit-dwarf-kind=split -C debuginfo=2 -g bar.rs
149 ls $(TMPDIR)/*.rlib
150 ls $(TMPDIR)/*.o && exit 1 || exit 0
151 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
152 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
153 $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \
154 -C split-debuginfo=packed -Zsplit-dwarf-kind=split -C debuginfo=2 -g main.rs
155 ls $(TMPDIR)/*.o && exit 1 || exit 0
156 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
157 rm $(TMPDIR)/main.dwp
158 rm $(TMPDIR)/$(call BIN,main)
159
160# - Debuginfo in `.o` files
161# - (bar) `.rlib` file created, contains `.o`
162# - (bar) `.o` deleted
163# - (bar) `.dwo` never created
164# - (bar) `.dwp` never created
165# - (main) `.o` deleted
166# - (main) `.dwo` never created
167# - (main) `.dwp` present
168packed-crosscrate-single:
169 $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=packed \
170 -Zsplit-dwarf-kind=single -C debuginfo=2 -g bar.rs
171 ls $(TMPDIR)/*.rlib
172 ls $(TMPDIR)/*.o && exit 1 || exit 0
173 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
174 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
175 $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \
176 -C split-debuginfo=packed -Zsplit-dwarf-kind=single -C debuginfo=2 -g main.rs
177 ls $(TMPDIR)/*.o && exit 1 || exit 0
178 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
179 rm $(TMPDIR)/main.dwp
180 rm $(TMPDIR)/$(call BIN,main)
181
182unpacked: unpacked-split unpacked-single unpacked-lto unpacked-remapped unpacked-crosscrate
183
184# - Debuginfo in `.dwo` files
185# - `.o` deleted
186# - `.dwo` present
187# - `.dwp` never created
188unpacked-split:
189 $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=unpacked -Zsplit-dwarf-kind=split
190 ls $(TMPDIR)/*.o && exit 1 || exit 0
191 rm $(TMPDIR)/*.dwo
192 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
193 rm $(TMPDIR)/$(call BIN,foo)
194
195# - Debuginfo in `.o` files
196# - `.o` present
197# - `.dwo` never created
198# - `.dwp` never created
199unpacked-single:
200 $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=unpacked -Zsplit-dwarf-kind=single
201 ls $(TMPDIR)/*.o
202 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
203 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
204 rm $(TMPDIR)/$(call BIN,foo)
205
206unpacked-lto: packed-lto-split packed-lto-single
207
208# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated
209# - `.o` never created
210# - `.dwo` never created
211# - `.dwp` never created
212unpacked-lto-split:
213 $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=unpacked -Zsplit-dwarf-kind=split \
214 --crate-type=rlib -Clinker-plugin-lto
215 ls $(TMPDIR)/*.o && exit 1 || exit 0
216 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
217 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
218 rm $(TMPDIR)/libbaz.rlib
219
220# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated
221# - `.o` never created
222# - `.dwo` never created
223# - `.dwp` never created
224unpacked-lto-single:
225 $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=unpacked -Zsplit-dwarf-kind=single \
226 --crate-type=rlib -Clinker-plugin-lto
227 ls $(TMPDIR)/*.o && exit 1 || exit 0
228 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
229 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
230 rm $(TMPDIR)/libbaz.rlib
231
232unpacked-remapped: unpacked-remapped-split unpacked-remapped-single
233
234# - Debuginfo in `.dwo` files
235# - `.o` and binary refer to remapped `.dwo` paths which do not exist
236# - `.o` deleted
237# - `.dwo` present
238# - `.dwp` never created
239unpacked-remapped-split:
240 $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
241 -Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g
242 objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
243 ls $(TMPDIR)/*.o && exit 1 || exit 0
244 rm $(TMPDIR)/*.dwo
245 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
246 rm $(TMPDIR)/$(call BIN,foo)
247
248# - Debuginfo in `.o` files
249# - `.o` and binary refer to remapped `.o` paths which do not exist
250# - `.o` present
251# - `.dwo` never created
252# - `.dwp` never created
253unpacked-remapped-single:
254 $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
255 -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g
256 objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
257 rm $(TMPDIR)/*.o
258 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
259 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
260 rm $(TMPDIR)/$(call BIN,foo)
261
262unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single
263
264# - Debuginfo in `.dwo` files
265# - (bar) `.rlib` file created, contains `.dwo`
266# - (bar) `.o` deleted
267# - (bar) `.dwo` present
268# - (bar) `.dwp` never created
269# - (main) `.o` deleted
270# - (main) `.dwo` present
271# - (main) `.dwp` never created
272unpacked-crosscrate-split:
273 $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=unpacked \
274 -Zsplit-dwarf-kind=split -C debuginfo=2 -g bar.rs
275 ls $(TMPDIR)/*.rlib
276 ls $(TMPDIR)/*.o && exit 1 || exit 0
277 ls $(TMPDIR)/*.dwo
278 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
279 $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \
280 -C split-debuginfo=unpacked -Zsplit-dwarf-kind=split -C debuginfo=2 -g main.rs
281 ls $(TMPDIR)/*.o && exit 1 || exit 0
282 rm $(TMPDIR)/*.dwo
283 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
284 rm $(TMPDIR)/$(call BIN,main)
285
286# - Debuginfo in `.o` files
287# - (bar) `.rlib` file created, contains `.o`
288# - (bar) `.o` present
289# - (bar) `.dwo` never created
290# - (bar) `.dwp` never created
291# - (main) `.o` present
292# - (main) `.dwo` never created
293# - (main) `.dwp` never created
294unpacked-crosscrate-single:
295 $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=unpacked \
296 -Zsplit-dwarf-kind=single -C debuginfo=2 -g bar.rs
297 ls $(TMPDIR)/*.rlib
298 ls $(TMPDIR)/*.o
299 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
300 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
301 $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \
302 -C split-debuginfo=unpacked -Zsplit-dwarf-kind=single -C debuginfo=2 -g main.rs
303 ls $(TMPDIR)/*.o
304 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
305 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
306 rm $(TMPDIR)/$(call BIN,main)
307endif
308endif
tests/run-make-fulldeps/split-debuginfo/bar.rs deleted-13
...@@ -1,13 +0,0 @@
1pub struct Bar {
2 x: u32,
3}
4
5impl Bar {
6 pub fn print(&self) {
7 println!("{}", self.x);
8 }
9}
10
11pub fn make_bar(x: u32) -> Bar {
12 Bar { x }
13}
tests/run-make-fulldeps/split-debuginfo/baz.rs deleted-1
...@@ -1 +0,0 @@
1// empty
tests/run-make-fulldeps/split-debuginfo/foo.rs deleted-15
...@@ -1,15 +0,0 @@
1pub struct Foo {
2 x: u32,
3}
4
5impl Foo {
6 pub fn print(&self) {
7 println!("{}", self.x);
8 }
9}
10
11pub fn make_foo(x: u32) -> Foo {
12 Foo { x }
13}
14
15fn main() {}
tests/run-make-fulldeps/split-debuginfo/main.rs deleted-8
...@@ -1,8 +0,0 @@
1extern crate bar;
2
3use bar::{Bar, make_bar};
4
5fn main() {
6 let b = make_bar(3);
7 b.print();
8}
tests/run-make-fulldeps/stable-symbol-names/Makefile deleted-41
...@@ -1,41 +0,0 @@
1include ../tools.mk
2
3# The following command will:
4# 1. dump the symbols of a library using `nm`
5# 2. extract only those lines that we are interested in via `grep`
6# 3. from those lines, extract just the symbol name via `sed`, which:
7# * always starts with "_ZN" and ends with "E" (`legacy` mangling)
8# * always starts with "_R" (`v0` mangling)
9# 4. sort those symbol names for deterministic comparison
10# 5. write the result into a file
11
12dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \
13 | grep -E "$(2)" \
14 | sed -E "s/.*(_ZN.*E|_R[a-zA-Z0-9_]*).*/\1/" \
15 | sort \
16 > "$(TMPDIR)/$(1)$(3).nm"
17
18# This test
19# - compiles each of the two crates 2 times and makes sure each time we get
20# exactly the same symbol names
21# - makes sure that both crates agree on the same symbol names for monomorphic
22# functions
23
24all:
25 $(RUSTC) stable-symbol-names1.rs
26 $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v1)
27 rm $(TMPDIR)/libstable_symbol_names1.rlib
28 $(RUSTC) stable-symbol-names1.rs
29 $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v2)
30 cmp "$(TMPDIR)/stable_symbol_names1_v1.nm" "$(TMPDIR)/stable_symbol_names1_v2.nm"
31
32 $(RUSTC) stable-symbol-names2.rs
33 $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v1)
34 rm $(TMPDIR)/libstable_symbol_names2.rlib
35 $(RUSTC) stable-symbol-names2.rs
36 $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v2)
37 cmp "$(TMPDIR)/stable_symbol_names2_v1.nm" "$(TMPDIR)/stable_symbol_names2_v2.nm"
38
39 $(call dump-symbols,stable_symbol_names1,mono_,_cross)
40 $(call dump-symbols,stable_symbol_names2,mono_,_cross)
41 cmp "$(TMPDIR)/stable_symbol_names1_cross.nm" "$(TMPDIR)/stable_symbol_names2_cross.nm"
tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs deleted-31
...@@ -1,31 +0,0 @@
1#![crate_type="rlib"]
2
3pub trait Foo {
4 fn generic_method<T>();
5}
6
7pub struct Bar;
8
9impl Foo for Bar {
10 fn generic_method<T>() {}
11}
12
13pub fn mono_function() {
14 Bar::generic_method::<Bar>();
15}
16
17pub fn mono_function_lifetime<'a>(x: &'a u64) -> u64 {
18 *x
19}
20
21pub fn generic_function<T>(t: T) -> T {
22 t
23}
24
25pub fn user() {
26 generic_function(0u32);
27 generic_function("abc");
28 let x = 2u64;
29 generic_function(&x);
30 let _ = mono_function_lifetime(&x);
31}
tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs deleted-17
...@@ -1,17 +0,0 @@
1#![crate_type="rlib"]
2
3extern crate stable_symbol_names1;
4
5pub fn user() {
6 stable_symbol_names1::generic_function(1u32);
7 stable_symbol_names1::generic_function("def");
8 let x = 2u64;
9 stable_symbol_names1::generic_function(&x);
10 stable_symbol_names1::mono_function();
11 stable_symbol_names1::mono_function_lifetime(&0);
12}
13
14pub fn trait_impl_test_function() {
15 use stable_symbol_names1::*;
16 Bar::generic_method::<Bar>();
17}
tests/run-make-fulldeps/static-dylib-by-default/Makefile deleted-16
...@@ -1,16 +0,0 @@
1include ../tools.mk
2
3TO_LINK := $(call DYLIB,bar)
4ifdef IS_MSVC
5LINK_ARG = $(TO_LINK:dll=dll.lib)
6else
7LINK_ARG = $(TO_LINK)
8endif
9
10all:
11 $(RUSTC) foo.rs
12 $(RUSTC) bar.rs
13 $(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS)
14 rm $(TMPDIR)/*.rlib
15 rm $(call DYLIB,foo)
16 $(call RUN,main)
tests/run-make-fulldeps/static-dylib-by-default/bar.rs deleted-8
...@@ -1,8 +0,0 @@
1#![crate_type = "dylib"]
2
3extern crate foo;
4
5#[no_mangle]
6pub extern "C" fn bar() {
7 foo::foo();
8}
tests/run-make-fulldeps/static-dylib-by-default/foo.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "rlib"]
2#![crate_type = "dylib"]
3
4pub fn foo() {}
tests/run-make-fulldeps/static-dylib-by-default/main.c deleted-6
...@@ -1,6 +0,0 @@
1extern void bar();
2
3int main() {
4 bar();
5 return 0;
6}
tests/run-make-fulldeps/static-extern-type/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all: $(call NATIVE_STATICLIB,define-foo)
4 $(RUSTC) -ldefine-foo use-foo.rs
5 $(call RUN,use-foo) || exit 1
tests/run-make-fulldeps/static-extern-type/define-foo.c deleted-11
...@@ -1,11 +0,0 @@
1#include <stdint.h>
2
3struct Foo {
4 uint8_t x;
5};
6
7struct Foo FOO = { 42 };
8
9uint8_t bar(const struct Foo* foo) {
10 return foo->x;
11}
tests/run-make-fulldeps/static-extern-type/use-foo.rs deleted-14
...@@ -1,14 +0,0 @@
1#![feature(extern_types)]
2
3extern "C" {
4 type Foo;
5 static FOO: Foo;
6 fn bar(foo: *const Foo) -> u8;
7}
8
9fn main() {
10 unsafe {
11 let foo = &FOO;
12 assert_eq!(bar(foo), 42);
13 }
14}
tests/run-make-fulldeps/static-unwinding/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) lib.rs
5 $(RUSTC) main.rs
6 $(call RUN,main)
tests/run-make-fulldeps/static-unwinding/lib.rs deleted-15
...@@ -1,15 +0,0 @@
1#![crate_type = "rlib"]
2
3pub static mut statik: isize = 0;
4
5struct A;
6impl Drop for A {
7 fn drop(&mut self) {
8 unsafe { statik = 1; }
9 }
10}
11
12pub fn callback<F>(f: F) where F: FnOnce() {
13 let _a = A;
14 f();
15}
tests/run-make-fulldeps/static-unwinding/main.rs deleted-24
...@@ -1,24 +0,0 @@
1extern crate lib;
2
3use std::thread;
4
5static mut statik: isize = 0;
6
7struct A;
8impl Drop for A {
9 fn drop(&mut self) {
10 unsafe { statik = 1; }
11 }
12}
13
14fn main() {
15 thread::spawn(move|| {
16 let _a = A;
17 lib::callback(|| panic!());
18 }).join().unwrap_err();
19
20 unsafe {
21 assert_eq!(lib::statik, 1);
22 assert_eq!(statik, 1);
23 }
24}
tests/run-make-fulldeps/staticlib-blank-lib/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 $(AR) crus $(TMPDIR)/libfoo.a foo.rs
5 $(AR) d $(TMPDIR)/libfoo.a foo.rs
6 $(RUSTC) foo.rs
tests/run-make-fulldeps/staticlib-blank-lib/foo.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_type = "staticlib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {}
5
6fn main() {}
tests/run-make-fulldeps/std-core-cycle/Makefile deleted-16
...@@ -1,16 +0,0 @@
1include ../tools.mk
2
3ifeq ($(UNAME),Darwin)
4FLAGS :=
5else
6ifdef IS_WINDOWS
7FLAGS :=
8else
9FLAGS := -C link-args=-Wl,--no-undefined
10endif
11endif
12
13all:
14 $(RUSTC) bar.rs
15 $(RUSTC) foo.rs $(FLAGS)
16 $(RUSTC) foo.rs $(FLAGS) -C panic=abort
tests/run-make-fulldeps/std-core-cycle/bar.rs deleted-16
...@@ -1,16 +0,0 @@
1#![feature(allocator_api)]
2#![crate_type = "rlib"]
3
4use std::alloc::*;
5
6pub struct A;
7
8unsafe impl GlobalAlloc for A {
9 unsafe fn alloc(&self, _: Layout) -> *mut u8 {
10 loop {}
11 }
12
13 unsafe fn dealloc(&self, _ptr: *mut u8, _: Layout) {
14 loop {}
15 }
16}
tests/run-make-fulldeps/std-core-cycle/foo.rs deleted-11
...@@ -1,11 +0,0 @@
1#![crate_type = "cdylib"]
2
3extern crate bar;
4
5#[global_allocator]
6static A: bar::A = bar::A;
7
8#[no_mangle]
9pub extern "C" fn a(a: u32, b: u32) -> u32 {
10 a / b
11}
tests/run-make-fulldeps/stdin-non-utf8/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 cp non-utf8 $(TMPDIR)/non-utf.rs
5 cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \
6 | $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8"
tests/run-make-fulldeps/stdin-non-utf8/non-utf8 deleted-1
...@@ -1 +0,0 @@
1
tests/run-make-fulldeps/suspicious-library/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs -C prefer-dynamic
5 touch $(call DYLIB,foo-something-special)
6 touch $(call DYLIB,foo-something-special2)
7 $(RUSTC) bar.rs
tests/run-make-fulldeps/suspicious-library/bar.rs deleted-3
...@@ -1,3 +0,0 @@
1extern crate foo;
2
3fn main() { foo::foo() }
tests/run-make-fulldeps/suspicious-library/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "dylib"]
2
3pub fn foo() {}
tests/run-make-fulldeps/symbol-visibility/Makefile deleted-122
...@@ -1,122 +0,0 @@
1include ../tools.mk
2
3# ignore-windows-msvc
4
5NM=nm -D
6CDYLIB_NAME=liba_cdylib.so
7RDYLIB_NAME=liba_rust_dylib.so
8PROC_MACRO_NAME=liba_proc_macro.so
9EXE_NAME=an_executable
10COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so
11
12ifeq ($(UNAME),Darwin)
13NM=nm -gU
14CDYLIB_NAME=liba_cdylib.dylib
15RDYLIB_NAME=liba_rust_dylib.dylib
16PROC_MACRO_NAME=liba_proc_macro.dylib
17EXE_NAME=an_executable
18COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib
19endif
20
21ifdef IS_WINDOWS
22NM=nm -g
23CDYLIB_NAME=liba_cdylib.dll.a
24RDYLIB_NAME=liba_rust_dylib.dll.a
25PROC_MACRO_NAME=liba_proc_macro.dll
26EXE_NAME=an_executable.exe
27COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dll.a
28endif
29
30# `grep` regex for symbols produced by either `legacy` or `v0` mangling
31RE_ANY_RUST_SYMBOL="_ZN.*h.*E\|_R[a-zA-Z0-9_]+"
32
33all:
34 $(RUSTC) -Zshare-generics=no an_rlib.rs
35 $(RUSTC) -Zshare-generics=no a_cdylib.rs
36 $(RUSTC) -Zshare-generics=no a_rust_dylib.rs
37 $(RUSTC) -Zshare-generics=no a_proc_macro.rs
38 $(RUSTC) -Zshare-generics=no an_executable.rs
39 $(RUSTC) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
40
41 # Check that a cdylib exports its public #[no_mangle] functions
42 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
43 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
44 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
45 # Check that a cdylib DOES NOT export any public Rust functions
46 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
47
48 # Check that a Rust dylib exports its monomorphic functions
49 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
50 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
51 # Check that a Rust dylib does not export generics if -Zshare-generics=no
52 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]
53
54
55 # Check that a Rust dylib exports the monomorphic functions from its dependencies
56 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
57 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ]
58 # Check that a Rust dylib does not export generics if -Zshare-generics=no
59 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "0" ]
60
61 # Check that a proc macro exports its public #[no_mangle] functions
62 # FIXME(#99978) avoid exporting #[no_mangle] symbols for proc macros
63 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
64 # Check that a proc macro exports the public #[no_mangle] functions of dependencies
65 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
66 # Check that a proc macro DOES NOT export any public Rust functions
67 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
68
69# FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032
70ifndef IS_WINDOWS
71 # Check that an executable does not export any dynamic symbols
72 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ]
73 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_rust_function_from_exe)" -eq "0" ]
74endif
75
76
77 # Check the combined case, where we generate a cdylib and an rlib in the same
78 # compilation session:
79 # Check that a cdylib exports its public #[no_mangle] functions
80 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
81 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
82 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
83 # Check that a cdylib DOES NOT export any public Rust functions
84 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
85
86
87 $(RUSTC) -Zshare-generics=yes an_rlib.rs
88 $(RUSTC) -Zshare-generics=yes a_cdylib.rs
89 $(RUSTC) -Zshare-generics=yes a_rust_dylib.rs
90 $(RUSTC) -Zshare-generics=yes a_proc_macro.rs
91 $(RUSTC) -Zshare-generics=yes an_executable.rs
92
93 # Check that a cdylib exports its public #[no_mangle] functions
94 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
95 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
96 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
97 # Check that a cdylib DOES NOT export any public Rust functions
98 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
99
100 # Check that a Rust dylib exports its monomorphic functions, including generics this time
101 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
102 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
103 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rust_dylib)" -eq "1" ]
104
105 # Check that a Rust dylib exports the monomorphic functions from its dependencies
106 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
107 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ]
108 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "1" ]
109
110 # Check that a proc macro exports its public #[no_mangle] functions
111 # FIXME(#99978) avoid exporting #[no_mangle] symbols for proc macros
112 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
113 # Check that a proc macro exports the public #[no_mangle] functions of dependencies
114 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
115 # Check that a proc macro DOES NOT export any public Rust functions
116 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
117
118ifndef IS_WINDOWS
119 # Check that an executable does not export any dynamic symbols
120 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ]
121 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_rust_function_from_exe)" -eq "0" ]
122endif
tests/run-make-fulldeps/symbol-visibility/a_cdylib.rs deleted-12
...@@ -1,12 +0,0 @@
1#![crate_type="cdylib"]
2
3extern crate an_rlib;
4
5// This should not be exported
6pub fn public_rust_function_from_cdylib() {}
7
8// This should be exported
9#[no_mangle]
10pub extern "C" fn public_c_function_from_cdylib() {
11 an_rlib::public_c_function_from_rlib();
12}
tests/run-make-fulldeps/symbol-visibility/a_proc_macro.rs deleted-9
...@@ -1,9 +0,0 @@
1#![crate_type = "proc-macro"]
2
3extern crate an_rlib;
4
5// This should not be exported
6#[no_mangle]
7extern "C" fn public_c_function_from_cdylib() {
8 an_rlib::public_c_function_from_rlib();
9}
tests/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs deleted-15
...@@ -1,15 +0,0 @@
1#![crate_type="dylib"]
2
3extern crate an_rlib;
4
5// This should be exported
6pub fn public_rust_function_from_rust_dylib() {}
7
8// This should be exported
9#[no_mangle]
10pub extern "C" fn public_c_function_from_rust_dylib() {
11 let _ = public_generic_function_from_rust_dylib(1u16);
12}
13
14// This should be exported if -Zshare-generics=yes
15pub fn public_generic_function_from_rust_dylib<T>(x: T) -> T { x }
tests/run-make-fulldeps/symbol-visibility/an_executable.rs deleted-7
...@@ -1,7 +0,0 @@
1#![crate_type="bin"]
2
3extern crate an_rlib;
4
5pub fn public_rust_function_from_exe() {}
6
7fn main() {}
tests/run-make-fulldeps/symbol-visibility/an_rlib.rs deleted-12
...@@ -1,12 +0,0 @@
1#![crate_type="rlib"]
2
3pub fn public_rust_function_from_rlib() {}
4
5#[no_mangle]
6pub extern "C" fn public_c_function_from_rlib() {
7 let _ = public_generic_function_from_rlib(0u64);
8}
9
10pub fn public_generic_function_from_rlib<T>(x: T) -> T {
11 x
12}
tests/run-make-fulldeps/symbols-include-type-name/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# Check that symbol names for methods include type names, instead of <impl>.
4
5OUT=$(TMPDIR)/lib.s
6
7all:
8 $(RUSTC) --crate-type staticlib --emit asm lib.rs
9 $(CGREP) Def < $(OUT)
tests/run-make-fulldeps/symbols-include-type-name/lib.rs deleted-14
...@@ -1,14 +0,0 @@
1pub struct Def {
2 pub id: i32,
3}
4
5impl Def {
6 pub fn new(id: i32) -> Def {
7 Def { id: id }
8 }
9}
10
11#[no_mangle]
12pub fn user() {
13 let _ = Def::new(0);
14}
tests/run-make-fulldeps/symlinked-extern/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4# `ln` is actually `cp` on msys.
5
6all:
7 $(RUSTC) foo.rs
8 mkdir -p $(TMPDIR)/other
9 ln -nsf $(TMPDIR)/libfoo.rlib $(TMPDIR)/other
10 $(RUSTC) bar.rs -L $(TMPDIR)
11 $(RUSTC) baz.rs --extern foo=$(TMPDIR)/other/libfoo.rlib -L $(TMPDIR)
tests/run-make-fulldeps/symlinked-extern/bar.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_type = "rlib"]
2
3extern crate foo;
4
5pub fn bar(_s: foo::S) {
6}
tests/run-make-fulldeps/symlinked-extern/baz.rs deleted-6
...@@ -1,6 +0,0 @@
1extern crate bar;
2extern crate foo;
3
4fn main() {
5 bar::bar(foo::foo());
6}
tests/run-make-fulldeps/symlinked-extern/foo.rs deleted-5
...@@ -1,5 +0,0 @@
1#![crate_type = "rlib"]
2
3pub struct S;
4
5pub fn foo() -> S { S }
tests/run-make-fulldeps/symlinked-libraries/Makefile deleted-10
...@@ -1,10 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4# `ln` is actually `cp` on msys.
5
6all:
7 $(RUSTC) foo.rs -C prefer-dynamic
8 mkdir -p $(TMPDIR)/other
9 ln -nsf $(TMPDIR)/$(call DYLIB_GLOB,foo) $(TMPDIR)/other
10 $(RUSTC) bar.rs -L $(TMPDIR)/other
tests/run-make-fulldeps/symlinked-libraries/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::bar();
5}
tests/run-make-fulldeps/symlinked-libraries/foo.rs deleted-3
...@@ -1,3 +0,0 @@
1#![crate_type = "dylib"]
2
3pub fn bar() {}
tests/run-make-fulldeps/symlinked-rlib/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# ignore-windows
4# `ln` is actually `cp` on msys.
5
6all:
7 $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo.xxx
8 ln -nsf $(TMPDIR)/foo.xxx $(TMPDIR)/libfoo.rlib
9 $(RUSTC) bar.rs -L $(TMPDIR)
tests/run-make-fulldeps/symlinked-rlib/bar.rs deleted-5
...@@ -1,5 +0,0 @@
1extern crate foo;
2
3fn main() {
4 foo::bar();
5}
tests/run-make-fulldeps/symlinked-rlib/foo.rs deleted-1
...@@ -1 +0,0 @@
1pub fn bar() {}
tests/run-make-fulldeps/sysroot-crates-are-unstable/Makefile deleted-2
...@@ -1,2 +0,0 @@
1all:
2 '$(PYTHON)' test.py
tests/run-make-fulldeps/sysroot-crates-are-unstable/test.py deleted-74
...@@ -1,74 +0,0 @@
1import sys
2import os
3from os import listdir
4from os.path import isfile, join
5from subprocess import PIPE, Popen
6
7
8# This is n list of files which are stable crates or simply are not crates,
9# we don't check for the instability of these crates as they're all stable!
10STABLE_CRATES = ['std', 'alloc', 'core', 'proc_macro',
11 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', 'clang_rt']
12
13
14def convert_to_string(s):
15 if s.__class__.__name__ == 'bytes':
16 return s.decode('utf-8')
17 return s
18
19
20def set_ld_lib_path():
21 var = os.environ.get("LD_LIB_PATH_ENVVAR")
22 rpath = os.environ.get("HOST_RPATH_DIR")
23 if var and rpath:
24 path = os.environ.get(var)
25 if path:
26 os.environ[var] = rpath + os.pathsep + path
27 else:
28 os.environ[var] = rpath
29
30
31def exec_command(command, to_input=None):
32 child = None
33 if to_input is None:
34 child = Popen(command, stdout=PIPE, stderr=PIPE)
35 else:
36 child = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE)
37 stdout, stderr = child.communicate(input=to_input)
38 return (convert_to_string(stdout), convert_to_string(stderr))
39
40
41def check_lib(lib):
42 if lib['name'] in STABLE_CRATES:
43 return True
44 print('verifying if {} is an unstable crate'.format(lib['name']))
45 stdout, stderr = exec_command([os.environ['RUSTC'], '-', '--crate-type', 'rlib',
46 '--extern', '{}={}'.format(lib['name'], lib['path'])],
47 to_input=('extern crate {};'.format(lib['name'])).encode('utf-8'))
48 if not 'use of unstable library feature' in '{}{}'.format(stdout, stderr):
49 print('crate {} "{}" is not unstable'.format(lib['name'], lib['path']))
50 print('{}{}'.format(stdout, stderr))
51 print('')
52 return False
53 return True
54
55# Generate a list of all crates in the sysroot. To do this we list all files in
56# rustc's sysroot, look at the filename, strip everything after the `-`, and
57# strip the leading `lib` (if present)
58def get_all_libs(dir_path):
59 return [{ 'path': join(dir_path, f), 'name': f[3:].split('-')[0] }
60 for f in listdir(dir_path)
61 if isfile(join(dir_path, f)) and f.endswith('.rlib') and f not in STABLE_CRATES]
62
63
64set_ld_lib_path()
65sysroot = exec_command([os.environ['RUSTC'], '--print', 'sysroot'])[0].replace('\n', '')
66assert sysroot, "Could not read the rustc sysroot!"
67libs = get_all_libs(join(sysroot, 'lib/rustlib/{}/lib'.format(os.environ['TARGET'])))
68
69ret = 0
70for lib in libs:
71 if not check_lib(lib):
72 # We continue so users can see all the not unstable crates.
73 ret = 1
74sys.exit(ret)
tests/run-make-fulldeps/target-cpu-native/Makefile deleted-20
...@@ -1,20 +0,0 @@
1include ../tools.mk
2
3# only-linux
4# only-x86_64
5#
6# I *really* don't want to deal with a cross-platform way to compare file sizes,
7# tests in `make` sort of are awful
8
9all: $(TMPDIR)/out.log
10 # Make sure no warnings about "unknown CPU `native`" were emitted
11 if [ "$$(wc -c $(TMPDIR)/out.log | cut -d' ' -f 1)" = "0" ]; then \
12 echo no warnings generated; \
13 else \
14 exit 1; \
15 fi
16
17
18$(TMPDIR)/out.log:
19 $(RUSTC) foo.rs -C target-cpu=native 2>&1 | tee $(TMPDIR)/out.log
20 $(call RUN,foo)
tests/run-make-fulldeps/target-cpu-native/foo.rs deleted-2
...@@ -1,2 +0,0 @@
1fn main() {
2}
tests/run-make-fulldeps/target-specs/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2all:
3 $(RUSTC) foo.rs --target=my-awesome-platform.json --crate-type=lib --emit=asm
4 $(CGREP) -v morestack < $(TMPDIR)/foo.s
5 $(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | $(CGREP) "Error loading target specification"
6 $(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | $(CGREP) 'Field llvm-target'
7 RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm
8 RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
9 $(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -
10 $(RUSTC) foo.rs --target=definitely-not-builtin-target 2>&1 | $(CGREP) 'may not set is_builtin'
11 $(RUSTC) foo.rs --target=mismatching-data-layout --crate-type=lib
tests/run-make-fulldeps/target-specs/definitely-not-builtin-target.json deleted-7
...@@ -1,7 +0,0 @@
1{
2 "arch": "x86_64",
3 "is-builtin": true,
4 "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
5 "llvm-target": "x86_64-unknown-unknown-gnu",
6 "target-pointer-width": "64"
7}
tests/run-make-fulldeps/target-specs/foo.rs deleted-24
...@@ -1,24 +0,0 @@
1#![feature(lang_items, no_core, auto_traits)]
2#![no_core]
3
4#[lang = "copy"]
5trait Copy {}
6
7#[lang = "sized"]
8trait Sized {}
9
10#[lang = "freeze"]
11auto trait Freeze {}
12
13#[lang = "start"]
14fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
15 0
16}
17
18extern "C" {
19 fn _foo() -> [u8; 16];
20}
21
22fn _main() {
23 let _a = unsafe { _foo() };
24}
tests/run-make-fulldeps/target-specs/mismatching-data-layout.json deleted-6
...@@ -1,6 +0,0 @@
1{
2 "arch": "x86_64",
3 "data-layout": "e-m:e-i64:16:32:64",
4 "llvm-target": "x86_64-unknown-unknown-gnu",
5 "target-pointer-width": "64"
6}
tests/run-make-fulldeps/target-specs/my-awesome-platform.json deleted-11
...@@ -1,11 +0,0 @@
1{
2 "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128",
3 "linker-flavor": "gcc",
4 "llvm-target": "i686-unknown-linux-gnu",
5 "target-endian": "little",
6 "target-pointer-width": "32",
7 "target-c-int-width": "32",
8 "arch": "x86",
9 "os": "linux",
10 "morestack": false
11}
tests/run-make-fulldeps/target-specs/my-incomplete-platform.json deleted-10
...@@ -1,10 +0,0 @@
1{
2 "data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32",
3 "linker-flavor": "gcc",
4 "target-endian": "little",
5 "target-pointer-width": "32",
6 "target-c-int-width": "32",
7 "arch": "x86",
8 "os": "foo",
9 "morestack": false
10}
tests/run-make-fulldeps/target-specs/my-invalid-platform.json deleted-1
...@@ -1 +0,0 @@
1wow this json is really broke!
tests/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json deleted-12
...@@ -1,12 +0,0 @@
1{
2 "pre-link-args": {"gcc": ["-m64"]},
3 "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
4 "linker-flavor": "gcc",
5 "llvm-target": "x86_64-unknown-linux-gnu",
6 "target-endian": "little",
7 "target-pointer-width": "64",
8 "target-c-int-width": "32",
9 "arch": "x86_64",
10 "os": "linux",
11 "morestack": false
12}
tests/run-make-fulldeps/target-without-atomic-cas/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3# The target used below doesn't support atomic CAS operations. Verify that's the case
4all:
5 $(RUSTC) --print cfg --target thumbv6m-none-eabi | $(CGREP) -v 'target_has_atomic="ptr"'
tests/run-make-fulldeps/test-harness/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3all:
4 # check that #[cfg_attr(..., ignore)] does the right thing.
5 $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg
6 $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored'
7 $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$"
8 $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should'
tests/run-make-fulldeps/test-harness/test-ignore-cfg.rs deleted-9
...@@ -1,9 +0,0 @@
1#[test]
2#[cfg_attr(ignorecfg, ignore)]
3fn shouldignore() {
4}
5
6#[test]
7#[cfg_attr(noignorecfg, ignore)]
8fn shouldnotignore() {
9}
tests/run-make-fulldeps/tools.mk deleted-187
...@@ -1,187 +0,0 @@
1# These deliberately use `=` and not `:=` so that client makefiles can
2# augment HOST_RPATH_DIR / TARGET_RPATH_DIR.
3HOST_RPATH_ENV = \
4 $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
5TARGET_RPATH_ENV = \
6 $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
7
8RUSTC_ORIGINAL := $(RUSTC)
9BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)'
10BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)'
11RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS)
12RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR)
13ifdef RUSTC_LINKER
14RUSTC := $(RUSTC) -Clinker='$(RUSTC_LINKER)'
15RUSTDOC := $(RUSTDOC) -Clinker='$(RUSTC_LINKER)'
16endif
17#CC := $(CC) -L $(TMPDIR)
18HTMLDOCCK := '$(PYTHON)' '$(S)/src/etc/htmldocck.py'
19CGREP := "$(S)/src/etc/cat-and-grep.sh"
20
21# diff with common flags for multi-platform diffs against text output
22DIFF := diff -u --strip-trailing-cr
23
24# Some of the Rust CI platforms use `/bin/dash` to run `shell` script in
25# Makefiles. Other platforms, including many developer platforms, default to
26# `/bin/bash`. (In many cases, `make` is actually using `/bin/sh`, but `sh`
27# is configured to execute one or the other shell binary). `dash` features
28# support only a small subset of `bash` features, so `dash` can be thought of as
29# the lowest common denominator, and tests should be validated against `dash`
30# whenever possible. Most developer platforms include `/bin/dash`, but to ensure
31# tests still work when `/bin/dash`, if not available, this `SHELL` override is
32# conditional:
33ifndef IS_WINDOWS # dash interprets backslashes in executable paths incorrectly
34ifneq (,$(wildcard /bin/dash))
35SHELL := /bin/dash
36endif
37endif
38
39# This is the name of the binary we will generate and run; use this
40# e.g. for `$(CC) -o $(RUN_BINFILE)`.
41RUN_BINFILE = $(TMPDIR)/$(1)
42
43# Invoke the generated binary on the remote machine if compiletest was
44# configured to use a remote test device, otherwise run it on the current host.
45ifdef REMOTE_TEST_CLIENT
46# FIXME: if a test requires additional files, this will need to be changed to
47# also push them (by changing the 0 to the number of additional files, and
48# providing the path of the additional files as the last arguments).
49EXECUTE = $(REMOTE_TEST_CLIENT) run 0 $(RUN_BINFILE)
50else
51EXECUTE = $(RUN_BINFILE)
52endif
53
54# RUN and FAIL are basic way we will invoke the generated binary. On
55# non-windows platforms, they set the LD_LIBRARY_PATH environment
56# variable before running the binary.
57
58RLIB_GLOB = lib$(1)*.rlib
59BIN = $(1)
60
61UNAME = $(shell uname)
62
63ifeq ($(UNAME),Darwin)
64RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
65FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
66DYLIB_GLOB = lib$(1)*.dylib
67DYLIB = $(TMPDIR)/lib$(1).dylib
68STATICLIB = $(TMPDIR)/lib$(1).a
69STATICLIB_GLOB = lib$(1)*.a
70else
71ifdef IS_WINDOWS
72RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE)
73FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE) && exit 1 || exit 0
74DYLIB_GLOB = $(1)*.dll
75DYLIB = $(TMPDIR)/$(1).dll
76ifdef IS_MSVC
77STATICLIB = $(TMPDIR)/$(1).lib
78STATICLIB_GLOB = $(1)*.lib
79else
80IMPLIB = $(TMPDIR)/lib$(1).dll.a
81STATICLIB = $(TMPDIR)/lib$(1).a
82STATICLIB_GLOB = lib$(1)*.a
83endif
84BIN = $(1).exe
85LLVM_FILECHECK := $(shell cygpath -u "$(LLVM_FILECHECK)")
86else
87RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
88FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
89DYLIB_GLOB = lib$(1)*.so
90DYLIB = $(TMPDIR)/lib$(1).so
91STATICLIB = $(TMPDIR)/lib$(1).a
92STATICLIB_GLOB = lib$(1)*.a
93endif
94endif
95
96ifdef IS_MSVC
97COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2)
98COMPILE_OBJ_CXX = $(CXX) -EHs -c -Fo:`cygpath -w $(1)` $(2)
99NATIVE_STATICLIB_FILE = $(1).lib
100NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1))
101OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \
102 -Fo:`cygpath -w $(TMPDIR)/$(1).obj`
103else
104COMPILE_OBJ = $(CC) -v -c -o $(1) $(2)
105COMPILE_OBJ_CXX = $(CXX) -c -o $(1) $(2)
106NATIVE_STATICLIB_FILE = lib$(1).a
107NATIVE_STATICLIB = $(call STATICLIB,$(1))
108OUT_EXE=-o $(TMPDIR)/$(1)
109endif
110
111
112# Extra flags needed to compile a working executable with the standard library
113ifdef IS_WINDOWS
114ifdef IS_MSVC
115 EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib bcrypt.lib ntdll.lib
116else
117 EXTRACFLAGS := -lws2_32 -luserenv -lbcrypt -lntdll
118 EXTRACXXFLAGS := -lstdc++
119 # So this is a bit hacky: we can't use the DLL version of libstdc++ because
120 # it pulls in the DLL version of libgcc, which means that we end up with 2
121 # instances of the DW2 unwinding implementation. This is a problem on
122 # i686-pc-windows-gnu because each module (DLL/EXE) needs to register its
123 # unwind information with the unwinding implementation, and libstdc++'s
124 # __cxa_throw won't see the unwinding info we registered with our statically
125 # linked libgcc.
126 #
127 # Now, simply statically linking libstdc++ would fix this problem, except
128 # that it is compiled with the expectation that pthreads is dynamically
129 # linked as a DLL and will fail to link with a statically linked libpthread.
130 #
131 # So we end up with the following hack: we link use static:-bundle to only
132 # link the parts of libstdc++ that we actually use, which doesn't include
133 # the dependency on the pthreads DLL.
134 EXTRARSCXXFLAGS := -l static:-bundle=stdc++
135endif
136else
137ifeq ($(UNAME),Darwin)
138 EXTRACFLAGS := -lresolv
139 EXTRACXXFLAGS := -lc++
140 EXTRARSCXXFLAGS := -lc++
141else
142ifeq ($(UNAME),FreeBSD)
143 EXTRACFLAGS := -lm -lpthread -lgcc_s
144else
145ifeq ($(UNAME),SunOS)
146 EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv
147else
148ifeq ($(UNAME),OpenBSD)
149 EXTRACFLAGS := -lm -lpthread -lc++abi
150 RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))"
151else
152 EXTRACFLAGS := -lm -lrt -ldl -lpthread
153 EXTRACXXFLAGS := -lstdc++
154 EXTRARSCXXFLAGS := -lstdc++
155endif
156endif
157endif
158endif
159endif
160
161REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
162REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
163
164%.a: %.o
165 $(AR) crus $@ $<
166ifdef IS_MSVC
167%.lib: lib%.o
168 $(MSVC_LIB) -out:`cygpath -w $@` $<
169else
170%.lib: lib%.o
171 $(AR) crus $@ $<
172endif
173%.dylib: %.o
174 $(CC) -dynamiclib -Wl,-dylib -o $@ $<
175%.so: %.o
176 $(CC) -o $@ $< -shared
177
178ifdef IS_MSVC
179%.dll: lib%.o
180 $(CC) $< -link -dll -out:`cygpath -w $@`
181else
182%.dll: lib%.o
183 $(CC) -o $@ $< -shared -Wl,--out-implib=$@.a
184endif
185
186$(TMPDIR)/lib%.o: %.c
187 $(call COMPILE_OBJ,$@,$<)
tests/run-make-fulldeps/type-mismatch-same-crate-name/Makefile deleted-19
...@@ -1,19 +0,0 @@
1include ../tools.mk
2
3all:
4 # compile two different versions of crateA
5 $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-1 -C extra-filename=-1
6 $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-2 -C extra-filename=-2
7 # make crateB depend on version 1 of crateA
8 $(RUSTC) --crate-type=rlib crateB.rs --extern crateA=$(TMPDIR)/libcrateA-1.rlib
9 # make crateC depend on version 2 of crateA
10 $(RUSTC) crateC.rs --extern crateA=$(TMPDIR)/libcrateA-2.rlib 2>&1 | \
11 tr -d '\r\n' | $(CGREP) -e \
12 "mismatched types.*\
13 crateB::try_foo\(foo2\);.*\
14 expected \`crateA::foo::Foo\`, found \`Foo\`.*\
15 different versions of crate \`crateA\`.*\
16 mismatched types.*\
17 crateB::try_bar\(bar2\);.*\
18 expected trait \`crateA::bar::Bar\`, found trait \`Bar\`.*\
19 different versions of crate \`crateA\`"
tests/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs deleted-16
...@@ -1,16 +0,0 @@
1mod foo {
2 pub struct Foo;
3}
4
5mod bar {
6 pub trait Bar{}
7
8 pub fn bar() -> Box<Bar> {
9 unimplemented!()
10 }
11}
12
13// This makes the publicly accessible path
14// differ from the internal one.
15pub use foo::Foo;
16pub use bar::{Bar, bar};
tests/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs deleted-4
...@@ -1,4 +0,0 @@
1extern crate crateA;
2
3pub fn try_foo(x: crateA::Foo){}
4pub fn try_bar(x: Box<crateA::Bar>){}
tests/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs deleted-25
...@@ -1,25 +0,0 @@
1// This tests the extra note reported when a type error deals with
2// seemingly identical types.
3// The main use case of this error is when there are two crates
4// (generally different versions of the same crate) with the same name
5// causing a type mismatch.
6
7// The test is nearly the same as the one in
8// ui/type/type-mismatch-same-crate-name.rs
9// but deals with the case where one of the crates
10// is only introduced as an indirect dependency.
11// and the type is accessed via a re-export.
12// This is similar to how the error can be introduced
13// when using cargo's automatic dependency resolution.
14
15extern crate crateA;
16
17fn main() {
18 let foo2 = crateA::Foo;
19 let bar2 = crateA::bar();
20 {
21 extern crate crateB;
22 crateB::try_foo(foo2);
23 crateB::try_bar(bar2);
24 }
25}
tests/run-make-fulldeps/use-extern-for-plugins/Makefile deleted-17
...@@ -1,17 +0,0 @@
1include ../tools.mk
2
3# ignore-freebsd
4# ignore-openbsd
5# ignore-sunos
6
7HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
8ifeq ($(findstring i686,$(HOST)),i686)
9TARGET := $(subst i686,x86_64,$(HOST))
10else
11TARGET := $(subst x86_64,i686,$(HOST))
12endif
13
14all:
15 $(RUSTC) foo.rs -C extra-filename=-host
16 $(RUSTC) bar.rs -C extra-filename=-targ --target $(TARGET)
17 $(RUSTC) baz.rs --extern a=$(TMPDIR)/liba-targ.rlib --target $(TARGET)
tests/run-make-fulldeps/use-extern-for-plugins/bar.rs deleted-9
...@@ -1,9 +0,0 @@
1#![feature(no_core)]
2#![no_core]
3#![crate_type = "lib"]
4#![crate_name = "a"]
5
6#[macro_export]
7macro_rules! bar {
8 () => ()
9}
tests/run-make-fulldeps/use-extern-for-plugins/baz.rs deleted-8
...@@ -1,8 +0,0 @@
1#![feature(no_core)]
2#![no_core]
3#![crate_type = "lib"]
4
5#[macro_use]
6extern crate a;
7
8bar!();
tests/run-make-fulldeps/use-extern-for-plugins/foo.rs deleted-8
...@@ -1,8 +0,0 @@
1#![no_std]
2#![crate_type = "lib"]
3#![crate_name = "a"]
4
5#[macro_export]
6macro_rules! foo {
7 () => ()
8}
tests/run-make-fulldeps/use-suggestions-rust-2018/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) ep-nested-lib.rs
5
6 $(RUSTC) use-suggestions.rs --edition=2018 --extern ep_nested_lib=$(TMPDIR)/libep_nested_lib.rlib 2>&1 | $(CGREP) "use ep_nested_lib::foo::bar::Baz"
7
tests/run-make-fulldeps/use-suggestions-rust-2018/ep-nested-lib.rs deleted-7
...@@ -1,7 +0,0 @@
1#![crate_type = "rlib"]
2
3pub mod foo {
4 pub mod bar {
5 pub struct Baz;
6 }
7}
tests/run-make-fulldeps/use-suggestions-rust-2018/use-suggestions.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 let x = Baz{};
3}
tests/run-make-fulldeps/used-cdylib-macos/Makefile deleted-11
...@@ -1,11 +0,0 @@
1include ../tools.mk
2
3# only-macos
4#
5# This checks that `#[used]` passes through to the linker on
6# darwin. This is subject to change in the future, see
7# https://github.com/rust-lang/rust/pull/93718 for discussion
8
9all:
10 $(RUSTC) -Copt-level=3 dylib_used.rs
11 nm $(TMPDIR)/libdylib_used.dylib | $(CGREP) VERY_IMPORTANT_SYMBOL
tests/run-make-fulldeps/used-cdylib-macos/dylib_used.rs deleted-4
...@@ -1,4 +0,0 @@
1#![crate_type = "cdylib"]
2
3#[used]
4static VERY_IMPORTANT_SYMBOL: u32 = 12345;
tests/run-make-fulldeps/used/Makefile deleted-7
...@@ -1,7 +0,0 @@
1include ../tools.mk
2
3# ignore-windows-msvc
4
5all:
6 $(RUSTC) -C opt-level=3 --emit=obj used.rs
7 nm $(TMPDIR)/used.o | $(CGREP) FOO
tests/run-make-fulldeps/used/used.rs deleted-6
...@@ -1,6 +0,0 @@
1#![crate_type = "lib"]
2
3#[used]
4static FOO: u32 = 0;
5
6static BAR: u32 = 0;
tests/run-make-fulldeps/version/Makefile deleted-6
...@@ -1,6 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -V
5 $(RUSTC) -vV
6 $(RUSTC) --version --verbose
tests/run-make-fulldeps/volatile-intrinsics/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3all:
4 # The tests must pass...
5 $(RUSTC) main.rs
6 $(call RUN,main)
7 # ... and the loads/stores must not be optimized out.
8 $(RUSTC) main.rs --emit=llvm-ir
9 $(CGREP) "load volatile" "store volatile" < $(TMPDIR)/main.ll
tests/run-make-fulldeps/volatile-intrinsics/main.rs deleted-24
...@@ -1,24 +0,0 @@
1#![feature(core_intrinsics, volatile)]
2
3use std::intrinsics::{
4 unaligned_volatile_load, unaligned_volatile_store, volatile_load, volatile_store,
5};
6use std::ptr::{read_volatile, write_volatile};
7
8pub fn main() {
9 unsafe {
10 let mut i: isize = 1;
11 volatile_store(&mut i, 2);
12 assert_eq!(volatile_load(&i), 2);
13 }
14 unsafe {
15 let mut i: isize = 1;
16 unaligned_volatile_store(&mut i, 2);
17 assert_eq!(unaligned_volatile_load(&i), 2);
18 }
19 unsafe {
20 let mut i: isize = 1;
21 write_volatile(&mut i, 2);
22 assert_eq!(read_volatile(&i), 2);
23 }
24}
tests/run-make-fulldeps/weird-output-filenames/Makefile deleted-15
...@@ -1,15 +0,0 @@
1include ../tools.mk
2
3all:
4 cp foo.rs $(TMPDIR)/.foo.rs
5 $(RUSTC) $(TMPDIR)/.foo.rs 2>&1 \
6 | $(CGREP) -e "invalid character.*in crate name:"
7 cp foo.rs $(TMPDIR)/.foo.bar
8 $(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \
9 | $(CGREP) -e "invalid character.*in crate name:"
10 cp foo.rs $(TMPDIR)/+foo+bar.rs
11 $(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \
12 | $(CGREP) -e "invalid character.*in crate name:"
13 cp foo.rs $(TMPDIR)/-foo.rs
14 $(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \
15 | $(CGREP) 'crate names cannot start with a `-`'
tests/run-make-fulldeps/weird-output-filenames/foo.rs deleted-1
...@@ -1 +0,0 @@
1fn main() {}
tests/run-make-fulldeps/windows-binary-no-external-deps/Makefile deleted-9
...@@ -1,9 +0,0 @@
1include ../tools.mk
2
3# only-windows
4
5PATH=$(SYSTEMROOT)/system32
6
7all:
8 $(RUSTC) hello.rs
9 $(TMPDIR)/hello.exe
tests/run-make-fulldeps/windows-binary-no-external-deps/hello.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 println!("Hello World!");
3}
tests/run-make-fulldeps/windows-spawn/Makefile deleted-8
...@@ -1,8 +0,0 @@
1include ../tools.mk
2
3# only-windows
4
5all:
6 $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs
7 $(RUSTC) spawn.rs
8 $(TMPDIR)/spawn.exe
tests/run-make-fulldeps/windows-spawn/hello.rs deleted-3
...@@ -1,3 +0,0 @@
1fn main() {
2 println!("Hello World!");
3}
tests/run-make-fulldeps/windows-spawn/spawn.rs deleted-12
...@@ -1,12 +0,0 @@
1use std::io::ErrorKind;
2use std::process::Command;
3
4fn main() {
5 // Make sure it doesn't try to run "hopefullydoesntexist bar.exe".
6 assert_eq!(Command::new("hopefullydoesntexist")
7 .arg("bar")
8 .spawn()
9 .unwrap_err()
10 .kind(),
11 ErrorKind::NotFound);
12}
tests/run-make-fulldeps/windows-subsystem/Makefile deleted-5
...@@ -1,5 +0,0 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) windows.rs
5 $(RUSTC) console.rs
tests/run-make-fulldeps/windows-subsystem/console.rs deleted-3
...@@ -1,3 +0,0 @@
1#![windows_subsystem = "console"]
2
3fn main() {}
tests/run-make-fulldeps/windows-subsystem/windows.rs deleted-3
...@@ -1,3 +0,0 @@
1#![windows_subsystem = "windows"]
2
3fn main() {}
tests/run-make/a-b-a-linker-guard/Makefile created+16
...@@ -0,0 +1,16 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test that if we build `b` against a version of `a` that has one set
5# of types, it will not run with a dylib that has a different set of
6# types.
7
8# NOTE(eddyb) this test only works with the `legacy` mangling,
9# and will probably get removed once `legacy` is gone.
10
11all:
12 $(RUSTC) a.rs --cfg x -C prefer-dynamic -Z unstable-options -C symbol-mangling-version=legacy
13 $(RUSTC) b.rs -C prefer-dynamic -Z unstable-options -C symbol-mangling-version=legacy
14 $(call RUN,b)
15 $(RUSTC) a.rs --cfg y -C prefer-dynamic -Z unstable-options -C symbol-mangling-version=legacy
16 $(call FAIL,b)
tests/run-make/a-b-a-linker-guard/a.rs created+8
...@@ -0,0 +1,8 @@
1#![crate_name = "a"]
2#![crate_type = "dylib"]
3
4#[cfg(x)]
5pub fn foo(x: u32) { }
6
7#[cfg(y)]
8pub fn foo(x: i32) { }
tests/run-make/a-b-a-linker-guard/b.rs created+7
...@@ -0,0 +1,7 @@
1#![crate_name = "b"]
2
3extern crate a;
4
5fn main() {
6 a::foo(22_u32);
7}
tests/run-make/alloc-no-oom-handling/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_global_oom_handling
tests/run-make/alloc-no-rc/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_rc
tests/run-make/alloc-no-sync/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_sync
tests/run-make/allow-non-lint-warnings-cmdline/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test that -A warnings makes the 'empty trait list for derive' warning go away
5OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" )
6
7all: foo
8 test -z '$(OUT)'
9
10# This is just to make sure the above command actually succeeds
11foo:
12 $(RUSTC) foo.rs -A warnings
tests/run-make/allow-non-lint-warnings-cmdline/foo.rs created+5
...@@ -0,0 +1,5 @@
1#[derive()]
2#[derive(Copy, Clone)]
3pub struct Foo;
4
5pub fn main() { }
tests/run-make/allow-warnings-cmdline-stability/Makefile created+16
...@@ -0,0 +1,16 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test that -A warnings makes the 'empty trait list for derive' warning go away
5DEP=$(shell $(RUSTC) bar.rs)
6OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" )
7
8all: foo bar
9 test -z '$(OUT)'
10
11# These are just to ensure that the above commands actually work
12bar:
13 $(RUSTC) bar.rs
14
15foo: bar
16 $(RUSTC) foo.rs -A warnings
tests/run-make/allow-warnings-cmdline-stability/bar.rs created+5
...@@ -0,0 +1,5 @@
1#![crate_type = "lib"]
2#![feature(staged_api)]
3#![unstable(feature = "unstable_test_feature", issue = "none")]
4
5pub fn baz() {}
tests/run-make/allow-warnings-cmdline-stability/foo.rs created+5
...@@ -0,0 +1,5 @@
1#![feature(unstable_test_feature)]
2
3extern crate bar;
4
5pub fn main() { bar::baz() }
tests/run-make/archive-duplicate-names/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 mkdir $(TMPDIR)/a
6 mkdir $(TMPDIR)/b
7 $(call COMPILE_OBJ,$(TMPDIR)/a/foo.o,foo.c)
8 $(call COMPILE_OBJ,$(TMPDIR)/b/foo.o,bar.c)
9 $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o
10 $(RUSTC) foo.rs
11 $(RUSTC) bar.rs
12 $(call RUN,bar)
tests/run-make/archive-duplicate-names/bar.c created+1
...@@ -0,0 +1 @@
1void bar() {}
tests/run-make/archive-duplicate-names/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::baz();
5}
tests/run-make/archive-duplicate-names/foo.c created+1
...@@ -0,0 +1 @@
1void foo() {}
tests/run-make/archive-duplicate-names/foo.rs created+14
...@@ -0,0 +1,14 @@
1#![crate_type = "rlib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {
5 fn foo();
6 fn bar();
7}
8
9pub fn baz() {
10 unsafe {
11 foo();
12 bar();
13 }
14}
tests/run-make/arguments-non-c-like-enum/Makefile created+8
...@@ -0,0 +1,8 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) --crate-type=staticlib nonclike.rs
6 $(CC) test.c $(call STATICLIB,nonclike) $(call OUT_EXE,test) \
7 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
8 $(call RUN,test)
tests/run-make/arguments-non-c-like-enum/nonclike.rs created+31
...@@ -0,0 +1,31 @@
1#[repr(C, u8)]
2pub enum TT {
3 AA(u64, u64),
4 BB,
5}
6
7#[no_mangle]
8pub extern "C" fn tt_add(a: TT, b: TT) -> u64 {
9 match (a, b) {
10 (TT::AA(a1, b1), TT::AA(a2, b2)) => a1 + a2 + b1 + b2,
11 (TT::AA(a1, b1), TT::BB) => a1 + b1,
12 (TT::BB, TT::AA(a1, b1)) => a1 + b1,
13 _ => 0,
14 }
15}
16
17#[repr(C, u8)]
18pub enum T {
19 A(u64),
20 B,
21}
22
23#[no_mangle]
24pub extern "C" fn t_add(a: T, b: T) -> u64 {
25 match (a, b) {
26 (T::A(a), T::A(b)) => a + b,
27 (T::A(a), T::B) => a,
28 (T::B, T::A(b)) => b,
29 _ => 0,
30 }
31}
tests/run-make/arguments-non-c-like-enum/test.c created+66
...@@ -0,0 +1,66 @@
1#include <stdint.h>
2#include <assert.h>
3
4#include <stdio.h>
5
6/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
7 * type in nonclike.rs . */
8enum TT_Tag {
9 AA,
10 BB,
11};
12typedef uint8_t TT_Tag;
13
14typedef struct {
15 uint64_t _0;
16 uint64_t _1;
17} AA_Body;
18
19typedef struct {
20 TT_Tag tag;
21 union {
22 AA_Body aa;
23 };
24} TT;
25
26/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
27 * in nonclike.rs . */
28enum T_Tag {
29 A,
30 B,
31};
32typedef uint8_t T_Tag;
33
34typedef struct {
35 uint64_t _0;
36} A_Body;
37
38typedef struct {
39 T_Tag tag;
40 union {
41 A_Body a;
42 };
43} T;
44
45/* These symbols are defined by the Rust staticlib built from
46 * nonclike.rs. */
47extern uint64_t t_add(T a, T b);
48extern uint64_t tt_add(TT a, TT b);
49
50int main(int argc, char *argv[]) {
51 (void)argc; (void)argv;
52
53 /* This example works. */
54 TT xx = { .tag = AA, .aa = { ._0 = 1, ._1 = 2 } };
55 TT yy = { .tag = AA, .aa = { ._0 = 10, ._1 = 20 } };
56 uint64_t rr = tt_add(xx, yy);
57 assert(33 == rr);
58
59 /* This one used to return an incorrect result (see issue #68190). */
60 T x = { .tag = A, .a = { ._0 = 1 } };
61 T y = { .tag = A, .a = { ._0 = 10 } };
62 uint64_t r = t_add(x, y);
63 assert(11 == r);
64
65 return 0;
66}
tests/run-make/atomic-lock-free/Makefile created+48
...@@ -0,0 +1,48 @@
1include ../tools.mk
2
3# This tests ensure that atomic types are never lowered into runtime library calls that are not
4# guaranteed to be lock-free.
5
6all:
7ifeq ($(UNAME),Linux)
8ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
9 $(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs
10 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
11 $(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs
12 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
13endif
14ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm)
15 $(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs
16 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
17 $(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs
18 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
19 $(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs
20 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
21 $(RUSTC) --target=thumbv7neon-unknown-linux-gnueabihf atomic_lock_free.rs
22 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
23endif
24ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64)
25 $(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs
26 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
27endif
28ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips)
29 $(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs
30 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
31 $(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs
32 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
33endif
34ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc)
35 $(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs
36 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
37 $(RUSTC) --target=powerpc-unknown-linux-gnuspe atomic_lock_free.rs
38 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
39 $(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs
40 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
41 $(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs
42 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
43endif
44ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz)
45 $(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs
46 nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add
47endif
48endif
tests/run-make/atomic-lock-free/atomic_lock_free.rs created+66
...@@ -0,0 +1,66 @@
1#![feature(no_core, intrinsics, lang_items)]
2#![crate_type="rlib"]
3#![no_core]
4
5extern "rust-intrinsic" {
6 fn atomic_xadd_seqcst<T>(dst: *mut T, src: T) -> T;
7}
8
9#[lang = "sized"]
10trait Sized {}
11#[lang = "copy"]
12trait Copy {}
13#[lang = "freeze"]
14trait Freeze {}
15
16impl<T: ?Sized> Copy for *mut T {}
17
18#[cfg(target_has_atomic = "8")]
19pub unsafe fn atomic_u8(x: *mut u8) {
20 atomic_xadd_seqcst(x, 1);
21 atomic_xadd_seqcst(x, 1);
22}
23#[cfg(target_has_atomic = "8")]
24pub unsafe fn atomic_i8(x: *mut i8) {
25 atomic_xadd_seqcst(x, 1);
26}
27#[cfg(target_has_atomic = "16")]
28pub unsafe fn atomic_u16(x: *mut u16) {
29 atomic_xadd_seqcst(x, 1);
30}
31#[cfg(target_has_atomic = "16")]
32pub unsafe fn atomic_i16(x: *mut i16) {
33 atomic_xadd_seqcst(x, 1);
34}
35#[cfg(target_has_atomic = "32")]
36pub unsafe fn atomic_u32(x: *mut u32) {
37 atomic_xadd_seqcst(x, 1);
38}
39#[cfg(target_has_atomic = "32")]
40pub unsafe fn atomic_i32(x: *mut i32) {
41 atomic_xadd_seqcst(x, 1);
42}
43#[cfg(target_has_atomic = "64")]
44pub unsafe fn atomic_u64(x: *mut u64) {
45 atomic_xadd_seqcst(x, 1);
46}
47#[cfg(target_has_atomic = "64")]
48pub unsafe fn atomic_i64(x: *mut i64) {
49 atomic_xadd_seqcst(x, 1);
50}
51#[cfg(target_has_atomic = "128")]
52pub unsafe fn atomic_u128(x: *mut u128) {
53 atomic_xadd_seqcst(x, 1);
54}
55#[cfg(target_has_atomic = "128")]
56pub unsafe fn atomic_i128(x: *mut i128) {
57 atomic_xadd_seqcst(x, 1);
58}
59#[cfg(target_has_atomic = "ptr")]
60pub unsafe fn atomic_usize(x: *mut usize) {
61 atomic_xadd_seqcst(x, 1);
62}
63#[cfg(target_has_atomic = "ptr")]
64pub unsafe fn atomic_isize(x: *mut isize) {
65 atomic_xadd_seqcst(x, 1);
66}
tests/run-make/bare-outfile/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 cp foo.rs $(TMPDIR)
6 cd $(TMPDIR) && $(RUSTC) -o foo foo.rs
7 $(call RUN,foo)
tests/run-make/bare-outfile/foo.rs created+2
...@@ -0,0 +1,2 @@
1fn main() {
2}
tests/run-make/c-dynamic-dylib/Makefile created+13
...@@ -0,0 +1,13 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-macos
5#
6# This hits an assertion in the linker on older versions of osx apparently
7
8all: $(call DYLIB,cfoo)
9 $(RUSTC) foo.rs -C prefer-dynamic
10 $(RUSTC) bar.rs
11 $(call RUN,bar)
12 $(call REMOVE_DYLIBS,cfoo)
13 $(call FAIL,bar)
tests/run-make/c-dynamic-dylib/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::rsfoo();
5}
tests/run-make/c-dynamic-dylib/cfoo.c created+4
...@@ -0,0 +1,4 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int foo() { return 0; }
tests/run-make/c-dynamic-dylib/foo.rs created+10
...@@ -0,0 +1,10 @@
1#![crate_type = "dylib"]
2
3#[link(name = "cfoo")]
4extern "C" {
5 fn foo();
6}
7
8pub fn rsfoo() {
9 unsafe { foo() }
10}
tests/run-make/c-dynamic-rlib/Makefile created+16
...@@ -0,0 +1,16 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-macos
5#
6# This hits an assertion in the linker on older versions of osx apparently
7
8# This overrides the LD_LIBRARY_PATH for RUN
9TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR)
10
11all: $(call DYLIB,cfoo)
12 $(RUSTC) foo.rs
13 $(RUSTC) bar.rs
14 $(call RUN,bar)
15 $(call REMOVE_DYLIBS,cfoo)
16 $(call FAIL,bar)
tests/run-make/c-dynamic-rlib/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::rsfoo();
5}
tests/run-make/c-dynamic-rlib/cfoo.c created+4
...@@ -0,0 +1,4 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int foo() { return 0; }
tests/run-make/c-dynamic-rlib/foo.rs created+10
...@@ -0,0 +1,10 @@
1#![crate_type = "rlib"]
2
3#[link(name = "cfoo")]
4extern "C" {
5 fn foo();
6}
7
8pub fn rsfoo() {
9 unsafe { foo() }
10}
tests/run-make/c-link-to-rust-dylib/Makefile created+18
...@@ -0,0 +1,18 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(TMPDIR)/$(call BIN,bar)
5 $(call RUN,bar)
6 $(call REMOVE_DYLIBS,foo)
7 $(call FAIL,bar)
8
9ifdef IS_MSVC
10$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo)
11 $(CC) bar.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,bar)
12else
13$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo)
14 $(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -L $(TMPDIR)
15endif
16
17$(call DYLIB,foo): foo.rs
18 $(RUSTC) foo.rs
tests/run-make/c-link-to-rust-dylib/bar.c created+6
...@@ -0,0 +1,6 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make/c-link-to-rust-dylib/foo.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "dylib"]
2
3#[no_mangle]
4pub extern "C" fn foo() {}
tests/run-make/c-link-to-rust-staticlib/Makefile created+13
...@@ -0,0 +1,13 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-freebsd
5# FIXME
6
7all:
8 $(RUSTC) foo.rs
9 $(CC) bar.c $(call STATICLIB,foo) $(call OUT_EXE,bar) \
10 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
11 $(call RUN,bar)
12 rm $(call STATICLIB,foo)
13 $(call RUN,bar)
tests/run-make/c-link-to-rust-staticlib/bar.c created+6
...@@ -0,0 +1,6 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make/c-link-to-rust-staticlib/foo.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "staticlib"]
2
3#[no_mangle]
4pub extern "C" fn foo() {}
tests/run-make/c-link-to-rust-va-list-fn/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) checkrust.rs
6 $(CC) test.c $(call STATICLIB,checkrust) $(call OUT_EXE,test) $(EXTRACFLAGS)
7 $(call RUN,test)
tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs created+148
...@@ -0,0 +1,148 @@
1#![crate_type = "staticlib"]
2#![feature(c_variadic)]
3#![feature(rustc_private)]
4
5extern crate libc;
6
7use libc::{c_char, c_double, c_int, c_long, c_longlong};
8use std::ffi::VaList;
9use std::ffi::{CString, CStr};
10
11macro_rules! continue_if {
12 ($cond:expr) => {
13 if !($cond) {
14 return 0xff;
15 }
16 }
17}
18
19unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool {
20 let cstr0 = CStr::from_ptr(ptr);
21 match CString::new(val) {
22 Ok(cstr1) => &*cstr1 == cstr0,
23 Err(_) => false,
24 }
25}
26
27#[no_mangle]
28pub unsafe extern "C" fn check_list_0(mut ap: VaList) -> usize {
29 continue_if!(ap.arg::<c_longlong>() == 1);
30 continue_if!(ap.arg::<c_int>() == 2);
31 continue_if!(ap.arg::<c_longlong>() == 3);
32 0
33}
34
35#[no_mangle]
36pub unsafe extern "C" fn check_list_1(mut ap: VaList) -> usize {
37 continue_if!(ap.arg::<c_int>() == -1);
38 continue_if!(ap.arg::<c_char>() == 'A' as c_char);
39 continue_if!(ap.arg::<c_char>() == '4' as c_char);
40 continue_if!(ap.arg::<c_char>() == ';' as c_char);
41 continue_if!(ap.arg::<c_int>() == 0x32);
42 continue_if!(ap.arg::<c_int>() == 0x10000001);
43 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Valid!"));
44 0
45}
46
47#[no_mangle]
48pub unsafe extern "C" fn check_list_2(mut ap: VaList) -> usize {
49 continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor());
50 continue_if!(ap.arg::<c_long>() == 12);
51 continue_if!(ap.arg::<c_char>() == 'a' as c_char);
52 continue_if!(ap.arg::<c_double>().floor() == 6.18f64.floor());
53 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Hello"));
54 continue_if!(ap.arg::<c_int>() == 42);
55 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "World"));
56 0
57}
58
59#[no_mangle]
60pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize {
61 continue_if!(ap.arg::<c_double>().floor() == 6.28f64.floor());
62 continue_if!(ap.arg::<c_int>() == 16);
63 continue_if!(ap.arg::<c_char>() == 'A' as c_char);
64 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!"));
65 ap.with_copy(|mut ap| {
66 if compare_c_str(ap.arg::<*const c_char>(), "Correct") {
67 0
68 } else {
69 0xff
70 }
71 })
72}
73
74#[no_mangle]
75pub unsafe extern "C" fn check_varargs_0(_: c_int, mut ap: ...) -> usize {
76 continue_if!(ap.arg::<c_int>() == 42);
77 continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Hello, World!"));
78 0
79}
80
81#[no_mangle]
82pub unsafe extern "C" fn check_varargs_1(_: c_int, mut ap: ...) -> usize {
83 continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor());
84 continue_if!(ap.arg::<c_long>() == 12);
85 continue_if!(ap.arg::<c_char>() == 'A' as c_char);
86 continue_if!(ap.arg::<c_longlong>() == 1);
87 0
88}
89
90#[no_mangle]
91pub unsafe extern "C" fn check_varargs_2(_: c_int, _ap: ...) -> usize {
92 0
93}
94
95#[no_mangle]
96pub unsafe extern "C" fn check_varargs_3(_: c_int, mut ap: ...) -> usize {
97 continue_if!(ap.arg::<c_int>() == 1);
98 continue_if!(ap.arg::<c_int>() == 2);
99 continue_if!(ap.arg::<c_int>() == 3);
100 continue_if!(ap.arg::<c_int>() == 4);
101 continue_if!(ap.arg::<c_int>() == 5);
102 continue_if!(ap.arg::<c_int>() == 6);
103 continue_if!(ap.arg::<c_int>() == 7);
104 continue_if!(ap.arg::<c_int>() == 8);
105 continue_if!(ap.arg::<c_int>() == 9);
106 continue_if!(ap.arg::<c_int>() == 10);
107 0
108}
109
110#[no_mangle]
111pub unsafe extern "C" fn check_varargs_4(_: c_double, mut ap: ...) -> usize {
112 continue_if!(ap.arg::<c_double>() == 1.0);
113 continue_if!(ap.arg::<c_double>() == 2.0);
114 continue_if!(ap.arg::<c_double>() == 3.0);
115 continue_if!(ap.arg::<c_double>() == 4.0);
116 continue_if!(ap.arg::<c_double>() == 5.0);
117 continue_if!(ap.arg::<c_double>() == 6.0);
118 continue_if!(ap.arg::<c_double>() == 7.0);
119 continue_if!(ap.arg::<c_double>() == 8.0);
120 continue_if!(ap.arg::<c_double>() == 9.0);
121 continue_if!(ap.arg::<c_double>() == 10.0);
122 0
123}
124
125#[no_mangle]
126pub unsafe extern "C" fn check_varargs_5(_: c_int, mut ap: ...) -> usize {
127 continue_if!(ap.arg::<c_double>() == 1.0);
128 continue_if!(ap.arg::<c_int>() == 1);
129 continue_if!(ap.arg::<c_double>() == 2.0);
130 continue_if!(ap.arg::<c_int>() == 2);
131 continue_if!(ap.arg::<c_double>() == 3.0);
132 continue_if!(ap.arg::<c_int>() == 3);
133 continue_if!(ap.arg::<c_double>() == 4.0);
134 continue_if!(ap.arg::<c_int>() == 4);
135 continue_if!(ap.arg::<c_int>() == 5);
136 continue_if!(ap.arg::<c_double>() == 5.0);
137 continue_if!(ap.arg::<c_int>() == 6);
138 continue_if!(ap.arg::<c_double>() == 6.0);
139 continue_if!(ap.arg::<c_int>() == 7);
140 continue_if!(ap.arg::<c_double>() == 7.0);
141 continue_if!(ap.arg::<c_int>() == 8);
142 continue_if!(ap.arg::<c_double>() == 8.0);
143 continue_if!(ap.arg::<c_int>() == 9);
144 continue_if!(ap.arg::<c_double>() == 9.0);
145 continue_if!(ap.arg::<c_int>() == 10);
146 continue_if!(ap.arg::<c_double>() == 10.0);
147 0
148}
tests/run-make/c-link-to-rust-va-list-fn/test.c created+50
...@@ -0,0 +1,50 @@
1#include <stdarg.h>
2#include <assert.h>
3#include <stdint.h>
4#include <stdlib.h>
5#include <stdio.h>
6
7extern size_t check_list_0(va_list ap);
8extern size_t check_list_1(va_list ap);
9extern size_t check_list_2(va_list ap);
10extern size_t check_list_copy_0(va_list ap);
11extern size_t check_varargs_0(int fixed, ...);
12extern size_t check_varargs_1(int fixed, ...);
13extern size_t check_varargs_2(int fixed, ...);
14extern size_t check_varargs_3(int fixed, ...);
15extern size_t check_varargs_4(double fixed, ...);
16extern size_t check_varargs_5(int fixed, ...);
17
18int test_rust(size_t (*fn)(va_list), ...) {
19 size_t ret = 0;
20 va_list ap;
21 va_start(ap, fn);
22 ret = fn(ap);
23 va_end(ap);
24 return ret;
25}
26
27int main(int argc, char* argv[]) {
28 assert(test_rust(check_list_0, 0x01LL, 0x02, 0x03LL) == 0);
29
30 assert(test_rust(check_list_1, -1, 'A', '4', ';', 0x32, 0x10000001, "Valid!") == 0);
31
32 assert(test_rust(check_list_2, 3.14, 12l, 'a', 6.28, "Hello", 42, "World") == 0);
33
34 assert(test_rust(check_list_copy_0, 6.28, 16, 'A', "Skip Me!", "Correct") == 0);
35
36 assert(check_varargs_0(0, 42, "Hello, World!") == 0);
37
38 assert(check_varargs_1(0, 3.14, 12l, 'A', 0x1LL) == 0);
39
40 assert(check_varargs_2(0, "All", "of", "these", "are", "ignored", ".") == 0);
41
42 assert(check_varargs_3(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) == 0);
43
44 assert(check_varargs_4(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0) == 0);
45
46 assert(check_varargs_5(0, 1.0, 1, 2.0, 2, 3.0, 3, 4.0, 4, 5, 5.0, 6, 6.0, 7, 7.0, 8, 8.0,
47 9, 9.0, 10, 10.0) == 0);
48
49 return 0;
50}
tests/run-make/c-static-dylib/Makefile created+10
...@@ -0,0 +1,10 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,cfoo)
5 $(RUSTC) foo.rs -C prefer-dynamic
6 $(RUSTC) bar.rs
7 rm $(call NATIVE_STATICLIB,cfoo)
8 $(call RUN,bar)
9 $(call REMOVE_DYLIBS,foo)
10 $(call FAIL,bar)
tests/run-make/c-static-dylib/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::rsfoo();
5}
tests/run-make/c-static-dylib/cfoo.c created+1
...@@ -0,0 +1 @@
1int foo() { return 0; }
tests/run-make/c-static-dylib/foo.rs created+10
...@@ -0,0 +1,10 @@
1#![crate_type = "dylib"]
2
3#[link(name = "cfoo", kind = "static")]
4extern "C" {
5 fn foo();
6}
7
8pub fn rsfoo() {
9 unsafe { foo() }
10}
tests/run-make/c-static-rlib/Makefile created+9
...@@ -0,0 +1,9 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,cfoo)
5 $(RUSTC) foo.rs
6 $(RUSTC) bar.rs
7 $(call REMOVE_RLIBS,foo)
8 rm $(call NATIVE_STATICLIB,cfoo)
9 $(call RUN,bar)
tests/run-make/c-static-rlib/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::rsfoo();
5}
tests/run-make/c-static-rlib/cfoo.c created+1
...@@ -0,0 +1 @@
1int foo() { return 0; }
tests/run-make/c-static-rlib/foo.rs created+10
...@@ -0,0 +1,10 @@
1#![crate_type = "rlib"]
2
3#[link(name = "cfoo", kind = "static")]
4extern "C" {
5 fn foo();
6}
7
8pub fn rsfoo() {
9 unsafe { foo() }
10}
tests/run-make/c-unwind-abi-catch-lib-panic/Makefile created+31
...@@ -0,0 +1,31 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: archive
5 # Compile `main.rs`, which will link into our library, and run it.
6 $(RUSTC) main.rs
7 $(call RUN,main)
8
9ifdef IS_MSVC
10archive: add.o panic.o
11 # Now, create an archive using these two objects.
12 $(AR) crus $(TMPDIR)/add.lib $(TMPDIR)/add.o $(TMPDIR)/panic.o
13else
14archive: add.o panic.o
15 # Now, create an archive using these two objects.
16 $(AR) crus $(TMPDIR)/libadd.a $(TMPDIR)/add.o $(TMPDIR)/panic.o
17endif
18
19# Compile `panic.rs` into an object file.
20#
21# Note that we invoke `rustc` directly, so we may emit an object rather
22# than an archive. We'll do that later.
23panic.o:
24 $(BARE_RUSTC) $(RUSTFLAGS) \
25 --out-dir $(TMPDIR) \
26 --emit=obj panic.rs
27
28# Compile `add.c` into an object file.
29add.o:
30 $(call COMPILE_OBJ,$(TMPDIR)/add.o,add.c)
31
tests/run-make/c-unwind-abi-catch-lib-panic/add.c created+12
...@@ -0,0 +1,12 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4
5// An external function, defined in Rust.
6extern void panic_if_greater_than_10(unsigned x);
7
8unsigned add_small_numbers(unsigned a, unsigned b) {
9 unsigned c = a + b;
10 panic_if_greater_than_10(c);
11 return c;
12}
tests/run-make/c-unwind-abi-catch-lib-panic/main.rs created+35
...@@ -0,0 +1,35 @@
1//! A test for calling `C-unwind` functions across foreign function boundaries.
2//!
3//! This test triggers a panic in a Rust library that our foreign function invokes. This shows
4//! that we can unwind through the C code in that library, and catch the underlying panic.
5#![feature(c_unwind)]
6
7use std::panic::{catch_unwind, AssertUnwindSafe};
8
9fn main() {
10 // Call `add_small_numbers`, passing arguments that will NOT trigger a panic.
11 let (a, b) = (9, 1);
12 let c = unsafe { add_small_numbers(a, b) };
13 assert_eq!(c, 10);
14
15 // Call `add_small_numbers`, passing arguments that will trigger a panic, and catch it.
16 let caught_unwind = catch_unwind(AssertUnwindSafe(|| {
17 let (a, b) = (10, 1);
18 let _c = unsafe { add_small_numbers(a, b) };
19 unreachable!("should have unwound instead of returned");
20 }));
21
22 // Assert that we did indeed panic, then unwrap and downcast the panic into the sum.
23 assert!(caught_unwind.is_err());
24 let panic_obj = caught_unwind.unwrap_err();
25 let msg = panic_obj.downcast_ref::<String>().unwrap();
26 assert_eq!(msg, "11");
27}
28
29#[link(name = "add", kind = "static")]
30extern "C-unwind" {
31 /// An external function, defined in C.
32 ///
33 /// Returns the sum of two numbers, or panics if the sum is greater than 10.
34 fn add_small_numbers(a: u32, b: u32) -> u32;
35}
tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs created+12
...@@ -0,0 +1,12 @@
1#![crate_type = "staticlib"]
2#![feature(c_unwind)]
3
4/// This function will panic if `x` is greater than 10.
5///
6/// This function is called by `add_small_numbers`.
7#[no_mangle]
8pub extern "C-unwind" fn panic_if_greater_than_10(x: u32) {
9 if x > 10 {
10 panic!("{}", x); // That is too big!
11 }
12}
tests/run-make/c-unwind-abi-catch-panic/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,add)
5 $(RUSTC) main.rs
6 $(call RUN,main) || exit 1
tests/run-make/c-unwind-abi-catch-panic/add.c created+12
...@@ -0,0 +1,12 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4
5// An external function, defined in Rust.
6extern void panic_if_greater_than_10(unsigned x);
7
8unsigned add_small_numbers(unsigned a, unsigned b) {
9 unsigned c = a + b;
10 panic_if_greater_than_10(c);
11 return c;
12}
tests/run-make/c-unwind-abi-catch-panic/main.rs created+44
...@@ -0,0 +1,44 @@
1//! A test for calling `C-unwind` functions across foreign function boundaries.
2//!
3//! This test triggers a panic when calling a foreign function that calls *back* into Rust.
4#![feature(c_unwind)]
5
6use std::panic::{catch_unwind, AssertUnwindSafe};
7
8fn main() {
9 // Call `add_small_numbers`, passing arguments that will NOT trigger a panic.
10 let (a, b) = (9, 1);
11 let c = unsafe { add_small_numbers(a, b) };
12 assert_eq!(c, 10);
13
14 // Call `add_small_numbers`, passing arguments that will trigger a panic, and catch it.
15 let caught_unwind = catch_unwind(AssertUnwindSafe(|| {
16 let (a, b) = (10, 1);
17 let _c = unsafe { add_small_numbers(a, b) };
18 unreachable!("should have unwound instead of returned");
19 }));
20
21 // Assert that we did indeed panic, then unwrap and downcast the panic into the sum.
22 assert!(caught_unwind.is_err());
23 let panic_obj = caught_unwind.unwrap_err();
24 let msg = panic_obj.downcast_ref::<String>().unwrap();
25 assert_eq!(msg, "11");
26}
27
28#[link(name = "add", kind = "static")]
29extern "C-unwind" {
30 /// An external function, defined in C.
31 ///
32 /// Returns the sum of two numbers, or panics if the sum is greater than 10.
33 fn add_small_numbers(a: u32, b: u32) -> u32;
34}
35
36/// This function will panic if `x` is greater than 10.
37///
38/// This function is called by `add_small_numbers`.
39#[no_mangle]
40pub extern "C-unwind" fn panic_if_greater_than_10(x: u32) {
41 if x > 10 {
42 panic!("{}", x); // That is too big!
43 }
44}
tests/run-make/cat-and-grep-sanity-check/Makefile created+46
...@@ -0,0 +1,46 @@
1include ../tools.mk
2
3all:
4 echo a | $(CGREP) a
5 ! echo b | $(CGREP) a
6 echo xyz | $(CGREP) x y z
7 ! echo abc | $(CGREP) b c d
8 printf "x\ny\nz" | $(CGREP) x y z
9
10 echo AbCd | $(CGREP) -i a b C D
11 ! echo AbCd | $(CGREP) a b C D
12
13 true | $(CGREP) -v nothing
14 ! echo nothing | $(CGREP) -v nothing
15 ! echo xyz | $(CGREP) -v w x y
16 ! echo xyz | $(CGREP) -v x y z
17 echo xyz | $(CGREP) -v a b c
18
19 ! echo 'foo bar baz' | $(CGREP) 'foo baz'
20 echo 'foo bar baz' | $(CGREP) foo baz
21 echo 'x a `b` c y z' | $(CGREP) 'a `b` c'
22
23 echo baaac | $(CGREP) -e 'ba*c'
24 echo bc | $(CGREP) -e 'ba*c'
25 ! echo aaac | $(CGREP) -e 'ba*c'
26
27 echo aaa | $(CGREP) -e 'a+'
28 ! echo bbb | $(CGREP) -e 'a+'
29
30 echo abc | $(CGREP) -e 'a|e|i|o|u'
31 ! echo fgh | $(CGREP) -e 'a|e|i|o|u'
32 echo abc | $(CGREP) -e '[aeiou]'
33 ! echo fgh | $(CGREP) -e '[aeiou]'
34 ! echo abc | $(CGREP) -e '[^aeiou]{3}'
35 echo fgh | $(CGREP) -e '[^aeiou]{3}'
36 echo ab cd ef gh | $(CGREP) -e '\bcd\b'
37 ! echo abcdefgh | $(CGREP) -e '\bcd\b'
38 echo xyz | $(CGREP) -e '...'
39 ! echo xy | $(CGREP) -e '...'
40 ! echo xyz | $(CGREP) -e '\.\.\.'
41 echo ... | $(CGREP) -e '\.\.\.'
42
43 echo foo bar baz | $(CGREP) -e 'foo.*baz'
44 ! echo foo bar baz | $(CGREP) -ve 'foo.*baz'
45 ! echo foo bar baz | $(CGREP) -e 'baz.*foo'
46 echo foo bar baz | $(CGREP) -ve 'baz.*foo'
tests/run-make/cdylib-dylib-linkage/Makefile created+28
...@@ -0,0 +1,28 @@
1# ignore-cross-compile
2include ../tools.mk
3
4TARGET_SYSROOT := $(shell $(RUSTC) --print sysroot)/lib/rustlib/$(TARGET)/lib
5
6ifdef IS_MSVC
7LIBSTD := $(wildcard $(TARGET_SYSROOT)/libstd-*.dll.lib)
8else
9LIBSTD := $(wildcard $(TARGET_SYSROOT)/$(call DYLIB_GLOB,std))
10STD := $(basename $(patsubst lib%,%, $(notdir $(LIBSTD))))
11endif
12
13all: $(call RUN_BINFILE,foo)
14 $(call RUN,foo)
15
16ifdef IS_MSVC
17CLIBS := $(TMPDIR)/foo.dll.lib $(TMPDIR)/bar.dll.lib $(LIBSTD)
18$(call RUN_BINFILE,foo): $(call DYLIB,foo)
19 $(CC) $(CFLAGS) foo.c $(CLIBS) $(call OUT_EXE,foo)
20else
21CLIBS := -lfoo -lbar -l$(STD) -L $(TMPDIR) -L $(TARGET_SYSROOT)
22$(call RUN_BINFILE,foo): $(call DYLIB,foo)
23 $(CC) $(CFLAGS) foo.c $(CLIBS) -o $(call RUN_BINFILE,foo)
24endif
25
26$(call DYLIB,foo):
27 $(RUSTC) -C prefer-dynamic bar.rs
28 $(RUSTC) foo.rs
tests/run-make/cdylib-dylib-linkage/bar.rs created+5
...@@ -0,0 +1,5 @@
1#![crate_type = "dylib"]
2
3pub fn bar() {
4 println!("hello!");
5}
tests/run-make/cdylib-dylib-linkage/foo.c created+10
...@@ -0,0 +1,10 @@
1#include <assert.h>
2
3extern void foo();
4extern unsigned bar(unsigned a, unsigned b);
5
6int main() {
7 foo();
8 assert(bar(1, 2) == 3);
9 return 0;
10}
tests/run-make/cdylib-dylib-linkage/foo.rs created+13
...@@ -0,0 +1,13 @@
1#![crate_type = "cdylib"]
2
3extern crate bar;
4
5#[no_mangle]
6pub extern "C" fn foo() {
7 bar::bar();
8}
9
10#[no_mangle]
11pub extern "C" fn bar(a: u32, b: u32) -> u32 {
12 a + b
13}
tests/run-make/cdylib-fewer-symbols/Makefile created+13
...@@ -0,0 +1,13 @@
1# ignore-cross-compile
2# Test that allocator-related symbols don't show up as exported from a cdylib as
3# they're internal to Rust and not part of the public ABI.
4
5include ../tools.mk
6
7# ignore-windows
8# FIXME: The __rdl_ and __rust_ symbol still remains, no matter using MSVC or GNU
9# See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753
10
11all:
12 $(RUSTC) foo.rs
13 nm -g "$(call DYLIB,foo)" | $(CGREP) -v __rdl_ __rde_ __rg_ __rust_
tests/run-make/cdylib-fewer-symbols/foo.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_type = "cdylib"]
2
3#[no_mangle]
4pub extern "C" fn foo() -> u32 {
5 3
6}
tests/run-make/cdylib/Makefile created+20
...@@ -0,0 +1,20 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call RUN_BINFILE,foo)
5 $(call RUN,foo)
6 rm $(call DYLIB,foo)
7 $(RUSTC) foo.rs -C lto
8 $(call RUN,foo)
9
10ifdef IS_MSVC
11$(call RUN_BINFILE,foo): $(call DYLIB,foo)
12 $(CC) $(CFLAGS) foo.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,foo)
13else
14$(call RUN_BINFILE,foo): $(call DYLIB,foo)
15 $(CC) $(CFLAGS) foo.c -lfoo -o $(call RUN_BINFILE,foo) -L $(TMPDIR)
16endif
17
18$(call DYLIB,foo):
19 $(RUSTC) bar.rs
20 $(RUSTC) foo.rs
tests/run-make/cdylib/bar.rs created+5
...@@ -0,0 +1,5 @@
1#![crate_type = "rlib"]
2
3pub fn bar() {
4 println!("hello!");
5}
tests/run-make/cdylib/foo.c created+10
...@@ -0,0 +1,10 @@
1#include <assert.h>
2
3extern void foo();
4extern unsigned bar(unsigned a, unsigned b);
5
6int main() {
7 foo();
8 assert(bar(1, 2) == 3);
9 return 0;
10}
tests/run-make/cdylib/foo.rs created+13
...@@ -0,0 +1,13 @@
1#![crate_type = "cdylib"]
2
3extern crate bar;
4
5#[no_mangle]
6pub extern "C" fn foo() {
7 bar::bar();
8}
9
10#[no_mangle]
11pub extern "C" fn bar(a: u32, b: u32) -> u32 {
12 a + b
13}
tests/run-make/codegen-options-parsing/Makefile created+32
...@@ -0,0 +1,32 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 #Option taking a number
6 $(RUSTC) -C codegen-units dummy.rs 2>&1 | \
7 $(CGREP) 'codegen option `codegen-units` requires a number'
8 $(RUSTC) -C codegen-units= dummy.rs 2>&1 | \
9 $(CGREP) 'incorrect value `` for codegen option `codegen-units` - a number was expected'
10 $(RUSTC) -C codegen-units=foo dummy.rs 2>&1 | \
11 $(CGREP) 'incorrect value `foo` for codegen option `codegen-units` - a number was expected'
12 $(RUSTC) -C codegen-units=1 dummy.rs
13 #Option taking a string
14 $(RUSTC) -C extra-filename dummy.rs 2>&1 | \
15 $(CGREP) 'codegen option `extra-filename` requires a string'
16 $(RUSTC) -C extra-filename= dummy.rs 2>&1
17 $(RUSTC) -C extra-filename=foo dummy.rs 2>&1
18 #Option taking no argument
19 $(RUSTC) -C lto= dummy.rs 2>&1 | \
20 $(CGREP) 'codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted'
21 $(RUSTC) -C lto=1 dummy.rs 2>&1 | \
22 $(CGREP) 'codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted'
23 $(RUSTC) -C lto=foo dummy.rs 2>&1 | \
24 $(CGREP) 'codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted'
25 $(RUSTC) -C lto dummy.rs
26
27 # Should not link dead code...
28 $(RUSTC) --print link-args dummy.rs 2>&1 | \
29 $(CGREP) -e '--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF'
30 # ... unless you specifically ask to keep it
31 $(RUSTC) --print link-args -C link-dead-code dummy.rs 2>&1 | \
32 $(CGREP) -ve '--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF'
tests/run-make/codegen-options-parsing/dummy.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/compile-stdin/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 echo 'fn main(){}' | $(RUSTC) -
6 $(call RUN,rust_out)
tests/run-make/compiler-lookup-paths-2/Makefile created+8
...@@ -0,0 +1,8 @@
1include ../tools.mk
2
3all:
4 mkdir -p $(TMPDIR)/a $(TMPDIR)/b
5 $(RUSTC) a.rs && mv $(TMPDIR)/liba.rlib $(TMPDIR)/a
6 $(RUSTC) b.rs -L $(TMPDIR)/a && mv $(TMPDIR)/libb.rlib $(TMPDIR)/b
7 $(RUSTC) c.rs -L crate=$(TMPDIR)/b -L dependency=$(TMPDIR)/a \
8 && exit 1 || exit 0
tests/run-make/compiler-lookup-paths-2/a.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "lib"]
tests/run-make/compiler-lookup-paths-2/b.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "lib"]
2extern crate a;
tests/run-make/compiler-lookup-paths-2/c.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "lib"]
2extern crate b;
3extern crate a;
tests/run-make/compiler-lookup-paths/Makefile created+41
...@@ -0,0 +1,41 @@
1include ../tools.mk
2
3# ignore-wasm32 (need a C compiler)
4# ignore-wasm64 (need a C compiler)
5
6all: $(TMPDIR)/libnative.a
7 mkdir -p $(TMPDIR)/crate
8 mkdir -p $(TMPDIR)/native
9 mv $(TMPDIR)/libnative.a $(TMPDIR)/native
10 $(RUSTC) a.rs
11 mv $(TMPDIR)/liba.rlib $(TMPDIR)/crate
12 $(RUSTC) b.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0
13 $(RUSTC) b.rs -L dependency=$(TMPDIR)/crate && exit 1 || exit 0
14 $(RUSTC) b.rs -L crate=$(TMPDIR)/crate
15 $(RUSTC) b.rs -L all=$(TMPDIR)/crate
16 $(RUSTC) c.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0
17 $(RUSTC) c.rs -L crate=$(TMPDIR)/crate && exit 1 || exit 0
18 $(RUSTC) c.rs -L dependency=$(TMPDIR)/crate
19 $(RUSTC) c.rs -L all=$(TMPDIR)/crate
20 $(RUSTC) d.rs -L dependency=$(TMPDIR)/native && exit 1 || exit 0
21 $(RUSTC) d.rs -L crate=$(TMPDIR)/native && exit 1 || exit 0
22 $(RUSTC) d.rs -L native=$(TMPDIR)/native
23 $(RUSTC) d.rs -L all=$(TMPDIR)/native
24 # Deduplication tests:
25 # Same hash, no errors.
26 mkdir -p $(TMPDIR)/e1
27 mkdir -p $(TMPDIR)/e2
28 $(RUSTC) e.rs -o $(TMPDIR)/e1/libe.rlib
29 $(RUSTC) e.rs -o $(TMPDIR)/e2/libe.rlib
30 $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2
31 $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2
32 $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2
33 # Different hash, errors.
34 $(RUSTC) e2.rs -o $(TMPDIR)/e2/libe.rlib
35 $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0
36 $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0
37 $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 && exit 1 || exit 0
38 # Native/dependency paths don't cause errors.
39 $(RUSTC) f.rs -L native=$(TMPDIR)/e1 -L $(TMPDIR)/e2
40 $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L $(TMPDIR)/e2
41 $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2
tests/run-make/compiler-lookup-paths/a.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "lib"]
tests/run-make/compiler-lookup-paths/b.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "lib"]
2extern crate a;
tests/run-make/compiler-lookup-paths/c.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "lib"]
2extern crate b;
tests/run-make/compiler-lookup-paths/d.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "rlib"]
2
3#[link(name = "native", kind = "static")]
4extern "C" {}
tests/run-make/compiler-lookup-paths/e.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_name = "e"]
2#![crate_type = "rlib"]
tests/run-make/compiler-lookup-paths/e2.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_name = "e"]
2#![crate_type = "rlib"]
3
4pub fn f() {}
tests/run-make/compiler-lookup-paths/f.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "rlib"]
2extern crate e;
tests/run-make/compiler-lookup-paths/native.c created+1
...@@ -0,0 +1 @@
1// intentionally empty
tests/run-make/compiler-rt-works-on-mingw/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3# only-windows-gnu
4
5all:
6 $(CXX) foo.cpp -c -o $(TMPDIR)/foo.o
7 $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o
8 $(RUSTC) foo.rs -lfoo -lstdc++
9 $(call RUN,foo)
tests/run-make/compiler-rt-works-on-mingw/foo.cpp created+4
...@@ -0,0 +1,4 @@
1extern "C" void foo() {
2 int *a = new int(3);
3 delete a;
4}
tests/run-make/compiler-rt-works-on-mingw/foo.rs created+10
...@@ -0,0 +1,10 @@
1extern "C" {
2 fn foo();
3}
4
5pub fn main() {
6 unsafe {
7 foo();
8 }
9 assert_eq!(7f32.powi(3), 343f32);
10}
tests/run-make/const_fn_mir/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 $(RUSTC) main.rs --emit=mir -o "$(TMPDIR)"/dump.mir4 $(RUSTC) main.rs --emit=mir -o "$(TMPDIR)"/dump.mir
tests/run-make/core-no-fp-fmt-parse/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/core/src/lib.rs --cfg no_fp_fmt_parse
tests/run-make/coverage/coverage_tools.mk+1-1
...@@ -3,4 +3,4 @@...@@ -3,4 +3,4 @@
3#3#
4# include ../coverage/coverage_tools.mk4# include ../coverage/coverage_tools.mk
55
6include ../../run-make-fulldeps/tools.mk6include ../tools.mk
tests/run-make/crate-data-smoke/Makefile created+10
...@@ -0,0 +1,10 @@
1include ../tools.mk
2
3all:
4 [ `$(RUSTC) --print crate-name crate.rs` = "foo" ]
5 [ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ]
6 [ `$(RUSTC) --print file-names --crate-type=lib \
7 --test crate.rs` = "$(call BIN,foo)" ]
8 [ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ]
9 $(RUSTC) --print file-names lib.rs
10 $(RUSTC) --print file-names rlib.rs
tests/run-make/crate-data-smoke/crate.rs created+7
...@@ -0,0 +1,7 @@
1#![crate_name = "foo"]
2
3// Querying about the crate metadata should *not* parse the entire crate, it
4// only needs the crate attributes (which are guaranteed to be at the top) be
5// sure that if we have an error like a missing module that we can still query
6// about the crate id.
7mod error;
tests/run-make/crate-data-smoke/lib.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_name = "mylib"]
2#![crate_type = "lib"]
tests/run-make/crate-data-smoke/rlib.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_name = "mylib"]
2#![crate_type = "rlib"]
tests/run-make/crate-hash-rustc-version/Makefile created+38
...@@ -0,0 +1,38 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Ensure that crates compiled with different rustc versions cannot
5# be dynamically linked.
6
7FLAGS := -Cprefer-dynamic -Zsymbol-mangling-version=v0
8UNAME := $(shell uname)
9ifeq ($(UNAME),Linux)
10 EXT=".so"
11 NM_CMD := nm -D
12endif
13ifeq ($(UNAME),Darwin)
14 EXT=".dylib"
15 NM_CMD := nm
16endif
17
18ifndef NM_CMD
19all:
20 exit 0
21else
22all:
23 # a.rs is a dylib
24 $(RUSTC) a.rs --crate-type=dylib $(FLAGS)
25 # Write symbols to disk.
26 $(NM_CMD) $(call DYLIB,a) > $(TMPDIR)/symbolsbefore
27 # b.rs is a binary
28 $(RUSTC) b.rs --extern a=$(TMPDIR)/liba$(EXT) --crate-type=bin -Crpath $(FLAGS)
29 $(call RUN,b)
30 # Now re-compile a.rs with another rustc version
31 RUSTC_FORCE_RUSTC_VERSION=deadfeed $(RUSTC) a.rs --crate-type=dylib $(FLAGS)
32 # After compiling with a different rustc version, write symbols to disk again.
33 $(NM_CMD) $(call DYLIB,a) > $(TMPDIR)/symbolsafter
34 # As a sanity check, test if the symbols changed:
35 # If the symbols are identical, there's been an error.
36 if diff $(TMPDIR)/symbolsbefore $(TMPDIR)/symbolsafter; then exit 1; fi
37 $(call FAIL,b)
38endif
tests/run-make/crate-hash-rustc-version/a.rs created+4
...@@ -0,0 +1,4 @@
1pub fn foo(mut x: String) -> String {
2 x.push_str(", world!");
3 x
4}
tests/run-make/crate-hash-rustc-version/b.rs created+8
...@@ -0,0 +1,8 @@
1extern crate a;
2
3use a::foo;
4
5fn main() {
6 let x = String::from("Hello");
7 println!("{}", foo(x));
8}
tests/run-make/crate-name-priority/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs
6 rm $(TMPDIR)/$(call BIN,foo)
7 $(RUSTC) foo.rs --crate-name bar
8 rm $(TMPDIR)/$(call BIN,bar)
9 $(RUSTC) foo1.rs
10 rm $(TMPDIR)/$(call BIN,foo)
11 $(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1)
12 rm $(TMPDIR)/$(call BIN,bar1)
tests/run-make/crate-name-priority/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/crate-name-priority/foo1.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_name = "foo"]
2
3fn main() {}
tests/run-make/cross-lang-lto-clang/Makefile created+25
...@@ -0,0 +1,25 @@
1# needs-matching-clang
2
3# This test makes sure that cross-language inlining actually works by checking
4# the generated machine code.
5
6include ../tools.mk
7
8all: cpp-executable rust-executable
9
10cpp-executable:
11 $(RUSTC) -Clinker-plugin-lto=on -o $(TMPDIR)/librustlib-xlto.a -Copt-level=2 -Ccodegen-units=1 ./rustlib.rs
12 $(CLANG) -flto=thin -fuse-ld=lld -L $(TMPDIR) -lrustlib-xlto -o $(TMPDIR)/cmain ./cmain.c -O3
13 # Make sure we don't find a call instruction to the function we expect to
14 # always be inlined.
15 "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -v -e "call.*rust_always_inlined"
16 # As a sanity check, make sure we do find a call instruction to a
17 # non-inlined function
18 "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/cmain | $(CGREP) -e "call.*rust_never_inlined"
19
20rust-executable:
21 $(CLANG) ./clib.c -flto=thin -c -o $(TMPDIR)/clib.o -O2
22 (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
23 $(RUSTC) -Clinker-plugin-lto=on -L$(TMPDIR) -Copt-level=2 -Clinker=$(CLANG) -Clink-arg=-fuse-ld=lld ./main.rs -o $(TMPDIR)/rsmain
24 "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -e "call.*c_never_inlined"
25 "$(LLVM_BIN_DIR)"/llvm-objdump -d $(TMPDIR)/rsmain | $(CGREP) -v -e "call.*c_always_inlined"
tests/run-make/cross-lang-lto-clang/clib.c created+9
...@@ -0,0 +1,9 @@
1#include <stdint.h>
2
3uint32_t c_always_inlined() {
4 return 1234;
5}
6
7__attribute__((noinline)) uint32_t c_never_inlined() {
8 return 12345;
9}
tests/run-make/cross-lang-lto-clang/cmain.c created+12
...@@ -0,0 +1,12 @@
1#include <stdint.h>
2
3// A trivial function defined in Rust, returning a constant value. This should
4// always be inlined.
5uint32_t rust_always_inlined();
6
7
8uint32_t rust_never_inlined();
9
10int main(int argc, char** argv) {
11 return rust_never_inlined() + rust_always_inlined();
12}
tests/run-make/cross-lang-lto-clang/main.rs created+11
...@@ -0,0 +1,11 @@
1#[link(name = "xyz")]
2extern "C" {
3 fn c_always_inlined() -> u32;
4 fn c_never_inlined() -> u32;
5}
6
7fn main() {
8 unsafe {
9 println!("blub: {}", c_always_inlined() + c_never_inlined());
10 }
11}
tests/run-make/cross-lang-lto-clang/rustlib.rs created+12
...@@ -0,0 +1,12 @@
1#![crate_type="staticlib"]
2
3#[no_mangle]
4pub extern "C" fn rust_always_inlined() -> u32 {
5 42
6}
7
8#[no_mangle]
9#[inline(never)]
10pub extern "C" fn rust_never_inlined() -> u32 {
11 421
12}
tests/run-make/cross-lang-lto-pgo-smoketest/Makefile created+87
...@@ -0,0 +1,87 @@
1# needs-matching-clang
2
3# This test makes sure that cross-language inlining can be used in conjunction
4# with profile-guided optimization. The test only tests that the whole workflow
5# can be executed without anything crashing. It does not test whether PGO or
6# xLTO have any specific effect on the generated code.
7
8include ../tools.mk
9
10COMMON_FLAGS=-Copt-level=3 -Ccodegen-units=1
11
12# LLVM doesn't support instrumenting binaries that use SEH:
13# https://bugs.llvm.org/show_bug.cgi?id=41279
14#
15# Things work fine with -Cpanic=abort though.
16ifdef IS_MSVC
17COMMON_FLAGS+= -Cpanic=abort
18endif
19
20all: cpp-executable rust-executable
21
22cpp-executable:
23 $(RUSTC) -Clinker-plugin-lto=on \
24 -Cprofile-generate="$(TMPDIR)"/cpp-profdata \
25 -o "$(TMPDIR)"/librustlib-xlto.a \
26 $(COMMON_FLAGS) \
27 ./rustlib.rs
28 $(CLANG) -flto=thin \
29 -fprofile-generate="$(TMPDIR)"/cpp-profdata \
30 -fuse-ld=lld \
31 -L "$(TMPDIR)" \
32 -lrustlib-xlto \
33 -o "$(TMPDIR)"/cmain \
34 -O3 \
35 ./cmain.c
36 $(TMPDIR)/cmain
37 # Postprocess the profiling data so it can be used by the compiler
38 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
39 -o "$(TMPDIR)"/cpp-profdata/merged.profdata \
40 "$(TMPDIR)"/cpp-profdata/default_*.profraw
41 $(RUSTC) -Clinker-plugin-lto=on \
42 -Cprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \
43 -o "$(TMPDIR)"/librustlib-xlto.a \
44 $(COMMON_FLAGS) \
45 ./rustlib.rs
46 $(CLANG) -flto=thin \
47 -fprofile-use="$(TMPDIR)"/cpp-profdata/merged.profdata \
48 -fuse-ld=lld \
49 -L "$(TMPDIR)" \
50 -lrustlib-xlto \
51 -o "$(TMPDIR)"/cmain \
52 -O3 \
53 ./cmain.c
54
55rust-executable:
56 exit
57 $(CLANG) ./clib.c -fprofile-generate="$(TMPDIR)"/rs-profdata -flto=thin -c -o $(TMPDIR)/clib.o -O3
58 (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
59 $(RUSTC) -Clinker-plugin-lto=on \
60 -Cprofile-generate="$(TMPDIR)"/rs-profdata \
61 -L$(TMPDIR) \
62 $(COMMON_FLAGS) \
63 -Clinker=$(CLANG) \
64 -Clink-arg=-fuse-ld=lld \
65 -o $(TMPDIR)/rsmain \
66 ./main.rs
67 $(TMPDIR)/rsmain
68 # Postprocess the profiling data so it can be used by the compiler
69 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
70 -o "$(TMPDIR)"/rs-profdata/merged.profdata \
71 "$(TMPDIR)"/rs-profdata/default_*.profraw
72 $(CLANG) ./clib.c \
73 -fprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \
74 -flto=thin \
75 -c \
76 -o $(TMPDIR)/clib.o \
77 -O3
78 rm "$(TMPDIR)"/libxyz.a
79 (cd $(TMPDIR); $(AR) crus ./libxyz.a ./clib.o)
80 $(RUSTC) -Clinker-plugin-lto=on \
81 -Cprofile-use="$(TMPDIR)"/rs-profdata/merged.profdata \
82 -L$(TMPDIR) \
83 $(COMMON_FLAGS) \
84 -Clinker=$(CLANG) \
85 -Clink-arg=-fuse-ld=lld \
86 -o $(TMPDIR)/rsmain \
87 ./main.rs
tests/run-make/cross-lang-lto-pgo-smoketest/clib.c created+9
...@@ -0,0 +1,9 @@
1#include <stdint.h>
2
3uint32_t c_always_inlined() {
4 return 1234;
5}
6
7__attribute__((noinline)) uint32_t c_never_inlined() {
8 return 12345;
9}
tests/run-make/cross-lang-lto-pgo-smoketest/cmain.c created+12
...@@ -0,0 +1,12 @@
1#include <stdint.h>
2
3// A trivial function defined in Rust, returning a constant value. This should
4// always be inlined.
5uint32_t rust_always_inlined();
6
7
8uint32_t rust_never_inlined();
9
10int main(int argc, char** argv) {
11 return (rust_never_inlined() + rust_always_inlined()) * 0;
12}
tests/run-make/cross-lang-lto-pgo-smoketest/main.rs created+11
...@@ -0,0 +1,11 @@
1#[link(name = "xyz")]
2extern "C" {
3 fn c_always_inlined() -> u32;
4 fn c_never_inlined() -> u32;
5}
6
7fn main() {
8 unsafe {
9 println!("blub: {}", c_always_inlined() + c_never_inlined());
10 }
11}
tests/run-make/cross-lang-lto-pgo-smoketest/rustlib.rs created+12
...@@ -0,0 +1,12 @@
1#![crate_type="staticlib"]
2
3#[no_mangle]
4pub extern "C" fn rust_always_inlined() -> u32 {
5 42
6}
7
8#[no_mangle]
9#[inline(never)]
10pub extern "C" fn rust_never_inlined() -> u32 {
11 421
12}
tests/run-make/cross-lang-lto-upstream-rlibs/Makefile created+32
...@@ -0,0 +1,32 @@
1include ../tools.mk
2
3# ignore windows due to libLLVM being present in PATH and the PATH and library path being the same
4# (so fixing it is harder). See #57765 for context
5ifndef IS_WINDOWS
6
7# This test makes sure that we don't loose upstream object files when compiling
8# staticlibs with -C linker-plugin-lto
9
10all: staticlib.rs upstream.rs
11 $(RUSTC) upstream.rs -C linker-plugin-lto -Ccodegen-units=1
12
13 # Check No LTO
14 $(RUSTC) staticlib.rs -C linker-plugin-lto -Ccodegen-units=1 -L. -o $(TMPDIR)/staticlib.a
15 (cd $(TMPDIR); "$(LLVM_BIN_DIR)"/llvm-ar x ./staticlib.a)
16 # Make sure the upstream object file was included
17 ls $(TMPDIR)/upstream.*.rcgu.o
18
19 # Cleanup
20 rm $(TMPDIR)/*
21
22 # Check ThinLTO
23 $(RUSTC) upstream.rs -C linker-plugin-lto -Ccodegen-units=1 -Clto=thin
24 $(RUSTC) staticlib.rs -C linker-plugin-lto -Ccodegen-units=1 -Clto=thin -L. -o $(TMPDIR)/staticlib.a
25 (cd $(TMPDIR); "$(LLVM_BIN_DIR)"/llvm-ar x ./staticlib.a)
26 ls $(TMPDIR)/upstream.*.rcgu.o
27
28else
29
30all:
31
32endif
tests/run-make/cross-lang-lto-upstream-rlibs/staticlib.rs created+8
...@@ -0,0 +1,8 @@
1#![crate_type="staticlib"]
2
3extern crate upstream;
4
5#[no_mangle]
6pub extern "C" fn bar() {
7 upstream::foo();
8}
tests/run-make/cross-lang-lto-upstream-rlibs/upstream.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "rlib"]
2
3pub fn foo() {}
tests/run-make/cross-lang-lto/Makefile created+57
...@@ -0,0 +1,57 @@
1
2include ../tools.mk
3
4# ignore windows due to libLLVM being present in PATH and the PATH and library path being the same
5# (so fixing it is harder). See #57765 for context
6ifndef IS_WINDOWS
7
8# This test makes sure that the object files we generate are actually
9# LLVM bitcode files (as used by linker LTO plugins) when compiling with
10# -Clinker-plugin-lto.
11
12# this only succeeds for bitcode files
13ASSERT_IS_BITCODE_OBJ=("$(LLVM_BIN_DIR)"/llvm-bcanalyzer $(1))
14EXTRACT_OBJS=(cd $(TMPDIR); rm -f ./*.o; "$(LLVM_BIN_DIR)"/llvm-ar x $(1))
15
16BUILD_LIB=$(RUSTC) lib.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1
17BUILD_EXE=$(RUSTC) main.rs -Copt-level=2 -Clinker-plugin-lto -Ccodegen-units=1 --emit=obj
18
19all: staticlib staticlib-fat-lto staticlib-thin-lto rlib exe cdylib rdylib
20
21staticlib: lib.rs
22 $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib.a
23 $(call EXTRACT_OBJS, liblib.a)
24 for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
25
26staticlib-fat-lto: lib.rs
27 $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-fat-lto.a -Clto=fat
28 $(call EXTRACT_OBJS, liblib-fat-lto.a)
29 for file in $(TMPDIR)/liblib-fat-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
30
31staticlib-thin-lto: lib.rs
32 $(BUILD_LIB) --crate-type=staticlib -o $(TMPDIR)/liblib-thin-lto.a -Clto=thin
33 $(call EXTRACT_OBJS, liblib-thin-lto.a)
34 for file in $(TMPDIR)/liblib-thin-lto.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
35
36rlib: lib.rs
37 $(BUILD_LIB) --crate-type=rlib -o $(TMPDIR)/liblib.rlib
38 $(call EXTRACT_OBJS, liblib.rlib)
39 for file in $(TMPDIR)/liblib.*.rcgu.o; do $(call ASSERT_IS_BITCODE_OBJ, $$file); done
40
41cdylib: lib.rs
42 $(BUILD_LIB) --crate-type=cdylib --emit=obj -o $(TMPDIR)/cdylib.o
43 $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/cdylib.o)
44
45rdylib: lib.rs
46 $(BUILD_LIB) --crate-type=dylib --emit=obj -o $(TMPDIR)/rdylib.o
47 $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/rdylib.o)
48
49exe: lib.rs
50 $(BUILD_EXE) -o $(TMPDIR)/exe.o
51 $(call ASSERT_IS_BITCODE_OBJ, $(TMPDIR)/exe.o)
52
53else
54
55all:
56
57endif
tests/run-make/cross-lang-lto/lib.rs created+4
...@@ -0,0 +1,4 @@
1#[no_mangle]
2pub extern "C" fn foo() {
3 println!("abc");
4}
tests/run-make/cross-lang-lto/main.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 println!("Hello World");
3}
tests/run-make/debug-assertions/Makefile created+26
...@@ -0,0 +1,26 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) debug.rs -C debug-assertions=no
6 $(call RUN,debug) good
7 $(RUSTC) debug.rs -C opt-level=0
8 $(call RUN,debug) bad
9 $(RUSTC) debug.rs -C opt-level=1
10 $(call RUN,debug) good
11 $(RUSTC) debug.rs -C opt-level=2
12 $(call RUN,debug) good
13 $(RUSTC) debug.rs -C opt-level=3
14 $(call RUN,debug) good
15 $(RUSTC) debug.rs -C opt-level=s
16 $(call RUN,debug) good
17 $(RUSTC) debug.rs -C opt-level=z
18 $(call RUN,debug) good
19 $(RUSTC) debug.rs -O
20 $(call RUN,debug) good
21 $(RUSTC) debug.rs
22 $(call RUN,debug) bad
23 $(RUSTC) debug.rs -C debug-assertions=yes -O
24 $(call RUN,debug) bad
25 $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1
26 $(call RUN,debug) bad
tests/run-make/debug-assertions/debug.rs created+33
...@@ -0,0 +1,33 @@
1#![feature(rustc_attrs)]
2#![deny(warnings)]
3
4use std::env;
5use std::thread;
6
7fn main() {
8 let should_fail = env::args().nth(1) == Some("bad".to_string());
9
10 assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail);
11 assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail);
12 assert_eq!(thread::spawn(overflow).join().is_err(), should_fail);
13}
14
15fn debug_assert_eq() {
16 let mut hit1 = false;
17 let mut hit2 = false;
18 debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 });
19 assert!(!hit1);
20 assert!(!hit2);
21}
22
23fn debug_assert() {
24 let mut hit = false;
25 debug_assert!({ hit = true; false });
26 assert!(!hit);
27}
28
29fn overflow() {
30 fn add(a: u8, b: u8) -> u8 { a + b }
31
32 add(200u8, 200u8);
33}
tests/run-make/dep-graph/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-cross-compile3# ignore-cross-compile
44
tests/run-make/dep-info-doesnt-run-much/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --emit dep-info
tests/run-make/dep-info-doesnt-run-much/foo.rs created+5
...@@ -0,0 +1,5 @@
1// We're only emitting dep info, so we shouldn't be running static analysis to
2// figure out that this program is erroneous.
3fn main() {
4 let a: u8 = "a";
5}
tests/run-make/dep-info-spaces/Makefile created+19
...@@ -0,0 +1,19 @@
1include ../tools.mk
2
3# ignore-windows
4# ignore-freebsd
5# FIXME: (windows: see `../dep-info/Makefile`)
6
7all:
8 cp lib.rs $(TMPDIR)/
9 cp 'foo foo.rs' $(TMPDIR)/
10 cp bar.rs $(TMPDIR)/
11 $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs
12 sleep 1
13 touch $(TMPDIR)/'foo foo.rs'
14 -rm -f $(TMPDIR)/done
15 $(MAKE) -drf Makefile.foo
16 rm $(TMPDIR)/done
17 pwd
18 $(MAKE) -drf Makefile.foo
19 rm $(TMPDIR)/done && exit 1 || exit 0
tests/run-make/dep-info-spaces/Makefile.foo created+7
...@@ -0,0 +1,7 @@
1LIB := $(shell $(RUSTC) --print file-names --crate-type=lib $(TMPDIR)/lib.rs)
2
3$(TMPDIR)/$(LIB):
4 $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs
5 touch $(TMPDIR)/done
6
7-include $(TMPDIR)/lib.d
tests/run-make/dep-info-spaces/bar.rs created+1
...@@ -0,0 +1 @@
1pub fn bar() {}
tests/run-make/dep-info-spaces/foo foo.rs created+1
...@@ -0,0 +1 @@
1pub fn foo() {}
tests/run-make/dep-info-spaces/lib.rs created+4
...@@ -0,0 +1,4 @@
1#[path="foo foo.rs"]
2pub mod foo;
3
4pub mod bar;
tests/run-make/dep-info/Makefile created+25
...@@ -0,0 +1,25 @@
1include ../tools.mk
2
3# ignore-windows
4# ignore-freebsd
5# FIXME: on windows `rustc --dep-info` produces Makefile dependency with
6# windows native paths (e.g. `c:\path\to\libfoo.a`)
7# but msys make seems to fail to recognize such paths, so test fails.
8
9all:
10 cp *.rs $(TMPDIR)
11 $(RUSTC) --emit dep-info,link --crate-type=lib $(TMPDIR)/lib.rs
12 sleep 2
13 touch $(TMPDIR)/foo.rs
14 -rm -f $(TMPDIR)/done
15 $(MAKE) -drf Makefile.foo
16 sleep 2
17 rm $(TMPDIR)/done
18 pwd
19 $(MAKE) -drf Makefile.foo
20 rm $(TMPDIR)/done && exit 1 || exit 0
21
22 # When a source file is deleted `make` should still work
23 rm $(TMPDIR)/bar.rs
24 cp $(TMPDIR)/lib2.rs $(TMPDIR)/lib.rs
25 $(MAKE) -drf Makefile.foo
tests/run-make/dep-info/Makefile.foo created+7
...@@ -0,0 +1,7 @@
1LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs)
2
3$(TMPDIR)/$(LIB):
4 $(RUSTC) --emit dep-info,link --crate-type=lib lib.rs
5 touch $(TMPDIR)/done
6
7-include $(TMPDIR)/foo.d
tests/run-make/dep-info/bar.rs created+1
...@@ -0,0 +1 @@
1pub fn bar() {}
tests/run-make/dep-info/foo.rs created+1
...@@ -0,0 +1 @@
1pub fn foo() {}
tests/run-make/dep-info/lib.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_name = "foo"]
2
3pub mod foo;
4pub mod bar;
tests/run-make/dep-info/lib2.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_name = "foo"]
2
3pub mod foo;
tests/run-make/doctests-keep-binaries/Makefile created+22
...@@ -0,0 +1,22 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Check that valid binaries are persisted by running them, regardless of whether the --run or --no-run option is used.
5
6all: run no_run
7
8run:
9 mkdir -p $(TMPDIR)/doctests
10 $(RUSTC) --crate-type rlib t.rs
11 $(RUSTDOC) -Zunstable-options --test --persist-doctests $(TMPDIR)/doctests --extern t=$(TMPDIR)/libt.rlib t.rs
12 $(TMPDIR)/doctests/t_rs_2_0/rust_out
13 $(TMPDIR)/doctests/t_rs_8_0/rust_out
14 rm -rf $(TMPDIR)/doctests
15
16no_run:
17 mkdir -p $(TMPDIR)/doctests
18 $(RUSTC) --crate-type rlib t.rs
19 $(RUSTDOC) -Zunstable-options --test --persist-doctests $(TMPDIR)/doctests --extern t=$(TMPDIR)/libt.rlib t.rs --no-run
20 $(TMPDIR)/doctests/t_rs_2_0/rust_out
21 $(TMPDIR)/doctests/t_rs_8_0/rust_out
22 rm -rf $(TMPDIR)/doctests
tests/run-make/doctests-keep-binaries/t.rs created+11
...@@ -0,0 +1,11 @@
1/// Fungle the foople.
2/// ```
3/// t::foople();
4/// ```
5pub fn foople() {}
6
7/// Flomble the florp
8/// ```
9/// t::florp();
10/// ```
11pub fn florp() {}
tests/run-make/dump-mono-stats/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 $(RUSTC) --crate-type lib foo.rs -Z dump-mono-stats=$(TMPDIR) -Zdump-mono-stats-format=json4 $(RUSTC) --crate-type lib foo.rs -Z dump-mono-stats=$(TMPDIR) -Zdump-mono-stats-format=json
tests/run-make/duplicate-output-flavors/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --crate-type=rlib foo.rs
5 $(RUSTC) --crate-type=rlib,rlib foo.rs
tests/run-make/duplicate-output-flavors/foo.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "rlib"]
tests/run-make/dylib-chain/Makefile created+13
...@@ -0,0 +1,13 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) m1.rs -C prefer-dynamic
6 $(RUSTC) m2.rs -C prefer-dynamic
7 $(RUSTC) m3.rs -C prefer-dynamic
8 $(RUSTC) m4.rs
9 $(call RUN,m4)
10 $(call REMOVE_DYLIBS,m1)
11 $(call REMOVE_DYLIBS,m2)
12 $(call REMOVE_DYLIBS,m3)
13 $(call FAIL,m4)
tests/run-make/dylib-chain/m1.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "dylib"]
2pub fn m1() {}
tests/run-make/dylib-chain/m2.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "dylib"]
2extern crate m1;
3
4pub fn m2() { m1::m1() }
tests/run-make/dylib-chain/m3.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "dylib"]
2extern crate m2;
3
4pub fn m3() { m2::m2() }
tests/run-make/dylib-chain/m4.rs created+3
...@@ -0,0 +1,3 @@
1extern crate m3;
2
3fn main() { m3::m3() }
tests/run-make/emit-named-files/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3OUT=$(TMPDIR)/emit3OUT=$(TMPDIR)/emit
44
tests/run-make/emit-path-unhashed/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3OUT=$(TMPDIR)/emit3OUT=$(TMPDIR)/emit
44
tests/run-make/emit-shared-files/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3INVOCATION_ONLY = $(TMPDIR)/invocation-only3INVOCATION_ONLY = $(TMPDIR)/invocation-only
4TOOLCHAIN_ONLY = $(TMPDIR)/toolchain-only4TOOLCHAIN_ONLY = $(TMPDIR)/toolchain-only
tests/run-make/emit-stack-sizes/Makefile created+12
...@@ -0,0 +1,12 @@
1include ../tools.mk
2
3# ignore-windows
4# ignore-macos
5#
6# This feature only works when the output object format is ELF so we ignore
7# macOS and Windows
8
9# check that the .stack_sizes section is generated
10all:
11 $(RUSTC) -C opt-level=3 -Z emit-stack-sizes --emit=obj foo.rs
12 size -A $(TMPDIR)/foo.o | $(CGREP) .stack_sizes
tests/run-make/emit-stack-sizes/foo.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "lib"]
2
3pub fn foo() {}
tests/run-make/emit/Makefile created+22
...@@ -0,0 +1,22 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
6 $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
7 $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
8 $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
9 $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
10 $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs
11 $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
12 $(call RUN,test-26235) || exit 1
13 $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
14 $(call RUN,test-26235) || exit 1
15 $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
16 $(call RUN,test-26235) || exit 1
17 $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
18 $(call RUN,test-26235) || exit 1
19 $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
20 $(call RUN,test-26235) || exit 1
21 $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs
22 $(call RUN,test-26235) || exit 1
tests/run-make/emit/test-24876.rs created+9
...@@ -0,0 +1,9 @@
1// Checks for issue #24876
2
3fn main() {
4 let mut v = 0;
5 for i in 0..0 {
6 v += i;
7 }
8 println!("{}", v)
9}
tests/run-make/emit/test-26235.rs created+46
...@@ -0,0 +1,46 @@
1// Checks for issue #26235
2
3fn main() {
4 use std::thread;
5
6 type Key = u32;
7 const NUM_THREADS: usize = 2;
8
9 #[derive(Clone,Copy)]
10 struct Stats<S> {
11 upsert: S,
12 delete: S,
13 insert: S,
14 update: S
15 };
16
17 impl<S> Stats<S> where S: Copy {
18 fn dot<B, F, T>(self, s: Stats<T>, f: F) -> Stats<B> where F: Fn(S, T) -> B {
19 let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self;
20 let Stats { upsert: u2, delete: d2, insert: i2, update: p2 } = s;
21 Stats { upsert: f(u1, u2), delete: f(d1, d2), insert: f(i1, i2), update: f(p1, p2) }
22 }
23
24 fn new(init: S) -> Self {
25 Stats { upsert: init, delete: init, insert: init, update: init }
26 }
27 }
28
29 fn make_threads() -> Vec<thread::JoinHandle<()>> {
30 let mut t = Vec::with_capacity(NUM_THREADS);
31 for _ in 0..NUM_THREADS {
32 t.push(thread::spawn(move || {}));
33 }
34 t
35 }
36
37 let stats = [Stats::new(0); NUM_THREADS];
38 make_threads();
39
40 {
41 let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold(
42 Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y)));
43 println!("upserts: {}, deletes: {}, inserts: {}, updates: {}",
44 upsert, delete, insert, update);
45 }
46}
tests/run-make/env-dep-info/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`3# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`
4# instead of hardcoding them everywhere they're needed.4# instead of hardcoding them everywhere they're needed.
tests/run-make/error-found-staticlib-instead-crate/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --crate-type staticlib
5 $(RUSTC) bar.rs 2>&1 | $(CGREP) "found staticlib"
tests/run-make/error-found-staticlib-instead-crate/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::foo();
5}
tests/run-make/error-found-staticlib-instead-crate/foo.rs created+1
...@@ -0,0 +1 @@
1pub fn foo() {}
tests/run-make/error-writing-dependencies/Makefile created+8
...@@ -0,0 +1,8 @@
1include ../tools.mk
2
3all:
4 # Let's get a nice error message
5 $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \
6 $(CGREP) "error writing dependencies"
7 # Make sure the filename shows up
8 $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | $(CGREP) "baz"
tests/run-make/error-writing-dependencies/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/exit-code/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) success.rs; [ $$? -eq 0 ]
6 $(RUSTC) --invalid-arg-foo; [ $$? -eq 1 ]
7 $(RUSTC) compile-error.rs; [ $$? -eq 1 ]
8 $(RUSTC) -Ztreat-err-as-bug compile-error.rs; [ $$? -eq 101 ]
9 $(RUSTDOC) -o $(TMPDIR)/exit-code success.rs; [ $$? -eq 0 ]
10 $(RUSTDOC) --invalid-arg-foo; [ $$? -eq 1 ]
11 $(RUSTDOC) compile-error.rs; [ $$? -eq 1 ]
12 $(RUSTDOC) lint-failure.rs; [ $$? -eq 1 ]
tests/run-make/exit-code/compile-error.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 compile_error!("kaboom");
3}
tests/run-make/exit-code/lint-failure.rs created+6
...@@ -0,0 +1,6 @@
1#![deny(broken_intra_doc_links)]
2
3/// [intradoc::failure]
4pub fn main() {
5 println!("Hello, world!");
6}
tests/run-make/exit-code/success.rs created+4
...@@ -0,0 +1,4 @@
1/// Main function
2fn main() {
3 println!("Hello, world!");
4}
tests/run-make/export-executable-symbols/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-wasm323# ignore-wasm32
4# ignore-wasm644# ignore-wasm64
tests/run-make/extern-diff-internal-name/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) lib.rs
6 $(RUSTC) test.rs --extern foo=$(TMPDIR)/libbar.rlib
tests/run-make/extern-diff-internal-name/lib.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_name = "bar"]
2#![crate_type = "rlib"]
tests/run-make/extern-diff-internal-name/test.rs created+5
...@@ -0,0 +1,5 @@
1#[macro_use]
2extern crate foo;
3
4fn main() {
5}
tests/run-make/extern-flag-disambiguates/Makefile created+26
...@@ -0,0 +1,26 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Attempt to build this dependency tree:
5#
6# A.1 A.2
7# |\ |
8# | \ |
9# B \ C
10# \ | /
11# \|/
12# D
13#
14# Note that A.1 and A.2 are crates with the same name.
15
16all:
17 $(RUSTC) -C metadata=1 -C extra-filename=-1 a.rs
18 $(RUSTC) -C metadata=2 -C extra-filename=-2 a.rs
19 $(RUSTC) b.rs --extern a=$(TMPDIR)/liba-1.rlib
20 $(RUSTC) c.rs --extern a=$(TMPDIR)/liba-2.rlib
21 @echo before
22 $(RUSTC) --cfg before d.rs --extern a=$(TMPDIR)/liba-1.rlib
23 $(call RUN,d)
24 @echo after
25 $(RUSTC) --cfg after d.rs --extern a=$(TMPDIR)/liba-1.rlib
26 $(call RUN,d)
tests/run-make/extern-flag-disambiguates/a.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_name = "a"]
2#![crate_type = "rlib"]
3
4static FOO: usize = 3;
5
6pub fn token() -> &'static usize { &FOO }
tests/run-make/extern-flag-disambiguates/b.rs created+9
...@@ -0,0 +1,9 @@
1#![crate_name = "b"]
2#![crate_type = "rlib"]
3
4extern crate a;
5
6static FOO: usize = 3;
7
8pub fn token() -> &'static usize { &FOO }
9pub fn a_token() -> &'static usize { a::token() }
tests/run-make/extern-flag-disambiguates/c.rs created+9
...@@ -0,0 +1,9 @@
1#![crate_name = "c"]
2#![crate_type = "rlib"]
3
4extern crate a;
5
6static FOO: usize = 3;
7
8pub fn token() -> &'static usize { &FOO }
9pub fn a_token() -> &'static usize { a::token() }
tests/run-make/extern-flag-disambiguates/d.rs created+11
...@@ -0,0 +1,11 @@
1#[cfg(before)] extern crate a;
2extern crate b;
3extern crate c;
4#[cfg(after)] extern crate a;
5
6fn t(a: &'static usize) -> usize { a as *const _ as usize }
7
8fn main() {
9 assert_eq!(t(a::token()), t(b::a_token()));
10 assert!(t(a::token()) != t(c::a_token()));
11}
tests/run-make/extern-flag-fun/Makefile created+20
...@@ -0,0 +1,20 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) bar.rs --crate-type=rlib
6 $(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a
7 $(RUSTC) bar-alt.rs --crate-type=rlib
8 $(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0
9 $(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0
10 $(RUSTC) foo.rs \
11 --extern bar=$(TMPDIR)/libbar.rlib \
12 --extern bar=$(TMPDIR)/libbar-alt.rlib \
13 && exit 1 || exit 0
14 $(RUSTC) foo.rs \
15 --extern bar=$(TMPDIR)/libbar.rlib \
16 --extern bar=$(TMPDIR)/libbar-a.rlib
17 $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib
18 # Try to be sneaky and load a private crate from with a non-private name.
19 $(RUSTC) rustc.rs -Zforce-unstable-if-unmarked --crate-type=rlib
20 $(RUSTC) gated_unstable.rs --extern alloc=$(TMPDIR)/librustc.rlib 2>&1 | $(CGREP) 'rustc_private'
tests/run-make/extern-flag-fun/bar-alt.rs created+1
...@@ -0,0 +1 @@
1pub fn f() {}
tests/run-make/extern-flag-fun/bar.rs created+1
...@@ -0,0 +1 @@
1// intentionally empty
tests/run-make/extern-flag-fun/foo.rs created+3
...@@ -0,0 +1,3 @@
1extern crate bar;
2
3fn main() {}
tests/run-make/extern-flag-fun/gated_unstable.rs created+3
...@@ -0,0 +1,3 @@
1extern crate alloc;
2
3fn main() {}
tests/run-make/extern-flag-fun/rustc.rs created+1
...@@ -0,0 +1 @@
1pub fn foo() {}
tests/run-make/extern-flag-pathless/Makefile created+19
...@@ -0,0 +1,19 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test mixing pathless --extern with paths.
5
6all:
7 $(RUSTC) bar-static.rs --crate-name=bar --crate-type=rlib
8 $(RUSTC) bar-dynamic.rs --crate-name=bar --crate-type=dylib -C prefer-dynamic
9 # rlib preferred over dylib
10 $(RUSTC) foo.rs --extern bar
11 $(call RUN,foo) | $(CGREP) 'static'
12 $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar
13 $(call RUN,foo) | $(CGREP) 'static'
14 # explicit --extern overrides pathless
15 $(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar
16 $(call RUN,foo) | $(CGREP) 'dynamic'
17 # prefer-dynamic does what it says
18 $(RUSTC) foo.rs --extern bar -C prefer-dynamic
19 $(call RUN,foo) | $(CGREP) 'dynamic'
tests/run-make/extern-flag-pathless/bar-dynamic.rs created+3
...@@ -0,0 +1,3 @@
1pub fn f() {
2 println!("dynamic");
3}
tests/run-make/extern-flag-pathless/bar-static.rs created+3
...@@ -0,0 +1,3 @@
1pub fn f() {
2 println!("static");
3}
tests/run-make/extern-flag-pathless/foo.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 bar::f();
3}
tests/run-make/extern-flag-rename-transitive/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs
5 $(RUSTC) bar.rs
6 $(RUSTC) baz.rs --extern a=$(TMPDIR)/libfoo.rlib
7
tests/run-make/extern-flag-rename-transitive/bar.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "rlib"]
2
3extern crate foo;
tests/run-make/extern-flag-rename-transitive/baz.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "rlib"]
2
3extern crate a;
4extern crate bar;
tests/run-make/extern-flag-rename-transitive/foo.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "rlib"]
tests/run-make/extern-fn-generic/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,test)
5 $(RUSTC) testcrate.rs
6 $(RUSTC) test.rs
7 $(call RUN,test) || exit 1
tests/run-make/extern-fn-generic/test.c created+16
...@@ -0,0 +1,16 @@
1#include <stdint.h>
2
3typedef struct TestStruct {
4 uint8_t x;
5 int32_t y;
6} TestStruct;
7
8typedef int callback(TestStruct s);
9
10uint32_t call(callback *c) {
11 TestStruct s;
12 s.x = 'a';
13 s.y = 3;
14
15 return c(s);
16}
tests/run-make/extern-fn-generic/test.rs created+20
...@@ -0,0 +1,20 @@
1extern crate testcrate;
2
3extern "C" fn bar<T>(ts: testcrate::TestStruct<T>) -> T {
4 ts.y
5}
6
7#[link(name = "test", kind = "static")]
8extern "C" {
9 fn call(c: extern "C" fn(testcrate::TestStruct<i32>) -> i32) -> i32;
10}
11
12fn main() {
13 // Let's test calling it cross crate
14 let back = unsafe { testcrate::call(testcrate::foo::<i32>) };
15 assert_eq!(3, back);
16
17 // And just within this crate
18 let back = unsafe { call(bar::<i32>) };
19 assert_eq!(3, back);
20}
tests/run-make/extern-fn-generic/testcrate.rs created+16
...@@ -0,0 +1,16 @@
1#![crate_type = "lib"]
2
3#[repr(C)]
4pub struct TestStruct<T> {
5 pub x: u8,
6 pub y: T,
7}
8
9pub extern "C" fn foo<T>(ts: TestStruct<T>) -> T {
10 ts.y
11}
12
13#[link(name = "test", kind = "static")]
14extern "C" {
15 pub fn call(c: extern "C" fn(TestStruct<i32>) -> i32) -> i32;
16}
tests/run-make/extern-fn-mangle/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,test)
5 $(RUSTC) test.rs
6 $(call RUN,test) || exit 1
tests/run-make/extern-fn-mangle/test.c created+8
...@@ -0,0 +1,8 @@
1#include <stdint.h>
2
3uint32_t foo();
4uint32_t bar();
5
6uint32_t add() {
7 return foo() + bar();
8}
tests/run-make/extern-fn-mangle/test.rs created+19
...@@ -0,0 +1,19 @@
1#[no_mangle]
2pub extern "C" fn foo() -> i32 {
3 3
4}
5
6#[no_mangle]
7pub extern "C" fn bar() -> i32 {
8 5
9}
10
11#[link(name = "test", kind = "static")]
12extern "C" {
13 fn add() -> i32;
14}
15
16fn main() {
17 let back = unsafe { add() };
18 assert_eq!(8, back);
19}
tests/run-make/extern-fn-reachable/Makefile created+26
...@@ -0,0 +1,26 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows-msvc
5
6NM=nm -D
7
8ifeq ($(UNAME),Darwin)
9NM=nm -gU
10endif
11
12ifdef IS_WINDOWS
13NM=nm -g
14endif
15
16# This overrides the LD_LIBRARY_PATH for RUN
17TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR)
18
19all:
20 $(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so -C prefer-dynamic
21
22 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun1)" -eq "1" ]
23 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun2)" -eq "1" ]
24 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun3)" -eq "1" ]
25 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun4)" -eq "1" ]
26 [ "$$($(NM) $(TMPDIR)/libdylib.so | grep -v __imp_ | grep -c fun5)" -eq "1" ]
tests/run-make/extern-fn-reachable/dylib.rs created+14
...@@ -0,0 +1,14 @@
1#![crate_type = "dylib"]
2#![allow(dead_code)]
3
4#[no_mangle] pub extern "C" fn fun1() {}
5#[no_mangle] extern "C" fn fun2() {}
6
7mod foo {
8 #[no_mangle] pub extern "C" fn fun3() {}
9}
10pub mod bar {
11 #[no_mangle] pub extern "C" fn fun4() {}
12}
13
14#[no_mangle] pub fn fun5() {}
tests/run-make/extern-fn-struct-passing-abi/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,test)
5 $(RUSTC) test.rs
6 $(call RUN,test) || exit 1
tests/run-make/extern-fn-struct-passing-abi/test.c created+314
...@@ -0,0 +1,314 @@
1#include <assert.h>
2#include <stdint.h>
3
4struct Rect {
5 int32_t a;
6 int32_t b;
7 int32_t c;
8 int32_t d;
9};
10
11struct BiggerRect {
12 struct Rect s;
13 int32_t a;
14 int32_t b;
15};
16
17struct FloatRect {
18 int32_t a;
19 int32_t b;
20 double c;
21};
22
23struct Huge {
24 int32_t a;
25 int32_t b;
26 int32_t c;
27 int32_t d;
28 int32_t e;
29};
30
31struct FloatPoint {
32 double x;
33 double y;
34};
35
36struct FloatOne {
37 double x;
38};
39
40struct IntOdd {
41 int8_t a;
42 int8_t b;
43 int8_t c;
44};
45
46// System V x86_64 ABI:
47// a, b, c, d, e should be in registers
48// s should be byval pointer
49//
50// Win64 ABI:
51// a, b, c, d should be in registers
52// e should be on the stack
53// s should be byval pointer
54void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Rect s) {
55 assert(a == 1);
56 assert(b == 2);
57 assert(c == 3);
58 assert(d == 4);
59 assert(e == 5);
60 assert(s.a == 553);
61 assert(s.b == 554);
62 assert(s.c == 555);
63 assert(s.d == 556);
64}
65
66// System V x86_64 ABI:
67// a, b, c, d, e, f should be in registers
68// s should be byval pointer on the stack
69//
70// Win64 ABI:
71// a, b, c, d should be in registers
72// e, f should be on the stack
73// s should be byval pointer on the stack
74void byval_many_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e,
75 int32_t f, struct Rect s) {
76 assert(a == 1);
77 assert(b == 2);
78 assert(c == 3);
79 assert(d == 4);
80 assert(e == 5);
81 assert(f == 6);
82 assert(s.a == 553);
83 assert(s.b == 554);
84 assert(s.c == 555);
85 assert(s.d == 556);
86}
87
88// System V x86_64 ABI:
89// a, b, c, d, e, f, g should be in sse registers
90// s should be split across 2 registers
91// t should be byval pointer
92//
93// Win64 ABI:
94// a, b, c, d should be in sse registers
95// e, f, g should be on the stack
96// s should be on the stack (treated as 2 i64's)
97// t should be on the stack (treated as an i64 and a double)
98void byval_rect_floats(float a, float b, double c, float d, float e,
99 float f, double g, struct Rect s, struct FloatRect t) {
100 assert(a == 1.);
101 assert(b == 2.);
102 assert(c == 3.);
103 assert(d == 4.);
104 assert(e == 5.);
105 assert(f == 6.);
106 assert(g == 7.);
107 assert(s.a == 553);
108 assert(s.b == 554);
109 assert(s.c == 555);
110 assert(s.d == 556);
111 assert(t.a == 3489);
112 assert(t.b == 3490);
113 assert(t.c == 8.);
114}
115
116// System V x86_64 ABI:
117// a, b, d, e, f should be in registers
118// c passed via sse registers
119// s should be byval pointer
120//
121// Win64 ABI:
122// a, b, d should be in registers
123// c passed via sse registers
124// e, f should be on the stack
125// s should be byval pointer
126void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d,
127 int32_t e, int32_t f, struct Rect s) {
128 assert(a == 1);
129 assert(b == 2);
130 assert(c == 3.);
131 assert(d == 4);
132 assert(e == 5);
133 assert(f == 6);
134 assert(s.a == 553);
135 assert(s.b == 554);
136 assert(s.c == 555);
137 assert(s.d == 556);
138}
139
140// System V x86_64 ABI:
141// a, b, d, e, f should be byval pointer (on the stack)
142// g passed via register (fixes #41375)
143//
144// Win64 ABI:
145// a, b, d, e, f, g should be byval pointer
146void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c,
147 struct Huge d, struct Huge e, struct Huge f,
148 struct Rect g) {
149 assert(g.a == 123);
150 assert(g.b == 456);
151 assert(g.c == 789);
152 assert(g.d == 420);
153}
154
155// System V x86_64 & Win64 ABI:
156// a, b should be in registers
157// s should be split across 2 integer registers
158void split_rect(int32_t a, int32_t b, struct Rect s) {
159 assert(a == 1);
160 assert(b == 2);
161 assert(s.a == 553);
162 assert(s.b == 554);
163 assert(s.c == 555);
164 assert(s.d == 556);
165}
166
167// System V x86_64 & Win64 ABI:
168// a, b should be in sse registers
169// s should be split across integer & sse registers
170void split_rect_floats(float a, float b, struct FloatRect s) {
171 assert(a == 1.);
172 assert(b == 2.);
173 assert(s.a == 3489);
174 assert(s.b == 3490);
175 assert(s.c == 8.);
176}
177
178// System V x86_64 ABI:
179// a, b, d, f should be in registers
180// c, e passed via sse registers
181// s should be split across 2 registers
182//
183// Win64 ABI:
184// a, b, d should be in registers
185// c passed via sse registers
186// e, f should be on the stack
187// s should be on the stack (treated as 2 i64's)
188void split_rect_with_floats(int32_t a, int32_t b, float c,
189 int32_t d, float e, int32_t f, struct Rect s) {
190 assert(a == 1);
191 assert(b == 2);
192 assert(c == 3.);
193 assert(d == 4);
194 assert(e == 5.);
195 assert(f == 6);
196 assert(s.a == 553);
197 assert(s.b == 554);
198 assert(s.c == 555);
199 assert(s.d == 556);
200}
201
202// System V x86_64 & Win64 ABI:
203// a, b, c should be in registers
204// s should be split across 2 registers
205// t should be a byval pointer
206void split_and_byval_rect(int32_t a, int32_t b, int32_t c, struct Rect s, struct Rect t) {
207 assert(a == 1);
208 assert(b == 2);
209 assert(c == 3);
210 assert(s.a == 553);
211 assert(s.b == 554);
212 assert(s.c == 555);
213 assert(s.d == 556);
214 assert(t.a == 553);
215 assert(t.b == 554);
216 assert(t.c == 555);
217 assert(t.d == 556);
218}
219
220// System V x86_64 & Win64 ABI:
221// a, b should in registers
222// s and return should be split across 2 registers
223struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) {
224 assert(a == 1);
225 assert(b == 2);
226 assert(s.a == 553);
227 assert(s.b == 554);
228 assert(s.c == 555);
229 assert(s.d == 556);
230 return s;
231}
232
233// System V x86_64 & Win64 ABI:
234// a, b, c, d should be in registers
235// return should be in a hidden sret pointer
236// s should be a byval pointer
237struct BiggerRect sret_byval_struct(int32_t a, int32_t b, int32_t c, int32_t d, struct Rect s) {
238 assert(a == 1);
239 assert(b == 2);
240 assert(c == 3);
241 assert(d == 4);
242 assert(s.a == 553);
243 assert(s.b == 554);
244 assert(s.c == 555);
245 assert(s.d == 556);
246
247 struct BiggerRect t;
248 t.s = s; t.a = 27834; t.b = 7657;
249 return t;
250}
251
252// System V x86_64 & Win64 ABI:
253// a, b should be in registers
254// return should be in a hidden sret pointer
255// s should be split across 2 registers
256struct BiggerRect sret_split_struct(int32_t a, int32_t b, struct Rect s) {
257 assert(a == 1);
258 assert(b == 2);
259 assert(s.a == 553);
260 assert(s.b == 554);
261 assert(s.c == 555);
262 assert(s.d == 556);
263
264 struct BiggerRect t;
265 t.s = s; t.a = 27834; t.b = 7657;
266 return t;
267}
268
269// System V x86_64 & Win64 ABI:
270// s should be byval pointer (since sizeof(s) > 16)
271// return should in a hidden sret pointer
272struct Huge huge_struct(struct Huge s) {
273 assert(s.a == 5647);
274 assert(s.b == 5648);
275 assert(s.c == 5649);
276 assert(s.d == 5650);
277 assert(s.e == 5651);
278
279 return s;
280}
281
282// System V x86_64 ABI:
283// p should be in registers
284// return should be in registers
285//
286// Win64 ABI and 64-bit PowerPC ELFv1 ABI:
287// p should be a byval pointer
288// return should be in a hidden sret pointer
289struct FloatPoint float_point(struct FloatPoint p) {
290 assert(p.x == 5.);
291 assert(p.y == -3.);
292
293 return p;
294}
295
296// 64-bit PowerPC ELFv1 ABI:
297// f1 should be in a register
298// return should be in a hidden sret pointer
299struct FloatOne float_one(struct FloatOne f1) {
300 assert(f1.x == 7.);
301
302 return f1;
303}
304
305// 64-bit PowerPC ELFv1 ABI:
306// i should be in the least-significant bits of a register
307// return should be in a hidden sret pointer
308struct IntOdd int_odd(struct IntOdd i) {
309 assert(i.a == 1);
310 assert(i.b == 2);
311 assert(i.c == 3);
312
313 return i;
314}
tests/run-make/extern-fn-struct-passing-abi/test.rs created+138
...@@ -0,0 +1,138 @@
1// Passing structs via FFI should work regardless of whether
2// they get passed in multiple registers, byval pointers or the stack
3
4#[derive(Clone, Copy, Debug, PartialEq)]
5#[repr(C)]
6struct Rect {
7 a: i32,
8 b: i32,
9 c: i32,
10 d: i32,
11}
12
13#[derive(Clone, Copy, Debug, PartialEq)]
14#[repr(C)]
15struct BiggerRect {
16 s: Rect,
17 a: i32,
18 b: i32,
19}
20
21#[derive(Clone, Copy, Debug, PartialEq)]
22#[repr(C)]
23struct FloatRect {
24 a: i32,
25 b: i32,
26 c: f64,
27}
28
29#[derive(Clone, Copy, Debug, PartialEq)]
30#[repr(C)]
31struct Huge {
32 a: i32,
33 b: i32,
34 c: i32,
35 d: i32,
36 e: i32,
37}
38
39#[derive(Clone, Copy, Debug, PartialEq)]
40#[repr(C)]
41struct FloatPoint {
42 x: f64,
43 y: f64,
44}
45
46#[derive(Clone, Copy, Debug, PartialEq)]
47#[repr(C)]
48struct FloatOne {
49 x: f64,
50}
51
52#[derive(Clone, Copy, Debug, PartialEq)]
53#[repr(C)]
54struct IntOdd {
55 a: i8,
56 b: i8,
57 c: i8,
58}
59
60#[link(name = "test", kind = "static")]
61extern "C" {
62 fn byval_rect(a: i32, b: i32, c: i32, d: i32, e: i32, s: Rect);
63
64 fn byval_many_rect(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, s: Rect);
65
66 fn byval_rect_floats(
67 a: f32,
68 b: f32,
69 c: f64,
70 d: f32,
71 e: f32,
72 f: f32,
73 g: f64,
74 s: Rect,
75 t: FloatRect,
76 );
77
78 fn byval_rect_with_float(a: i32, b: i32, c: f32, d: i32, e: i32, f: i32, s: Rect);
79
80 fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect);
81
82 fn split_rect(a: i32, b: i32, s: Rect);
83
84 fn split_rect_floats(a: f32, b: f32, s: FloatRect);
85
86 fn split_rect_with_floats(a: i32, b: i32, c: f32, d: i32, e: f32, f: i32, s: Rect);
87
88 fn split_and_byval_rect(a: i32, b: i32, c: i32, s: Rect, t: Rect);
89
90 fn split_ret_byval_struct(a: i32, b: i32, s: Rect) -> Rect;
91
92 fn sret_byval_struct(a: i32, b: i32, c: i32, d: i32, s: Rect) -> BiggerRect;
93
94 fn sret_split_struct(a: i32, b: i32, s: Rect) -> BiggerRect;
95
96 fn huge_struct(s: Huge) -> Huge;
97
98 fn float_point(p: FloatPoint) -> FloatPoint;
99
100 fn float_one(f: FloatOne) -> FloatOne;
101
102 fn int_odd(i: IntOdd) -> IntOdd;
103}
104
105fn main() {
106 let s = Rect { a: 553, b: 554, c: 555, d: 556 };
107 let t = BiggerRect { s: s, a: 27834, b: 7657 };
108 let u = FloatRect { a: 3489, b: 3490, c: 8. };
109 let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 };
110 let p = FloatPoint { x: 5., y: -3. };
111 let f1 = FloatOne { x: 7. };
112 let i = IntOdd { a: 1, b: 2, c: 3 };
113
114 unsafe {
115 byval_rect(1, 2, 3, 4, 5, s);
116 byval_many_rect(1, 2, 3, 4, 5, 6, s);
117 byval_rect_floats(1., 2., 3., 4., 5., 6., 7., s, u);
118 byval_rect_with_float(1, 2, 3.0, 4, 5, 6, s);
119 byval_rect_with_many_huge(v, v, v, v, v, v, Rect { a: 123, b: 456, c: 789, d: 420 });
120 split_rect(1, 2, s);
121 split_rect_floats(1., 2., u);
122 split_rect_with_floats(1, 2, 3.0, 4, 5.0, 6, s);
123 split_and_byval_rect(1, 2, 3, s, s);
124 split_rect(1, 2, s);
125 assert_eq!(huge_struct(v), v);
126 assert_eq!(split_ret_byval_struct(1, 2, s), s);
127 assert_eq!(sret_byval_struct(1, 2, 3, 4, s), t);
128 assert_eq!(sret_split_struct(1, 2, s), t);
129 assert_eq!(float_point(p), p);
130 assert_eq!(int_odd(i), i);
131
132 // MSVC/GCC/Clang are not consistent in the ABI of single-float aggregates.
133 // x86_64: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82028
134 // i686: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82041
135 #[cfg(not(all(windows, target_env = "gnu")))]
136 assert_eq!(float_one(f1), f1);
137 }
138}
tests/run-make/extern-fn-with-extern-types/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,ctest)
5 $(RUSTC) test.rs
6 $(call RUN,test) || exit 1
tests/run-make/extern-fn-with-extern-types/ctest.c created+16
...@@ -0,0 +1,16 @@
1#include <stdio.h>
2#include <stdint.h>
3
4typedef struct data {
5 uint32_t magic;
6} data;
7
8data* data_create(uint32_t magic) {
9 static data d;
10 d.magic = magic;
11 return &d;
12}
13
14uint32_t data_get(data* p) {
15 return p->magic;
16}
tests/run-make/extern-fn-with-extern-types/test.rs created+17
...@@ -0,0 +1,17 @@
1#![feature(extern_types)]
2
3#[link(name = "ctest", kind = "static")]
4extern "C" {
5 type data;
6
7 fn data_create(magic: u32) -> *mut data;
8 fn data_get(data: *mut data) -> u32;
9}
10
11const MAGIC: u32 = 0xdeadbeef;
12fn main() {
13 unsafe {
14 let data = data_create(MAGIC);
15 assert_eq!(data_get(data), MAGIC);
16 }
17}
tests/run-make/extern-fn-with-packed-struct/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,test)
5 $(RUSTC) test.rs
6 $(call RUN,test) || exit 1
tests/run-make/extern-fn-with-packed-struct/test.c created+26
...@@ -0,0 +1,26 @@
1// Pragma needed cause of gcc bug on windows: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
2
3#include <assert.h>
4
5#ifdef _MSC_VER
6#pragma pack(push,1)
7struct Foo {
8 char a;
9 short b;
10 char c;
11};
12#else
13#pragma pack(1)
14struct __attribute__((packed)) Foo {
15 char a;
16 short b;
17 char c;
18};
19#endif
20
21struct Foo foo(struct Foo foo) {
22 assert(foo.a == 1);
23 assert(foo.b == 2);
24 assert(foo.c == 3);
25 return foo;
26}
tests/run-make/extern-fn-with-packed-struct/test.rs created+20
...@@ -0,0 +1,20 @@
1#[repr(C, packed)]
2#[derive(Copy, Clone, Debug, PartialEq)]
3struct Foo {
4 a: i8,
5 b: i16,
6 c: i8,
7}
8
9#[link(name = "test", kind = "static")]
10extern "C" {
11 fn foo(f: Foo) -> Foo;
12}
13
14fn main() {
15 unsafe {
16 let a = Foo { a: 1, b: 2, c: 3 };
17 let b = foo(a);
18 assert_eq!(a, b);
19 }
20}
tests/run-make/extern-fn-with-union/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,ctest)
5 $(RUSTC) testcrate.rs
6 $(RUSTC) test.rs
7 $(call RUN,test) || exit 1
tests/run-make/extern-fn-with-union/ctest.c created+10
...@@ -0,0 +1,10 @@
1#include <stdio.h>
2#include <stdint.h>
3
4typedef union TestUnion {
5 uint64_t bits;
6} TestUnion;
7
8uint64_t give_back(TestUnion tu) {
9 return tu.bits;
10}
tests/run-make/extern-fn-with-union/test.rs created+19
...@@ -0,0 +1,19 @@
1extern crate testcrate;
2
3use std::mem;
4
5extern "C" {
6 fn give_back(tu: testcrate::TestUnion) -> u64;
7}
8
9fn main() {
10 let magic: u64 = 0xDEADBEEF;
11
12 // Let's test calling it cross crate
13 let back = unsafe { testcrate::give_back(mem::transmute(magic)) };
14 assert_eq!(magic, back);
15
16 // And just within this crate
17 let back = unsafe { give_back(mem::transmute(magic)) };
18 assert_eq!(magic, back);
19}
tests/run-make/extern-fn-with-union/testcrate.rs created+11
...@@ -0,0 +1,11 @@
1#![crate_type = "lib"]
2
3#[repr(C)]
4pub struct TestUnion {
5 _val: u64,
6}
7
8#[link(name = "ctest", kind = "static")]
9extern "C" {
10 pub fn give_back(tu: TestUnion) -> u64;
11}
tests/run-make/extern-multiple-copies/Makefile created+9
...@@ -0,0 +1,9 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo1.rs
6 $(RUSTC) foo2.rs
7 mkdir $(TMPDIR)/foo
8 cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib
9 $(RUSTC) bar.rs --extern foo1=$(TMPDIR)/libfoo1.rlib -L $(TMPDIR)/foo
tests/run-make/extern-multiple-copies/bar.rs created+6
...@@ -0,0 +1,6 @@
1extern crate foo2; // foo2 first to exhibit the bug
2extern crate foo1;
3
4fn main() {
5 /* ... */
6}
tests/run-make/extern-multiple-copies/foo1.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "rlib"]
tests/run-make/extern-multiple-copies/foo2.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "rlib"]
tests/run-make/extern-multiple-copies2/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo1.rs
6 $(RUSTC) foo2.rs
7 mkdir $(TMPDIR)/foo
8 cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib
9 $(RUSTC) bar.rs \
10 --extern foo1=$(TMPDIR)/foo/libfoo1.rlib \
11 --extern foo2=$(TMPDIR)/libfoo2.rlib
tests/run-make/extern-multiple-copies2/bar.rs created+8
...@@ -0,0 +1,8 @@
1#[macro_use]
2extern crate foo2; // foo2 first to exhibit the bug
3#[macro_use]
4extern crate foo1;
5
6fn main() {
7 foo2::foo2(foo1::A);
8}
tests/run-make/extern-multiple-copies2/foo1.rs created+7
...@@ -0,0 +1,7 @@
1#![crate_type = "rlib"]
2
3pub struct A;
4
5pub fn foo1(a: A) {
6 drop(a);
7}
tests/run-make/extern-multiple-copies2/foo2.rs created+8
...@@ -0,0 +1,8 @@
1#![crate_type = "rlib"]
2
3#[macro_use]
4extern crate foo1;
5
6pub fn foo2(a: foo1::A) {
7 foo1::foo1(a);
8}
tests/run-make/extern-overrides-distribution/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) libc.rs -Cmetadata=foo
6 $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib
tests/run-make/extern-overrides-distribution/libc.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "lib"]
2
3pub fn foo() {}
tests/run-make/extern-overrides-distribution/main.rs created+5
...@@ -0,0 +1,5 @@
1extern crate libc;
2
3fn main() {
4 libc::foo();
5}
tests/run-make/extra-filename-with-temp-outputs/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) -C extra-filename=bar foo.rs -C save-temps
6 rm $(TMPDIR)/foobar.foo*0.rcgu.o
7 rm $(TMPDIR)/$(call BIN,foobar)
tests/run-make/extra-filename-with-temp-outputs/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/fmt-write-bloat/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-windows3# ignore-windows
44
tests/run-make/foreign-double-unwind/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: foo
5 $(call RUN,foo) | $(CGREP) -v unreachable
6
7foo: foo.rs $(call NATIVE_STATICLIB,foo)
8 $(RUSTC) $< -lfoo $(EXTRARSCXXFLAGS)
9
10$(TMPDIR)/libfoo.o: foo.cpp
11 $(call COMPILE_OBJ_CXX,$@,$<)
tests/run-make/foreign-double-unwind/foo.cpp created+33
...@@ -0,0 +1,33 @@
1#include <cstdio>
2#include <exception>
3
4void println(const char* s) {
5 puts(s);
6 fflush(stdout);
7}
8
9struct outer_exception {};
10struct inner_exception {};
11
12extern "C" {
13 void throw_cxx_exception() {
14 if (std::uncaught_exception()) {
15 println("throwing inner C++ exception");
16 throw inner_exception();
17 } else {
18 println("throwing outer C++ exception");
19 throw outer_exception();
20 }
21 }
22
23 void cxx_catch_callback(void (*cb)()) {
24 try {
25 cb();
26 println("unreachable: callback returns");
27 } catch (outer_exception) {
28 println("unreachable: caught outer exception in catch (...)");
29 } catch (inner_exception) {
30 println("unreachable: caught inner exception in catch (...)");
31 }
32 }
33}
tests/run-make/foreign-double-unwind/foo.rs created+26
...@@ -0,0 +1,26 @@
1// Tests that C++ double unwinding through Rust code will be properly guarded
2// against instead of exhibiting undefined behaviour.
3
4#![feature(c_unwind)]
5
6extern "C-unwind" {
7 fn throw_cxx_exception();
8 fn cxx_catch_callback(cb: extern "C-unwind" fn());
9}
10
11struct ThrowOnDrop;
12
13impl Drop for ThrowOnDrop {
14 fn drop(&mut self) {
15 unsafe { throw_cxx_exception() };
16 }
17}
18
19extern "C-unwind" fn test_double_unwind() {
20 let _a = ThrowOnDrop;
21 let _b = ThrowOnDrop;
22}
23
24fn main() {
25 unsafe { cxx_catch_callback(test_double_unwind) };
26}
tests/run-make/foreign-exceptions/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: foo
5 $(call RUN,foo)
6
7foo: foo.rs $(call NATIVE_STATICLIB,foo)
8 $(RUSTC) $< -lfoo $(EXTRARSCXXFLAGS)
9
10$(TMPDIR)/libfoo.o: foo.cpp
11 $(call COMPILE_OBJ_CXX,$@,$<)
tests/run-make/foreign-exceptions/foo.cpp created+60
...@@ -0,0 +1,60 @@
1#include <assert.h>
2#include <stddef.h>
3#include <stdio.h>
4
5void println(const char* s) {
6 puts(s);
7 fflush(stdout);
8}
9
10struct exception {};
11struct rust_panic {};
12
13struct drop_check {
14 bool* ok;
15 ~drop_check() {
16 println("~drop_check");
17
18 if (ok)
19 *ok = true;
20 }
21};
22
23extern "C" {
24 void rust_catch_callback(void (*cb)(), bool* rust_ok);
25
26 void throw_cxx_exception() {
27 println("throwing C++ exception");
28 throw exception();
29 }
30
31 void test_cxx_exception() {
32 bool rust_ok = false;
33 try {
34 rust_catch_callback(throw_cxx_exception, &rust_ok);
35 assert(false && "unreachable");
36 } catch (exception e) {
37 println("caught C++ exception");
38 assert(rust_ok);
39 return;
40 }
41 assert(false && "did not catch thrown C++ exception");
42 }
43
44 void cxx_catch_callback(void (*cb)(), bool* cxx_ok) {
45 drop_check x;
46 x.ok = NULL;
47 try {
48 cb();
49 } catch (rust_panic e) {
50 assert(false && "shouldn't be able to catch a rust panic");
51 } catch (...) {
52 println("caught foreign exception in catch (...)");
53 // Foreign exceptions are caught by catch (...). We only set the ok
54 // flag if we successfully caught the panic. The destructor of
55 // drop_check will then set the flag to true if it is executed.
56 x.ok = cxx_ok;
57 throw;
58 }
59 }
60}
tests/run-make/foreign-exceptions/foo.rs created+59
...@@ -0,0 +1,59 @@
1// Tests that C++ exceptions can unwind through Rust code run destructors and
2// are caught by catch_unwind. Also tests that Rust panics can unwind through
3// C++ code.
4
5#![feature(c_unwind)]
6
7use std::panic::{catch_unwind, AssertUnwindSafe};
8
9struct DropCheck<'a>(&'a mut bool);
10impl<'a> Drop for DropCheck<'a> {
11 fn drop(&mut self) {
12 println!("DropCheck::drop");
13 *self.0 = true;
14 }
15}
16
17extern "C" {
18 fn test_cxx_exception();
19}
20
21extern "C-unwind" {
22 fn cxx_catch_callback(cb: extern "C-unwind" fn(), ok: *mut bool);
23}
24
25#[no_mangle]
26extern "C-unwind" fn rust_catch_callback(cb: extern "C-unwind" fn(), rust_ok: &mut bool) {
27 let _drop = DropCheck(rust_ok);
28 cb();
29 unreachable!("should have unwound instead of returned");
30}
31
32fn test_rust_panic() {
33 extern "C-unwind" fn callback() {
34 println!("throwing rust panic");
35 panic!(1234i32);
36 }
37
38 let mut dropped = false;
39 let mut cxx_ok = false;
40 let caught_unwind = catch_unwind(AssertUnwindSafe(|| {
41 let _drop = DropCheck(&mut dropped);
42 unsafe {
43 cxx_catch_callback(callback, &mut cxx_ok);
44 }
45 unreachable!("should have unwound instead of returned");
46 }));
47 println!("caught rust panic");
48 assert!(dropped);
49 assert!(caught_unwind.is_err());
50 let panic_obj = caught_unwind.unwrap_err();
51 let panic_int = *panic_obj.downcast_ref::<i32>().unwrap();
52 assert_eq!(panic_int, 1234);
53 assert!(cxx_ok);
54}
55
56fn main() {
57 unsafe { test_cxx_exception() };
58 test_rust_panic();
59}
tests/run-make/foreign-rust-exceptions/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-cross-compile
2# ignore-i686-pc-windows-gnu
3
4# This test doesn't work on 32-bit MinGW as cdylib has its own copy of unwinder
5# so cross-DLL unwinding does not work.
6
7include ../tools.mk
8
9all:
10 $(RUSTC) bar.rs --crate-type=cdylib
11 $(RUSTC) foo.rs
12 $(call RUN,foo) 2>&1 | $(CGREP) "Rust cannot catch foreign exceptions"
tests/run-make/foreign-rust-exceptions/bar.rs created+7
...@@ -0,0 +1,7 @@
1#![crate_type = "cdylib"]
2#![feature(c_unwind)]
3
4#[no_mangle]
5extern "C-unwind" fn panic() {
6 panic!();
7}
tests/run-make/foreign-rust-exceptions/foo.rs created+13
...@@ -0,0 +1,13 @@
1#![feature(c_unwind)]
2
3#[cfg_attr(not(windows), link(name = "bar"))]
4#[cfg_attr(windows, link(name = "bar.dll"))]
5extern "C-unwind" {
6 fn panic();
7}
8
9fn main() {
10 let _ = std::panic::catch_unwind(|| {
11 unsafe { panic() };
12 });
13}
tests/run-make/fpic/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows
5# ignore-macos
6
7# Test for #39529.
8# `-z text` causes ld to error if there are any non-PIC sections
9
10all:
11 $(RUSTC) hello.rs -C link-args=-Wl,-z,text
tests/run-make/fpic/hello.rs created+1
...@@ -0,0 +1 @@
1fn main() { }
tests/run-make/glibc-staticlib-args/Makefile created+13
...@@ -0,0 +1,13 @@
1# ignore-cross-compile
2# only-gnu
3# only-linux
4
5include ../tools.mk
6
7# This ensures that std::env::args works in a library called from C on glibc Linux.
8
9all:
10 $(RUSTC) --crate-type=staticlib library.rs
11 $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) \
12 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
13 $(call RUN,program)
tests/run-make/glibc-staticlib-args/library.rs created+4
...@@ -0,0 +1,4 @@
1#[no_mangle]
2pub extern "C" fn args_check() {
3 assert_ne!(std::env::args_os().count(), 0);
4}
tests/run-make/glibc-staticlib-args/program.c created+6
...@@ -0,0 +1,6 @@
1void args_check();
2
3int main() {
4 args_check();
5 return 0;
6}
tests/run-make/hir-tree/Makefile created+8
...@@ -0,0 +1,8 @@
1include ../tools.mk
2
3# Test that hir-tree output doesn't crash and includes
4# the string constant we would expect to see.
5
6all:
7 $(RUSTC) -o $(TMPDIR)/input.hir -Z unpretty=hir-tree input.rs
8 $(CGREP) '"Hello, Rustaceans!\n"' < $(TMPDIR)/input.hir
tests/run-make/hir-tree/input.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 println!("Hello, Rustaceans!");
3}
tests/run-make/include_bytes_deps/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3# ignore-freebsd
4
5all:
6 $(RUSTC) --emit dep-info main.rs
7 $(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d
tests/run-make/include_bytes_deps/input.bin created+1
...@@ -0,0 +1 @@
1Hello world!
tests/run-make/include_bytes_deps/input.md created+1
...@@ -0,0 +1 @@
1# Hello, world!
tests/run-make/include_bytes_deps/input.txt created+1
...@@ -0,0 +1 @@
1Hello world!
tests/run-make/include_bytes_deps/main.rs created+10
...@@ -0,0 +1,10 @@
1#[doc = include_str!("input.md")]
2pub struct SomeStruct;
3
4pub fn main() {
5 const INPUT_TXT: &'static str = include_str!("input.txt");
6 const INPUT_BIN: &'static [u8] = include_bytes!("input.bin");
7
8 println!("{}", INPUT_TXT);
9 println!("{:?}", INPUT_BIN);
10}
tests/run-make/incr-add-rust-src-component/Makefile created+45
...@@ -0,0 +1,45 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# rust-lang/rust#70924: Test that if we add rust-src component in between two
5# incremental compiles, the compiler does not ICE on the second.
6
7# This test uses `ln -s` rather than copying to save testing time, but its
8# usage doesn't work on windows. So ignore windows.
9
10# ignore-windows
11
12SYSROOT:=$(shell $(RUSTC) --print sysroot)
13FAKEROOT=$(TMPDIR)/fakeroot
14INCR=$(TMPDIR)/incr
15
16# Make a local copy of the sysroot; then remove the rust-src part of it, if
17# present, for the *first* build. Then put in a facsimile of the rust-src
18# component for the second build, in order to expose the ICE from issue #70924.
19#
20# Note that it is much easier to just do `cp -a $(SYSROOT)/* $(FAKEROOT)` as a
21# first step, but I am concerned that would be too expensive in a unit test
22# compared to making symbolic links.
23#
24# Anyway, the pattern you'll see here is: For every prefix in
25# root/lib/rustlib/src, link all of prefix parent content, then remove the
26# prefix, then loop on the next prefix. This way, we basically create a copy of
27# the context around root/lib/rustlib/src, and can freely add/remove the src
28# component itself.
29all:
30 mkdir $(FAKEROOT)
31 ln -s $(SYSROOT)/* $(FAKEROOT)
32 rm -f $(FAKEROOT)/lib
33 mkdir $(FAKEROOT)/lib
34 ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
35 rm -f $(FAKEROOT)/lib/rustlib
36 mkdir $(FAKEROOT)/lib/rustlib
37 ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
38 rm -f $(FAKEROOT)/lib/rustlib/src
39 mkdir $(FAKEROOT)/lib/rustlib/src
40 ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
41 rm -f $(FAKEROOT)/lib/rustlib/src/rust
42 $(RUSTC) --sysroot $(FAKEROOT) -C incremental=$(INCR) main.rs
43 mkdir -p $(FAKEROOT)/lib/rustlib/src/rust/src/libstd
44 touch $(FAKEROOT)/lib/rustlib/src/rust/src/libstd/lib.rs
45 $(RUSTC) --sysroot $(FAKEROOT) -C incremental=$(INCR) main.rs
tests/run-make/incr-add-rust-src-component/main.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 println!("Hello World");
3}
tests/run-make/incr-foreign-head-span/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-none no-std is not supported3# ignore-none no-std is not supported
4# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for 'std'4# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for 'std'
tests/run-make/incr-prev-body-beyond-eof/Makefile+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1# ignore-none no-std is not supported1# ignore-none no-std is not supported
2# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for `std`2# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for `std`
33
4include ../../run-make-fulldeps/tools.mk4include ../tools.mk
55
6# Tests that we don't ICE during incremental compilation after modifying a6# Tests that we don't ICE during incremental compilation after modifying a
7# function span such that its previous end line exceeds the number of lines7# function span such that its previous end line exceeds the number of lines
tests/run-make/incremental-session-fail/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3SESSION_DIR := $(TMPDIR)/session3SESSION_DIR := $(TMPDIR)/session
4OUTPUT_FILE := $(TMPDIR)/build-output4OUTPUT_FILE := $(TMPDIR)/build-output
tests/run-make/inline-always-many-cgu/Makefile created+8
...@@ -0,0 +1,8 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2
5 if cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b'; then \
6 echo "found call instruction when one wasn't expected"; \
7 exit 1; \
8 fi
tests/run-make/inline-always-many-cgu/foo.rs created+15
...@@ -0,0 +1,15 @@
1#![crate_type = "lib"]
2
3pub mod a {
4 #[inline(always)]
5 pub fn foo() {
6 }
7
8 pub fn bar() {
9 }
10}
11
12#[no_mangle]
13pub fn bar() {
14 a::foo();
15}
tests/run-make/interdependent-c-libraries/Makefile created+15
...@@ -0,0 +1,15 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# The rust crate foo will link to the native library foo, while the rust crate
5# bar will link to the native library bar. There is also a dependency between
6# the native library bar to the natibe library foo.
7#
8# This test ensures that the ordering of -lfoo and -lbar on the command line is
9# correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo'
10# library will be stripped out, and the linkage will fail.
11
12all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar)
13 $(RUSTC) foo.rs
14 $(RUSTC) bar.rs
15 $(RUSTC) main.rs --print link-args
tests/run-make/interdependent-c-libraries/bar.c created+3
...@@ -0,0 +1,3 @@
1void foo();
2
3void bar() { foo(); }
tests/run-make/interdependent-c-libraries/bar.rs created+14
...@@ -0,0 +1,14 @@
1#![crate_type = "rlib"]
2
3extern crate foo;
4
5#[link(name = "bar", kind = "static")]
6extern "C" {
7 fn bar();
8}
9
10pub fn doit() {
11 unsafe {
12 bar();
13 }
14}
tests/run-make/interdependent-c-libraries/foo.c created+1
...@@ -0,0 +1 @@
1void foo() {}
tests/run-make/interdependent-c-libraries/foo.rs created+12
...@@ -0,0 +1,12 @@
1#![crate_type = "rlib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {
5 fn foo();
6}
7
8pub fn doit() {
9 unsafe {
10 foo();
11 }
12}
tests/run-make/interdependent-c-libraries/main.rs created+6
...@@ -0,0 +1,6 @@
1extern crate foo;
2extern crate bar;
3
4fn main() {
5 bar::doit();
6}
tests/run-make/intrinsic-unreachable/Makefile created+12
...@@ -0,0 +1,12 @@
1include ../tools.mk
2
3# needs-asm-support
4# ignore-windows-msvc
5#
6# Because of Windows exception handling, the code is not necessarily any shorter.
7# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466
8
9all:
10 $(RUSTC) -O --emit asm exit-ret.rs
11 $(RUSTC) -O --emit asm exit-unreachable.rs
12 test `wc -l < $(TMPDIR)/exit-unreachable.s` -lt `wc -l < $(TMPDIR)/exit-ret.s`
tests/run-make/intrinsic-unreachable/exit-ret.rs created+14
...@@ -0,0 +1,14 @@
1#![crate_type="lib"]
2use std::arch::asm;
3
4#[deny(unreachable_code)]
5pub fn exit(n: usize) -> i32 {
6 unsafe {
7 // Pretend this asm is an exit() syscall.
8 asm!("/*{0}*/", in(reg) n);
9 }
10 // This return value is just here to generate some extra code for a return
11 // value, making it easier for the test script to detect whether the
12 // compiler deleted it.
13 42
14}
tests/run-make/intrinsic-unreachable/exit-unreachable.rs created+18
...@@ -0,0 +1,18 @@
1#![feature(core_intrinsics)]
2#![crate_type="lib"]
3use std::arch::asm;
4
5use std::intrinsics;
6
7#[allow(unreachable_code)]
8pub fn exit(n: usize) -> i32 {
9 unsafe {
10 // Pretend this asm is an exit() syscall.
11 asm!("/*{0}*/", in(reg) n);
12 intrinsics::unreachable()
13 }
14 // This return value is just here to generate some extra code for a return
15 // value, making it easier for the test script to detect whether the
16 // compiler deleted it.
17 42
18}
tests/run-make/invalid-library/Makefile created+6
...@@ -0,0 +1,6 @@
1include ../tools.mk
2
3all:
4 touch $(TMPDIR)/lib.rmeta
5 $(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/lib.rmeta
6 $(RUSTC) foo.rs 2>&1 | $(CGREP) "found invalid metadata"
tests/run-make/invalid-library/foo.rs created+3
...@@ -0,0 +1,3 @@
1extern crate foo;
2
3fn main() {}
tests/run-make/invalid-so/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3DYLIB_NAME := $(shell echo | $(RUSTC) --crate-name foo --crate-type dylib --print file-names -)3DYLIB_NAME := $(shell echo | $(RUSTC) --crate-name foo --crate-type dylib --print file-names -)
44
tests/run-make/invalid-staticlib/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 touch $(TMPDIR)/libfoo.a
5 echo | $(RUSTC) - --crate-type=rlib -lstatic=foo 2>&1 | $(CGREP) "failed to add native library"
tests/run-make/issue-10971-temps-dir/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# Regression test for issue #109713# Regression test for issue #10971
4# Running two invocations in parallel would overwrite each other's temp files.4# Running two invocations in parallel would overwrite each other's temp files.
tests/run-make/issue-11908/Makefile created+22
...@@ -0,0 +1,22 @@
1# ignore-cross-compile
2# This test ensures that if you have the same rlib or dylib at two locations
3# in the same path that you don't hit an assertion in the compiler.
4#
5# Note that this relies on `liburl` to be in the path somewhere else,
6# and then our aux-built libraries will collide with liburl (they have
7# the same version listed)
8
9include ../tools.mk
10
11all:
12 mkdir $(TMPDIR)/other
13 $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic
14 mv $(call DYLIB,foo) $(TMPDIR)/other
15 $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic
16 $(RUSTC) bar.rs -L $(TMPDIR)/other
17 rm -rf $(TMPDIR)
18 mkdir -p $(TMPDIR)/other
19 $(RUSTC) foo.rs --crate-type=rlib
20 mv $(TMPDIR)/libfoo.rlib $(TMPDIR)/other
21 $(RUSTC) foo.rs --crate-type=rlib
22 $(RUSTC) bar.rs -L $(TMPDIR)/other
tests/run-make/issue-11908/bar.rs created+3
...@@ -0,0 +1,3 @@
1extern crate foo;
2
3fn main() {}
tests/run-make/issue-11908/foo.rs created+1
...@@ -0,0 +1 @@
1#![crate_name = "foo"]
tests/run-make/issue-14500/Makefile created+15
...@@ -0,0 +1,15 @@
1include ../tools.mk
2
3# ignore-cross-compile
4
5# Test to make sure that reachable extern fns are always available in final
6# productcs, including when LTO is used. In this test, the `foo` crate has a
7# reahable symbol, and is a dependency of the `bar` crate. When the `bar` crate
8# is compiled with LTO, it shouldn't strip the symbol from `foo`, and that's the
9# only way that `foo.c` will successfully compile.
10
11all:
12 $(RUSTC) foo.rs --crate-type=rlib
13 $(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a
14 $(CC) foo.c $(TMPDIR)/libbar.a $(EXTRACFLAGS) $(call OUT_EXE,foo)
15 $(call RUN,foo)
tests/run-make/issue-14500/bar.rs created+1
...@@ -0,0 +1 @@
1extern crate foo;
tests/run-make/issue-14500/foo.c created+7
...@@ -0,0 +1,7 @@
1extern void foo();
2extern char FOO_STATIC;
3
4int main() {
5 foo();
6 return (int)FOO_STATIC;
7}
tests/run-make/issue-14500/foo.rs created+5
...@@ -0,0 +1,5 @@
1#[no_mangle]
2pub extern "C" fn foo() {}
3
4#[no_mangle]
5pub static FOO_STATIC: u8 = 0;
tests/run-make/issue-14698/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 TMP=fake TMPDIR=fake $(RUSTC) foo.rs 2>&1 | $(CGREP) "couldn't create a temp dir:"
tests/run-make/issue-14698/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/issue-15460/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,foo)
5 $(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic
6 $(RUSTC) bar.rs
7 $(call RUN,bar)
tests/run-make/issue-15460/bar.rs created+4
...@@ -0,0 +1,4 @@
1extern crate foo;
2fn main() {
3 unsafe { foo::foo() }
4}
tests/run-make/issue-15460/foo.c created+6
...@@ -0,0 +1,6 @@
1// ignore-license
2
3#ifdef _WIN32
4__declspec(dllexport)
5#endif
6void foo() {}
tests/run-make/issue-15460/foo.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_type = "dylib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {
5 pub fn foo();
6}
tests/run-make/issue-18943/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3# Regression test for ICE #18943 when compiling as lib
4
5all:
6 $(RUSTC) foo.rs --crate-type lib
7 $(call REMOVE_RLIBS,foo) && exit 0 || exit 1
tests/run-make/issue-18943/foo.rs created+5
...@@ -0,0 +1,5 @@
1trait Foo { }
2
3trait Bar { }
4
5impl<'a> Foo for Bar + 'a { }
tests/run-make/issue-20626/Makefile created+9
...@@ -0,0 +1,9 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test output to be four
5# The original error only occurred when printing, not when comparing using assert!
6
7all:
8 $(RUSTC) foo.rs -O
9 [ `$(call RUN,foo)` = "4" ]
tests/run-make/issue-20626/foo.rs created+13
...@@ -0,0 +1,13 @@
1fn identity(a: &u32) -> &u32 { a }
2
3fn print_foo(f: &fn(&u32) -> &u32, x: &u32) {
4 print!("{}", (*f)(x));
5}
6
7fn main() {
8 let x = &4;
9 let f: fn(&u32) -> &u32 = identity;
10
11 // Didn't print 4 on optimized builds
12 print_foo(&f, x);
13}
tests/run-make/issue-22131/Makefile created+8
...@@ -0,0 +1,8 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: foo.rs
5 $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs
6 $(RUSTDOC) --test --cfg 'feature="bar"' \
7 -L $(TMPDIR) foo.rs |\
8 $(CGREP) 'foo.rs - foo (line 1) ... ok'
tests/run-make/issue-22131/foo.rs created+5
...@@ -0,0 +1,5 @@
1/// ```rust
2/// assert_eq!(foo::foo(), 1);
3/// ```
4#[cfg(feature = "bar")]
5pub fn foo() -> i32 { 1 }
tests/run-make/issue-24445/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# only-linux
5
6all:
7 $(RUSTC) foo.rs
8 $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo
9 $(call RUN,foo)
10 $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo
11 $(call RUN,foo)
tests/run-make/issue-24445/foo.c created+6
...@@ -0,0 +1,6 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make/issue-24445/foo.rs created+15
...@@ -0,0 +1,15 @@
1#![crate_type = "staticlib"]
2
3struct Destroy;
4impl Drop for Destroy {
5 fn drop(&mut self) { println!("drop"); }
6}
7
8thread_local! {
9 static X: Destroy = Destroy
10}
11
12#[no_mangle]
13pub extern "C" fn foo() {
14 X.with(|_| ());
15}
tests/run-make/issue-25581/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,test)
5 $(RUSTC) test.rs
6 $(call RUN,test) || exit 1
tests/run-make/issue-25581/test.c created+15
...@@ -0,0 +1,15 @@
1#include <stddef.h>
2#include <stdint.h>
3
4struct ByteSlice {
5 uint8_t *data;
6 size_t len;
7};
8
9size_t slice_len(struct ByteSlice bs) {
10 return bs.len;
11}
12
13uint8_t slice_elem(struct ByteSlice bs, size_t idx) {
14 return bs.data[idx];
15}
tests/run-make/issue-25581/test.rs created+18
...@@ -0,0 +1,18 @@
1#[link(name = "test", kind = "static")]
2extern "C" {
3 fn slice_len(s: &[u8]) -> usize;
4 fn slice_elem(s: &[u8], idx: usize) -> u8;
5}
6
7fn main() {
8 let data = [1, 2, 3, 4, 5];
9
10 unsafe {
11 assert_eq!(data.len(), slice_len(&data) as usize);
12 assert_eq!(data[0], slice_elem(&data, 0));
13 assert_eq!(data[1], slice_elem(&data, 1));
14 assert_eq!(data[2], slice_elem(&data, 2));
15 assert_eq!(data[3], slice_elem(&data, 3));
16 assert_eq!(data[4], slice_elem(&data, 4));
17 }
18}
tests/run-make/issue-26006/Makefile created+17
...@@ -0,0 +1,17 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows
5
6OUT := $(TMPDIR)/out
7
8all: time
9
10time: libc
11 mkdir -p $(OUT)/time $(OUT)/time/deps
12 ln -sf $(OUT)/libc/liblibc.rlib $(OUT)/time/deps/
13 $(RUSTC) in/time/lib.rs -Ldependency=$(OUT)/time/deps/
14
15libc:
16 mkdir -p $(OUT)/libc
17 $(RUSTC) in/libc/lib.rs --crate-name=libc -Cmetadata=foo -o $(OUT)/libc/liblibc.rlib
tests/run-make/issue-26006/in/libc/lib.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type="rlib"]
2
3pub fn something(){}
tests/run-make/issue-26006/in/time/lib.rs created+4
...@@ -0,0 +1,4 @@
1#![feature(rustc_private)]
2extern crate libc;
3
4fn main(){}
tests/run-make/issue-26092/Makefile created+6
...@@ -0,0 +1,6 @@
1include ../tools.mk
2
3# This test ensures that rustc does not panic with `-o ""` option.
4
5all:
6 $(RUSTC) -o "" blank.rs 2>&1 | $(CGREP) -i 'panic' && exit 1 || exit 0
tests/run-make/issue-26092/blank.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/issue-28595/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,a) $(call NATIVE_STATICLIB,b)
5 $(RUSTC) a.rs
6 $(RUSTC) b.rs
7 $(call RUN,b)
tests/run-make/issue-28595/a.c created+1
...@@ -0,0 +1 @@
1void a(void) {}
tests/run-make/issue-28595/a.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_type = "rlib"]
2
3#[link(name = "a", kind = "static")]
4extern "C" {
5 pub fn a();
6}
tests/run-make/issue-28595/b.c created+5
...@@ -0,0 +1,5 @@
1extern void a(void);
2
3void b(void) {
4 a();
5}
tests/run-make/issue-28595/b.rs created+12
...@@ -0,0 +1,12 @@
1extern crate a;
2
3#[link(name = "b", kind = "static")]
4extern "C" {
5 pub fn b();
6}
7
8fn main() {
9 unsafe {
10 b();
11 }
12}
tests/run-make/issue-28766/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -O foo.rs
5 $(RUSTC) -O -L $(TMPDIR) main.rs
tests/run-make/issue-28766/foo.rs created+8
...@@ -0,0 +1,8 @@
1#![crate_type="lib"]
2pub struct Foo(());
3
4impl Foo {
5 pub fn new() -> Foo {
6 Foo(())
7 }
8}
tests/run-make/issue-28766/main.rs created+7
...@@ -0,0 +1,7 @@
1#![crate_type="lib"]
2extern crate foo;
3use foo::Foo;
4
5pub fn crash() -> Box<Foo> {
6 Box::new(Foo::new())
7}
tests/run-make/issue-30063/Makefile created+36
...@@ -0,0 +1,36 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 rm -f $(TMPDIR)/foo-output
6 $(RUSTC) -C codegen-units=4 -o $(TMPDIR)/foo-output foo.rs
7 rm $(TMPDIR)/foo-output
8
9 rm -f $(TMPDIR)/asm-output
10 $(RUSTC) -C codegen-units=4 --emit=asm -o $(TMPDIR)/asm-output foo.rs
11 rm $(TMPDIR)/asm-output
12
13 rm -f $(TMPDIR)/bc-output
14 $(RUSTC) -C codegen-units=4 --emit=llvm-bc -o $(TMPDIR)/bc-output foo.rs
15 rm $(TMPDIR)/bc-output
16
17 rm -f $(TMPDIR)/ir-output
18 $(RUSTC) -C codegen-units=4 --emit=llvm-ir -o $(TMPDIR)/ir-output foo.rs
19 rm $(TMPDIR)/ir-output
20
21 rm -f $(TMPDIR)/link-output
22 $(RUSTC) -C codegen-units=4 --emit=link -o $(TMPDIR)/link-output foo.rs
23 rm $(TMPDIR)/link-output
24
25 rm -f $(TMPDIR)/obj-output
26 $(RUSTC) -C codegen-units=4 --emit=obj -o $(TMPDIR)/obj-output foo.rs
27 rm $(TMPDIR)/obj-output
28
29 rm -f $(TMPDIR)/dep-output
30 $(RUSTC) -C codegen-units=4 --emit=dep-info -o $(TMPDIR)/dep-output foo.rs
31 rm $(TMPDIR)/dep-output
32
33# # (This case doesn't work yet, and may be fundamentally wrong-headed anyway.)
34# rm -f $(TMPDIR)/multi-output
35# $(RUSTC) -C codegen-units=4 --emit=asm,obj -o $(TMPDIR)/multi-output foo.rs
36# rm $(TMPDIR)/multi-output
tests/run-make/issue-30063/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() { }
tests/run-make/issue-33329/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --target x86_64_unknown-linux-musl main.rs 2>&1 | $(CGREP) \
5 "error: Error loading target specification: Could not find specification for target"
tests/run-make/issue-33329/main.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/issue-35164/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) main.rs --error-format json 2>&1 | $(CGREP) -e '"byte_start":23\b' '"byte_end":29\b'
tests/run-make/issue-35164/main.rs created+5
...@@ -0,0 +1,5 @@
1mod submodule;
2
3fn main() {
4 submodule::foo();
5}
tests/run-make/issue-35164/submodule/mod.rs created+3
...@@ -0,0 +1,3 @@
1pub fn foo() {
2 let _MyFoo = 2;
3}
tests/run-make/issue-36710/Makefile+2-1
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1# ignore-cross-compile
1# ignore-none no-std is not supported2# ignore-none no-std is not supported
2# ignore-wasm32 FIXME: don't attempt to compile C++ to WASM3# ignore-wasm32 FIXME: don't attempt to compile C++ to WASM
3# ignore-wasm64 FIXME: don't attempt to compile C++ to WASM4# ignore-wasm64 FIXME: don't attempt to compile C++ to WASM
...@@ -6,7 +7,7 @@...@@ -6,7 +7,7 @@
6# (see dist-i586-gnu-i586-i686-musl Dockerfile)7# (see dist-i586-gnu-i586-i686-musl Dockerfile)
7# ignore-sgx8# ignore-sgx
89
9include ../../run-make-fulldeps/tools.mk10include ../tools.mk
1011
11all: foo12all: foo
12 $(call RUN,foo)13 $(call RUN,foo)
tests/run-make/issue-37839/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) a.rs && $(RUSTC) b.rs
6 $(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \
7 --out-dir=$(TMPDIR)
tests/run-make/issue-37839/a.rs created+2
...@@ -0,0 +1,2 @@
1#![allow(unused)]
2#![crate_type = "proc-macro"]
tests/run-make/issue-37839/b.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "lib"]
2#[macro_use] extern crate a;
tests/run-make/issue-37839/c.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "lib"]
2extern crate b;
tests/run-make/issue-37893/Makefile created+5
...@@ -0,0 +1,5 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) a.rs && $(RUSTC) b.rs && $(RUSTC) c.rs
tests/run-make/issue-37893/a.rs created+2
...@@ -0,0 +1,2 @@
1#![allow(unused)]
2#![crate_type = "proc-macro"]
tests/run-make/issue-37893/b.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "lib"]
2#[macro_use] extern crate a;
tests/run-make/issue-37893/c.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "staticlib"]
2extern crate b;
3extern crate a;
tests/run-make/issue-38237/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs; $(RUSTC) bar.rs
6 $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR)
tests/run-make/issue-38237/bar.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "lib"]
2
3#[derive(Debug)]
4pub struct S;
tests/run-make/issue-38237/baz.rs created+8
...@@ -0,0 +1,8 @@
1extern crate foo;
2extern crate bar;
3
4pub struct Bar;
5impl ::std::ops::Deref for Bar {
6 type Target = bar::S;
7 fn deref(&self) -> &Self::Target { unimplemented!() }
8}
tests/run-make/issue-38237/foo.rs created+9
...@@ -0,0 +1,9 @@
1#![crate_type = "proc-macro"]
2
3extern crate proc_macro;
4
5#[proc_macro_derive(A)]
6pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { ts }
7
8#[derive(Debug)]
9struct S;
tests/run-make/issue-40535/Makefile created+13
...@@ -0,0 +1,13 @@
1include ../tools.mk
2
3# The ICE occurred in the following situation:
4# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`)
5# * `bar` declares and depends on `extern crate baz`
6# * All crates built in metadata-only mode (`cargo check`)
7all:
8 # cc https://github.com/rust-lang/rust/issues/40623
9 $(RUSTC) baz.rs --emit=metadata
10 $(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta
11 $(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta 2>&1 | \
12 $(CGREP) -v "unexpectedly panicked"
13 # ^ Succeeds if it doesn't find the ICE message
tests/run-make/issue-40535/bar.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "lib"]
2
3extern crate baz;
tests/run-make/issue-40535/baz.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "lib"]
tests/run-make/issue-40535/foo.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "lib"]
2
3extern crate bar;
4extern crate baz;
tests/run-make/issue-46239/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) main.rs -C opt-level=1
6 $(call RUN,main)
tests/run-make/issue-46239/main.rs created+8
...@@ -0,0 +1,8 @@
1fn project<T>(x: &(T,)) -> &T { &x.0 }
2
3fn dummy() {}
4
5fn main() {
6 let f = (dummy as fn(),);
7 (*project(&f))();
8}
tests/run-make/issue-47384/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-linux3# only-linux
4# ignore-cross-compile4# ignore-cross-compile
tests/run-make/issue-47551/Makefile created+9
...@@ -0,0 +1,9 @@
1# only-linux
2# ignore-32bit
3
4include ../tools.mk
5
6all:
7 $(RUSTC) eh_frame-terminator.rs
8 $(call RUN,eh_frame-terminator) | $(CGREP) '1122334455667788'
9 objdump --dwarf=frames $(TMPDIR)/eh_frame-terminator | $(CGREP) 'ZERO terminator'
tests/run-make/issue-47551/eh_frame-terminator.rs created+22
...@@ -0,0 +1,22 @@
1// run-pass
2
3#[derive(Clone, Copy)]
4struct Foo {
5 array: [u64; 10240],
6}
7
8impl Foo {
9 const fn new() -> Self {
10 Self {
11 array: [0x1122_3344_5566_7788; 10240]
12 }
13 }
14}
15
16static BAR: [Foo; 10240] = [Foo::new(); 10240];
17
18fn main() {
19 let bt = std::backtrace::Backtrace::force_capture();
20 println!("Hello, world! {:?}", bt);
21 println!("{:x}", BAR[0].array[0]);
22}
tests/run-make/issue-51671/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3# ignore-windows-msvc
4
5all:
6 $(RUSTC) --emit=obj app.rs
7 nm $(TMPDIR)/app.o | $(CGREP) rust_begin_unwind
8 nm $(TMPDIR)/app.o | $(CGREP) rust_eh_personality
9 nm $(TMPDIR)/app.o | $(CGREP) __rg_oom
tests/run-make/issue-51671/app.rs created+20
...@@ -0,0 +1,20 @@
1#![crate_type = "bin"]
2#![feature(lang_items, alloc_error_handler)]
3#![no_main]
4#![no_std]
5
6use core::alloc::Layout;
7use core::panic::PanicInfo;
8
9#[panic_handler]
10fn panic(_: &PanicInfo) -> ! {
11 loop {}
12}
13
14#[lang = "eh_personality"]
15fn eh() {}
16
17#[alloc_error_handler]
18fn oom(_: Layout) -> ! {
19 loop {}
20}
tests/run-make/issue-53964/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) panic.rs
5 $(RUSTC) -C panic=abort --emit=obj app.rs -L $(TMPDIR)
tests/run-make/issue-53964/app.rs created+8
...@@ -0,0 +1,8 @@
1#![crate_type = "bin"]
2#![no_main]
3#![no_std]
4
5#![deny(unused_extern_crates)]
6
7// `panic` provides a `panic_handler` so it shouldn't trip the `unused_extern_crates` lint
8extern crate panic;
tests/run-make/issue-53964/panic.rs created+10
...@@ -0,0 +1,10 @@
1#![crate_type = "lib"]
2#![feature(panic_handler)]
3#![no_std]
4
5use core::panic::PanicInfo;
6
7#[panic_handler]
8fn panic(_: &PanicInfo) -> ! {
9 loop {}
10}
tests/run-make/issue-64153/Makefile created+26
...@@ -0,0 +1,26 @@
1include ../tools.mk
2
3# `llvm-objdump`'s output looks different on windows than on other platforms.
4# It should be enough to check on Unix platforms, so:
5# ignore-windows
6
7# Staticlibs don't include Rust object files from upstream crates if the same
8# code was already pulled into the lib via LTO. However, the bug described in
9# https://github.com/rust-lang/rust/issues/64153 lead to this exclusion not
10# working properly if the upstream crate was compiled with an explicit filename
11# (via `-o`).
12#
13# This test makes sure that functions defined in the upstream crates do not
14# appear twice in the final staticlib when listing all the symbols from it.
15
16all:
17 $(RUSTC) --crate-type rlib upstream.rs -o $(TMPDIR)/libupstream.rlib -Ccodegen-units=1
18 $(RUSTC) --crate-type staticlib downstream.rs -Clto -Ccodegen-units=1 -o $(TMPDIR)/libdownstream.a
19 # Dump all the symbols from the staticlib into `syms`
20 "$(LLVM_BIN_DIR)"/llvm-objdump -t $(TMPDIR)/libdownstream.a > $(TMPDIR)/syms
21 # Count the global instances of `issue64153_test_function`. There'll be 2
22 # if the `upstream` object file got erroneously included twice.
23 # The line we are testing for with the regex looks something like:
24 # 0000000000000000 g F .text.issue64153_test_function 00000023 issue64153_test_function
25 grep -c -e "[[:space:]]g[[:space:]]*F[[:space:]].*issue64153_test_function" $(TMPDIR)/syms > $(TMPDIR)/count
26 [ "$$(cat $(TMPDIR)/count)" -eq "1" ]
tests/run-make/issue-64153/downstream.rs created+6
...@@ -0,0 +1,6 @@
1extern crate upstream;
2
3#[no_mangle]
4pub extern "C" fn foo() {
5 print!("1 + 1 = {}", upstream::issue64153_test_function(1));
6}
tests/run-make/issue-64153/upstream.rs created+6
...@@ -0,0 +1,6 @@
1// Make this function extern "C", public, and no-mangle, so that it gets
2// exported from the downstream staticlib.
3#[no_mangle]
4pub extern "C" fn issue64153_test_function(x: u32) -> u32 {
5 x + 1
6}
tests/run-make/issue-68794-textrel-on-minimal-lib/Makefile created+18
...@@ -0,0 +1,18 @@
1# ignore-cross-compile
2# Regression test for issue #68794
3#
4# Verify that no text relocations are accidentally introduced by linking a
5# minimal rust staticlib.
6#
7# The test links a rust static library into a shared library, and checks that
8# the linker doesn't have to flag the resulting file as containing TEXTRELs.
9
10include ../tools.mk
11
12# only-linux
13
14all:
15 $(RUSTC) foo.rs
16 $(CC) bar.c $(call STATICLIB,foo) -fPIC -shared -o $(call DYLIB,bar) \
17 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
18 readelf -d $(call DYLIB,bar) | grep TEXTREL; test $$? -eq 1
tests/run-make/issue-68794-textrel-on-minimal-lib/bar.c created+6
...@@ -0,0 +1,6 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make/issue-68794-textrel-on-minimal-lib/foo.rs created+8
...@@ -0,0 +1,8 @@
1#![crate_type = "staticlib"]
2
3#[no_mangle]
4pub extern "C" fn foo(x: u32) {
5 // using the println! makes it so that enough code from the standard
6 // library is included (see issue #68794)
7 println!("foo: {}", x);
8}
tests/run-make/issue-69368/Makefile created+19
...@@ -0,0 +1,19 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test that previously triggered a linker failure with root cause
5# similar to one found in the issue #69368.
6#
7# The crate that provides oom lang item is missing some other lang
8# items. Necessary to prevent the use of start-group / end-group.
9#
10# The weak lang items are defined in a separate compilation units,
11# so that linker could omit them if not used.
12#
13# The crates that need those weak lang items are dependencies of
14# crates that provide them.
15
16all:
17 $(RUSTC) a.rs
18 $(RUSTC) b.rs
19 $(RUSTC) c.rs
tests/run-make/issue-69368/a.rs created+26
...@@ -0,0 +1,26 @@
1#![crate_type = "rlib"]
2#![feature(lang_items)]
3#![feature(panic_unwind)]
4#![no_std]
5
6extern crate panic_unwind;
7
8#[panic_handler]
9pub fn panic_handler(_: &core::panic::PanicInfo) -> ! {
10 loop {}
11}
12
13#[no_mangle]
14extern "C" fn __rust_drop_panic() -> ! {
15 loop {}
16}
17
18#[no_mangle]
19extern "C" fn __rust_foreign_exception() -> ! {
20 loop {}
21}
22
23#[lang = "eh_personality"]
24fn eh_personality() {
25 loop {}
26}
tests/run-make/issue-69368/b.rs created+8
...@@ -0,0 +1,8 @@
1#![crate_type = "rlib"]
2#![feature(alloc_error_handler)]
3#![no_std]
4
5#[alloc_error_handler]
6pub fn error_handler(_: core::alloc::Layout) -> ! {
7 panic!();
8}
tests/run-make/issue-69368/c.rs created+34
...@@ -0,0 +1,34 @@
1#![crate_type = "bin"]
2#![feature(start)]
3#![no_std]
4
5extern crate alloc;
6extern crate a;
7extern crate b;
8
9use alloc::vec::Vec;
10use core::alloc::*;
11
12struct Allocator;
13
14unsafe impl GlobalAlloc for Allocator {
15 unsafe fn alloc(&self, _: Layout) -> *mut u8 {
16 loop {}
17 }
18
19 unsafe fn dealloc(&self, _: *mut u8, _: Layout) {
20 loop {}
21 }
22}
23
24#[global_allocator]
25static ALLOCATOR: Allocator = Allocator;
26
27#[start]
28fn main(argc: isize, _argv: *const *const u8) -> isize {
29 let mut v = Vec::new();
30 for i in 0..argc {
31 v.push(i);
32 }
33 v.iter().sum()
34}
tests/run-make/issue-71519/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-msvc3# ignore-msvc
4# needs-rust-lld4# needs-rust-lld
tests/run-make/issue-7349/Makefile created+11
...@@ -0,0 +1,11 @@
1include ../tools.mk
2
3# Test to make sure that inner functions within a polymorphic outer function
4# don't get re-codegened when the outer function is monomorphized. The test
5# code monomorphizes the outer functions several times, but the magic constants
6# used in the inner functions should each appear only once in the generated IR.
7
8all:
9 $(RUSTC) foo.rs --emit=llvm-ir
10 [ "$$(grep -c 'ret i32 8675309' "$(TMPDIR)/foo.ll")" -eq "1" ]
11 [ "$$(grep -c 'ret i32 11235813' "$(TMPDIR)/foo.ll")" -eq "1" ]
tests/run-make/issue-7349/foo.rs created+22
...@@ -0,0 +1,22 @@
1fn outer<T>() {
2 #[allow(dead_code)]
3 fn inner() -> u32 {
4 8675309
5 }
6 inner();
7}
8
9extern "C" fn outer_foreign<T>() {
10 #[allow(dead_code)]
11 fn inner() -> u32 {
12 11235813
13 }
14 inner();
15}
16
17fn main() {
18 outer::<isize>();
19 outer::<usize>();
20 outer_foreign::<isize>();
21 outer_foreign::<usize>();
22}
tests/run-make/issue-83045/Makefile created+33
...@@ -0,0 +1,33 @@
1include ../tools.mk
2
3# This test case creates a situation where the crate loader would run
4# into an ICE when confronted with an invalid setup where it cannot
5# find the dependency of a direct dependency.
6#
7# The test case makes sure that the compiler produces the expected
8# error message but does not ICE immediately after.
9#
10# See https://github.com/rust-lang/rust/issues/83045
11
12# This is a platform-independent issue, no need to waste time testing
13# everywhere.
14# only-x86_64
15# only-linux
16
17# NOTE: We use BARE_RUSTC below so that the compiler can't find liba.rlib
18# If we used RUSTC the additional '-L TMPDIR' option would allow rustc to
19# actually find the crate.
20#
21# We check that we get the expected error message
22# But that we do not get an ICE
23
24all:
25 $(RUSTC) --crate-name=a --crate-type=rlib a.rs --verbose
26 $(RUSTC) --crate-name=b --crate-type=rlib --extern a=$(TMPDIR)/liba.rlib b.rs --verbose
27 $(BARE_RUSTC) --out-dir $(TMPDIR) \
28 --extern b=$(TMPDIR)/libb.rlib \
29 --crate-type=rlib \
30 --edition=2018 \
31 c.rs 2>&1 | tee $(TMPDIR)/output.txt || exit 0
32 $(CGREP) E0519 < $(TMPDIR)/output.txt
33 $(CGREP) -v "internal compiler error" < $(TMPDIR)/output.txt
tests/run-make/issue-83045/a.rs created+1
...@@ -0,0 +1 @@
1// empty on purpose
tests/run-make/issue-83045/b.rs created+1
...@@ -0,0 +1 @@
1extern crate a;
tests/run-make/issue-83045/c.rs created+1
...@@ -0,0 +1 @@
1use b as _;
tests/run-make/issue-83112-incr-test-moved-file/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-none no-std is not supported3# ignore-none no-std is not supported
4# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for 'std'4# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for 'std'
tests/run-make/issue-84395-lto-embed-bitcode/Makefile created+11
...@@ -0,0 +1,11 @@
1# needs-matching-clang
2
3# This test makes sure the embed bitcode in elf created with
4# lto-embed-bitcode=optimized is valid llvm BC module.
5
6include ../tools.mk
7
8all:
9 $(RUSTC) test.rs --target $(TARGET) -Clink-arg=-fuse-ld=lld -Clinker-plugin-lto -Clinker=$(CLANG) -Clink-arg=-Wl,--plugin-opt=-lto-embed-bitcode=optimized -Zemit-thin-lto=no
10 $(LLVM_BIN_DIR)/objcopy --dump-section .llvmbc=$(TMPDIR)/test.bc $(TMPDIR)/test
11 $(LLVM_BIN_DIR)/llvm-dis $(TMPDIR)/test.bc
tests/run-make/issue-84395-lto-embed-bitcode/test.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 println!("Hello World!");
3}
tests/run-make/issue-85019-moved-src-dir/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3INCR=$(TMPDIR)/incr3INCR=$(TMPDIR)/incr
4FIRST_SRC=$(TMPDIR)/first_src4FIRST_SRC=$(TMPDIR)/first_src
tests/run-make/issue-85401-static-mir/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# Regression test for issue #854013# Regression test for issue #85401
4# Verify that we do not ICE when trying to access MIR for statics,4# Verify that we do not ICE when trying to access MIR for statics,
tests/run-make/issue-85441/Makefile+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1# only-windows-msvc1# only-windows-msvc
22
3include ../../run-make-fulldeps/tools.mk3include ../tools.mk
44
5# Tests that WS2_32.dll is not unnecessarily linked, see issue #854415# Tests that WS2_32.dll is not unnecessarily linked, see issue #85441
66
tests/run-make/issue-88756-default-output/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 $(BARE_RUSTDOC) 2>&1 | sed -E 's@/nightly/|/beta/|/stable/|/1\.[0-9]+\.[0-9]+/@/$$CHANNEL/@g' | diff - output-default.stdout4 $(BARE_RUSTDOC) 2>&1 | sed -E 's@/nightly/|/beta/|/stable/|/1\.[0-9]+\.[0-9]+/@/$$CHANNEL/@g' | diff - output-default.stdout
tests/run-make/issue-96498/Makefile+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1# only-windows1# only-windows
2# needs-rust-lld2# needs-rust-lld
33
4include ../../run-make-fulldeps/tools.mk4include ../tools.mk
55
6# Ensure that LLD can link6# Ensure that LLD can link
7all:7all:
tests/run-make/issue-97463-abi-param-passing/Makefile created+15
...@@ -0,0 +1,15 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-msvc
5
6# The issue exercised by this test, rust-lang/rust#97463, explicitly needs `-O`
7# flags (like `-O3`) to reproduce. Thus, we call $(CC) instead of nicer
8# alternatives provided by tools.mk like using `COMPILE_OBJ` or using a
9# `NATIVE_STATICLIB` dependency.
10
11all:
12 $(CC) -c -O3 -o $(TMPDIR)/bad.o bad.c
13 $(AR) rcs $(TMPDIR)/libbad.a $(TMPDIR)/bad.o
14 $(RUSTC) param_passing.rs -L$(TMPDIR) -lbad -C opt-level=3
15 $(call RUN,param_passing)
tests/run-make/issue-97463-abi-param-passing/bad.c created+24
...@@ -0,0 +1,24 @@
1#include <stdlib.h>
2#include <stdint.h>
3#include <stdio.h>
4
5
6struct bloc {
7 uint16_t a;
8 uint16_t b;
9 uint16_t c;
10};
11
12uint16_t c_read_value(uint32_t a, uint32_t b, uint32_t c) {
13 struct bloc *data = malloc(sizeof(struct bloc));
14
15 data->a = a & 0xFFFF;
16 data->b = b & 0xFFFF;
17 data->c = c & 0xFFFF;
18
19 printf("C struct: a = %u, b = %u, c = %u\n",
20 (unsigned) data->a, (unsigned) data->b, (unsigned) data->c);
21 printf("C function returns %u\n", (unsigned) data->b);
22
23 return data->b; /* leak data */
24}
tests/run-make/issue-97463-abi-param-passing/param_passing.rs created+38
...@@ -0,0 +1,38 @@
1// NOTE: Exposing the bug encoded in this test is sensitive to
2// LLVM optimization choices. See additional note below for an
3// example.
4
5#[link(name = "bad")]
6extern "C" {
7 pub fn c_read_value(a: u32, b: u32, c: u32) -> u16;
8}
9
10fn main() {
11 const C1: usize = 0x327b23c6;
12 const C2: usize = C1 & 0xFFFF;
13
14 let r1: usize = 0x0;
15 let r2: usize = C1;
16 let r3: usize = 0x0;
17 let value: u16 = unsafe { c_read_value(r1 as u32, r2 as u32, r3 as u32) };
18
19 // NOTE: as an example of the sensitivity of this test to optimization choices,
20 // uncommenting this block of code makes the bug go away on pnkfelix's machine.
21 // (But observing via `dbg!` doesn't hide the bug. At least sometimes.)
22 /*
23 println!("{}", value);
24 println!("{}", value as usize);
25 println!("{}", usize::from(value));
26 println!("{}", (value as usize) & 0xFFFF);
27 */
28
29 let d1 = value;
30 let d2 = value as usize;
31 let d3 = usize::from(value);
32 let d4 = (value as usize) & 0xFFFF;
33
34 let d = (&d1, &d2, &d3, &d4);
35 let d_ = (d1, d2, d3, d4);
36
37 assert_eq!(((&(C2 as u16), &C2, &C2, &C2), (C2 as u16, C2, C2, C2)), (d, d_));
38}
tests/run-make/issue64319/Makefile created+40
...@@ -0,0 +1,40 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Different optimization levels imply different values for `-Zshare-generics`,
5# so try out a whole bunch of combinations to make sure everything is compatible
6all:
7 # First up, try some defaults
8 $(RUSTC) --crate-type rlib foo.rs
9 $(RUSTC) --crate-type dylib bar.rs -C opt-level=3
10
11 # Next try mixing up some things explicitly
12 $(RUSTC) --crate-type rlib foo.rs -Z share-generics=no
13 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
14 $(RUSTC) --crate-type rlib foo.rs -Z share-generics=no
15 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
16 $(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes
17 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
18 $(RUSTC) --crate-type rlib foo.rs -Z share-generics=yes
19 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
20
21 # Now combine a whole bunch of options together
22 $(RUSTC) --crate-type rlib foo.rs
23 $(RUSTC) --crate-type dylib bar.rs
24 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=no
25 $(RUSTC) --crate-type dylib bar.rs -Z share-generics=yes
26 $(RUSTC) --crate-type dylib bar.rs -C opt-level=1
27 $(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=no
28 $(RUSTC) --crate-type dylib bar.rs -C opt-level=1 -Z share-generics=yes
29 $(RUSTC) --crate-type dylib bar.rs -C opt-level=2
30 $(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=no
31 $(RUSTC) --crate-type dylib bar.rs -C opt-level=2 -Z share-generics=yes
32 $(RUSTC) --crate-type dylib bar.rs -C opt-level=3
33 $(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=no
34 $(RUSTC) --crate-type dylib bar.rs -C opt-level=3 -Z share-generics=yes
35 $(RUSTC) --crate-type dylib bar.rs -C opt-level=s
36 $(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=no
37 $(RUSTC) --crate-type dylib bar.rs -C opt-level=s -Z share-generics=yes
38 $(RUSTC) --crate-type dylib bar.rs -C opt-level=z
39 $(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=no
40 $(RUSTC) --crate-type dylib bar.rs -C opt-level=z -Z share-generics=yes
tests/run-make/issue64319/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3pub fn bar() {
4 foo::foo();
5}
tests/run-make/issue64319/foo.rs created+9
...@@ -0,0 +1,9 @@
1pub fn foo() {
2 bar::<usize>();
3}
4
5pub fn bar<T>() {
6 baz();
7}
8
9fn baz() {}
tests/run-make/jobserver-error/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-linux3# only-linux
44
tests/run-make/libs-through-symlinks/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows
5
6NAME := $(shell $(RUSTC) --print file-names foo.rs)
7
8all:
9 mkdir -p $(TMPDIR)/outdir
10 $(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME)
11 ln -nsf outdir/$(NAME) $(TMPDIR)
12 RUSTC_LOG=rustc_metadata::loader $(RUSTC) bar.rs
tests/run-make/libs-through-symlinks/bar.rs created+3
...@@ -0,0 +1,3 @@
1extern crate foo;
2
3fn main() {}
tests/run-make/libs-through-symlinks/foo.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "rlib"]
2#![crate_name = "foo"]
tests/run-make/libtest-json/Makefile created+19
...@@ -0,0 +1,19 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test expected libtest's JSON output
5
6OUTPUT_FILE_DEFAULT := $(TMPDIR)/libtest-json-output-default.json
7OUTPUT_FILE_STDOUT_SUCCESS := $(TMPDIR)/libtest-json-output-stdout-success.json
8
9all: f.rs validate_json.py output-default.json output-stdout-success.json
10 $(RUSTC) --test f.rs
11 RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE_DEFAULT) || true
12 RUST_BACKTRACE=0 $(call RUN,f) -Z unstable-options --test-threads=1 --format=json --show-output > $(OUTPUT_FILE_STDOUT_SUCCESS) || true
13
14 cat $(OUTPUT_FILE_DEFAULT) | "$(PYTHON)" validate_json.py
15 cat $(OUTPUT_FILE_STDOUT_SUCCESS) | "$(PYTHON)" validate_json.py
16
17 # Normalize the actual output and compare to expected output file
18 cat $(OUTPUT_FILE_DEFAULT) | sed 's/"exec_time": [0-9.]*/"exec_time": $$TIME/' | diff output-default.json -
19 cat $(OUTPUT_FILE_STDOUT_SUCCESS) | sed 's/"exec_time": [0-9.]*/"exec_time": $$TIME/' | diff output-stdout-success.json -
tests/run-make/libtest-json/f.rs created+22
...@@ -0,0 +1,22 @@
1#[test]
2fn a() {
3 println!("print from successful test");
4 // Should pass
5}
6
7#[test]
8fn b() {
9 assert!(false);
10}
11
12#[test]
13#[should_panic]
14fn c() {
15 assert!(false);
16}
17
18#[test]
19#[ignore = "msg"]
20fn d() {
21 assert!(false);
22}
tests/run-make/libtest-json/output-default.json created+10
...@@ -0,0 +1,10 @@
1{ "type": "suite", "event": "started", "test_count": 4 }
2{ "type": "test", "event": "started", "name": "a" }
3{ "type": "test", "name": "a", "event": "ok" }
4{ "type": "test", "event": "started", "name": "b" }
5{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
6{ "type": "test", "event": "started", "name": "c" }
7{ "type": "test", "name": "c", "event": "ok" }
8{ "type": "test", "event": "started", "name": "d" }
9{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
10{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
tests/run-make/libtest-json/output-stdout-success.json created+10
...@@ -0,0 +1,10 @@
1{ "type": "suite", "event": "started", "test_count": 4 }
2{ "type": "test", "event": "started", "name": "a" }
3{ "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" }
4{ "type": "test", "event": "started", "name": "b" }
5{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
6{ "type": "test", "event": "started", "name": "c" }
7{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at 'assertion failed: false', f.rs:15:5\n" }
8{ "type": "test", "event": "started", "name": "d" }
9{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
10{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
tests/run-make/libtest-json/validate_json.py created+8
...@@ -0,0 +1,8 @@
1#!/usr/bin/env python
2
3import sys
4import json
5
6# Try to decode line in order to ensure it is a valid JSON document
7for line in sys.stdin:
8 json.loads(line)
tests/run-make/libtest-thread-limit/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-linux3# only-linux
44
tests/run-make/link-arg/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" --print link-args
3
4all:
5 $(RUSTC) $(RUSTC_FLAGS) empty.rs | $(CGREP) lfoo lbar
tests/run-make/link-arg/empty.rs created+1
...@@ -0,0 +1 @@
1fn main() { }
tests/run-make/link-args-order/Makefile created+10
...@@ -0,0 +1,10 @@
1# ignore-msvc
2
3include ../tools.mk
4
5RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args="d e" -C link-arg=f
6RUSTC_FLAGS_PRE = -C linker-flavor=ld -Z pre-link-arg=a -Z pre-link-args="b c" -Z pre-link-args="d e" -Z pre-link-arg=f
7
8all:
9 $(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
10 $(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
tests/run-make/link-args-order/empty.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/link-cfg/Makefile created+23
...@@ -0,0 +1,23 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3)
5 ls $(TMPDIR)
6 $(BARE_RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static
7
8 $(RUSTC) no-deps.rs --cfg foo
9 $(call RUN,no-deps)
10 $(RUSTC) no-deps.rs --cfg bar
11 $(call RUN,no-deps)
12
13 $(RUSTC) dep.rs
14 $(RUSTC) with-deps.rs --cfg foo
15 $(call RUN,with-deps)
16 $(RUSTC) with-deps.rs --cfg bar
17 $(call RUN,with-deps)
18
19 $(RUSTC) dep-with-staticlib.rs
20 $(RUSTC) with-staticlib-deps.rs --cfg foo
21 $(call RUN,with-staticlib-deps)
22 $(RUSTC) with-staticlib-deps.rs --cfg bar
23 $(call RUN,with-staticlib-deps)
tests/run-make/link-cfg/dep-with-staticlib.rs created+8
...@@ -0,0 +1,8 @@
1#![feature(link_cfg)]
2#![crate_type = "rlib"]
3
4#[link(name = "return1", cfg(foo))]
5#[link(name = "return3", kind = "static", cfg(bar))]
6extern "C" {
7 pub fn my_function() -> i32;
8}
tests/run-make/link-cfg/dep.rs created+8
...@@ -0,0 +1,8 @@
1#![feature(link_cfg)]
2#![crate_type = "rlib"]
3
4#[link(name = "return1", cfg(foo))]
5#[link(name = "return2", cfg(bar))]
6extern "C" {
7 pub fn my_function() -> i32;
8}
tests/run-make/link-cfg/no-deps.rs created+20
...@@ -0,0 +1,20 @@
1#![feature(link_cfg)]
2
3#[link(name = "return1", cfg(foo))]
4#[link(name = "return2", cfg(bar))]
5extern "C" {
6 fn my_function() -> i32;
7}
8
9fn main() {
10 unsafe {
11 let v = my_function();
12 if cfg!(foo) {
13 assert_eq!(v, 1);
14 } else if cfg!(bar) {
15 assert_eq!(v, 2);
16 } else {
17 panic!("unknown");
18 }
19 }
20}
tests/run-make/link-cfg/return1.c created+6
...@@ -0,0 +1,6 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int my_function() {
5 return 1;
6}
tests/run-make/link-cfg/return2.c created+6
...@@ -0,0 +1,6 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int my_function() {
5 return 2;
6}
tests/run-make/link-cfg/return3.c created+6
...@@ -0,0 +1,6 @@
1#ifdef _WIN32
2__declspec(dllexport)
3#endif
4int my_function() {
5 return 3;
6}
tests/run-make/link-cfg/with-deps.rs created+14
...@@ -0,0 +1,14 @@
1extern crate dep;
2
3fn main() {
4 unsafe {
5 let v = dep::my_function();
6 if cfg!(foo) {
7 assert_eq!(v, 1);
8 } else if cfg!(bar) {
9 assert_eq!(v, 2);
10 } else {
11 panic!("unknown");
12 }
13 }
14}
tests/run-make/link-cfg/with-staticlib-deps.rs created+14
...@@ -0,0 +1,14 @@
1extern crate dep_with_staticlib;
2
3fn main() {
4 unsafe {
5 let v = dep_with_staticlib::my_function();
6 if cfg!(foo) {
7 assert_eq!(v, 1);
8 } else if cfg!(bar) {
9 assert_eq!(v, 3);
10 } else {
11 panic!("unknown");
12 }
13 }
14}
tests/run-make/link-dedup/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-msvc
2
3include ../tools.mk
4
5all:
6 $(RUSTC) depa.rs
7 $(RUSTC) depb.rs
8 $(RUSTC) depc.rs
9 $(RUSTC) empty.rs --cfg bar 2>&1 | $(CGREP) '"-ltesta" "-ltestb" "-ltesta"'
10 $(RUSTC) empty.rs 2>&1 | $(CGREP) '"-ltesta"'
11 $(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltestb"'
12 $(RUSTC) empty.rs 2>&1 | $(CGREP) -v '"-ltesta" "-ltesta" "-ltesta"'
tests/run-make/link-dedup/depa.rs created+10
...@@ -0,0 +1,10 @@
1#![crate_type = "rlib"]
2
3#[link(name = "testa")]
4extern "C" {}
5
6#[link(name = "testa")]
7extern "C" {}
8
9#[link(name = "testa")]
10extern "C" {}
tests/run-make/link-dedup/depb.rs created+8
...@@ -0,0 +1,8 @@
1#![feature(link_cfg)]
2#![crate_type = "rlib"]
3
4#[link(name = "testb", cfg(foo))]
5extern "C" {}
6
7#[link(name = "testb", cfg(bar))]
8extern "C" {}
tests/run-make/link-dedup/depc.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "rlib"]
2
3#[link(name = "testa")]
4extern "C" {}
tests/run-make/link-dedup/empty.rs created+5
...@@ -0,0 +1,5 @@
1extern crate depa;
2extern crate depb;
3extern crate depc;
4
5fn main() {}
tests/run-make/link-path-order/Makefile created+19
...@@ -0,0 +1,19 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Verifies that the -L arguments given to the linker is in the same order
5# as the -L arguments on the rustc command line.
6
7CORRECT_DIR=$(TMPDIR)/correct
8WRONG_DIR=$(TMPDIR)/wrong
9
10F := $(call NATIVE_STATICLIB_FILE,foo)
11
12all: $(call NATIVE_STATICLIB,correct) $(call NATIVE_STATICLIB,wrong)
13 mkdir -p $(CORRECT_DIR) $(WRONG_DIR)
14 mv $(call NATIVE_STATICLIB,correct) $(CORRECT_DIR)/$(F)
15 mv $(call NATIVE_STATICLIB,wrong) $(WRONG_DIR)/$(F)
16 $(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR)
17 $(call RUN,should_succeed)
18 $(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR)
19 $(call FAIL,should_fail)
tests/run-make/link-path-order/correct.c created+1
...@@ -0,0 +1 @@
1int should_return_one() { return 1; }
tests/run-make/link-path-order/main.rs created+16
...@@ -0,0 +1,16 @@
1#![feature(rustc_private)]
2
3extern crate libc;
4
5#[link(name = "foo", kind = "static")]
6extern "C" {
7 fn should_return_one() -> libc::c_int;
8}
9
10fn main() {
11 let result = unsafe { should_return_one() };
12
13 if result != 1 {
14 std::process::exit(255);
15 }
16}
tests/run-make/link-path-order/wrong.c created+1
...@@ -0,0 +1 @@
1int should_return_one() { return 0; }
tests/run-make/linkage-attr-on-static/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,foo)
5 $(RUSTC) bar.rs
6 $(call RUN,bar) || exit 1
tests/run-make/linkage-attr-on-static/bar.rs created+16
...@@ -0,0 +1,16 @@
1#![feature(linkage)]
2
3#[no_mangle]
4#[linkage = "external"]
5static BAZ: i32 = 21;
6
7#[link(name = "foo", kind = "static")]
8extern "C" {
9 fn what() -> i32;
10}
11
12fn main() {
13 unsafe {
14 assert_eq!(what(), BAZ);
15 }
16}
tests/run-make/linkage-attr-on-static/foo.c created+7
...@@ -0,0 +1,7 @@
1#include <stdint.h>
2
3extern int32_t BAZ;
4
5int32_t what() {
6 return BAZ;
7}
tests/run-make/llvm-outputs/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 echo 'fn main() {}' | $(BARE_RUSTC) - --out-dir=$(TMPDIR)/random_directory_that_does_not_exist_ir/ --emit=llvm-ir4 echo 'fn main() {}' | $(BARE_RUSTC) - --out-dir=$(TMPDIR)/random_directory_that_does_not_exist_ir/ --emit=llvm-ir
tests/run-make/long-linker-command-lines-cmd-exe/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs -g
6 cp foo.bat $(TMPDIR)/
7 OUT_DIR="$(TMPDIR)" RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo)
tests/run-make/long-linker-command-lines-cmd-exe/foo.bat created+1
...@@ -0,0 +1 @@
1%MY_LINKER% %*
tests/run-make/long-linker-command-lines-cmd-exe/foo.rs created+101
...@@ -0,0 +1,101 @@
1// Like the `long-linker-command-lines` test this test attempts to blow
2// a command line limit for running the linker. Unlike that test, however,
3// this test is testing `cmd.exe` specifically rather than the OS.
4//
5// Unfortunately `cmd.exe` has a 8192 limit which is relatively small
6// in the grand scheme of things and anyone sripting rustc's linker
7// is probably using a `*.bat` script and is likely to hit this limit.
8//
9// This test uses a `foo.bat` script as the linker which just simply
10// delegates back to this program. The compiler should use a lower
11// limit for arguments before passing everything via `@`, which
12// means that everything should still succeed here.
13
14use std::env;
15use std::fs::{self, File};
16use std::io::{BufWriter, Write, Read};
17use std::path::PathBuf;
18use std::process::Command;
19
20fn main() {
21 if !cfg!(windows) {
22 return
23 }
24
25 let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
26 let ok = tmpdir.join("ok");
27 let not_ok = tmpdir.join("not_ok");
28 if env::var("YOU_ARE_A_LINKER").is_ok() {
29 match env::args_os().find(|a| a.to_string_lossy().contains("@")) {
30 Some(file) => {
31 let file = file.to_str().unwrap();
32 fs::copy(&file[1..], &ok).unwrap();
33 }
34 None => { File::create(&not_ok).unwrap(); }
35 }
36 return
37 }
38
39 let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
40 let me = env::current_exe().unwrap();
41 let bat = me.parent()
42 .unwrap()
43 .join("foo.bat");
44 let bat_linker = format!("linker={}", bat.display());
45 for i in (1..).map(|i| i * 10) {
46 println!("attempt: {}", i);
47
48 let file = tmpdir.join("bar.rs");
49 let mut f = BufWriter::new(File::create(&file).unwrap());
50 let mut lib_name = String::new();
51 for _ in 0..i {
52 lib_name.push_str("foo");
53 }
54 for j in 0..i {
55 writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap();
56 }
57 writeln!(f, "extern {{}}\nfn main() {{}}").unwrap();
58 f.into_inner().unwrap();
59
60 drop(fs::remove_file(&ok));
61 drop(fs::remove_file(&not_ok));
62 let status = Command::new(&rustc)
63 .arg(&file)
64 .arg("-C").arg(&bat_linker)
65 .arg("--out-dir").arg(&tmpdir)
66 .env("YOU_ARE_A_LINKER", "1")
67 .env("MY_LINKER", &me)
68 .status()
69 .unwrap();
70
71 if !status.success() {
72 panic!("rustc didn't succeed: {}", status);
73 }
74
75 if !ok.exists() {
76 assert!(not_ok.exists());
77 continue
78 }
79
80 let mut contents = Vec::new();
81 File::open(&ok).unwrap().read_to_end(&mut contents).unwrap();
82
83 for j in 0..i {
84 let exp = format!("{}{}", lib_name, j);
85 let exp = if cfg!(target_env = "msvc") {
86 let mut out = Vec::with_capacity(exp.len() * 2);
87 for c in exp.encode_utf16() {
88 // encode in little endian
89 out.push(c as u8);
90 out.push((c >> 8) as u8);
91 }
92 out
93 } else {
94 exp.into_bytes()
95 };
96 assert!(contents.windows(exp.len()).any(|w| w == &exp[..]));
97 }
98
99 break
100 }
101}
tests/run-make/long-linker-command-lines/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs -g -O
6 RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo)
tests/run-make/long-linker-command-lines/foo.rs created+106
...@@ -0,0 +1,106 @@
1// This is a test which attempts to blow out the system limit with how many
2// arguments can be passed to a process. This'll successively call rustc with
3// larger and larger argument lists in an attempt to find one that's way too
4// big for the system at hand. This file itself is then used as a "linker" to
5// detect when the process creation succeeds.
6//
7// Eventually we should see an argument that looks like `@` as we switch from
8// passing literal arguments to passing everything in the file.
9
10use std::collections::HashSet;
11use std::env;
12use std::fs::{self, File};
13use std::io::{BufWriter, Write};
14use std::path::{Path, PathBuf};
15use std::process::Command;
16
17fn write_test_case(file: &Path, n: usize) -> HashSet<String> {
18 let mut libs = HashSet::new();
19 let mut f = BufWriter::new(File::create(&file).unwrap());
20 let mut prefix = String::new();
21 for _ in 0..n {
22 prefix.push_str("foo");
23 }
24 for i in 0..n {
25 writeln!(f, "#[link(name = \"S{}{}S\")]", prefix, i).unwrap();
26 libs.insert(format!("{}{}", prefix, i));
27 }
28 writeln!(f, "extern \"C\" {{}}\nfn main() {{}}").unwrap();
29 f.into_inner().unwrap();
30
31 libs
32}
33
34fn read_linker_args(path: &Path) -> String {
35 let contents = fs::read(path).unwrap();
36 if cfg!(target_env = "msvc") {
37 let mut i = contents.chunks(2).map(|c| {
38 c[0] as u16 | ((c[1] as u16) << 8)
39 });
40 assert_eq!(i.next(), Some(0xfeff), "Expected UTF-16 BOM");
41 String::from_utf16(&i.collect::<Vec<u16>>()).unwrap()
42 } else {
43 String::from_utf8(contents).unwrap()
44 }
45}
46
47fn main() {
48 let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap());
49 let ok = tmpdir.join("ok");
50 if env::var("YOU_ARE_A_LINKER").is_ok() {
51 if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) {
52 let file = file.to_str().expect("non-utf8 file argument");
53 fs::copy(&file[1..], &ok).unwrap();
54 }
55 return
56 }
57
58 let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
59 let me_as_linker = format!("linker={}", env::current_exe().unwrap().display());
60 for i in (1..).map(|i| i * 100) {
61 println!("attempt: {}", i);
62 let file = tmpdir.join("bar.rs");
63 let mut expected_libs = write_test_case(&file, i);
64
65 drop(fs::remove_file(&ok));
66 let output = Command::new(&rustc)
67 .arg(&file)
68 .arg("-C").arg(&me_as_linker)
69 .arg("--out-dir").arg(&tmpdir)
70 .env("YOU_ARE_A_LINKER", "1")
71 .output()
72 .unwrap();
73
74 if !output.status.success() {
75 let stderr = String::from_utf8_lossy(&output.stderr);
76 panic!("status: {}\nstdout:\n{}\nstderr:\n{}",
77 output.status,
78 String::from_utf8_lossy(&output.stdout),
79 stderr.lines().map(|l| {
80 if l.len() > 200 {
81 format!("{}...\n", &l[..200])
82 } else {
83 format!("{}\n", l)
84 }
85 }).collect::<String>());
86 }
87
88 if !ok.exists() {
89 continue
90 }
91
92 let linker_args = read_linker_args(&ok);
93 for arg in linker_args.split('S') {
94 expected_libs.remove(arg);
95 }
96
97 assert!(
98 expected_libs.is_empty(),
99 "expected but missing libraries: {:#?}\nlinker arguments: \n{}",
100 expected_libs,
101 linker_args,
102 );
103
104 break
105 }
106}
tests/run-make/longjmp-across-rust/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,foo)
5 $(RUSTC) main.rs
6 $(call RUN,main)
tests/run-make/longjmp-across-rust/foo.c created+18
...@@ -0,0 +1,18 @@
1#include <assert.h>
2#include <setjmp.h>
3
4static jmp_buf ENV;
5
6extern void test_middle();
7
8void test_start(void(*f)()) {
9 if (setjmp(ENV) != 0)
10 return;
11 f();
12 assert(0);
13}
14
15void test_end() {
16 longjmp(ENV, 1);
17 assert(0);
18}
tests/run-make/longjmp-across-rust/main.rs created+29
...@@ -0,0 +1,29 @@
1#[link(name = "foo", kind = "static")]
2extern "C" {
3 fn test_start(f: extern "C" fn());
4 fn test_end();
5}
6
7fn main() {
8 unsafe {
9 test_start(test_middle);
10 }
11}
12
13struct A;
14
15impl Drop for A {
16 fn drop(&mut self) {}
17}
18
19extern "C" fn test_middle() {
20 let _a = A;
21 foo();
22}
23
24fn foo() {
25 let _a = A;
26 unsafe {
27 test_end();
28 }
29}
tests/run-make/ls-metadata/Makefile created+8
...@@ -0,0 +1,8 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs
6 $(RUSTC) -Z ls $(TMPDIR)/foo
7 touch $(TMPDIR)/bar
8 $(RUSTC) -Z ls $(TMPDIR)/bar
tests/run-make/ls-metadata/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/lto-dylib-dep/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test that we don't run into an assertion when using a Rust dylib dependency
5# while compiling with full LTO.
6# See https://github.com/rust-lang/rust/issues/59137
7
8all:
9 $(RUSTC) a_dylib.rs --crate-type=dylib -C prefer-dynamic
10 $(RUSTC) main.rs -C lto
11 $(call RUN,main)
tests/run-make/lto-dylib-dep/a_dylib.rs created+3
...@@ -0,0 +1,3 @@
1pub fn foo() {
2 println!("bar");
3}
tests/run-make/lto-dylib-dep/main.rs created+5
...@@ -0,0 +1,5 @@
1extern crate a_dylib;
2
3fn main() {
4 a_dylib::foo();
5}
tests/run-make/lto-empty/Makefile created+13
...@@ -0,0 +1,13 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: cdylib-fat cdylib-thin
5
6cdylib-fat:
7 $(RUSTC) lib.rs -C lto=fat -C opt-level=3 -C incremental=$(TMPDIR)/inc-fat
8 $(RUSTC) lib.rs -C lto=fat -C opt-level=3 -C incremental=$(TMPDIR)/inc-fat
9
10cdylib-thin:
11 $(RUSTC) lib.rs -C lto=thin -C opt-level=3 -C incremental=$(TMPDIR)/inc-thin
12 $(RUSTC) lib.rs -C lto=thin -C opt-level=3 -C incremental=$(TMPDIR)/inc-thin
13
tests/run-make/lto-empty/lib.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "cdylib"]
tests/run-make/lto-no-link-whole-rlib/Makefile created+9
...@@ -0,0 +1,9 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar)
5 $(RUSTC) lib1.rs
6 $(RUSTC) lib2.rs
7 $(RUSTC) main.rs -Clto
8 $(call RUN,main)
9
tests/run-make/lto-no-link-whole-rlib/bar.c created+3
...@@ -0,0 +1,3 @@
1int foo() {
2 return 2;
3}
tests/run-make/lto-no-link-whole-rlib/foo.c created+3
...@@ -0,0 +1,3 @@
1int foo() {
2 return 1;
3}
tests/run-make/lto-no-link-whole-rlib/lib1.rs created+10
...@@ -0,0 +1,10 @@
1#![crate_type = "rlib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {
5 fn foo() -> i32;
6}
7
8pub fn foo1() -> i32 {
9 unsafe { foo() }
10}
tests/run-make/lto-no-link-whole-rlib/lib2.rs created+12
...@@ -0,0 +1,12 @@
1#![crate_type = "rlib"]
2
3extern crate lib1;
4
5#[link(name = "bar", kind = "static")]
6extern "C" {
7 fn foo() -> i32;
8}
9
10pub fn foo2() -> i32 {
11 unsafe { foo() }
12}
tests/run-make/lto-no-link-whole-rlib/main.rs created+7
...@@ -0,0 +1,7 @@
1extern crate lib1;
2extern crate lib2;
3
4fn main() {
5 assert_eq!(lib1::foo1(), 2);
6 assert_eq!(lib2::foo2(), 2);
7}
tests/run-make/lto-readonly-lib/Makefile created+13
...@@ -0,0 +1,13 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) lib.rs
6
7 # the compiler needs to copy and modify the rlib file when performing
8 # LTO, so we should ensure that it can cope with the original rlib
9 # being read-only.
10 chmod 444 $(TMPDIR)/*.rlib
11
12 $(RUSTC) main.rs -C lto
13 $(call RUN,main)
tests/run-make/lto-readonly-lib/lib.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "rlib"]
tests/run-make/lto-readonly-lib/main.rs created+3
...@@ -0,0 +1,3 @@
1extern crate lib;
2
3fn main() {}
tests/run-make/lto-smoke-c/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Apparently older versions of GCC segfault if -g is passed...
5CC := $(CC:-g=)
6
7all:
8 $(RUSTC) foo.rs -C lto
9 $(CC) bar.c $(call STATICLIB,foo) \
10 $(call OUT_EXE,bar) \
11 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
12 $(call RUN,bar)
tests/run-make/lto-smoke-c/bar.c created+6
...@@ -0,0 +1,6 @@
1void foo();
2
3int main() {
4 foo();
5 return 0;
6}
tests/run-make/lto-smoke-c/foo.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "staticlib"]
2
3#[no_mangle]
4pub extern "C" fn foo() {}
tests/run-make/lto-smoke/Makefile created+31
...@@ -0,0 +1,31 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: noparam bool_true bool_false thin fat
5
6noparam:
7 $(RUSTC) lib.rs
8 $(RUSTC) main.rs -C lto
9 $(call RUN,main)
10
11bool_true:
12 $(RUSTC) lib.rs
13 $(RUSTC) main.rs -C lto=yes
14 $(call RUN,main)
15
16
17bool_false:
18 $(RUSTC) lib.rs
19 $(RUSTC) main.rs -C lto=off
20 $(call RUN,main)
21
22thin:
23 $(RUSTC) lib.rs
24 $(RUSTC) main.rs -C lto=thin
25 $(call RUN,main)
26
27fat:
28 $(RUSTC) lib.rs
29 $(RUSTC) main.rs -C lto=fat
30 $(call RUN,main)
31
tests/run-make/lto-smoke/lib.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "rlib"]
tests/run-make/lto-smoke/main.rs created+3
...@@ -0,0 +1,3 @@
1extern crate lib;
2
3fn main() {}
tests/run-make/macos-deployment-target/Makefile+1-1
...@@ -4,7 +4,7 @@...@@ -4,7 +4,7 @@
4# This is important since its a compatibility hazard. The linker will4# This is important since its a compatibility hazard. The linker will
5# generate load commands differently based on what minimum OS it can assume.5# generate load commands differently based on what minimum OS it can assume.
66
7include ../../run-make-fulldeps/tools.mk7include ../tools.mk
88
9ifeq ($(strip $(shell uname -m)),arm64)9ifeq ($(strip $(shell uname -m)),arm64)
10 GREP_PATTERN = "minos 11.0"10 GREP_PATTERN = "minos 11.0"
tests/run-make/macos-fat-archive/Makefile+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1# only-macos1# only-macos
22
3-include ../../run-make-fulldeps/tools.mk3include ../tools.mk
44
5"$(TMPDIR)"/libnative-library.a: native-library.c5"$(TMPDIR)"/libnative-library.a: native-library.c
6 $(CC) -arch arm64 -arch x86_64 native-library.c -c -o "$(TMPDIR)"/native-library.o6 $(CC) -arch arm64 -arch x86_64 native-library.c -c -o "$(TMPDIR)"/native-library.o
tests/run-make/manual-crate-name/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --crate-name foo bar.rs
5 rm $(TMPDIR)/libfoo.rlib
tests/run-make/manual-crate-name/bar.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "rlib"]
tests/run-make/manual-link/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(TMPDIR)/libbar.a
5 $(RUSTC) foo.rs -lstatic=bar
6 $(RUSTC) main.rs
7 $(call RUN,main)
tests/run-make/manual-link/bar.c created+1
...@@ -0,0 +1 @@
1void bar() {}
tests/run-make/manual-link/foo.c created+1
...@@ -0,0 +1 @@
1void bar() {}
tests/run-make/manual-link/foo.rs created+11
...@@ -0,0 +1,11 @@
1#![crate_type = "rlib"]
2
3extern "C" {
4 fn bar();
5}
6
7pub fn foo() {
8 unsafe {
9 bar();
10 }
11}
tests/run-make/manual-link/main.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::foo();
5}
tests/run-make/many-crates-but-no-match/Makefile created+35
...@@ -0,0 +1,35 @@
1include ../tools.mk
2
3# Modelled after ui/changing-crates.rs test, but this one puts
4# more than one (mismatching) candidate crate into the search path,
5# which did not appear directly expressible in UI testing infrastructure.
6#
7# Note that we move the built libraries into target direcrtories rather than
8# use the `--out-dir` option because the `../tools.mk` file already bakes a
9# use of `--out-dir` into the definition of $(RUSTC).
10
11A1=$(TMPDIR)/a1
12A2=$(TMPDIR)/a2
13A3=$(TMPDIR)/a3
14
15# A hack to match distinct lines of output from a single run.
16LOG=$(TMPDIR)/log.txt
17
18all:
19 mkdir -p $(A1) $(A2) $(A3)
20 $(RUSTC) --crate-type=rlib crateA1.rs
21 mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1)
22 $(RUSTC) --crate-type=rlib -L $(A1) crateB.rs
23 $(RUSTC) --crate-type=rlib crateA2.rs
24 mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2)
25 $(RUSTC) --crate-type=rlib crateA3.rs
26 mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3)
27 # Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match
28 $(RUSTC) -L $(A2) -L $(A3) crateC.rs >$(LOG) 2>&1 || true
29 $(CGREP) \
30 'found possibly newer version of crate `crateA` which `crateB` depends on' \
31 'note: perhaps that crate needs to be recompiled?' \
32 'crate `crateA`:' \
33 'crate `crateB`:' \
34 < $(LOG)
35 # the 'crate `crateA`' will match two entries.
tests/run-make/many-crates-but-no-match/crateA1.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_name="crateA"]
2
3// Base crate
4pub fn func<T>() {}
tests/run-make/many-crates-but-no-match/crateA2.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_name="crateA"]
2
3// Base crate
4pub fn func<T>() { println!("hello"); }
tests/run-make/many-crates-but-no-match/crateA3.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_name="crateA"]
2
3// Base crate
4pub fn foo<T>() { println!("world!"); }
tests/run-make/many-crates-but-no-match/crateB.rs created+1
...@@ -0,0 +1 @@
1extern crate crateA;
tests/run-make/many-crates-but-no-match/crateC.rs created+3
...@@ -0,0 +1,3 @@
1extern crate crateB;
2
3fn main() {}
tests/run-make/metadata-flag-frobs-symbols/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs -C metadata=a -C extra-filename=-a
6 $(RUSTC) foo.rs -C metadata=b -C extra-filename=-b
7 $(RUSTC) bar.rs \
8 --extern foo1=$(TMPDIR)/libfoo-a.rlib \
9 --extern foo2=$(TMPDIR)/libfoo-b.rlib \
10 --print link-args
11 $(call RUN,bar)
tests/run-make/metadata-flag-frobs-symbols/bar.rs created+8
...@@ -0,0 +1,8 @@
1extern crate foo1;
2extern crate foo2;
3
4fn main() {
5 let a = foo1::foo();
6 let b = foo2::foo();
7 assert!(a as *const _ != b as *const _);
8}
tests/run-make/metadata-flag-frobs-symbols/foo.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_name = "foo"]
2#![crate_type = "rlib"]
3
4static FOO: usize = 3;
5
6pub fn foo() -> &'static usize { &FOO }
tests/run-make/min-global-align/Makefile created+22
...@@ -0,0 +1,22 @@
1include ../tools.mk
2
3# only-linux
4
5# This tests ensure that global variables respect the target minimum alignment.
6# The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have
7# type-alignment of 1, but some targets require greater global alignment.
8
9SRC = min_global_align.rs
10LL = $(TMPDIR)/min_global_align.ll
11
12all:
13# Most targets are happy with default alignment -- take i686 for example.
14ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
15 $(RUSTC) --target=i686-unknown-linux-gnu --emit=llvm-ir $(SRC)
16 [ "$$(grep -c 'align 1' "$(LL)")" -eq "3" ]
17endif
18# SystemZ requires even alignment for PC-relative addressing.
19ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz)
20 $(RUSTC) --target=s390x-unknown-linux-gnu --emit=llvm-ir $(SRC)
21 [ "$$(grep -c 'align 2' "$(LL)")" -eq "3" ]
22endif
tests/run-make/min-global-align/min_global_align.rs created+32
...@@ -0,0 +1,32 @@
1#![feature(no_core, lang_items)]
2#![crate_type = "rlib"]
3#![no_core]
4
5pub static STATIC_BOOL: bool = true;
6
7pub static mut STATIC_MUT_BOOL: bool = true;
8
9const CONST_BOOL: bool = true;
10pub static CONST_BOOL_REF: &'static bool = &CONST_BOOL;
11
12#[lang = "sized"]
13trait Sized {}
14
15#[lang = "copy"]
16trait Copy {}
17impl Copy for bool {}
18impl Copy for &bool {}
19
20#[lang = "freeze"]
21trait Freeze {}
22
23// No `UnsafeCell`, so everything is `Freeze`.
24impl<T: ?Sized> Freeze for T {}
25
26#[lang = "sync"]
27trait Sync {}
28impl Sync for bool {}
29impl Sync for &'static bool {}
30
31#[lang = "drop_in_place"]
32pub unsafe fn drop_in_place<T: ?Sized>(_: *mut T) {}
tests/run-make/mingw-export-call-convention/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3# only-windows-gnu
4
5all:
6 $(RUSTC) foo.rs
7 # FIXME: we should make sure __stdcall calling convention is used here
8 # but that only works with LLD right now
9 nm -g "$(call IMPLIB,foo)" | $(CGREP) bar
tests/run-make/mingw-export-call-convention/foo.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "cdylib"]
2
3#[no_mangle]
4pub extern "system" fn bar() {}
tests/run-make/mismatching-target-triples/Makefile created+11
...@@ -0,0 +1,11 @@
1include ../tools.mk
2
3# Issue #10814
4#
5# these are no_std to avoid having to have the standard library or any
6# linkers/assemblers for the relevant platform
7
8all:
9 $(RUSTC) foo.rs --target=i686-unknown-linux-gnu
10 $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \
11 | $(CGREP) 'couldn'"'"'t find crate `foo` with expected target triple x86_64-unknown-linux-gnu'
tests/run-make/mismatching-target-triples/bar.rs created+3
...@@ -0,0 +1,3 @@
1#![feature(no_core)]
2#![no_core]
3extern crate foo;
tests/run-make/mismatching-target-triples/foo.rs created+3
...@@ -0,0 +1,3 @@
1#![feature(no_core)]
2#![no_core]
3#![crate_type = "lib"]
tests/run-make/missing-crate-dependency/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --crate-type=rlib crateA.rs
5 $(RUSTC) --crate-type=rlib crateB.rs
6 $(call REMOVE_RLIBS,crateA)
7 # Ensure crateC fails to compile since dependency crateA is missing
8 $(RUSTC) crateC.rs 2>&1 | \
9 $(CGREP) 'can'"'"'t find crate for `crateA` which `crateB` depends on'
tests/run-make/missing-crate-dependency/crateA.rs created+2
...@@ -0,0 +1,2 @@
1// Base crate
2pub fn func() {}
tests/run-make/missing-crate-dependency/crateB.rs created+1
...@@ -0,0 +1 @@
1extern crate crateA;
tests/run-make/missing-crate-dependency/crateC.rs created+3
...@@ -0,0 +1,3 @@
1extern crate crateB;
2
3fn main() {}
tests/run-make/mixing-deps/Makefile created+8
...@@ -0,0 +1,8 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) both.rs -C prefer-dynamic
6 $(RUSTC) dylib.rs -C prefer-dynamic
7 $(RUSTC) prog.rs
8 $(call RUN,prog)
tests/run-make/mixing-deps/both.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "rlib"]
2#![crate_type = "dylib"]
3
4pub static foo: isize = 4;
tests/run-make/mixing-deps/dylib.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_type = "dylib"]
2extern crate both;
3
4use std::mem;
5
6pub fn addr() -> usize { unsafe { mem::transmute(&both::foo) } }
tests/run-make/mixing-deps/prog.rs created+9
...@@ -0,0 +1,9 @@
1extern crate dylib;
2extern crate both;
3
4use std::mem;
5
6fn main() {
7 assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) },
8 dylib::addr());
9}
tests/run-make/mixing-formats/Makefile created+75
...@@ -0,0 +1,75 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Testing various mixings of rlibs and dylibs. Makes sure that it's possible to
5# link an rlib to a dylib. The dependency tree among the file looks like:
6#
7# foo
8# / \
9# bar1 bar2
10# / \ /
11# baz baz2
12#
13# This is generally testing the permutations of the foo/bar1/bar2 layer against
14# the baz/baz2 layer
15
16all:
17 # Building just baz
18 $(RUSTC) --crate-type=rlib foo.rs
19 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
20 $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic
21 $(RUSTC) --crate-type=bin baz.rs
22 rm $(TMPDIR)/*
23 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
24 $(RUSTC) --crate-type=rlib bar1.rs
25 $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic
26 $(RUSTC) --crate-type=bin baz.rs
27 rm $(TMPDIR)/*
28 # Building baz2
29 $(RUSTC) --crate-type=rlib foo.rs
30 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
31 $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic
32 $(RUSTC) --crate-type=dylib baz2.rs && exit 1 || exit 0
33 $(RUSTC) --crate-type=bin baz2.rs && exit 1 || exit 0
34 rm $(TMPDIR)/*
35 $(RUSTC) --crate-type=rlib foo.rs
36 $(RUSTC) --crate-type=rlib bar1.rs
37 $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic
38 $(RUSTC) --crate-type=dylib,rlib baz2.rs
39 $(RUSTC) --crate-type=bin baz2.rs
40 rm $(TMPDIR)/*
41 $(RUSTC) --crate-type=rlib foo.rs
42 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
43 $(RUSTC) --crate-type=rlib bar2.rs
44 $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic
45 $(RUSTC) --crate-type=bin baz2.rs
46 rm $(TMPDIR)/*
47 $(RUSTC) --crate-type=rlib foo.rs
48 $(RUSTC) --crate-type=rlib bar1.rs
49 $(RUSTC) --crate-type=rlib bar2.rs
50 $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic
51 $(RUSTC) --crate-type=bin baz2.rs
52 rm $(TMPDIR)/*
53 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
54 $(RUSTC) --crate-type=rlib bar1.rs
55 $(RUSTC) --crate-type=rlib bar2.rs
56 $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic
57 $(RUSTC) --crate-type=bin baz2.rs
58 rm $(TMPDIR)/*
59 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
60 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
61 $(RUSTC) --crate-type=rlib bar2.rs
62 $(RUSTC) --crate-type=dylib,rlib baz2.rs
63 $(RUSTC) --crate-type=bin baz2.rs
64 rm $(TMPDIR)/*
65 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
66 $(RUSTC) --crate-type=rlib bar1.rs
67 $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic
68 $(RUSTC) --crate-type=dylib,rlib baz2.rs
69 $(RUSTC) --crate-type=bin baz2.rs
70 rm $(TMPDIR)/*
71 $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic
72 $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic
73 $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic
74 $(RUSTC) --crate-type=dylib,rlib baz2.rs
75 $(RUSTC) --crate-type=bin baz2.rs
tests/run-make/mixing-formats/bar1.rs created+1
...@@ -0,0 +1 @@
1extern crate foo;
tests/run-make/mixing-formats/bar2.rs created+1
...@@ -0,0 +1 @@
1extern crate foo;
tests/run-make/mixing-formats/baz.rs created+3
...@@ -0,0 +1,3 @@
1extern crate bar1;
2
3fn main() {}
tests/run-make/mixing-formats/baz2.rs created+4
...@@ -0,0 +1,4 @@
1extern crate bar1;
2extern crate bar2;
3
4fn main() {}
tests/run-make/mixing-formats/foo.rs created+1
...@@ -0,0 +1 @@
1// intentionally empty
tests/run-make/mixing-libs/Makefile created+10
...@@ -0,0 +1,10 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) rlib.rs
6 $(RUSTC) dylib.rs
7 $(RUSTC) rlib.rs --crate-type=dylib
8 $(RUSTC) dylib.rs
9 $(call REMOVE_DYLIBS,rlib)
10 $(RUSTC) prog.rs && exit 1 || exit 0
tests/run-make/mixing-libs/dylib.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "dylib"]
2extern crate rlib;
3
4pub fn dylib() { rlib::rlib() }
tests/run-make/mixing-libs/prog.rs created+7
...@@ -0,0 +1,7 @@
1extern crate dylib;
2extern crate rlib;
3
4fn main() {
5 dylib::dylib();
6 rlib::rlib();
7}
tests/run-make/mixing-libs/rlib.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "rlib"]
2pub fn rlib() {}
tests/run-make/msvc-opt-minsize/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs -Copt-level=z 2>&1
6 $(call RUN,foo)
tests/run-make/msvc-opt-minsize/foo.rs created+19
...@@ -0,0 +1,19 @@
1#![feature(test)]
2extern crate test;
3
4fn foo(x: i32, y: i32) -> i64 {
5 (x + y) as i64
6}
7
8#[inline(never)]
9fn bar() {
10 let _f = Box::new(0);
11 // This call used to trigger an LLVM bug in opt-level z where the base
12 // pointer gets corrupted, see issue #45034
13 let y: fn(i32, i32) -> i64 = test::black_box(foo);
14 test::black_box(y(1, 2));
15}
16
17fn main() {
18 bar();
19}
tests/run-make/multiple-emits/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out 2>&1
5 rm $(TMPDIR)/out.ll $(TMPDIR)/out.s
6 $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out2.ext 2>&1
7 rm $(TMPDIR)/out2.ll $(TMPDIR)/out2.s
tests/run-make/multiple-emits/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/native-link-modifier-bundle/Makefile+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1# ignore-cross-compile1# ignore-cross-compile
2# ignore-windows-msvc2# ignore-windows-msvc
33
4include ../../run-make-fulldeps/tools.mk4include ../tools.mk
55
6# We're using the llvm-nm instead of the system nm to ensure it is compatible6# We're using the llvm-nm instead of the system nm to ensure it is compatible
7# with the LLVM bitcode generated by rustc.7# with the LLVM bitcode generated by rustc.
tests/run-make/native-link-modifier-verbatim-linker/Makefile+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1# ignore-cross-compile1# ignore-cross-compile
2# ignore-macos2# ignore-macos
33
4include ../../run-make-fulldeps/tools.mk4include ../tools.mk
55
6all:6all:
7 # Verbatim allows specify precise name.7 # Verbatim allows specify precise name.
tests/run-make/native-link-modifier-verbatim-rustc/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 # Verbatim allows specify precise name.4 # Verbatim allows specify precise name.
tests/run-make/native-link-modifier-whole-archive/Makefile+1-1
...@@ -8,7 +8,7 @@...@@ -8,7 +8,7 @@
8# that code would never make it into the final executable and we'd thus be missing some8# that code would never make it into the final executable and we'd thus be missing some
9# of the output.9# of the output.
1010
11include ../../run-make-fulldeps/tools.mk11include ../tools.mk
1212
13all: $(TMPDIR)/$(call BIN,directly_linked) \13all: $(TMPDIR)/$(call BIN,directly_linked) \
14 $(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive) \14 $(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive) \
tests/run-make/no-builtins-lto/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3all:
4 # Compile a `#![no_builtins]` rlib crate
5 $(RUSTC) no_builtins.rs
6 # Build an executable that depends on that crate using LTO. The no_builtins crate doesn't
7 # participate in LTO, so its rlib must be explicitly linked into the final binary. Verify this by
8 # grepping the linker arguments.
9 $(RUSTC) main.rs -C lto --print link-args | $(CGREP) 'libno_builtins.rlib'
tests/run-make/no-builtins-lto/main.rs created+3
...@@ -0,0 +1,3 @@
1extern crate no_builtins;
2
3fn main() {}
tests/run-make/no-builtins-lto/no_builtins.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "lib"]
2#![no_builtins]
tests/run-make/no-duplicate-libs/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4ifdef IS_MSVC
5# FIXME(#27979)
6all:
7else
8all: $(call STATICLIB,foo) $(call STATICLIB,bar)
9 $(RUSTC) main.rs
10 $(call RUN,main)
11endif
tests/run-make/no-duplicate-libs/bar.c created+5
...@@ -0,0 +1,5 @@
1extern void foo();
2
3void bar() {
4 foo();
5}
tests/run-make/no-duplicate-libs/foo.c created+1
...@@ -0,0 +1 @@
1void foo() {}
tests/run-make/no-duplicate-libs/main.rs created+10
...@@ -0,0 +1,10 @@
1#[link(name = "foo")] // linker should drop this library, no symbols used
2#[link(name = "bar")] // symbol comes from this library
3#[link(name = "foo")] // now linker picks up `foo` b/c `bar` library needs it
4extern "C" {
5 fn bar();
6}
7
8fn main() {
9 unsafe { bar() }
10}
tests/run-make/no-input-file/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 $(RUSTC) --print crate-name 2>&1 | diff - no-input-file.stderr4 $(RUSTC) --print crate-name 2>&1 | diff - no-input-file.stderr
tests/run-make/no-intermediate-extras/Makefile created+8
...@@ -0,0 +1,8 @@
1# ignore-cross-compile
2# Regression test for issue #10973
3
4include ../tools.mk
5
6all:
7 $(RUSTC) --crate-type=rlib --test foo.rs
8 rm $(TMPDIR)/foo.bc && exit 1 || exit 0
tests/run-make/no-intermediate-extras/foo.rs created+1
...@@ -0,0 +1 @@
1// intentionally empty
tests/run-make/obey-crate-type-flag/Makefile created+14
...@@ -0,0 +1,14 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# check that rustc builds all crate_type attributes
5# delete rlib
6# delete whatever dylib is made for this system
7# check that rustc only builds --crate-type flags, ignoring attributes
8# fail if an rlib was built
9all:
10 $(RUSTC) test.rs
11 $(call REMOVE_RLIBS,test)
12 $(call REMOVE_DYLIBS,test)
13 $(RUSTC) --crate-type dylib test.rs
14 $(call REMOVE_RLIBS,test) && exit 1 || exit 0
tests/run-make/obey-crate-type-flag/test.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "rlib"]
2#![crate_type = "dylib"]
tests/run-make/output-filename-conflicts-with-directory/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3all:
4 cp foo.rs $(TMPDIR)/foo.rs
5 mkdir $(TMPDIR)/foo
6 $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \
7 | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\""
tests/run-make/output-filename-conflicts-with-directory/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/output-filename-overwrites-input/Makefile created+14
...@@ -0,0 +1,14 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 cp foo.rs $(TMPDIR)/foo
6 $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \
7 | $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable"
8 cp bar.rs $(TMPDIR)/bar.rlib
9 $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \
10 | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable"
11 $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1
12 cp foo.rs $(TMPDIR)/foo.rs
13 $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \
14 | $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable"
tests/run-make/output-filename-overwrites-input/bar.rs created+1
...@@ -0,0 +1 @@
1#![crate_type = "lib"]
tests/run-make/output-filename-overwrites-input/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/output-type-permutations/Makefile created+147
...@@ -0,0 +1,147 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib
6 $(call REMOVE_RLIBS,bar)
7 $(call REMOVE_DYLIBS,bar)
8 rm $(call STATICLIB,bar)
9 rm -f $(TMPDIR)/{lib,}bar.{dll.exp,dll.lib,pdb,dll.a}
10 # Check that $(TMPDIR) is empty.
11 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
12
13 $(RUSTC) foo.rs --crate-type=bin
14 rm $(TMPDIR)/$(call BIN,bar)
15 rm -f $(TMPDIR)/bar.pdb
16 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
17
18 $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link
19 rm $(TMPDIR)/bar.ll
20 rm $(TMPDIR)/bar.bc
21 rm $(TMPDIR)/bar.s
22 rm $(TMPDIR)/bar.o
23 rm $(TMPDIR)/$(call BIN,bar)
24 rm -f $(TMPDIR)/bar.pdb
25 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
26
27 $(RUSTC) foo.rs --emit asm -o $(TMPDIR)/foo
28 rm $(TMPDIR)/foo
29 $(RUSTC) foo.rs --emit asm=$(TMPDIR)/foo
30 rm $(TMPDIR)/foo
31 $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/foo
32 rm $(TMPDIR)/foo
33 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
34
35 $(RUSTC) foo.rs --emit llvm-bc -o $(TMPDIR)/foo
36 rm $(TMPDIR)/foo
37 $(RUSTC) foo.rs --emit llvm-bc=$(TMPDIR)/foo
38 rm $(TMPDIR)/foo
39 $(RUSTC) foo.rs --emit=llvm-bc=$(TMPDIR)/foo
40 rm $(TMPDIR)/foo
41 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
42
43 $(RUSTC) foo.rs --emit llvm-ir -o $(TMPDIR)/foo
44 rm $(TMPDIR)/foo
45 $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/foo
46 rm $(TMPDIR)/foo
47 $(RUSTC) foo.rs --emit=llvm-ir=$(TMPDIR)/foo
48 rm $(TMPDIR)/foo
49 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
50
51 $(RUSTC) foo.rs --emit obj -o $(TMPDIR)/foo
52 rm $(TMPDIR)/foo
53 $(RUSTC) foo.rs --emit obj=$(TMPDIR)/foo
54 rm $(TMPDIR)/foo
55 $(RUSTC) foo.rs --emit=obj=$(TMPDIR)/foo
56 rm $(TMPDIR)/foo
57 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
58
59 $(RUSTC) foo.rs --emit link -o $(TMPDIR)/$(call BIN,foo)
60 rm $(TMPDIR)/$(call BIN,foo)
61 $(RUSTC) foo.rs --emit link=$(TMPDIR)/$(call BIN,foo)
62 rm $(TMPDIR)/$(call BIN,foo)
63 $(RUSTC) foo.rs --emit=link=$(TMPDIR)/$(call BIN,foo)
64 rm $(TMPDIR)/$(call BIN,foo)
65 rm -f $(TMPDIR)/foo.pdb
66 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
67
68 $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo
69 rm $(TMPDIR)/foo
70 $(RUSTC) foo.rs --crate-type=rlib --emit link=$(TMPDIR)/foo
71 rm $(TMPDIR)/foo
72 $(RUSTC) foo.rs --crate-type=rlib --emit=link=$(TMPDIR)/foo
73 rm $(TMPDIR)/foo
74 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
75
76 $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/$(call BIN,foo)
77 rm $(TMPDIR)/$(call BIN,foo)
78 $(RUSTC) foo.rs --crate-type=dylib --emit link=$(TMPDIR)/$(call BIN,foo)
79 rm $(TMPDIR)/$(call BIN,foo)
80 $(RUSTC) foo.rs --crate-type=dylib --emit=link=$(TMPDIR)/$(call BIN,foo)
81 rm $(TMPDIR)/$(call BIN,foo)
82 rm -f $(TMPDIR)/{lib,}foo.{dll.exp,dll.lib,pdb,dll.a,exe.a}
83 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] || (ls -1 $(TMPDIR) && exit 1)
84
85 $(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo
86 rm $(TMPDIR)/foo
87 $(RUSTC) foo.rs --crate-type=staticlib --emit link=$(TMPDIR)/foo
88 rm $(TMPDIR)/foo
89 $(RUSTC) foo.rs --crate-type=staticlib --emit=link=$(TMPDIR)/foo
90 rm $(TMPDIR)/foo
91 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
92
93 $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/$(call BIN,foo)
94 rm $(TMPDIR)/$(call BIN,foo)
95 $(RUSTC) foo.rs --crate-type=bin --emit link=$(TMPDIR)/$(call BIN,foo)
96 rm $(TMPDIR)/$(call BIN,foo)
97 $(RUSTC) foo.rs --crate-type=bin --emit=link=$(TMPDIR)/$(call BIN,foo)
98 rm $(TMPDIR)/$(call BIN,foo)
99 rm -f $(TMPDIR)/foo.pdb
100 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
101
102 $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/ir \
103 --emit link \
104 --crate-type=rlib
105 rm $(TMPDIR)/ir
106 rm $(TMPDIR)/libbar.rlib
107 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
108
109 $(RUSTC) foo.rs --emit asm=$(TMPDIR)/asm \
110 --emit llvm-ir=$(TMPDIR)/ir \
111 --emit llvm-bc=$(TMPDIR)/bc \
112 --emit obj=$(TMPDIR)/obj \
113 --emit link=$(TMPDIR)/link \
114 --crate-type=staticlib
115 rm $(TMPDIR)/asm
116 rm $(TMPDIR)/ir
117 rm $(TMPDIR)/bc
118 rm $(TMPDIR)/obj
119 rm $(TMPDIR)/link
120 $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/asm \
121 --emit llvm-ir=$(TMPDIR)/ir \
122 --emit=llvm-bc=$(TMPDIR)/bc \
123 --emit obj=$(TMPDIR)/obj \
124 --emit=link=$(TMPDIR)/link \
125 --crate-type=staticlib
126 rm $(TMPDIR)/asm
127 rm $(TMPDIR)/ir
128 rm $(TMPDIR)/bc
129 rm $(TMPDIR)/obj
130 rm $(TMPDIR)/link
131 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
132
133 $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link --crate-type=staticlib
134 rm $(TMPDIR)/bar.ll
135 rm $(TMPDIR)/bar.s
136 rm $(TMPDIR)/bar.o
137 rm $(call STATICLIB,bar)
138 mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc
139 # Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later
140 # comparison.
141
142 $(RUSTC) foo.rs --emit=llvm-bc,link --crate-type=rlib
143 cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
144 rm $(TMPDIR)/bar.bc
145 rm $(TMPDIR)/foo.bc
146 $(call REMOVE_RLIBS,bar)
147 [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ]
tests/run-make/output-type-permutations/foo.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_name = "bar"]
2
3fn main() {}
tests/run-make/output-with-hyphens/Makefile created+8
...@@ -0,0 +1,8 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo-bar.rs --crate-type bin
6 [ -f $(TMPDIR)/$(call BIN,foo-bar) ]
7 $(RUSTC) foo-bar.rs --crate-type lib
8 [ -f $(TMPDIR)/libfoo_bar.rlib ]
tests/run-make/output-with-hyphens/foo-bar.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/override-aliased-flags/Makefile created+23
...@@ -0,0 +1,23 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# FIXME: it would be good to check that it's actually the rightmost flags
5# that are used when multiple flags are specified, but I can't think of a
6# reliable way to check this.
7
8all:
9 # Test that `-O` and `-C opt-level` can be specified multiple times.
10 # The rightmost flag will be used over any previous flags.
11 $(RUSTC) -O -O main.rs
12 $(RUSTC) -O -C opt-level=0 main.rs
13 $(RUSTC) -C opt-level=0 -O main.rs
14 $(RUSTC) -C opt-level=0 -C opt-level=2 main.rs
15 $(RUSTC) -C opt-level=2 -C opt-level=0 main.rs
16
17 # Test that `-g` and `-C debuginfo` can be specified multiple times.
18 # The rightmost flag will be used over any previous flags.
19 $(RUSTC) -g -g main.rs
20 $(RUSTC) -g -C debuginfo=0 main.rs
21 $(RUSTC) -C debuginfo=0 -g main.rs
22 $(RUSTC) -C debuginfo=0 -C debuginfo=2 main.rs
23 $(RUSTC) -C debuginfo=2 -C debuginfo=0 main.rs
tests/run-make/override-aliased-flags/main.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/overwrite-input/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 $(RUSTC) main.rs -o main.rs 2> $(TMPDIR)/file.stderr || echo "failed successfully"4 $(RUSTC) main.rs -o main.rs 2> $(TMPDIR)/file.stderr || echo "failed successfully"
tests/run-make/panic-impl-transitive/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3# NOTE we use --emit=llvm-ir to avoid running the linker (linking will fail because there's no main
4# in this crate)
5all:
6 $(RUSTC) panic-impl-provider.rs
7 $(RUSTC) panic-impl-consumer.rs -C panic=abort --emit=llvm-ir -L $(TMPDIR)
tests/run-make/panic-impl-transitive/panic-impl-consumer.rs created+5
...@@ -0,0 +1,5 @@
1#![no_std]
2#![no_main]
3
4// this crate provides the `panic_impl` lang item so we don't need to define it here
5extern crate panic_impl_provider;
tests/run-make/panic-impl-transitive/panic-impl-provider.rs created+9
...@@ -0,0 +1,9 @@
1#![crate_type = "rlib"]
2#![no_std]
3
4use core::panic::PanicInfo;
5
6#[panic_handler]
7fn panic(info: &PanicInfo) -> ! {
8 loop {}
9}
tests/run-make/pass-linker-flags-from-dep/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 # Build deps4 # Build deps
tests/run-make/pass-linker-flags/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 $(RUSTC) rs.rs -Z unstable-options -l static=l1 -l link-arg=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*a1.*l2.*a2.*d1.*a3'4 $(RUSTC) rs.rs -Z unstable-options -l static=l1 -l link-arg=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*a1.*l2.*a2.*d1.*a3'
tests/run-make/pass-non-c-like-enum-to-c/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,test)
5 $(RUSTC) nonclike.rs -L$(TMPDIR) -ltest
6 $(call RUN,nonclike)
tests/run-make/pass-non-c-like-enum-to-c/nonclike.rs created+21
...@@ -0,0 +1,21 @@
1#[repr(C, u8)]
2pub enum TT {
3 AA(u64, u64),
4 BB,
5}
6
7#[repr(C,u8)]
8pub enum T {
9 A(u64),
10 B,
11}
12
13extern "C" {
14 pub fn t_add(a: T, b: T) -> u64;
15 pub fn tt_add(a: TT, b: TT) -> u64;
16}
17
18fn main() {
19 assert_eq!(33, unsafe { tt_add(TT::AA(1,2), TT::AA(10,20)) });
20 assert_eq!(11, unsafe { t_add(T::A(1), T::A(10)) });
21}
tests/run-make/pass-non-c-like-enum-to-c/test.c created+85
...@@ -0,0 +1,85 @@
1#include <stdint.h>
2
3/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
4 * type in nonclike.rs . */
5enum TT_Tag {
6 AA,
7 BB,
8};
9typedef uint8_t TT_Tag;
10
11typedef struct {
12 uint64_t _0;
13 uint64_t _1;
14} AA_Body;
15
16typedef struct {
17 TT_Tag tag;
18 union {
19 AA_Body aa;
20 };
21} TT;
22
23/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
24 * in nonclike.rs . */
25enum T_Tag {
26 A,
27 B,
28};
29typedef uint8_t T_Tag;
30
31typedef struct {
32 uint64_t _0;
33} A_Body;
34
35typedef struct {
36 T_Tag tag;
37 union {
38 A_Body a;
39 };
40} T;
41
42uint64_t tt_add(TT a, TT b) {
43 if (a.tag == AA && b.tag == AA) {
44 return a.aa._0 + a.aa._1 + b.aa._0 + b.aa._1;
45 } else if (a.tag == AA) {
46 return a.aa._0 + a.aa._1;
47 } else if (b.tag == BB) {
48 return b.aa._0 + b.aa._1;
49 } else {
50 return 0;
51 }
52}
53
54uint64_t t_add(T a, T b) {
55 if (a.tag == A && b.tag == A) {
56 return a.a._0 + b.a._0;
57 } else if (a.tag == AA) {
58 return a.a._0;
59 } else if (b.tag == BB) {
60 return b.a._0;
61 } else {
62 return 0;
63 }
64}
65
66TT tt_new(uint64_t a, uint64_t b) {
67 TT tt = {
68 .tag = AA,
69 .aa = {
70 ._0 = a,
71 ._1 = b,
72 },
73 };
74 return tt;
75}
76
77T t_new(uint64_t a) {
78 T t = {
79 .tag = A,
80 .a = {
81 ._0 = a,
82 },
83 };
84 return t;
85}
tests/run-make/pgo-branch-weights/Makefile created+34
...@@ -0,0 +1,34 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9# For some very small programs GNU ld seems to not properly handle
10# instrumentation sections correctly. Neither Gold nor LLD have that problem.
11ifeq ($(UNAME),Linux)
12ifneq (,$(findstring x86,$(TARGET)))
13COMMON_FLAGS=-Clink-args=-fuse-ld=gold
14endif
15endif
16
17
18all:
19 # We don't compile `opaque` with either optimizations or instrumentation.
20 $(RUSTC) $(COMMON_FLAGS) opaque.rs || exit 1
21 # Compile the test program with instrumentation
22 mkdir -p "$(TMPDIR)/prof_data_dir" || exit 1
23 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
24 -Cprofile-generate="$(TMPDIR)/prof_data_dir" -O -Ccodegen-units=1 || exit 1
25 $(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)/prof_data_dir" -O || exit 1
26 # The argument below generates to the expected branch weights
27 $(call RUN,main aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc) || exit 1
28 "$(LLVM_BIN_DIR)/llvm-profdata" merge \
29 -o "$(TMPDIR)/prof_data_dir/merged.profdata" \
30 "$(TMPDIR)/prof_data_dir" || exit 1
31 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
32 -Cprofile-use="$(TMPDIR)/prof_data_dir/merged.profdata" -O \
33 -Ccodegen-units=1 --emit=llvm-ir || exit 1
34 cat "$(TMPDIR)/interesting.ll" | "$(LLVM_FILECHECK)" filecheck-patterns.txt
tests/run-make/pgo-branch-weights/filecheck-patterns.txt created+24
...@@ -0,0 +1,24 @@
1
2# First, establish that certain !prof labels are attached to the expected
3# functions and branching instructions.
4
5CHECK: define void @function_called_twice(i32 {{.*}} !prof [[function_called_twice_id:![0-9]+]] {
6CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !prof [[branch_weights0:![0-9]+]]
7
8CHECK: define void @function_called_42_times(i32{{.*}} %c) {{.*}} !prof [[function_called_42_times_id:![0-9]+]] {
9CHECK: switch i32 %c, label {{.*}} [
10CHECK-NEXT: i32 97, label {{.*}}
11CHECK-NEXT: i32 98, label {{.*}}
12CHECK-NEXT: ], !prof [[branch_weights1:![0-9]+]]
13
14CHECK: define void @function_called_never(i32 {{.*}} !prof [[function_called_never_id:![0-9]+]] {
15
16
17
18# Now check that those !prof tags hold the expected counts
19
20CHECK: [[function_called_twice_id]] = !{!"function_entry_count", i64 2}
21CHECK: [[branch_weights0]] = !{!"branch_weights", i32 2, i32 0}
22CHECK: [[function_called_42_times_id]] = !{!"function_entry_count", i64 42}
23CHECK: [[branch_weights1]] = !{!"branch_weights", i32 2, i32 12, i32 28}
24CHECK: [[function_called_never_id]] = !{!"function_entry_count", i64 0}
tests/run-make/pgo-branch-weights/interesting.rs created+40
...@@ -0,0 +1,40 @@
1#![crate_name="interesting"]
2#![crate_type="rlib"]
3
4extern crate opaque;
5
6#[no_mangle]
7#[inline(never)]
8pub fn function_called_twice(c: char) {
9 if c == '2' {
10 // This branch is taken twice
11 opaque::f1();
12 } else {
13 // This branch is never taken
14 opaque::f2();
15 }
16}
17
18#[no_mangle]
19#[inline(never)]
20pub fn function_called_42_times(c: char) {
21 if c == 'a' {
22 // This branch is taken 12 times
23 opaque::f1();
24 } else {
25
26 if c == 'b' {
27 // This branch is taken 28 times
28 opaque::f2();
29 } else {
30 // This branch is taken 2 times
31 opaque::f3();
32 }
33 }
34}
35
36#[no_mangle]
37#[inline(never)]
38pub fn function_called_never(_: char) {
39 opaque::f1();
40}
tests/run-make/pgo-branch-weights/main.rs created+17
...@@ -0,0 +1,17 @@
1extern crate interesting;
2
3fn main() {
4 let arg = std::env::args().skip(1).next().unwrap();
5
6 for c in arg.chars() {
7 if c == '2' {
8 interesting::function_called_twice(c);
9 } else {
10 interesting::function_called_42_times(c);
11 }
12
13 if c == '0' {
14 interesting::function_called_never(c);
15 }
16 }
17}
tests/run-make/pgo-branch-weights/opaque.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_name="opaque"]
2#![crate_type="rlib"]
3
4pub fn f1() {}
5pub fn f2() {}
6pub fn f3() {}
tests/run-make/pgo-gen-lto/Makefile created+14
...@@ -0,0 +1,14 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9COMPILE_FLAGS=-Copt-level=3 -Clto=fat -Cprofile-generate="$(TMPDIR)"
10
11all:
12 $(RUSTC) $(COMPILE_FLAGS) test.rs
13 $(call RUN,test) || exit 1
14 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1)
tests/run-make/pgo-gen-lto/test.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/pgo-gen-no-imp-symbols/Makefile created+13
...@@ -0,0 +1,13 @@
1# needs-profiler-support
2
3include ../tools.mk
4
5COMPILE_FLAGS=-O -Ccodegen-units=1 -Cprofile-generate="$(TMPDIR)"
6
7all:
8 $(RUSTC) $(COMPILE_FLAGS) --emit=llvm-ir test.rs
9 # We expect symbols starting with "__llvm_profile_".
10 $(CGREP) "__llvm_profile_" < $(TMPDIR)/test.ll
11 # We do NOT expect the "__imp_" version of these symbols.
12 $(CGREP) -v "__imp___llvm_profile_" < $(TMPDIR)/test.ll # 64 bit
13 $(CGREP) -v "__imp____llvm_profile_" < $(TMPDIR)/test.ll # 32 bit
tests/run-make/pgo-gen-no-imp-symbols/test.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/pgo-gen/Makefile created+14
...@@ -0,0 +1,14 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9COMPILE_FLAGS=-g -Cprofile-generate="$(TMPDIR)"
10
11all:
12 $(RUSTC) $(COMPILE_FLAGS) test.rs
13 $(call RUN,test) || exit 1
14 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1)
tests/run-make/pgo-gen/test.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/pgo-indirect-call-promotion/Makefile created+26
...@@ -0,0 +1,26 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9all:
10 # We don't compile `opaque` with either optimizations or instrumentation.
11 # We don't compile `opaque` with either optimizations or instrumentation.
12 $(RUSTC) $(COMMON_FLAGS) opaque.rs
13 # Compile the test program with instrumentation
14 mkdir -p "$(TMPDIR)"/prof_data_dir
15 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
16 -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O -Ccodegen-units=1
17 $(RUSTC) $(COMMON_FLAGS) main.rs -Cprofile-generate="$(TMPDIR)"/prof_data_dir -O
18 # The argument below generates to the expected branch weights
19 $(call RUN,main) || exit 1
20 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
21 -o "$(TMPDIR)"/prof_data_dir/merged.profdata \
22 "$(TMPDIR)"/prof_data_dir
23 $(RUSTC) $(COMMON_FLAGS) interesting.rs \
24 -Cprofile-use="$(TMPDIR)"/prof_data_dir/merged.profdata -O \
25 -Ccodegen-units=1 --emit=llvm-ir
26 cat "$(TMPDIR)"/interesting.ll | "$(LLVM_FILECHECK)" filecheck-patterns.txt
tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt created+16
...@@ -0,0 +1,16 @@
1CHECK: define void @call_a_bunch_of_functions({{.*}} {
2
3# Make sure that indirect call promotion inserted a check against the most
4# frequently called function.
5CHECK: %{{.*}} = icmp eq {{void \(\)\*|ptr}} %{{.*}}, @function_called_always
6
7# Check that the call to `function_called_always` was inlined, so that we
8# directly call `opaque_f1` from the upstream crate.
9CHECK: call void @opaque_f1()
10
11
12# Same checks as above, repeated for the trait object case
13
14CHECK: define void @call_a_bunch_of_trait_methods({{.*}}
15CHECK: %{{.*}} = icmp eq {{void \(\{\}\*\)\*|ptr}} %{{.*}}, {{.*}}@foo
16CHECK: tail call void @opaque_f2()
tests/run-make/pgo-indirect-call-promotion/interesting.rs created+56
...@@ -0,0 +1,56 @@
1#![crate_name="interesting"]
2#![crate_type="rlib"]
3
4extern crate opaque;
5
6#[no_mangle]
7pub fn function_called_always() {
8 opaque::opaque_f1();
9}
10
11#[no_mangle]
12pub fn function_called_never() {
13 opaque::opaque_f2();
14}
15
16#[no_mangle]
17pub fn call_a_bunch_of_functions(fns: &[fn()]) {
18
19 // Indirect call promotion transforms the below into something like
20 //
21 // for f in fns {
22 // if f == function_called_always {
23 // function_called_always()
24 // } else {
25 // f();
26 // }
27 // }
28 //
29 // where `function_called_always` actually gets inlined too.
30
31 for f in fns {
32 f();
33 }
34}
35
36
37pub trait Foo {
38 fn foo(&self);
39}
40
41impl Foo for u32 {
42
43 #[no_mangle]
44 fn foo(&self) {
45 opaque::opaque_f2();
46 }
47}
48
49#[no_mangle]
50pub fn call_a_bunch_of_trait_methods(trait_objects: &[&dyn Foo]) {
51
52 // Same as above, just with vtables in between
53 for x in trait_objects {
54 x.foo();
55 }
56}
tests/run-make/pgo-indirect-call-promotion/main.rs created+14
...@@ -0,0 +1,14 @@
1extern crate interesting;
2
3fn main() {
4 // function pointer case
5 let fns: Vec<_> = std::iter::repeat(interesting::function_called_always as fn())
6 .take(1000)
7 .collect();
8 interesting::call_a_bunch_of_functions(&fns[..]);
9
10 // Trait object case
11 let trait_objects = vec![0u32; 1000];
12 let trait_objects: Vec<_> = trait_objects.iter().map(|x| x as &dyn interesting::Foo).collect();
13 interesting::call_a_bunch_of_trait_methods(&trait_objects[..]);
14}
tests/run-make/pgo-indirect-call-promotion/opaque.rs created+7
...@@ -0,0 +1,7 @@
1#![crate_name="opaque"]
2#![crate_type="rlib"]
3
4#[no_mangle]
5pub fn opaque_f1() {}
6#[no_mangle]
7pub fn opaque_f2() {}
tests/run-make/pgo-use/Makefile created+46
...@@ -0,0 +1,46 @@
1# needs-profiler-support
2# ignore-windows-gnu
3
4# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
5# properly. Since we only have GCC on the CI ignore the test for now.
6
7include ../tools.mk
8
9# This test makes sure that PGO profiling data leads to cold functions being
10# marked as `cold` and hot functions with `inlinehint`.
11# The test program contains an `if` were actual execution only ever takes the
12# `else` branch. Accordingly, we expect the function that is never called to
13# be marked as cold.
14#
15# Disable the pre-inlining pass (i.e. a pass that does some inlining before
16# it adds the profiling instrumentation). Disabling this pass leads to
17# rather predictable IR which we need for this test to be stable.
18
19COMMON_FLAGS=-Copt-level=2 -Ccodegen-units=1 -Cllvm-args=-disable-preinline
20
21ifeq ($(UNAME),Darwin)
22# macOS does not have the `tac` command, but `tail -r` does the same thing
23TAC := tail -r
24else
25# some other platforms don't support the `-r` flag for `tail`, so use `tac`
26TAC := tac
27endif
28
29all:
30 # Compile the test program with instrumentation
31 $(RUSTC) $(COMMON_FLAGS) -Cprofile-generate="$(TMPDIR)" main.rs
32 # Run it in order to generate some profiling data
33 $(call RUN,main some-argument) || exit 1
34 # Postprocess the profiling data so it can be used by the compiler
35 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
36 -o "$(TMPDIR)"/merged.profdata \
37 "$(TMPDIR)"/default_*.profraw
38 # Compile the test program again, making use of the profiling data
39 $(RUSTC) $(COMMON_FLAGS) -Cprofile-use="$(TMPDIR)"/merged.profdata --emit=llvm-ir main.rs
40 # Check that the generate IR contains some things that we expect
41 #
42 # We feed the file into LLVM FileCheck tool *in reverse* so that we see the
43 # line with the function name before the line with the function attributes.
44 # FileCheck only supports checking that something matches on the next line,
45 # but not if something matches on the previous line.
46 $(TAC) "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck-patterns.txt
tests/run-make/pgo-use/filecheck-patterns.txt created+11
...@@ -0,0 +1,11 @@
1# Add a check that the IR contains some expected metadata
2CHECK: !{!"ProfileFormat", !"InstrProf"}
3CHECK: !"ProfileSummary"
4
5# Make sure that the hot function is marked with `inlinehint`
6CHECK: define {{.*}} @hot_function
7CHECK-NEXT: Function Attrs:{{.*}}inlinehint
8
9# Make sure that the cold function is marked with `cold`
10CHECK: define {{.*}} @cold_function
11CHECK-NEXT: Function Attrs:{{.*}}cold
tests/run-make/pgo-use/main.rs created+23
...@@ -0,0 +1,23 @@
1#[no_mangle]
2pub fn cold_function(c: u8) {
3 println!("cold {}", c);
4}
5
6#[no_mangle]
7pub fn hot_function(c: u8) {
8 std::env::set_var(format!("var{}", c), format!("hot {}", c));
9}
10
11fn main() {
12 let arg = std::env::args().skip(1).next().unwrap();
13
14 for i in 0 .. 1000_000 {
15 let some_value = arg.as_bytes()[i % arg.len()];
16 if some_value == b'!' {
17 // This branch is never taken at runtime
18 cold_function(some_value);
19 } else {
20 hot_function(some_value);
21 }
22 }
23}
tests/run-make/pointer-auth-link-with-c/Makefile created+14
...@@ -0,0 +1,14 @@
1include ../tools.mk
2
3# only-aarch64
4
5all:
6 $(COMPILE_OBJ) $(TMPDIR)/test.o test.c
7 $(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
8 $(RUSTC) -Z branch-protection=bti,pac-ret,leaf test.rs
9 $(call RUN,test)
10
11 $(COMPILE_OBJ) $(TMPDIR)/test.o test.c -mbranch-protection=bti+pac-ret+leaf
12 $(AR) rcs $(TMPDIR)/libtest.a $(TMPDIR)/test.o
13 $(RUSTC) -Z branch-protection=bti,pac-ret,leaf test.rs
14 $(call RUN,test)
tests/run-make/pointer-auth-link-with-c/test.c created+1
...@@ -0,0 +1 @@
1int foo() { return 0; }
tests/run-make/pointer-auth-link-with-c/test.rs created+8
...@@ -0,0 +1,8 @@
1#[link(name = "test")]
2extern "C" {
3 fn foo() -> i32;
4}
5
6fn main() {
7 unsafe {foo();}
8}
tests/run-make/prefer-dylib/Makefile created+9
...@@ -0,0 +1,9 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib -C prefer-dynamic
6 $(RUSTC) foo.rs -C prefer-dynamic
7 $(call RUN,foo)
8 rm $(TMPDIR)/*bar*
9 $(call FAIL,foo)
tests/run-make/prefer-dylib/bar.rs created+1
...@@ -0,0 +1 @@
1pub fn bar() {}
tests/run-make/prefer-dylib/foo.rs created+5
...@@ -0,0 +1,5 @@
1extern crate bar;
2
3fn main() {
4 bar::bar();
5}
tests/run-make/prefer-rlib/Makefile created+9
...@@ -0,0 +1,9 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib
6 ls $(TMPDIR)/$(call RLIB_GLOB,bar)
7 $(RUSTC) foo.rs
8 rm $(TMPDIR)/*bar*
9 $(call RUN,foo)
tests/run-make/prefer-rlib/bar.rs created+1
...@@ -0,0 +1 @@
1pub fn bar() {}
tests/run-make/prefer-rlib/foo.rs created+5
...@@ -0,0 +1,5 @@
1extern crate bar;
2
3fn main() {
4 bar::bar();
5}
tests/run-make/pretty-print-to-file/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -o $(TMPDIR)/input.out -Zunpretty=normal input.rs
5 diff -u $(TMPDIR)/input.out input.pp
tests/run-make/pretty-print-to-file/input.pp created+3
...@@ -0,0 +1,3 @@
1
2#[crate_type = "lib"]
3pub fn foo() -> i32 { 45 }
tests/run-make/pretty-print-to-file/input.rs created+5
...@@ -0,0 +1,5 @@
1#[crate_type="lib"]
2
3pub fn
4foo() -> i32
5{ 45 }
tests/run-make/print-calling-conventions/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) --print calling-conventions
tests/run-make/print-cfg/Makefile created+20
...@@ -0,0 +1,20 @@
1# needs-llvm-components: x86 arm
2
3include ../tools.mk
4
5all: default
6 $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows
7 $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64
8 $(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc
9 $(RUSTC) --target i686-apple-darwin --print cfg | $(CGREP) macos
10 $(RUSTC) --target i686-unknown-linux-gnu --print cfg | $(CGREP) gnu
11 $(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) target_abi=
12 $(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) eabihf
13
14ifdef IS_WINDOWS
15default:
16 $(RUSTC) --print cfg | $(CGREP) windows
17else
18default:
19 $(RUSTC) --print cfg | $(CGREP) unix
20endif
tests/run-make/print-target-list/Makefile created+8
...@@ -0,0 +1,8 @@
1include ../tools.mk
2
3# Checks that all the targets returned by `rustc --print target-list` are valid
4# target specifications
5all:
6 for target in $(shell $(BARE_RUSTC) --print target-list); do \
7 $(BARE_RUSTC) --target $$target --print sysroot; \
8 done
tests/run-make/profile/Makefile created+12
...@@ -0,0 +1,12 @@
1# needs-profiler-support
2
3include ../tools.mk
4
5all:
6 $(RUSTC) -g -Z profile test.rs
7 $(call RUN,test) || exit 1
8 [ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1)
9 [ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1)
10 $(RUSTC) -g -Z profile -Z profile-emit=$(TMPDIR)/abc/abc.gcda test.rs
11 $(call RUN,test) || exit 1
12 [ -e "$(TMPDIR)/abc/abc.gcda" ] || (echo "gcda file not emitted to defined path"; exit 1)
tests/run-make/profile/test.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/prune-link-args/Makefile created+10
...@@ -0,0 +1,10 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows
5
6# Notice the space in the end, this emulates the output of pkg-config
7RUSTC_FLAGS = -C link-args="-lc "
8
9all:
10 $(RUSTC) $(RUSTC_FLAGS) empty.rs
tests/run-make/prune-link-args/empty.rs created+1
...@@ -0,0 +1 @@
1fn main() { }
tests/run-make/raw-dylib-alt-calling-convention/Makefile+1-1
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3# only-x863# only-x86
4# only-windows4# only-windows
55
6include ../../run-make-fulldeps/tools.mk6include ../tools.mk
77
8all:8all:
9 $(RUSTC) --crate-type lib --crate-name raw_dylib_alt_calling_convention_test lib.rs9 $(RUSTC) --crate-type lib --crate-name raw_dylib_alt_calling_convention_test lib.rs
tests/run-make/raw-dylib-c/Makefile+1-1
...@@ -2,7 +2,7 @@...@@ -2,7 +2,7 @@
22
3# only-windows3# only-windows
44
5include ../../run-make-fulldeps/tools.mk5include ../tools.mk
66
7all:7all:
8 $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs8 $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs
tests/run-make/raw-dylib-cross-compilation/Makefile+1-1
...@@ -7,7 +7,7 @@...@@ -7,7 +7,7 @@
7# i686 dlltool.exe can't product x64 binaries.7# i686 dlltool.exe can't product x64 binaries.
8# ignore-i686-pc-windows-gnu8# ignore-i686-pc-windows-gnu
99
10include ../../run-make-fulldeps/tools.mk10include ../tools.mk
1111
12all:12all:
13 # Build as x86 and make sure that we have x86 objects only.13 # Build as x86 and make sure that we have x86 objects only.
tests/run-make/raw-dylib-import-name-type/Makefile+1-1
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3# only-x863# only-x86
4# only-windows4# only-windows
55
6-include ../../run-make-fulldeps/tools.mk6include ../tools.mk
77
8all:8all:
9 $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)"9 $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)"
tests/run-make/raw-dylib-inline-cross-dylib/Makefile+1-1
...@@ -2,7 +2,7 @@...@@ -2,7 +2,7 @@
22
3# only-windows3# only-windows
44
5include ../../run-make-fulldeps/tools.mk5include ../tools.mk
66
7# We'd be using the llvm-objdump instead of the system objdump to ensure compatibility7# We'd be using the llvm-objdump instead of the system objdump to ensure compatibility
8# with the LLVM bitcode generated by rustc but on Windows piping/IO redirection under MSYS2 is wonky with llvm-objdump.8# with the LLVM bitcode generated by rustc but on Windows piping/IO redirection under MSYS2 is wonky with llvm-objdump.
tests/run-make/raw-dylib-link-ordinal/Makefile+1-1
...@@ -2,7 +2,7 @@...@@ -2,7 +2,7 @@
22
3# only-windows3# only-windows
44
5include ../../run-make-fulldeps/tools.mk5include ../tools.mk
66
7all:7all:
8 $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs8 $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs
tests/run-make/raw-dylib-stdcall-ordinal/Makefile+1-1
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3# only-x863# only-x86
4# only-windows4# only-windows
55
6include ../../run-make-fulldeps/tools.mk6include ../tools.mk
77
8all:8all:
9 $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs9 $(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs
tests/run-make/redundant-libs/Makefile created+24
...@@ -0,0 +1,24 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows-msvc
5
6# rustc will remove one of the two redundant references to foo below. Depending
7# on which one gets removed, we'll get a linker error on SOME platforms (like
8# Linux). On these platforms, when a library is referenced, the linker will
9# only pull in the symbols needed _at that point in time_. If a later library
10# depends on additional symbols from the library, they will not have been pulled
11# in, and you'll get undefined symbols errors.
12#
13# So in this example, we need to ensure that rustc keeps the _later_ reference
14# to foo, and not the former one.
15RUSTC_FLAGS = \
16 -l static=bar \
17 -l foo \
18 -l static=baz \
19 -l foo \
20 --print link-args
21
22all: $(call DYLIB,foo) $(call STATICLIB,bar) $(call STATICLIB,baz)
23 $(RUSTC) $(RUSTC_FLAGS) main.rs
24 $(call RUN,main)
tests/run-make/redundant-libs/bar.c created+1
...@@ -0,0 +1 @@
1void bar() {}
tests/run-make/redundant-libs/baz.c created+7
...@@ -0,0 +1,7 @@
1extern void foo1();
2extern void foo2();
3
4void baz() {
5 foo1();
6 foo2();
7}
tests/run-make/redundant-libs/foo.c created+2
...@@ -0,0 +1,2 @@
1void foo1() {}
2void foo2() {}
tests/run-make/redundant-libs/main.rs created+11
...@@ -0,0 +1,11 @@
1extern "C" {
2 fn bar();
3 fn baz();
4}
5
6fn main() {
7 unsafe {
8 bar();
9 baz();
10 }
11}
tests/run-make/relocation-model/Makefile created+20
...@@ -0,0 +1,20 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: others
5 $(RUSTC) -C relocation-model=dynamic-no-pic foo.rs
6 $(call RUN,foo)
7
8 $(RUSTC) -C relocation-model=default foo.rs
9 $(call RUN,foo)
10
11 $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj
12
13ifdef IS_MSVC
14# FIXME(#28026)
15others:
16else
17others:
18 $(RUSTC) -C relocation-model=static foo.rs
19 $(call RUN,foo)
20endif
tests/run-make/relocation-model/foo.rs created+1
...@@ -0,0 +1 @@
1pub fn main() {}
tests/run-make/relro-levels/Makefile created+22
...@@ -0,0 +1,22 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# only-linux
5#
6# This tests the different -Zrelro-level values, and makes sure that they work properly.
7
8all:
9 # Ensure that binaries built with the full relro level links them with both
10 # RELRO and BIND_NOW for doing eager symbol resolving.
11 $(RUSTC) -Zrelro-level=full hello.rs
12 readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO
13 readelf -d $(TMPDIR)/hello | grep -q BIND_NOW
14
15 $(RUSTC) -Zrelro-level=partial hello.rs
16 readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO
17
18 # Ensure that we're *not* built with RELRO when setting it to off. We do
19 # not want to check for BIND_NOW however, as the linker might have that
20 # enabled by default.
21 $(RUSTC) -Zrelro-level=off hello.rs
22 ! readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO
tests/run-make/relro-levels/hello.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 println!("Hello, world!");
3}
tests/run-make/remap-path-prefix-dwarf/Makefile+1-1
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6SRC_DIR := $(abspath .)6SRC_DIR := $(abspath .)
7SRC_DIR_PARENT := $(abspath ..)7SRC_DIR_PARENT := $(abspath ..)
88
9include ../../run-make-fulldeps/tools.mk9include ../tools.mk
1010
11all: \11all: \
12 abs_input_outside_working_dir \12 abs_input_outside_working_dir \
tests/run-make/remap-path-prefix/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3# ignore-windows
4
5# Checks if remapping works if the remap-from string contains path to the working directory plus more
6all:
7 $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux --crate-type=lib --emit=metadata auxiliary/lib.rs
8 grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
9 ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
tests/run-make/remap-path-prefix/auxiliary/lib.rs created+3
...@@ -0,0 +1,3 @@
1pub fn lib() {
2 panic!("calm");
3}
tests/run-make/repr128-dwarf/Makefile+1-1
...@@ -2,7 +2,7 @@...@@ -2,7 +2,7 @@
2# This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit2# This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit
3# enums.3# enums.
44
5include ../../run-make-fulldeps/tools.mk5include ../tools.mk
66
7all:7all:
8 $(RUSTC) -Cdebuginfo=2 lib.rs -o $(TMPDIR)/repr128.rlib8 $(RUSTC) -Cdebuginfo=2 lib.rs -o $(TMPDIR)/repr128.rlib
tests/run-make/reproducible-build-2/Makefile created+27
...@@ -0,0 +1,27 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-musl
5# ignore-windows
6# Objects are reproducible but their path is not.
7
8all: \
9 fat_lto \
10 sysroot
11
12fat_lto:
13 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
14 $(RUSTC) reproducible-build-aux.rs
15 $(RUSTC) reproducible-build.rs -C lto=fat
16 cp $(TMPDIR)/reproducible-build $(TMPDIR)/reproducible-build-a
17 $(RUSTC) reproducible-build.rs -C lto=fat
18 cmp "$(TMPDIR)/reproducible-build-a" "$(TMPDIR)/reproducible-build" || exit 1
19
20sysroot:
21 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
22 $(RUSTC) reproducible-build-aux.rs
23 $(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(shell $(RUSTC) --print sysroot) --remap-path-prefix=$(shell $(RUSTC) --print sysroot)=/sysroot
24 cp -R $(shell $(RUSTC) --print sysroot) $(TMPDIR)/sysroot
25 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
26 $(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(TMPDIR)/sysroot --remap-path-prefix=$(TMPDIR)/sysroot=/sysroot
27 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
tests/run-make/reproducible-build-2/linker.rs created+44
...@@ -0,0 +1,44 @@
1use std::env;
2use std::path::Path;
3use std::fs::File;
4use std::io::{Read, Write};
5
6fn main() {
7 let mut dst = env::current_exe().unwrap();
8 dst.pop();
9 dst.push("linker-arguments1");
10 if dst.exists() {
11 dst.pop();
12 dst.push("linker-arguments2");
13 assert!(!dst.exists());
14 }
15
16 let mut out = String::new();
17 for arg in env::args().skip(1) {
18 let path = Path::new(&arg);
19 if !path.is_file() {
20 out.push_str(&arg);
21 out.push_str("\n");
22 continue
23 }
24
25 let mut contents = Vec::new();
26 File::open(path).unwrap().read_to_end(&mut contents).unwrap();
27
28 out.push_str(&format!("{}: {}\n", arg, hash(&contents)));
29 }
30
31 File::create(dst).unwrap().write_all(out.as_bytes()).unwrap();
32}
33
34// fnv hash for now
35fn hash(contents: &[u8]) -> u64 {
36 let mut hash = 0xcbf29ce484222325;
37
38 for byte in contents {
39 hash = hash ^ (*byte as u64);
40 hash = hash.wrapping_mul(0x100000001b3);
41 }
42
43 hash
44}
tests/run-make/reproducible-build-2/reproducible-build-aux.rs created+28
...@@ -0,0 +1,28 @@
1#![crate_type="lib"]
2
3pub static STATIC: i32 = 1234;
4
5pub struct Struct<T1, T2> {
6 _t1: std::marker::PhantomData<T1>,
7 _t2: std::marker::PhantomData<T2>,
8}
9
10pub fn regular_fn(_: i32) {}
11
12pub fn generic_fn<T1, T2>() {}
13
14impl<T1, T2> Drop for Struct<T1, T2> {
15 fn drop(&mut self) {}
16}
17
18pub enum Enum {
19 Variant1,
20 Variant2(u32),
21 Variant3 { x: u32 }
22}
23
24pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64);
25
26pub trait Trait<T1, T2> {
27 fn foo(&self);
28}
tests/run-make/reproducible-build-2/reproducible-build.rs created+116
...@@ -0,0 +1,116 @@
1// This test case makes sure that two identical invocations of the compiler
2// (i.e., same code base, same compile-flags, same compiler-versions, etc.)
3// produce the same output. In the past, symbol names of monomorphized functions
4// were not deterministic (which we want to avoid).
5//
6// The test tries to exercise as many different paths into symbol name
7// generation as possible:
8//
9// - regular functions
10// - generic functions
11// - methods
12// - statics
13// - closures
14// - enum variant constructors
15// - tuple struct constructors
16// - drop glue
17// - FnOnce adapters
18// - Trait object shims
19// - Fn Pointer shims
20
21#![allow(dead_code, warnings)]
22
23extern crate reproducible_build_aux;
24
25static STATIC: i32 = 1234;
26
27pub struct Struct<T1, T2> {
28 x: T1,
29 y: T2,
30}
31
32fn regular_fn(_: i32) {}
33
34fn generic_fn<T1, T2>() {}
35
36impl<T1, T2> Drop for Struct<T1, T2> {
37 fn drop(&mut self) {}
38}
39
40pub enum Enum {
41 Variant1,
42 Variant2(u32),
43 Variant3 { x: u32 }
44}
45
46struct TupleStruct(i8, i16, i32, i64);
47
48impl TupleStruct {
49 pub fn bar(&self) {}
50}
51
52trait Trait<T1, T2> {
53 fn foo(&self);
54}
55
56impl Trait<i32, u64> for u64 {
57 fn foo(&self) {}
58}
59
60impl reproducible_build_aux::Trait<char, String> for TupleStruct {
61 fn foo(&self) {}
62}
63
64fn main() {
65 regular_fn(STATIC);
66 generic_fn::<u32, char>();
67 generic_fn::<char, Struct<u32, u64>>();
68 generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
69
70 let dropped = Struct {
71 x: "",
72 y: 'a',
73 };
74
75 let _ = Enum::Variant1;
76 let _ = Enum::Variant2(0);
77 let _ = Enum::Variant3 { x: 0 };
78 let _ = TupleStruct(1, 2, 3, 4);
79
80 let closure = |x| {
81 x + 1i32
82 };
83
84 fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
85 f(STATIC)
86 }
87
88 println!("{}", inner(closure));
89
90 let object_shim: &Trait<i32, u64> = &0u64;
91 object_shim.foo();
92
93 fn with_fn_once_adapter<F: FnOnce(i32)>(f: F) {
94 f(0);
95 }
96
97 with_fn_once_adapter(|_:i32| { });
98
99 reproducible_build_aux::regular_fn(STATIC);
100 reproducible_build_aux::generic_fn::<u32, char>();
101 reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
102 reproducible_build_aux::generic_fn::<Struct<u64, u32>,
103 reproducible_build_aux::Struct<u32, u64>>();
104
105 let _ = reproducible_build_aux::Enum::Variant1;
106 let _ = reproducible_build_aux::Enum::Variant2(0);
107 let _ = reproducible_build_aux::Enum::Variant3 { x: 0 };
108 let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4);
109
110 let object_shim: &reproducible_build_aux::Trait<char, String> = &TupleStruct(0, 1, 2, 3);
111 object_shim.foo();
112
113 let pointer_shim: &Fn(i32) = &regular_fn;
114
115 TupleStruct(1, 2, 3, 4).bar();
116}
tests/run-make/reproducible-build/Makefile created+140
...@@ -0,0 +1,140 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-musl
5# Objects are reproducible but their path is not.
6
7all: \
8 smoke \
9 debug \
10 opt \
11 link_paths \
12 remap_paths \
13 different_source_dirs_rlib \
14 remap_cwd_rlib \
15 remap_cwd_to_empty \
16 extern_flags
17
18# TODO: Builds of `bin` crate types are not deterministic with debuginfo=2 on
19# Windows.
20# See: https://github.com/rust-lang/rust/pull/87320#issuecomment-920105533
21# Issue: https://github.com/rust-lang/rust/issues/88982
22#
23# different_source_dirs_bin \
24# remap_cwd_bin \
25
26smoke:
27 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
28 $(RUSTC) linker.rs -O
29 $(RUSTC) reproducible-build-aux.rs
30 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker)
31 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker)
32 diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2"
33
34debug:
35 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
36 $(RUSTC) linker.rs -O
37 $(RUSTC) reproducible-build-aux.rs -g
38 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g
39 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g
40 diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2"
41
42opt:
43 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
44 $(RUSTC) linker.rs -O
45 $(RUSTC) reproducible-build-aux.rs -O
46 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O
47 $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O
48 diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2"
49
50link_paths:
51 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
52 $(RUSTC) reproducible-build-aux.rs
53 $(RUSTC) reproducible-build.rs --crate-type rlib -L /b
54 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
55 $(RUSTC) reproducible-build.rs --crate-type rlib -L /a
56 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
57
58remap_paths:
59 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
60 $(RUSTC) reproducible-build-aux.rs
61 $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/a=/c
62 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
63 $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/b=/c
64 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
65
66different_source_dirs_bin:
67 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
68 $(RUSTC) reproducible-build-aux.rs
69 mkdir $(TMPDIR)/test
70 cp reproducible-build.rs $(TMPDIR)/test
71 $(RUSTC) reproducible-build.rs --crate-type bin --remap-path-prefix=$$PWD=/b
72 cp $(TMPDIR)/reproducible-build $(TMPDIR)/foo
73 (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \
74 --remap-path-prefix=$(TMPDIR)/test=/b \
75 --crate-type bin)
76 cmp "$(TMPDIR)/reproducible-build" "$(TMPDIR)/foo" || exit 1
77
78different_source_dirs_rlib:
79 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
80 $(RUSTC) reproducible-build-aux.rs
81 mkdir $(TMPDIR)/test
82 cp reproducible-build.rs $(TMPDIR)/test
83 $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=$$PWD=/b
84 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
85 (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \
86 --remap-path-prefix=$(TMPDIR)/test=/b \
87 --crate-type rlib)
88 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
89
90remap_cwd_bin:
91 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
92 $(RUSTC) reproducible-build-aux.rs
93 mkdir $(TMPDIR)/test
94 cp reproducible-build.rs $(TMPDIR)/test
95 $(RUSTC) reproducible-build.rs --crate-type bin -C debuginfo=2 \
96 -Z remap-cwd-prefix=.
97 cp $(TMPDIR)/reproducible-build $(TMPDIR)/first
98 (cd $(TMPDIR)/test && \
99 $(RUSTC) reproducible-build.rs --crate-type bin -C debuginfo=2 \
100 -Z remap-cwd-prefix=.)
101 cmp "$(TMPDIR)/first" "$(TMPDIR)/reproducible-build" || exit 1
102
103remap_cwd_rlib:
104 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
105 $(RUSTC) reproducible-build-aux.rs
106 mkdir $(TMPDIR)/test
107 cp reproducible-build.rs $(TMPDIR)/test
108 $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
109 -Z remap-cwd-prefix=.
110 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfirst.rlib
111 (cd $(TMPDIR)/test && \
112 $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
113 -Z remap-cwd-prefix=.)
114 cmp "$(TMPDIR)/libfirst.rlib" "$(TMPDIR)/libreproducible_build.rlib" || exit 1
115
116remap_cwd_to_empty:
117 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
118 $(RUSTC) reproducible-build-aux.rs
119 mkdir $(TMPDIR)/test
120 cp reproducible-build.rs $(TMPDIR)/test
121 $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
122 -Z remap-cwd-prefix=
123 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfirst.rlib
124 (cd $(TMPDIR)/test && \
125 $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
126 -Z remap-cwd-prefix=)
127 cmp "$(TMPDIR)/libfirst.rlib" "$(TMPDIR)/libreproducible_build.rlib" || exit 1
128
129extern_flags:
130 rm -rf $(TMPDIR) && mkdir $(TMPDIR)
131 $(RUSTC) reproducible-build-aux.rs
132 $(RUSTC) reproducible-build.rs \
133 --extern reproducible_build_aux=$(TMPDIR)/libreproducible_build_aux.rlib \
134 --crate-type rlib
135 cp $(TMPDIR)/libreproducible_build_aux.rlib $(TMPDIR)/libbar.rlib
136 cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib
137 $(RUSTC) reproducible-build.rs \
138 --extern reproducible_build_aux=$(TMPDIR)/libbar.rlib \
139 --crate-type rlib
140 cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
tests/run-make/reproducible-build/linker.rs created+50
...@@ -0,0 +1,50 @@
1use std::env;
2use std::path::Path;
3use std::fs::File;
4use std::io::{Read, Write};
5
6fn main() {
7 let mut dst = env::current_exe().unwrap();
8 dst.pop();
9 dst.push("linker-arguments1");
10 if dst.exists() {
11 dst.pop();
12 dst.push("linker-arguments2");
13 assert!(!dst.exists());
14 }
15
16 let mut out = String::new();
17 for arg in env::args().skip(1) {
18 let path = Path::new(&arg);
19 if !path.is_file() {
20 out.push_str(&arg);
21 out.push_str("\n");
22 continue
23 }
24
25 let mut contents = Vec::new();
26 File::open(path).unwrap().read_to_end(&mut contents).unwrap();
27
28 // This file is produced during linking in a temporary directory.
29 let arg = if arg.ends_with("/symbols.o") || arg.ends_with("\\symbols.o") {
30 "symbols.o"
31 } else {
32 &*arg
33 };
34 out.push_str(&format!("{}: {}\n", arg, hash(&contents)));
35 }
36
37 File::create(dst).unwrap().write_all(out.as_bytes()).unwrap();
38}
39
40// fnv hash for now
41fn hash(contents: &[u8]) -> u64 {
42 let mut hash = 0xcbf29ce484222325;
43
44 for byte in contents {
45 hash = hash ^ (*byte as u64);
46 hash = hash.wrapping_mul(0x100000001b3);
47 }
48
49 hash
50}
tests/run-make/reproducible-build/reproducible-build-aux.rs created+28
...@@ -0,0 +1,28 @@
1#![crate_type="lib"]
2
3pub static STATIC: i32 = 1234;
4
5pub struct Struct<T1, T2> {
6 _t1: std::marker::PhantomData<T1>,
7 _t2: std::marker::PhantomData<T2>,
8}
9
10pub fn regular_fn(_: i32) {}
11
12pub fn generic_fn<T1, T2>() {}
13
14impl<T1, T2> Drop for Struct<T1, T2> {
15 fn drop(&mut self) {}
16}
17
18pub enum Enum {
19 Variant1,
20 Variant2(u32),
21 Variant3 { x: u32 }
22}
23
24pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64);
25
26pub trait Trait<T1, T2> {
27 fn foo(&self);
28}
tests/run-make/reproducible-build/reproducible-build.rs created+116
...@@ -0,0 +1,116 @@
1// This test case makes sure that two identical invocations of the compiler
2// (i.e., same code base, same compile-flags, same compiler-versions, etc.)
3// produce the same output. In the past, symbol names of monomorphized functions
4// were not deterministic (which we want to avoid).
5//
6// The test tries to exercise as many different paths into symbol name
7// generation as possible:
8//
9// - regular functions
10// - generic functions
11// - methods
12// - statics
13// - closures
14// - enum variant constructors
15// - tuple struct constructors
16// - drop glue
17// - FnOnce adapters
18// - Trait object shims
19// - Fn Pointer shims
20
21#![allow(dead_code, warnings)]
22
23extern crate reproducible_build_aux;
24
25static STATIC: i32 = 1234;
26
27pub struct Struct<T1, T2> {
28 x: T1,
29 y: T2,
30}
31
32fn regular_fn(_: i32) {}
33
34fn generic_fn<T1, T2>() {}
35
36impl<T1, T2> Drop for Struct<T1, T2> {
37 fn drop(&mut self) {}
38}
39
40pub enum Enum {
41 Variant1,
42 Variant2(u32),
43 Variant3 { x: u32 }
44}
45
46struct TupleStruct(i8, i16, i32, i64);
47
48impl TupleStruct {
49 pub fn bar(&self) {}
50}
51
52trait Trait<T1, T2> {
53 fn foo(&self);
54}
55
56impl Trait<i32, u64> for u64 {
57 fn foo(&self) {}
58}
59
60impl reproducible_build_aux::Trait<char, String> for TupleStruct {
61 fn foo(&self) {}
62}
63
64fn main() {
65 regular_fn(STATIC);
66 generic_fn::<u32, char>();
67 generic_fn::<char, Struct<u32, u64>>();
68 generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
69
70 let dropped = Struct {
71 x: "",
72 y: 'a',
73 };
74
75 let _ = Enum::Variant1;
76 let _ = Enum::Variant2(0);
77 let _ = Enum::Variant3 { x: 0 };
78 let _ = TupleStruct(1, 2, 3, 4);
79
80 let closure = |x| {
81 x + 1i32
82 };
83
84 fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
85 f(STATIC)
86 }
87
88 println!("{}", inner(closure));
89
90 let object_shim: &Trait<i32, u64> = &0u64;
91 object_shim.foo();
92
93 fn with_fn_once_adapter<F: FnOnce(i32)>(f: F) {
94 f(0);
95 }
96
97 with_fn_once_adapter(|_:i32| { });
98
99 reproducible_build_aux::regular_fn(STATIC);
100 reproducible_build_aux::generic_fn::<u32, char>();
101 reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
102 reproducible_build_aux::generic_fn::<Struct<u64, u32>,
103 reproducible_build_aux::Struct<u32, u64>>();
104
105 let _ = reproducible_build_aux::Enum::Variant1;
106 let _ = reproducible_build_aux::Enum::Variant2(0);
107 let _ = reproducible_build_aux::Enum::Variant3 { x: 0 };
108 let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4);
109
110 let object_shim: &reproducible_build_aux::Trait<char, String> = &TupleStruct(0, 1, 2, 3);
111 object_shim.foo();
112
113 let pointer_shim: &Fn(i32) = &regular_fn;
114
115 TupleStruct(1, 2, 3, 4).bar();
116}
tests/run-make/resolve-rename/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -C extra-filename=-hash foo.rs
5 $(RUSTC) bar.rs
6 mv $(TMPDIR)/libfoo-hash.rlib $(TMPDIR)/libfoo-another-hash.rlib
7 $(RUSTC) baz.rs
tests/run-make/resolve-rename/bar.rs created+5
...@@ -0,0 +1,5 @@
1#![crate_type = "rlib"]
2
3extern crate foo;
4
5pub fn bar() { foo::foo() }
tests/run-make/resolve-rename/baz.rs created+5
...@@ -0,0 +1,5 @@
1#![crate_type = "rlib"]
2
3extern crate bar;
4
5pub fn baz() { bar::bar() }
tests/run-make/resolve-rename/foo.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "rlib"]
2
3pub fn foo() {}
tests/run-make/return-non-c-like-enum-from-c/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,test)
5 $(RUSTC) nonclike.rs -L$(TMPDIR) -ltest
6 $(call RUN,nonclike)
tests/run-make/return-non-c-like-enum-from-c/nonclike.rs created+31
...@@ -0,0 +1,31 @@
1#[repr(C, u8)]
2pub enum TT {
3 AA(u64, u64),
4 BB,
5}
6
7#[repr(C,u8)]
8pub enum T {
9 A(u64),
10 B,
11}
12
13extern "C" {
14 pub fn t_new(a: u64) -> T;
15 pub fn tt_new(a: u64, b: u64) -> TT;
16}
17
18fn main() {
19 if let TT::AA(a, b) = unsafe { tt_new(10, 11) } {
20 assert_eq!(10, a);
21 assert_eq!(11, b);
22 } else {
23 panic!("expected TT::AA");
24 }
25
26 if let T::A(a) = unsafe { t_new(10) } {
27 assert_eq!(10, a);
28 } else {
29 panic!("expected T::A");
30 }
31}
tests/run-make/return-non-c-like-enum-from-c/test.c created+61
...@@ -0,0 +1,61 @@
1#include <stdint.h>
2
3/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
4 * type in nonclike.rs . */
5enum TT_Tag {
6 AA,
7 BB,
8};
9typedef uint8_t TT_Tag;
10
11typedef struct {
12 uint64_t _0;
13 uint64_t _1;
14} AA_Body;
15
16typedef struct {
17 TT_Tag tag;
18 union {
19 AA_Body aa;
20 };
21} TT;
22
23/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
24 * in nonclike.rs . */
25enum T_Tag {
26 A,
27 B,
28};
29typedef uint8_t T_Tag;
30
31typedef struct {
32 uint64_t _0;
33} A_Body;
34
35typedef struct {
36 T_Tag tag;
37 union {
38 A_Body a;
39 };
40} T;
41
42TT tt_new(uint64_t a, uint64_t b) {
43 TT tt = {
44 .tag = AA,
45 .aa = {
46 ._0 = a,
47 ._1 = b,
48 },
49 };
50 return tt;
51}
52
53T t_new(uint64_t a) {
54 T t = {
55 .tag = A,
56 .a = {
57 ._0 = a,
58 },
59 };
60 return t;
61}
tests/run-make/return-non-c-like-enum/Makefile created+8
...@@ -0,0 +1,8 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) --crate-type=staticlib nonclike.rs
6 $(CC) test.c $(call STATICLIB,nonclike) $(call OUT_EXE,test) \
7 $(EXTRACFLAGS) $(EXTRACXXFLAGS)
8 $(call RUN,test)
tests/run-make/return-non-c-like-enum/nonclike.rs created+21
...@@ -0,0 +1,21 @@
1#[repr(C, u8)]
2pub enum TT {
3 AA(u64, u64),
4 BB,
5}
6
7#[no_mangle]
8pub extern "C" fn tt_new(a: u64, b: u64) -> TT {
9 TT::AA(a, b)
10}
11
12#[repr(C,u8)]
13pub enum T {
14 A(u64),
15 B,
16}
17
18#[no_mangle]
19pub extern "C" fn t_new(a: u64) -> T {
20 T::A(a)
21}
tests/run-make/return-non-c-like-enum/test.c created+63
...@@ -0,0 +1,63 @@
1#include <stdint.h>
2#include <assert.h>
3
4/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
5 * type in nonclike.rs . */
6enum TT_Tag {
7 AA,
8 BB,
9};
10typedef uint8_t TT_Tag;
11
12typedef struct {
13 uint64_t _0;
14 uint64_t _1;
15} AA_Body;
16
17typedef struct {
18 TT_Tag tag;
19 union {
20 AA_Body aa;
21 };
22} TT;
23
24/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
25 * in nonclike.rs . */
26enum T_Tag {
27 A,
28 B,
29};
30typedef uint8_t T_Tag;
31
32typedef struct {
33 uint64_t _0;
34} A_Body;
35
36typedef struct {
37 T_Tag tag;
38 union {
39 A_Body a;
40 };
41} T;
42
43/* These symbols are defined by the Rust staticlib built from
44 * nonclike.rs. */
45extern TT tt_new(uint64_t a, uint64_t b);
46extern T t_new(uint64_t v);
47
48int main(int argc, char *argv[]) {
49 (void)argc; (void)argv;
50
51 /* This example works. */
52 TT tt = tt_new(10, 20);
53 assert(AA == tt.tag);
54 assert(10 == tt.aa._0);
55 assert(20 == tt.aa._1);
56
57 /* This one used to segfault (see issue #68190). */
58 T t = t_new(10);
59 assert(A == t.tag);
60 assert(10 == t.a._0);
61
62 return 0;
63}
tests/run-make/rlib-chain/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) m1.rs
6 $(RUSTC) m2.rs
7 $(RUSTC) m3.rs
8 $(RUSTC) m4.rs
9 $(call RUN,m4)
10 rm $(TMPDIR)/*lib
11 $(call RUN,m4)
tests/run-make/rlib-chain/m1.rs created+2
...@@ -0,0 +1,2 @@
1#![crate_type = "rlib"]
2pub fn m1() {}
tests/run-make/rlib-chain/m2.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "rlib"]
2extern crate m1;
3
4pub fn m2() { m1::m1() }
tests/run-make/rlib-chain/m3.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "rlib"]
2extern crate m2;
3
4pub fn m3() { m2::m2() }
tests/run-make/rlib-chain/m4.rs created+3
...@@ -0,0 +1,3 @@
1extern crate m3;
2
3fn main() { m3::m3() }
tests/run-make/rlib-format-packed-bundled-libs-2/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1-include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-cross-compile3# ignore-cross-compile
44
tests/run-make/rlib-format-packed-bundled-libs-3/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1-include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-cross-compile3# ignore-cross-compile
4# only-linux4# only-linux
tests/run-make/rlib-format-packed-bundled-libs/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1-include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-cross-compile3# ignore-cross-compile
44
tests/run-make/rustc-macro-dep-files/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`3# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`
4# instead of hardcoding them everywhere they're needed.4# instead of hardcoding them everywhere they're needed.
tests/run-make/rustdoc-determinism/Makefile created+16
...@@ -0,0 +1,16 @@
1include ../tools.mk
2
3# Assert that the search index is generated deterministically, regardless of the
4# order that crates are documented in.
5
6# ignore-windows
7# Uses `diff`.
8
9all:
10 $(RUSTDOC) foo.rs -o $(TMPDIR)/foo_first
11 $(RUSTDOC) bar.rs -o $(TMPDIR)/foo_first
12
13 $(RUSTDOC) bar.rs -o $(TMPDIR)/bar_first
14 $(RUSTDOC) foo.rs -o $(TMPDIR)/bar_first
15
16 diff $(TMPDIR)/foo_first/search-index.js $(TMPDIR)/bar_first/search-index.js
tests/run-make/rustdoc-determinism/bar.rs created+1
...@@ -0,0 +1 @@
1pub struct Bar;
tests/run-make/rustdoc-determinism/foo.rs created+1
...@@ -0,0 +1 @@
1pub struct Foo;
tests/run-make/rustdoc-error-lines/Makefile created+13
...@@ -0,0 +1,13 @@
1include ../tools.mk
2
3# Test that hir-tree output doesn't crash and includes
4# the string constant we would expect to see.
5
6all:
7 $(RUSTDOC) --test input.rs > $(TMPDIR)/output || true
8 $(CGREP) 'input.rs - foo (line 5)' < $(TMPDIR)/output
9 $(CGREP) 'input.rs:7:15' < $(TMPDIR)/output
10 $(CGREP) 'input.rs - bar (line 15)' < $(TMPDIR)/output
11 $(CGREP) 'input.rs:17:15' < $(TMPDIR)/output
12 $(CGREP) 'input.rs - bar (line 24)' < $(TMPDIR)/output
13 $(CGREP) 'input.rs:26:15' < $(TMPDIR)/output
tests/run-make/rustdoc-error-lines/input.rs created+28
...@@ -0,0 +1,28 @@
1// Test for #45868
2
3// random #![feature] to ensure that crate attrs
4// do not offset things
5/// ```rust
6/// #![feature(bool_to_option)]
7/// let x: char = 1;
8/// ```
9pub fn foo() {
10
11}
12
13/// Add some text around the test...
14///
15/// ```rust
16/// #![feature(bool_to_option)]
17/// let x: char = 1;
18/// ```
19///
20/// ...to make sure that the line number is still correct.
21///
22/// Let's also add a second test in the same doc comment.
23///
24/// ```rust
25/// #![feature(bool_to_option)]
26/// let x: char = 1;
27/// ```
28pub fn bar() {}
tests/run-make/rustdoc-io-error/Makefile created+20
...@@ -0,0 +1,20 @@
1include ../tools.mk
2
3# This test verifies that rustdoc doesn't ICE when it encounters an IO error
4# while generating files. Ideally this would be a rustdoc-ui test, so we could
5# verify the error message as well.
6
7# ignore-windows
8# The test uses `chmod`.
9
10OUTPUT_DIR := "$(TMPDIR)/rustdoc-io-error"
11
12# This test operates by creating a temporary directory and modifying its
13# permissions so that it is not writable. We have to take special care to set
14# the permissions back to normal so that it's able to be deleted later.
15all:
16 mkdir -p $(OUTPUT_DIR)
17 chmod u-w $(OUTPUT_DIR)
18 -$(shell $(RUSTDOC) -o $(OUTPUT_DIR) foo.rs)
19 chmod u+w $(OUTPUT_DIR)
20 exit $($(.SHELLSTATUS) -eq 1)
tests/run-make/rustdoc-io-error/foo.rs created+1
...@@ -0,0 +1 @@
1pub struct Foo;
tests/run-make/rustdoc-map-file/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3all:
4 $(RUSTDOC) -Z unstable-options --generate-redirect-map foo.rs -o "$(TMPDIR)/out"
5 "$(PYTHON)" validate_json.py "$(TMPDIR)/out"
tests/run-make/rustdoc-map-file/expected.json created+5
...@@ -0,0 +1,5 @@
1{
2 "foo/macro.foo!.html": "foo/macro.foo.html",
3 "foo/private/struct.Quz.html": "foo/struct.Quz.html",
4 "foo/hidden/struct.Bar.html": "foo/struct.Bar.html"
5}
tests/run-make/rustdoc-map-file/foo.rs created+16
...@@ -0,0 +1,16 @@
1pub use private::Quz;
2pub use hidden::Bar;
3
4mod private {
5 pub struct Quz;
6}
7
8#[doc(hidden)]
9pub mod hidden {
10 pub struct Bar;
11}
12
13#[macro_export]
14macro_rules! foo {
15 () => {}
16}
tests/run-make/rustdoc-map-file/validate_json.py created+41
...@@ -0,0 +1,41 @@
1#!/usr/bin/env python
2
3import os
4import sys
5import json
6
7
8def find_redirect_map_file(folder, errors):
9 for root, dirs, files in os.walk(folder):
10 for name in files:
11 if not name.endswith("redirect-map.json"):
12 continue
13 with open(os.path.join(root, name)) as f:
14 data = json.load(f)
15 with open("expected.json") as f:
16 expected = json.load(f)
17 for key in expected:
18 if expected[key] != data.get(key):
19 errors.append("Expected `{}` for key `{}`, found: `{}`".format(
20 expected[key], key, data.get(key)))
21 else:
22 del data[key]
23 for key in data:
24 errors.append("Extra data not expected: key: `{}`, data: `{}`".format(
25 key, data[key]))
26 return True
27 return False
28
29
30if len(sys.argv) != 2:
31 print("Expected doc directory to check!")
32 sys.exit(1)
33
34errors = []
35if not find_redirect_map_file(sys.argv[1], errors):
36 print("Didn't find the map file in `{}`...".format(sys.argv[1]))
37 sys.exit(1)
38for err in errors:
39 print("=> {}".format(err))
40if len(errors) != 0:
41 sys.exit(1)
tests/run-make/rustdoc-output-path/Makefile created+4
...@@ -0,0 +1,4 @@
1include ../tools.mk
2
3all:
4 $(RUSTDOC) -o "$(TMPDIR)/foo/bar/doc" foo.rs
tests/run-make/rustdoc-output-path/foo.rs created+1
...@@ -0,0 +1 @@
1pub struct Foo;
tests/run-make/rustdoc-scrape-examples-macros/Makefile created+19
...@@ -0,0 +1,19 @@
1# ignore-cross-compile
2include ../../run-make/tools.mk
3
4OUTPUT_DIR := "$(TMPDIR)/rustdoc"
5DYLIB_NAME := $(shell echo | $(RUSTC) --crate-name foobar_macro --crate-type dylib --print file-names -)
6
7all:
8 $(RUSTC) src/proc.rs --crate-name foobar_macro --edition=2021 --crate-type proc-macro --emit=dep-info,link
9
10 $(RUSTC) src/lib.rs --crate-name foobar --edition=2021 --crate-type lib --emit=dep-info,link
11
12 $(RUSTDOC) examples/ex.rs --crate-name ex --crate-type bin --output $(OUTPUT_DIR) \
13 --extern foobar=$(TMPDIR)/libfoobar.rlib --extern foobar_macro=$(TMPDIR)/$(DYLIB_NAME) \
14 -Z unstable-options --scrape-examples-output-path $(TMPDIR)/ex.calls --scrape-examples-target-crate foobar
15
16 $(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) \
17 -Z unstable-options --with-examples $(TMPDIR)/ex.calls
18
19 $(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs
tests/run-make/rustdoc-scrape-examples-macros/examples/ex.rs created+27
...@@ -0,0 +1,27 @@
1extern crate foobar;
2extern crate foobar_macro;
3
4use foobar::*;
5use foobar_macro::*;
6
7a_proc_macro!(); // no
8
9#[an_attr_macro]
10fn a() {
11 f(); // no
12}
13
14#[an_attr_macro(with_span)]
15fn b() {
16 f(); // yes
17}
18
19fn c() {
20 a_rules_macro!(f()); // yes
21}
22
23fn d() {
24 a_rules_macro!(()); // no
25}
26
27fn main(){}
tests/run-make/rustdoc-scrape-examples-macros/src/lib.rs created+12
...@@ -0,0 +1,12 @@
1// Scraped example should only include line numbers for items b and c in ex.rs
2// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '14'
3// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '15'
4// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '21'
5// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '22'
6
7pub fn f() {}
8
9#[macro_export]
10macro_rules! a_rules_macro {
11 ($e:expr) => { ($e, foobar::f()); }
12}
tests/run-make/rustdoc-scrape-examples-macros/src/proc.rs created+39
...@@ -0,0 +1,39 @@
1extern crate proc_macro;
2use proc_macro::*;
3
4#[proc_macro]
5pub fn a_proc_macro(_item: TokenStream) -> TokenStream {
6 "fn ex() { foobar::f(); }".parse().unwrap()
7}
8
9// inserts foobar::f() to the end of the function
10#[proc_macro_attribute]
11pub fn an_attr_macro(attr: TokenStream, item: TokenStream) -> TokenStream {
12 let new_call: TokenStream = "foobar::f();".parse().unwrap();
13
14 let mut tokens = item.into_iter();
15
16 let fn_tok = tokens.next().unwrap();
17 let ident_tok = tokens.next().unwrap();
18 let args_tok = tokens.next().unwrap();
19 let body = match tokens.next().unwrap() {
20 TokenTree::Group(g) => {
21 let new_g = Group::new(g.delimiter(), new_call);
22 let mut outer_g = Group::new(
23 g.delimiter(),
24 [TokenTree::Group(g.clone()), TokenTree::Group(new_g)].into_iter().collect(),
25 );
26
27 if attr.to_string() == "with_span" {
28 outer_g.set_span(g.span());
29 }
30
31 TokenTree::Group(outer_g)
32 }
33 _ => unreachable!(),
34 };
35
36 let tokens = vec![fn_tok, ident_tok, args_tok, body].into_iter().collect::<TokenStream>();
37
38 tokens
39}
tests/run-make/rustdoc-scrape-examples-multiple/scrape.mk+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3OUTPUT_DIR := "$(TMPDIR)/rustdoc"3OUTPUT_DIR := "$(TMPDIR)/rustdoc"
44
tests/run-make/rustdoc-target-spec-json-path/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3# Test that rustdoc will properly canonicalize the target spec json path just like rustc
4
5OUTPUT_DIR := "$(TMPDIR)/rustdoc-target-spec-json-path"
6
7all:
8 $(RUSTC) --crate-type lib dummy_core.rs --target target.json
9 $(RUSTDOC) -o $(OUTPUT_DIR) -L $(TMPDIR) my_crate.rs --target target.json
tests/run-make/rustdoc-target-spec-json-path/dummy_core.rs created+2
...@@ -0,0 +1,2 @@
1#![feature(no_core)]
2#![no_core]
tests/run-make/rustdoc-target-spec-json-path/my_crate.rs created+3
...@@ -0,0 +1,3 @@
1#![feature(no_core)]
2#![no_core]
3extern crate dummy_core;
tests/run-make/rustdoc-target-spec-json-path/target.json created+38
...@@ -0,0 +1,38 @@
1{
2 "arch": "x86_64",
3 "cpu": "x86-64",
4 "crt-static-respected": true,
5 "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
6 "dynamic-linking": true,
7 "env": "gnu",
8 "executables": true,
9 "has-elf-tls": true,
10 "has-rpath": true,
11 "linker-is-gnu": true,
12 "llvm-target": "x86_64-unknown-linux-gnu",
13 "max-atomic-width": 64,
14 "os": "linux",
15 "position-independent-executables": true,
16 "pre-link-args": {
17 "gcc": [
18 "-m64"
19 ]
20 },
21 "relro-level": "full",
22 "stack-probes": {
23 "kind": "inline-or-call",
24 "min-llvm-version-for-inline": [
25 11,
26 0,
27 1
28 ]
29 },
30 "supported-sanitizers": [
31 "address",
32 "leak",
33 "memory",
34 "thread"
35 ],
36 "target-family": "unix",
37 "target-pointer-width": "64"
38}
tests/run-make/rustdoc-themes/Makefile created+10
...@@ -0,0 +1,10 @@
1include ../tools.mk
2
3# Test that rustdoc will properly load in a theme file and display it in the theme selector.
4
5OUTPUT_DIR := "$(TMPDIR)/rustdoc-themes"
6
7all:
8 cp $(S)/src/librustdoc/html/static/css/themes/light.css $(TMPDIR)/test.css
9 $(RUSTDOC) -o $(OUTPUT_DIR) foo.rs --theme $(TMPDIR)/test.css
10 $(HTMLDOCCK) $(OUTPUT_DIR) foo.rs
tests/run-make/rustdoc-themes/foo.rs created+4
...@@ -0,0 +1,4 @@
1// @has test.css
2// @has foo/struct.Foo.html
3// @has - '//*[@id="rustdoc-vars"]/@data-themes' 'test'
4pub struct Foo;
tests/run-make/rustdoc-verify-output-files/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3OUTPUT_DIR := "$(TMPDIR)/rustdoc"3OUTPUT_DIR := "$(TMPDIR)/rustdoc"
4TMP_OUTPUT_DIR := "$(TMPDIR)/tmp-rustdoc"4TMP_OUTPUT_DIR := "$(TMPDIR)/tmp-rustdoc"
tests/run-make/rustdoc-with-out-dir-option/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3OUTPUT_DIR := "$(TMPDIR)/rustdoc"3OUTPUT_DIR := "$(TMPDIR)/rustdoc"
44
tests/run-make/rustdoc-with-output-option/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3OUTPUT_DIR := "$(TMPDIR)/rustdoc"3OUTPUT_DIR := "$(TMPDIR)/rustdoc"
44
tests/run-make/rustdoc-with-short-out-dir-option/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3OUTPUT_DIR := "$(TMPDIR)/rustdoc"3OUTPUT_DIR := "$(TMPDIR)/rustdoc"
44
tests/run-make/sanitizer-cdylib-link/Makefile created+16
...@@ -0,0 +1,16 @@
1# needs-sanitizer-support
2# needs-sanitizer-address
3
4include ../tools.mk
5
6LOG := $(TMPDIR)/log.txt
7
8# This test builds a shared object, then an executable that links it as a native
9# rust library (contrast to an rlib). The shared library and executable both
10# are compiled with address sanitizer, and we assert that a fault in the cdylib
11# is correctly detected.
12
13all:
14 $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) library.rs
15 $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
16 LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
tests/run-make/sanitizer-cdylib-link/library.rs created+5
...@@ -0,0 +1,5 @@
1#[no_mangle]
2pub extern "C" fn overflow() {
3 let xs = [0, 1, 2, 3];
4 let _y = unsafe { *xs.as_ptr().offset(4) };
5}
tests/run-make/sanitizer-cdylib-link/program.rs created+7
...@@ -0,0 +1,7 @@
1extern "C" {
2 fn overflow();
3}
4
5fn main() {
6 unsafe { overflow() }
7}
tests/run-make/sanitizer-dylib-link/Makefile created+16
...@@ -0,0 +1,16 @@
1# needs-sanitizer-support
2# needs-sanitizer-address
3
4include ../tools.mk
5
6LOG := $(TMPDIR)/log.txt
7
8# This test builds a shared object, then an executable that links it as a native
9# rust library (contrast to an rlib). The shared library and executable both
10# are compiled with address sanitizer, and we assert that a fault in the dylib
11# is correctly detected.
12
13all:
14 $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) library.rs
15 $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
16 LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
tests/run-make/sanitizer-dylib-link/library.rs created+5
...@@ -0,0 +1,5 @@
1#[no_mangle]
2pub extern "C" fn overflow() {
3 let xs = [0, 1, 2, 3];
4 let _y = unsafe { *xs.as_ptr().offset(4) };
5}
tests/run-make/sanitizer-dylib-link/program.rs created+7
...@@ -0,0 +1,7 @@
1extern "C" {
2 fn overflow();
3}
4
5fn main() {
6 unsafe { overflow() }
7}
tests/run-make/sanitizer-staticlib-link/Makefile created+20
...@@ -0,0 +1,20 @@
1# needs-sanitizer-support
2# needs-sanitizer-address
3
4include ../tools.mk
5
6# This test first builds a staticlib with AddressSanitizer and checks that
7# linking it to an executable fails due to the missing sanitizer runtime.
8# It then builds an executable linking to the staticlib and checks that
9# the fault in the staticlib is detected correctly.
10
11# Note that checking for the link failure actually checks two things at once:
12# 1) That the library has the sanitizer intrumentation
13# 2) and that library does not have the sanitizer runtime
14
15all:
16 $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs
17 ! $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS)
18 $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -L . program.rs
19 LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
20
tests/run-make/sanitizer-staticlib-link/library.rs created+5
...@@ -0,0 +1,5 @@
1#[no_mangle]
2pub extern "C" fn overflow() {
3 let xs = [0, 1, 2, 3];
4 let _y = unsafe { *xs.as_ptr().offset(4) };
5}
tests/run-make/sanitizer-staticlib-link/program.c created+6
...@@ -0,0 +1,6 @@
1void overflow();
2
3int main() {
4 overflow();
5 return 0;
6}
tests/run-make/sanitizer-staticlib-link/program.rs created+10
...@@ -0,0 +1,10 @@
1#[link(name = "library")]
2extern "C" {
3 fn overflow();
4}
5
6fn main() {
7 unsafe {
8 overflow();
9 }
10}
tests/run-make/separate-link-fail/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3all:
4 echo 'fn main(){}' > $(TMPDIR)/main.rs
5 # Make sure that this fails
6 ! $(RUSTC) -Z link-only $(TMPDIR)/main.rs 2> $(TMPDIR)/stderr.txt
7 $(CGREP) "The input does not look like a .rlink file" < $(TMPDIR)/stderr.txt
tests/run-make/separate-link/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 echo 'fn main(){}' | $(RUSTC) -Z no-link -
6 $(RUSTC) -Z link-only $(TMPDIR)/rust_out.rlink
7 $(call RUN,rust_out)
tests/run-make/sepcomp-cci-copies/Makefile created+12
...@@ -0,0 +1,12 @@
1include ../tools.mk
2
3# Check that cross-crate inlined items are inlined in all compilation units
4# that refer to them, and not in any other compilation units.
5# Note that we have to pass `-C codegen-units=6` because up to two CGUs may be
6# created for each source module (see `rustc_const_eval::monomorphize::partitioning`).
7
8all:
9 $(RUSTC) cci_lib.rs
10 $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=6 \
11 -Z inline-in-all-cgus
12 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*cci_fn)" -eq "2" ]
tests/run-make/sepcomp-cci-copies/cci_lib.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_type = "rlib"]
2
3#[inline]
4pub fn cci_fn() -> usize {
5 1234
6}
tests/run-make/sepcomp-cci-copies/foo.rs created+25
...@@ -0,0 +1,25 @@
1extern crate cci_lib;
2use cci_lib::cci_fn;
3
4fn call1() -> usize {
5 cci_fn()
6}
7
8mod a {
9 use cci_lib::cci_fn;
10 pub fn call2() -> usize {
11 cci_fn()
12 }
13}
14
15mod b {
16 pub fn call3() -> usize {
17 0
18 }
19}
20
21fn main() {
22 call1();
23 a::call2();
24 b::call3();
25}
tests/run-make/sepcomp-inlining/Makefile created+15
...@@ -0,0 +1,15 @@
1include ../tools.mk
2
3# Test that #[inline] functions still get inlined across compilation unit
4# boundaries. Compilation should produce three IR files, but only the two
5# compilation units that have a usage of the #[inline] function should
6# contain a definition. Also, the non-#[inline] function should be defined
7# in only one compilation unit.
8
9all:
10 $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \
11 -Z inline-in-all-cgus
12 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ]
13 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ]
14 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ]
15 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c declare\ hidden\ i32\ .*normal)" -eq "2" ]
tests/run-make/sepcomp-inlining/foo.rs created+30
...@@ -0,0 +1,30 @@
1#![feature(start)]
2
3#[inline]
4fn inlined() -> u32 {
5 1234
6}
7
8fn normal() -> u32 {
9 2345
10}
11
12mod a {
13 pub fn f() -> u32 {
14 ::inlined() + ::normal()
15 }
16}
17
18mod b {
19 pub fn f() -> u32 {
20 ::inlined() + ::normal()
21 }
22}
23
24#[start]
25fn start(_: isize, _: *const *const u8) -> isize {
26 a::f();
27 b::f();
28
29 0
30}
tests/run-make/sepcomp-separate/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3# Test that separate compilation actually puts code into separate compilation
4# units. `foo.rs` defines `magic_fn` in three different modules, which should
5# wind up in three different compilation units.
6
7all:
8 $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3
9 [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*magic_fn)" -eq "3" ]
tests/run-make/sepcomp-separate/foo.rs created+21
...@@ -0,0 +1,21 @@
1fn magic_fn() -> usize {
2 1234
3}
4
5mod a {
6 pub fn magic_fn() -> usize {
7 2345
8 }
9}
10
11mod b {
12 pub fn magic_fn() -> usize {
13 3456
14 }
15}
16
17fn main() {
18 magic_fn();
19 a::magic_fn();
20 b::magic_fn();
21}
tests/run-make/share-generics-dylib/Makefile created+23
...@@ -0,0 +1,23 @@
1# ignore-cross-compile
2# This test makes sure all generic instances get re-exported from Rust dylibs for use by
3# `-Zshare-generics`. There are two rlibs (`instance_provider_a` and `instance_provider_b`)
4# which both provide an instance of `Cell<i32>::set`. There is `instance_user_dylib` which is
5# supposed to re-export both these instances, and then there are `instance_user_a_rlib` and
6# `instance_user_b_rlib` which each rely on a specific instance to be available.
7#
8# In the end everything is linked together into `linked_leaf`. If `instance_user_dylib` does
9# not export both then we'll get an `undefined reference` error for one of the instances.
10#
11# This is regression test for https://github.com/rust-lang/rust/issues/67276.
12
13include ../tools.mk
14
15COMMON_ARGS=-Cprefer-dynamic -Zshare-generics=yes -Ccodegen-units=1 -Csymbol-mangling-version=v0
16
17all:
18 $(RUSTC) instance_provider_a.rs $(COMMON_ARGS) --crate-type=rlib
19 $(RUSTC) instance_provider_b.rs $(COMMON_ARGS) --crate-type=rlib
20 $(RUSTC) instance_user_dylib.rs $(COMMON_ARGS) --crate-type=dylib
21 $(RUSTC) instance_user_a_rlib.rs $(COMMON_ARGS) --crate-type=rlib
22 $(RUSTC) instance_user_b_rlib.rs $(COMMON_ARGS) --crate-type=rlib
23 $(RUSTC) linked_leaf.rs $(COMMON_ARGS) --crate-type=bin
tests/run-make/share-generics-dylib/instance_provider_a.rs created+6
...@@ -0,0 +1,6 @@
1use std::cell::Cell;
2
3pub fn foo() {
4 let a: Cell<i32> = Cell::new(1);
5 a.set(123);
6}
tests/run-make/share-generics-dylib/instance_provider_b.rs created+6
...@@ -0,0 +1,6 @@
1use std::cell::Cell;
2
3pub fn foo() {
4 let b: Cell<i32> = Cell::new(1);
5 b.set(123);
6}
tests/run-make/share-generics-dylib/instance_user_a_rlib.rs created+9
...@@ -0,0 +1,9 @@
1extern crate instance_provider_a as upstream;
2use std::cell::Cell;
3
4pub fn foo() {
5 upstream::foo();
6
7 let b: Cell<i32> = Cell::new(1);
8 b.set(123);
9}
tests/run-make/share-generics-dylib/instance_user_b_rlib.rs created+9
...@@ -0,0 +1,9 @@
1extern crate instance_provider_b as upstream;
2use std::cell::Cell;
3
4pub fn foo() {
5 upstream::foo();
6
7 let b: Cell<i32> = Cell::new(1);
8 b.set(123);
9}
tests/run-make/share-generics-dylib/instance_user_dylib.rs created+7
...@@ -0,0 +1,7 @@
1extern crate instance_provider_a;
2extern crate instance_provider_b;
3
4pub fn foo() {
5 instance_provider_a::foo();
6 instance_provider_b::foo();
7}
tests/run-make/share-generics-dylib/linked_leaf.rs created+15
...@@ -0,0 +1,15 @@
1extern crate instance_user_dylib;
2extern crate instance_user_a_rlib;
3extern crate instance_user_b_rlib;
4
5use std::cell::Cell;
6
7fn main() {
8
9 instance_user_a_rlib::foo();
10 instance_user_b_rlib::foo();
11 instance_user_dylib::foo();
12
13 let a: Cell<i32> = Cell::new(1);
14 a.set(123);
15}
tests/run-make/simd-ffi/Makefile created+47
...@@ -0,0 +1,47 @@
1include ../tools.mk
2
3TARGETS =
4ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm)
5# construct a fairly exhaustive list of platforms that we
6# support. These ones don't follow a pattern
7TARGETS += arm-linux-androideabi arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabi
8endif
9
10ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86)
11X86_ARCHS = i686 x86_64
12else
13X86_ARCHS =
14endif
15
16# these ones do, each OS lists the architectures it supports
17LINUX=$(filter aarch64 mips,$(LLVM_COMPONENTS)) $(X86_ARCHS)
18ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips)
19LINUX += mipsel
20endif
21
22WINDOWS=$(X86_ARCHS)
23# fails with: failed to get iphonesimulator SDK path: no such file or directory
24#IOS=i386 aarch64 armv7
25DARWIN=$(X86_ARCHS)
26
27$(foreach arch,$(LINUX),$(eval TARGETS += $(arch)-unknown-linux-gnu))
28$(foreach arch,$(WINDOWS),$(eval TARGETS += $(arch)-pc-windows-gnu))
29#$(foreach arch,$(IOS),$(eval TARGETS += $(arch)-apple-ios))
30$(foreach arch,$(DARWIN),$(eval TARGETS += $(arch)-apple-darwin))
31
32all: $(TARGETS)
33
34define MK_TARGETS
35# compile the rust file to the given target, but only to asm and IR
36# form, to avoid having to have an appropriate linker.
37#
38# we need some features because the integer SIMD instructions are not
39# enabled by-default for i686 and ARM; these features will be invalid
40# on some platforms, but LLVM just prints a warning so that's fine for
41# now.
42$(1): simd.rs
43 $$(RUSTC) --target=$(1) --emit=llvm-ir,asm simd.rs \
44 -C target-feature='+neon,+sse2' -C extra-filename=-$(1)
45endef
46
47$(foreach targetxxx,$(TARGETS),$(eval $(call MK_TARGETS,$(targetxxx))))
tests/run-make/simd-ffi/simd.rs created+82
...@@ -0,0 +1,82 @@
1// ensures that public symbols are not removed completely
2#![crate_type = "lib"]
3// we can compile to a variety of platforms, because we don't need
4// cross-compiled standard libraries.
5#![feature(no_core, auto_traits)]
6#![no_core]
7#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)]
8
9#[derive(Copy)]
10#[repr(simd)]
11pub struct f32x4(f32, f32, f32, f32);
12
13extern "C" {
14 #[link_name = "llvm.sqrt.v4f32"]
15 fn vsqrt(x: f32x4) -> f32x4;
16}
17
18pub fn foo(x: f32x4) -> f32x4 {
19 unsafe { vsqrt(x) }
20}
21
22#[derive(Copy)]
23#[repr(simd)]
24pub struct i32x4(i32, i32, i32, i32);
25
26extern "C" {
27 // _mm_sll_epi32
28 #[cfg(any(target_arch = "x86", target_arch = "x86-64"))]
29 #[link_name = "llvm.x86.sse2.psll.d"]
30 fn integer(a: i32x4, b: i32x4) -> i32x4;
31
32 // vmaxq_s32
33 #[cfg(target_arch = "arm")]
34 #[link_name = "llvm.arm.neon.vmaxs.v4i32"]
35 fn integer(a: i32x4, b: i32x4) -> i32x4;
36 // vmaxq_s32
37 #[cfg(target_arch = "aarch64")]
38 #[link_name = "llvm.aarch64.neon.maxs.v4i32"]
39 fn integer(a: i32x4, b: i32x4) -> i32x4;
40
41 // just some substitute foreign symbol, not an LLVM intrinsic; so
42 // we still get type checking, but not as detailed as (ab)using
43 // LLVM.
44 #[cfg(not(any(
45 target_arch = "x86",
46 target_arch = "x86-64",
47 target_arch = "arm",
48 target_arch = "aarch64"
49 )))]
50 fn integer(a: i32x4, b: i32x4) -> i32x4;
51}
52
53pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
54 unsafe { integer(a, b) }
55}
56
57#[lang = "sized"]
58pub trait Sized {}
59
60#[lang = "copy"]
61pub trait Copy {}
62
63impl Copy for f32 {}
64impl Copy for i32 {}
65
66pub mod marker {
67 pub use Copy;
68}
69
70#[lang = "freeze"]
71auto trait Freeze {}
72
73#[macro_export]
74#[rustc_builtin_macro]
75macro_rules! Copy {
76 () => {};
77}
78#[macro_export]
79#[rustc_builtin_macro]
80macro_rules! derive {
81 () => {};
82}
tests/run-make/simple-dylib/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3all:
4 $(RUSTC) bar.rs --crate-type=dylib -C prefer-dynamic
5 $(RUSTC) foo.rs
6 $(call RUN,foo)
tests/run-make/simple-dylib/bar.rs created+1
...@@ -0,0 +1 @@
1pub fn bar() {}
tests/run-make/simple-dylib/foo.rs created+5
...@@ -0,0 +1,5 @@
1extern crate bar;
2
3fn main() {
4 bar::bar();
5}
tests/run-make/simple-rlib/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3all:
4 $(RUSTC) bar.rs --crate-type=rlib
5 $(RUSTC) foo.rs
6 $(call RUN,foo)
tests/run-make/simple-rlib/bar.rs created+1
...@@ -0,0 +1 @@
1pub fn bar() {}
tests/run-make/simple-rlib/foo.rs created+5
...@@ -0,0 +1,5 @@
1extern crate bar;
2
3fn main() {
4 bar::bar();
5}
tests/run-make/split-debuginfo/Makefile created+309
...@@ -0,0 +1,309 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: off packed unpacked
5
6ifeq ($(UNAME),Darwin)
7# If disabled, don't run `dsymutil`.
8off:
9 rm -rf $(TMPDIR)/*.dSYM
10 $(RUSTC) foo.rs -g -C split-debuginfo=off
11 [ ! -d $(TMPDIR)/foo.dSYM ]
12
13# Packed by default, but only if debuginfo is requested
14packed:
15 rm -rf $(TMPDIR)/*.dSYM
16 $(RUSTC) foo.rs
17 [ ! -d $(TMPDIR)/foo.dSYM ]
18 rm -rf $(TMPDIR)/*.dSYM
19 $(RUSTC) foo.rs -g
20 [ -d $(TMPDIR)/foo.dSYM ]
21 rm -rf $(TMPDIR)/*.dSYM
22 $(RUSTC) foo.rs -g -C split-debuginfo=packed
23 [ -d $(TMPDIR)/foo.dSYM ]
24 rm -rf $(TMPDIR)/*.dSYM
25
26# Object files are preserved with unpacked and `dsymutil` isn't run
27unpacked:
28 $(RUSTC) foo.rs -g -C split-debuginfo=unpacked
29 ls $(TMPDIR)/*.o
30 [ ! -d $(TMPDIR)/foo.dSYM ]
31else
32ifdef IS_WINDOWS
33# Windows only supports packed debuginfo - nothing to test.
34off:
35packed:
36unpacked:
37else
38# Some non-Windows, non-Darwin platforms are not stable, and some are.
39ifeq ($(UNAME),Linux)
40 UNSTABLEOPTS :=
41else
42 UNSTABLEOPTS := -Zunstable-options
43endif
44
45# - Debuginfo in `.o` files
46# - `.o` deleted
47# - `.dwo` never created
48# - `.dwp` never created
49off:
50 $(RUSTC) foo.rs -g -C $(UNSTABLEOPTS) split-debuginfo=off
51 [ ! -f $(TMPDIR)/*.dwp ]
52 [ ! -f $(TMPDIR)/*.dwo ]
53 $(RUSTC) foo.rs -g
54 [ ! -f $(TMPDIR)/*.dwp ]
55 [ ! -f $(TMPDIR)/*.dwo ]
56
57packed: packed-split packed-single packed-lto packed-remapped packed-crosscrate
58
59# - Debuginfo in `.dwo` files
60# - `.o` deleted
61# - `.dwo` deleted
62# - `.dwp` present
63packed-split:
64 $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=packed -Zsplit-dwarf-kind=split
65 ls $(TMPDIR)/*.o && exit 1 || exit 0
66 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
67 rm $(TMPDIR)/foo.dwp
68 rm $(TMPDIR)/$(call BIN,foo)
69
70# - Debuginfo in `.o` files
71# - `.o` deleted
72# - `.dwo` never created
73# - `.dwp` present
74packed-single:
75 $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=packed -Zsplit-dwarf-kind=single
76 ls $(TMPDIR)/*.o && exit 1 || exit 0
77 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
78 rm $(TMPDIR)/foo.dwp
79 rm $(TMPDIR)/$(call BIN,foo)
80
81packed-lto: packed-lto-split packed-lto-single
82
83# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated
84# - `.o` never created
85# - `.dwo` never created
86# - `.dwp` never created
87packed-lto-split:
88 $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split \
89 --crate-type=rlib -Clinker-plugin-lto
90 ls $(TMPDIR)/*.o && exit 1 || exit 0
91 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
92 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
93 rm $(TMPDIR)/libbaz.rlib
94
95# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated
96# - `.o` never created
97# - `.dwo` never created
98# - `.dwp` never created
99packed-lto-single:
100 $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=packed -Zsplit-dwarf-kind=single \
101 --crate-type=rlib -Clinker-plugin-lto
102 ls $(TMPDIR)/*.o && exit 1 || exit 0
103 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
104 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
105 rm $(TMPDIR)/libbaz.rlib
106
107packed-remapped: packed-remapped-split packed-remapped-single
108
109# - Debuginfo in `.dwo` files
110# - `.o` and binary refer to remapped `.dwo` paths which do not exist
111# - `.o` deleted
112# - `.dwo` deleted
113# - `.dwp` present
114packed-remapped-split:
115 $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
116 -Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g
117 objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
118 ls $(TMPDIR)/*.o && exit 1 || exit 0
119 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
120 rm $(TMPDIR)/foo.dwp
121 rm $(TMPDIR)/$(call BIN,foo)
122
123# - Debuginfo in `.o` files
124# - `.o` and binary refer to remapped `.o` paths which do not exist
125# - `.o` deleted
126# - `.dwo` never created
127# - `.dwp` present
128packed-remapped-single:
129 $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
130 -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g
131 objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
132 ls $(TMPDIR)/*.o && exit 1 || exit 0
133 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
134 rm $(TMPDIR)/foo.dwp
135 rm $(TMPDIR)/$(call BIN,foo)
136
137packed-crosscrate: packed-crosscrate-split packed-crosscrate-single
138
139# - Debuginfo in `.dwo` files
140# - (bar) `.rlib` file created, contains `.dwo`
141# - (bar) `.o` deleted
142# - (bar) `.dwo` deleted
143# - (bar) `.dwp` never created
144# - (main) `.o` deleted
145# - (main) `.dwo` deleted
146# - (main) `.dwp` present
147packed-crosscrate-split:
148 $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=packed \
149 -Zsplit-dwarf-kind=split -C debuginfo=2 -g bar.rs
150 ls $(TMPDIR)/*.rlib
151 ls $(TMPDIR)/*.o && exit 1 || exit 0
152 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
153 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
154 $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \
155 -C split-debuginfo=packed -Zsplit-dwarf-kind=split -C debuginfo=2 -g main.rs
156 ls $(TMPDIR)/*.o && exit 1 || exit 0
157 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
158 rm $(TMPDIR)/main.dwp
159 rm $(TMPDIR)/$(call BIN,main)
160
161# - Debuginfo in `.o` files
162# - (bar) `.rlib` file created, contains `.o`
163# - (bar) `.o` deleted
164# - (bar) `.dwo` never created
165# - (bar) `.dwp` never created
166# - (main) `.o` deleted
167# - (main) `.dwo` never created
168# - (main) `.dwp` present
169packed-crosscrate-single:
170 $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=packed \
171 -Zsplit-dwarf-kind=single -C debuginfo=2 -g bar.rs
172 ls $(TMPDIR)/*.rlib
173 ls $(TMPDIR)/*.o && exit 1 || exit 0
174 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
175 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
176 $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \
177 -C split-debuginfo=packed -Zsplit-dwarf-kind=single -C debuginfo=2 -g main.rs
178 ls $(TMPDIR)/*.o && exit 1 || exit 0
179 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
180 rm $(TMPDIR)/main.dwp
181 rm $(TMPDIR)/$(call BIN,main)
182
183unpacked: unpacked-split unpacked-single unpacked-lto unpacked-remapped unpacked-crosscrate
184
185# - Debuginfo in `.dwo` files
186# - `.o` deleted
187# - `.dwo` present
188# - `.dwp` never created
189unpacked-split:
190 $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=unpacked -Zsplit-dwarf-kind=split
191 ls $(TMPDIR)/*.o && exit 1 || exit 0
192 rm $(TMPDIR)/*.dwo
193 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
194 rm $(TMPDIR)/$(call BIN,foo)
195
196# - Debuginfo in `.o` files
197# - `.o` present
198# - `.dwo` never created
199# - `.dwp` never created
200unpacked-single:
201 $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=unpacked -Zsplit-dwarf-kind=single
202 ls $(TMPDIR)/*.o
203 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
204 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
205 rm $(TMPDIR)/$(call BIN,foo)
206
207unpacked-lto: packed-lto-split packed-lto-single
208
209# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated
210# - `.o` never created
211# - `.dwo` never created
212# - `.dwp` never created
213unpacked-lto-split:
214 $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=unpacked -Zsplit-dwarf-kind=split \
215 --crate-type=rlib -Clinker-plugin-lto
216 ls $(TMPDIR)/*.o && exit 1 || exit 0
217 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
218 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
219 rm $(TMPDIR)/libbaz.rlib
220
221# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated
222# - `.o` never created
223# - `.dwo` never created
224# - `.dwp` never created
225unpacked-lto-single:
226 $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=unpacked -Zsplit-dwarf-kind=single \
227 --crate-type=rlib -Clinker-plugin-lto
228 ls $(TMPDIR)/*.o && exit 1 || exit 0
229 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
230 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
231 rm $(TMPDIR)/libbaz.rlib
232
233unpacked-remapped: unpacked-remapped-split unpacked-remapped-single
234
235# - Debuginfo in `.dwo` files
236# - `.o` and binary refer to remapped `.dwo` paths which do not exist
237# - `.o` deleted
238# - `.dwo` present
239# - `.dwp` never created
240unpacked-remapped-split:
241 $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
242 -Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g
243 objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
244 ls $(TMPDIR)/*.o && exit 1 || exit 0
245 rm $(TMPDIR)/*.dwo
246 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
247 rm $(TMPDIR)/$(call BIN,foo)
248
249# - Debuginfo in `.o` files
250# - `.o` and binary refer to remapped `.o` paths which do not exist
251# - `.o` present
252# - `.dwo` never created
253# - `.dwp` never created
254unpacked-remapped-single:
255 $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
256 -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g
257 objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
258 rm $(TMPDIR)/*.o
259 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
260 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
261 rm $(TMPDIR)/$(call BIN,foo)
262
263unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single
264
265# - Debuginfo in `.dwo` files
266# - (bar) `.rlib` file created, contains `.dwo`
267# - (bar) `.o` deleted
268# - (bar) `.dwo` present
269# - (bar) `.dwp` never created
270# - (main) `.o` deleted
271# - (main) `.dwo` present
272# - (main) `.dwp` never created
273unpacked-crosscrate-split:
274 $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=unpacked \
275 -Zsplit-dwarf-kind=split -C debuginfo=2 -g bar.rs
276 ls $(TMPDIR)/*.rlib
277 ls $(TMPDIR)/*.o && exit 1 || exit 0
278 ls $(TMPDIR)/*.dwo
279 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
280 $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \
281 -C split-debuginfo=unpacked -Zsplit-dwarf-kind=split -C debuginfo=2 -g main.rs
282 ls $(TMPDIR)/*.o && exit 1 || exit 0
283 rm $(TMPDIR)/*.dwo
284 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
285 rm $(TMPDIR)/$(call BIN,main)
286
287# - Debuginfo in `.o` files
288# - (bar) `.rlib` file created, contains `.o`
289# - (bar) `.o` present
290# - (bar) `.dwo` never created
291# - (bar) `.dwp` never created
292# - (main) `.o` present
293# - (main) `.dwo` never created
294# - (main) `.dwp` never created
295unpacked-crosscrate-single:
296 $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=unpacked \
297 -Zsplit-dwarf-kind=single -C debuginfo=2 -g bar.rs
298 ls $(TMPDIR)/*.rlib
299 ls $(TMPDIR)/*.o
300 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
301 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
302 $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \
303 -C split-debuginfo=unpacked -Zsplit-dwarf-kind=single -C debuginfo=2 -g main.rs
304 ls $(TMPDIR)/*.o
305 ls $(TMPDIR)/*.dwo && exit 1 || exit 0
306 ls $(TMPDIR)/*.dwp && exit 1 || exit 0
307 rm $(TMPDIR)/$(call BIN,main)
308endif
309endif
tests/run-make/split-debuginfo/bar.rs created+13
...@@ -0,0 +1,13 @@
1pub struct Bar {
2 x: u32,
3}
4
5impl Bar {
6 pub fn print(&self) {
7 println!("{}", self.x);
8 }
9}
10
11pub fn make_bar(x: u32) -> Bar {
12 Bar { x }
13}
tests/run-make/split-debuginfo/baz.rs created+1
...@@ -0,0 +1 @@
1// empty
tests/run-make/split-debuginfo/foo.rs created+15
...@@ -0,0 +1,15 @@
1pub struct Foo {
2 x: u32,
3}
4
5impl Foo {
6 pub fn print(&self) {
7 println!("{}", self.x);
8 }
9}
10
11pub fn make_foo(x: u32) -> Foo {
12 Foo { x }
13}
14
15fn main() {}
tests/run-make/split-debuginfo/main.rs created+8
...@@ -0,0 +1,8 @@
1extern crate bar;
2
3use bar::{Bar, make_bar};
4
5fn main() {
6 let b = make_bar(3);
7 b.print();
8}
tests/run-make/stable-symbol-names/Makefile created+41
...@@ -0,0 +1,41 @@
1include ../tools.mk
2
3# The following command will:
4# 1. dump the symbols of a library using `nm`
5# 2. extract only those lines that we are interested in via `grep`
6# 3. from those lines, extract just the symbol name via `sed`, which:
7# * always starts with "_ZN" and ends with "E" (`legacy` mangling)
8# * always starts with "_R" (`v0` mangling)
9# 4. sort those symbol names for deterministic comparison
10# 5. write the result into a file
11
12dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \
13 | grep -E "$(2)" \
14 | sed -E "s/.*(_ZN.*E|_R[a-zA-Z0-9_]*).*/\1/" \
15 | sort \
16 > "$(TMPDIR)/$(1)$(3).nm"
17
18# This test
19# - compiles each of the two crates 2 times and makes sure each time we get
20# exactly the same symbol names
21# - makes sure that both crates agree on the same symbol names for monomorphic
22# functions
23
24all:
25 $(RUSTC) stable-symbol-names1.rs
26 $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v1)
27 rm $(TMPDIR)/libstable_symbol_names1.rlib
28 $(RUSTC) stable-symbol-names1.rs
29 $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v2)
30 cmp "$(TMPDIR)/stable_symbol_names1_v1.nm" "$(TMPDIR)/stable_symbol_names1_v2.nm"
31
32 $(RUSTC) stable-symbol-names2.rs
33 $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v1)
34 rm $(TMPDIR)/libstable_symbol_names2.rlib
35 $(RUSTC) stable-symbol-names2.rs
36 $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v2)
37 cmp "$(TMPDIR)/stable_symbol_names2_v1.nm" "$(TMPDIR)/stable_symbol_names2_v2.nm"
38
39 $(call dump-symbols,stable_symbol_names1,mono_,_cross)
40 $(call dump-symbols,stable_symbol_names2,mono_,_cross)
41 cmp "$(TMPDIR)/stable_symbol_names1_cross.nm" "$(TMPDIR)/stable_symbol_names2_cross.nm"
tests/run-make/stable-symbol-names/stable-symbol-names1.rs created+31
...@@ -0,0 +1,31 @@
1#![crate_type="rlib"]
2
3pub trait Foo {
4 fn generic_method<T>();
5}
6
7pub struct Bar;
8
9impl Foo for Bar {
10 fn generic_method<T>() {}
11}
12
13pub fn mono_function() {
14 Bar::generic_method::<Bar>();
15}
16
17pub fn mono_function_lifetime<'a>(x: &'a u64) -> u64 {
18 *x
19}
20
21pub fn generic_function<T>(t: T) -> T {
22 t
23}
24
25pub fn user() {
26 generic_function(0u32);
27 generic_function("abc");
28 let x = 2u64;
29 generic_function(&x);
30 let _ = mono_function_lifetime(&x);
31}
tests/run-make/stable-symbol-names/stable-symbol-names2.rs created+17
...@@ -0,0 +1,17 @@
1#![crate_type="rlib"]
2
3extern crate stable_symbol_names1;
4
5pub fn user() {
6 stable_symbol_names1::generic_function(1u32);
7 stable_symbol_names1::generic_function("def");
8 let x = 2u64;
9 stable_symbol_names1::generic_function(&x);
10 stable_symbol_names1::mono_function();
11 stable_symbol_names1::mono_function_lifetime(&0);
12}
13
14pub fn trait_impl_test_function() {
15 use stable_symbol_names1::*;
16 Bar::generic_method::<Bar>();
17}
tests/run-make/static-dylib-by-default/Makefile created+17
...@@ -0,0 +1,17 @@
1# ignore-cross-compile
2include ../tools.mk
3
4TO_LINK := $(call DYLIB,bar)
5ifdef IS_MSVC
6LINK_ARG = $(TO_LINK:dll=dll.lib)
7else
8LINK_ARG = $(TO_LINK)
9endif
10
11all:
12 $(RUSTC) foo.rs
13 $(RUSTC) bar.rs
14 $(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS)
15 rm $(TMPDIR)/*.rlib
16 rm $(call DYLIB,foo)
17 $(call RUN,main)
tests/run-make/static-dylib-by-default/bar.rs created+8
...@@ -0,0 +1,8 @@
1#![crate_type = "dylib"]
2
3extern crate foo;
4
5#[no_mangle]
6pub extern "C" fn bar() {
7 foo::foo();
8}
tests/run-make/static-dylib-by-default/foo.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "rlib"]
2#![crate_type = "dylib"]
3
4pub fn foo() {}
tests/run-make/static-dylib-by-default/main.c created+6
...@@ -0,0 +1,6 @@
1extern void bar();
2
3int main() {
4 bar();
5 return 0;
6}
tests/run-make/static-extern-type/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all: $(call NATIVE_STATICLIB,define-foo)
5 $(RUSTC) -ldefine-foo use-foo.rs
6 $(call RUN,use-foo) || exit 1
tests/run-make/static-extern-type/define-foo.c created+11
...@@ -0,0 +1,11 @@
1#include <stdint.h>
2
3struct Foo {
4 uint8_t x;
5};
6
7struct Foo FOO = { 42 };
8
9uint8_t bar(const struct Foo* foo) {
10 return foo->x;
11}
tests/run-make/static-extern-type/use-foo.rs created+14
...@@ -0,0 +1,14 @@
1#![feature(extern_types)]
2
3extern "C" {
4 type Foo;
5 static FOO: Foo;
6 fn bar(foo: *const Foo) -> u8;
7}
8
9fn main() {
10 unsafe {
11 let foo = &FOO;
12 assert_eq!(bar(foo), 42);
13 }
14}
tests/run-make/static-pie/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-x86_643# only-x86_64
4# only-linux4# only-linux
tests/run-make/static-unwinding/Makefile created+7
...@@ -0,0 +1,7 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) lib.rs
6 $(RUSTC) main.rs
7 $(call RUN,main)
tests/run-make/static-unwinding/lib.rs created+15
...@@ -0,0 +1,15 @@
1#![crate_type = "rlib"]
2
3pub static mut statik: isize = 0;
4
5struct A;
6impl Drop for A {
7 fn drop(&mut self) {
8 unsafe { statik = 1; }
9 }
10}
11
12pub fn callback<F>(f: F) where F: FnOnce() {
13 let _a = A;
14 f();
15}
tests/run-make/static-unwinding/main.rs created+24
...@@ -0,0 +1,24 @@
1extern crate lib;
2
3use std::thread;
4
5static mut statik: isize = 0;
6
7struct A;
8impl Drop for A {
9 fn drop(&mut self) {
10 unsafe { statik = 1; }
11 }
12}
13
14fn main() {
15 thread::spawn(move|| {
16 let _a = A;
17 lib::callback(|| panic!());
18 }).join().unwrap_err();
19
20 unsafe {
21 assert_eq!(lib::statik, 1);
22 assert_eq!(statik, 1);
23 }
24}
tests/run-make/staticlib-blank-lib/Makefile created+6
...@@ -0,0 +1,6 @@
1include ../tools.mk
2
3all:
4 $(AR) crus $(TMPDIR)/libfoo.a foo.rs
5 $(AR) d $(TMPDIR)/libfoo.a foo.rs
6 $(RUSTC) foo.rs
tests/run-make/staticlib-blank-lib/foo.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_type = "staticlib"]
2
3#[link(name = "foo", kind = "static")]
4extern "C" {}
5
6fn main() {}
tests/run-make/std-core-cycle/Makefile created+17
...@@ -0,0 +1,17 @@
1# ignore-cross-compile
2include ../tools.mk
3
4ifeq ($(UNAME),Darwin)
5FLAGS :=
6else
7ifdef IS_WINDOWS
8FLAGS :=
9else
10FLAGS := -C link-args=-Wl,--no-undefined
11endif
12endif
13
14all:
15 $(RUSTC) bar.rs
16 $(RUSTC) foo.rs $(FLAGS)
17 $(RUSTC) foo.rs $(FLAGS) -C panic=abort
tests/run-make/std-core-cycle/bar.rs created+16
...@@ -0,0 +1,16 @@
1#![feature(allocator_api)]
2#![crate_type = "rlib"]
3
4use std::alloc::*;
5
6pub struct A;
7
8unsafe impl GlobalAlloc for A {
9 unsafe fn alloc(&self, _: Layout) -> *mut u8 {
10 loop {}
11 }
12
13 unsafe fn dealloc(&self, _ptr: *mut u8, _: Layout) {
14 loop {}
15 }
16}
tests/run-make/std-core-cycle/foo.rs created+11
...@@ -0,0 +1,11 @@
1#![crate_type = "cdylib"]
2
3extern crate bar;
4
5#[global_allocator]
6static A: bar::A = bar::A;
7
8#[no_mangle]
9pub extern "C" fn a(a: u32, b: u32) -> u32 {
10 a / b
11}
tests/run-make/stdin-non-utf8/Makefile created+6
...@@ -0,0 +1,6 @@
1include ../tools.mk
2
3all:
4 cp non-utf8 $(TMPDIR)/non-utf.rs
5 cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \
6 | $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8"
tests/run-make/stdin-non-utf8/non-utf8 created+1
...@@ -0,0 +1 @@
1
tests/run-make/suspicious-library/Makefile created+8
...@@ -0,0 +1,8 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) foo.rs -C prefer-dynamic
6 touch $(call DYLIB,foo-something-special)
7 touch $(call DYLIB,foo-something-special2)
8 $(RUSTC) bar.rs
tests/run-make/suspicious-library/bar.rs created+3
...@@ -0,0 +1,3 @@
1extern crate foo;
2
3fn main() { foo::foo() }
tests/run-make/suspicious-library/foo.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "dylib"]
2
3pub fn foo() {}
tests/run-make/symbol-visibility/Makefile created+123
...@@ -0,0 +1,123 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows-msvc
5
6NM=nm -D
7CDYLIB_NAME=liba_cdylib.so
8RDYLIB_NAME=liba_rust_dylib.so
9PROC_MACRO_NAME=liba_proc_macro.so
10EXE_NAME=an_executable
11COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so
12
13ifeq ($(UNAME),Darwin)
14NM=nm -gU
15CDYLIB_NAME=liba_cdylib.dylib
16RDYLIB_NAME=liba_rust_dylib.dylib
17PROC_MACRO_NAME=liba_proc_macro.dylib
18EXE_NAME=an_executable
19COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib
20endif
21
22ifdef IS_WINDOWS
23NM=nm -g
24CDYLIB_NAME=liba_cdylib.dll.a
25RDYLIB_NAME=liba_rust_dylib.dll.a
26PROC_MACRO_NAME=liba_proc_macro.dll
27EXE_NAME=an_executable.exe
28COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dll.a
29endif
30
31# `grep` regex for symbols produced by either `legacy` or `v0` mangling
32RE_ANY_RUST_SYMBOL="_ZN.*h.*E\|_R[a-zA-Z0-9_]+"
33
34all:
35 $(RUSTC) -Zshare-generics=no an_rlib.rs
36 $(RUSTC) -Zshare-generics=no a_cdylib.rs
37 $(RUSTC) -Zshare-generics=no a_rust_dylib.rs
38 $(RUSTC) -Zshare-generics=no a_proc_macro.rs
39 $(RUSTC) -Zshare-generics=no an_executable.rs
40 $(RUSTC) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
41
42 # Check that a cdylib exports its public #[no_mangle] functions
43 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
44 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
45 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
46 # Check that a cdylib DOES NOT export any public Rust functions
47 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
48
49 # Check that a Rust dylib exports its monomorphic functions
50 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
51 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
52 # Check that a Rust dylib does not export generics if -Zshare-generics=no
53 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]
54
55
56 # Check that a Rust dylib exports the monomorphic functions from its dependencies
57 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
58 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ]
59 # Check that a Rust dylib does not export generics if -Zshare-generics=no
60 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "0" ]
61
62 # Check that a proc macro exports its public #[no_mangle] functions
63 # FIXME(#99978) avoid exporting #[no_mangle] symbols for proc macros
64 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
65 # Check that a proc macro exports the public #[no_mangle] functions of dependencies
66 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
67 # Check that a proc macro DOES NOT export any public Rust functions
68 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
69
70# FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032
71ifndef IS_WINDOWS
72 # Check that an executable does not export any dynamic symbols
73 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ]
74 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_rust_function_from_exe)" -eq "0" ]
75endif
76
77
78 # Check the combined case, where we generate a cdylib and an rlib in the same
79 # compilation session:
80 # Check that a cdylib exports its public #[no_mangle] functions
81 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
82 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
83 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
84 # Check that a cdylib DOES NOT export any public Rust functions
85 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
86
87
88 $(RUSTC) -Zshare-generics=yes an_rlib.rs
89 $(RUSTC) -Zshare-generics=yes a_cdylib.rs
90 $(RUSTC) -Zshare-generics=yes a_rust_dylib.rs
91 $(RUSTC) -Zshare-generics=yes a_proc_macro.rs
92 $(RUSTC) -Zshare-generics=yes an_executable.rs
93
94 # Check that a cdylib exports its public #[no_mangle] functions
95 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
96 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
97 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
98 # Check that a cdylib DOES NOT export any public Rust functions
99 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
100
101 # Check that a Rust dylib exports its monomorphic functions, including generics this time
102 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
103 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
104 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rust_dylib)" -eq "1" ]
105
106 # Check that a Rust dylib exports the monomorphic functions from its dependencies
107 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
108 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ]
109 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "1" ]
110
111 # Check that a proc macro exports its public #[no_mangle] functions
112 # FIXME(#99978) avoid exporting #[no_mangle] symbols for proc macros
113 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
114 # Check that a proc macro exports the public #[no_mangle] functions of dependencies
115 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
116 # Check that a proc macro DOES NOT export any public Rust functions
117 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
118
119ifndef IS_WINDOWS
120 # Check that an executable does not export any dynamic symbols
121 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ]
122 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_rust_function_from_exe)" -eq "0" ]
123endif
tests/run-make/symbol-visibility/a_cdylib.rs created+12
...@@ -0,0 +1,12 @@
1#![crate_type="cdylib"]
2
3extern crate an_rlib;
4
5// This should not be exported
6pub fn public_rust_function_from_cdylib() {}
7
8// This should be exported
9#[no_mangle]
10pub extern "C" fn public_c_function_from_cdylib() {
11 an_rlib::public_c_function_from_rlib();
12}
tests/run-make/symbol-visibility/a_proc_macro.rs created+9
...@@ -0,0 +1,9 @@
1#![crate_type = "proc-macro"]
2
3extern crate an_rlib;
4
5// This should not be exported
6#[no_mangle]
7extern "C" fn public_c_function_from_cdylib() {
8 an_rlib::public_c_function_from_rlib();
9}
tests/run-make/symbol-visibility/a_rust_dylib.rs created+15
...@@ -0,0 +1,15 @@
1#![crate_type="dylib"]
2
3extern crate an_rlib;
4
5// This should be exported
6pub fn public_rust_function_from_rust_dylib() {}
7
8// This should be exported
9#[no_mangle]
10pub extern "C" fn public_c_function_from_rust_dylib() {
11 let _ = public_generic_function_from_rust_dylib(1u16);
12}
13
14// This should be exported if -Zshare-generics=yes
15pub fn public_generic_function_from_rust_dylib<T>(x: T) -> T { x }
tests/run-make/symbol-visibility/an_executable.rs created+7
...@@ -0,0 +1,7 @@
1#![crate_type="bin"]
2
3extern crate an_rlib;
4
5pub fn public_rust_function_from_exe() {}
6
7fn main() {}
tests/run-make/symbol-visibility/an_rlib.rs created+12
...@@ -0,0 +1,12 @@
1#![crate_type="rlib"]
2
3pub fn public_rust_function_from_rlib() {}
4
5#[no_mangle]
6pub extern "C" fn public_c_function_from_rlib() {
7 let _ = public_generic_function_from_rlib(0u64);
8}
9
10pub fn public_generic_function_from_rlib<T>(x: T) -> T {
11 x
12}
tests/run-make/symbols-include-type-name/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3# Check that symbol names for methods include type names, instead of <impl>.
4
5OUT=$(TMPDIR)/lib.s
6
7all:
8 $(RUSTC) --crate-type staticlib --emit asm lib.rs
9 $(CGREP) Def < $(OUT)
tests/run-make/symbols-include-type-name/lib.rs created+14
...@@ -0,0 +1,14 @@
1pub struct Def {
2 pub id: i32,
3}
4
5impl Def {
6 pub fn new(id: i32) -> Def {
7 Def { id: id }
8 }
9}
10
11#[no_mangle]
12pub fn user() {
13 let _ = Def::new(0);
14}
tests/run-make/symlinked-extern/Makefile created+12
...@@ -0,0 +1,12 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows
5# `ln` is actually `cp` on msys.
6
7all:
8 $(RUSTC) foo.rs
9 mkdir -p $(TMPDIR)/other
10 ln -nsf $(TMPDIR)/libfoo.rlib $(TMPDIR)/other
11 $(RUSTC) bar.rs -L $(TMPDIR)
12 $(RUSTC) baz.rs --extern foo=$(TMPDIR)/other/libfoo.rlib -L $(TMPDIR)
tests/run-make/symlinked-extern/bar.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_type = "rlib"]
2
3extern crate foo;
4
5pub fn bar(_s: foo::S) {
6}
tests/run-make/symlinked-extern/baz.rs created+6
...@@ -0,0 +1,6 @@
1extern crate bar;
2extern crate foo;
3
4fn main() {
5 bar::bar(foo::foo());
6}
tests/run-make/symlinked-extern/foo.rs created+5
...@@ -0,0 +1,5 @@
1#![crate_type = "rlib"]
2
3pub struct S;
4
5pub fn foo() -> S { S }
tests/run-make/symlinked-libraries/Makefile created+11
...@@ -0,0 +1,11 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows
5# `ln` is actually `cp` on msys.
6
7all:
8 $(RUSTC) foo.rs -C prefer-dynamic
9 mkdir -p $(TMPDIR)/other
10 ln -nsf $(TMPDIR)/$(call DYLIB_GLOB,foo) $(TMPDIR)/other
11 $(RUSTC) bar.rs -L $(TMPDIR)/other
tests/run-make/symlinked-libraries/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::bar();
5}
tests/run-make/symlinked-libraries/foo.rs created+3
...@@ -0,0 +1,3 @@
1#![crate_type = "dylib"]
2
3pub fn bar() {}
tests/run-make/symlinked-rlib/Makefile created+10
...@@ -0,0 +1,10 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# ignore-windows
5# `ln` is actually `cp` on msys.
6
7all:
8 $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo.xxx
9 ln -nsf $(TMPDIR)/foo.xxx $(TMPDIR)/libfoo.rlib
10 $(RUSTC) bar.rs -L $(TMPDIR)
tests/run-make/symlinked-rlib/bar.rs created+5
...@@ -0,0 +1,5 @@
1extern crate foo;
2
3fn main() {
4 foo::bar();
5}
tests/run-make/symlinked-rlib/foo.rs created+1
...@@ -0,0 +1 @@
1pub fn bar() {}
tests/run-make/sysroot-crates-are-unstable/Makefile created+2
...@@ -0,0 +1,2 @@
1all:
2 '$(PYTHON)' test.py
tests/run-make/sysroot-crates-are-unstable/test.py created+75
...@@ -0,0 +1,75 @@
1import sys
2import os
3from os import listdir
4from os.path import isfile, join
5from subprocess import PIPE, Popen
6
7
8# This is n list of files which are stable crates or simply are not crates,
9# we don't check for the instability of these crates as they're all stable!
10STABLE_CRATES = ['std', 'alloc', 'core', 'proc_macro',
11 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', 'clang_rt']
12
13
14def convert_to_string(s):
15 if s.__class__.__name__ == 'bytes':
16 return s.decode('utf-8')
17 return s
18
19
20def set_ld_lib_path():
21 var = os.environ.get("LD_LIB_PATH_ENVVAR")
22 rpath = os.environ.get("HOST_RPATH_DIR")
23 if var and rpath:
24 path = os.environ.get(var)
25 if path:
26 os.environ[var] = rpath + os.pathsep + path
27 else:
28 os.environ[var] = rpath
29
30
31def exec_command(command, to_input=None):
32 child = None
33 if to_input is None:
34 child = Popen(command, stdout=PIPE, stderr=PIPE)
35 else:
36 child = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE)
37 stdout, stderr = child.communicate(input=to_input)
38 return (convert_to_string(stdout), convert_to_string(stderr))
39
40
41def check_lib(lib):
42 if lib['name'] in STABLE_CRATES:
43 return True
44 print('verifying if {} is an unstable crate'.format(lib['name']))
45 stdout, stderr = exec_command([os.environ['RUSTC'], '-', '--crate-type', 'rlib',
46 '--target', os.environ['TARGET'],
47 '--extern', '{}={}'.format(lib['name'], lib['path'])],
48 to_input=('extern crate {};'.format(lib['name'])).encode('utf-8'))
49 if not 'use of unstable library feature' in '{}{}'.format(stdout, stderr):
50 print('crate {} "{}" is not unstable'.format(lib['name'], lib['path']))
51 print('{}{}'.format(stdout, stderr))
52 print('')
53 return False
54 return True
55
56# Generate a list of all crates in the sysroot. To do this we list all files in
57# rustc's sysroot, look at the filename, strip everything after the `-`, and
58# strip the leading `lib` (if present)
59def get_all_libs(dir_path):
60 return [{ 'path': join(dir_path, f), 'name': f[3:].split('-')[0] }
61 for f in listdir(dir_path)
62 if isfile(join(dir_path, f)) and f.endswith('.rlib') and f not in STABLE_CRATES]
63
64
65set_ld_lib_path()
66sysroot = exec_command([os.environ['RUSTC'], '--print', 'sysroot'])[0].replace('\n', '')
67assert sysroot, "Could not read the rustc sysroot!"
68libs = get_all_libs(join(sysroot, 'lib/rustlib/{}/lib'.format(os.environ['TARGET'])))
69
70ret = 0
71for lib in libs:
72 if not check_lib(lib):
73 # We continue so users can see all the not unstable crates.
74 ret = 1
75sys.exit(ret)
tests/run-make/target-cpu-native/Makefile created+20
...@@ -0,0 +1,20 @@
1include ../tools.mk
2
3# only-linux
4# only-x86_64
5#
6# I *really* don't want to deal with a cross-platform way to compare file sizes,
7# tests in `make` sort of are awful
8
9all: $(TMPDIR)/out.log
10 # Make sure no warnings about "unknown CPU `native`" were emitted
11 if [ "$$(wc -c $(TMPDIR)/out.log | cut -d' ' -f 1)" = "0" ]; then \
12 echo no warnings generated; \
13 else \
14 exit 1; \
15 fi
16
17
18$(TMPDIR)/out.log:
19 $(RUSTC) foo.rs -C target-cpu=native 2>&1 | tee $(TMPDIR)/out.log
20 $(call RUN,foo)
tests/run-make/target-cpu-native/foo.rs created+2
...@@ -0,0 +1,2 @@
1fn main() {
2}
tests/run-make/target-specs/Makefile created+11
...@@ -0,0 +1,11 @@
1include ../tools.mk
2all:
3 $(RUSTC) foo.rs --target=my-awesome-platform.json --crate-type=lib --emit=asm
4 $(CGREP) -v morestack < $(TMPDIR)/foo.s
5 $(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | $(CGREP) "Error loading target specification"
6 $(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | $(CGREP) 'Field llvm-target'
7 RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm
8 RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
9 $(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -
10 $(RUSTC) foo.rs --target=definitely-not-builtin-target 2>&1 | $(CGREP) 'may not set is_builtin'
11 $(RUSTC) foo.rs --target=mismatching-data-layout --crate-type=lib
tests/run-make/target-specs/definitely-not-builtin-target.json created+7
...@@ -0,0 +1,7 @@
1{
2 "arch": "x86_64",
3 "is-builtin": true,
4 "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
5 "llvm-target": "x86_64-unknown-unknown-gnu",
6 "target-pointer-width": "64"
7}
tests/run-make/target-specs/foo.rs created+24
...@@ -0,0 +1,24 @@
1#![feature(lang_items, no_core, auto_traits)]
2#![no_core]
3
4#[lang = "copy"]
5trait Copy {}
6
7#[lang = "sized"]
8trait Sized {}
9
10#[lang = "freeze"]
11auto trait Freeze {}
12
13#[lang = "start"]
14fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
15 0
16}
17
18extern "C" {
19 fn _foo() -> [u8; 16];
20}
21
22fn _main() {
23 let _a = unsafe { _foo() };
24}
tests/run-make/target-specs/mismatching-data-layout.json created+6
...@@ -0,0 +1,6 @@
1{
2 "arch": "x86_64",
3 "data-layout": "e-m:e-i64:16:32:64",
4 "llvm-target": "x86_64-unknown-unknown-gnu",
5 "target-pointer-width": "64"
6}
tests/run-make/target-specs/my-awesome-platform.json created+11
...@@ -0,0 +1,11 @@
1{
2 "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128",
3 "linker-flavor": "gcc",
4 "llvm-target": "i686-unknown-linux-gnu",
5 "target-endian": "little",
6 "target-pointer-width": "32",
7 "target-c-int-width": "32",
8 "arch": "x86",
9 "os": "linux",
10 "morestack": false
11}
tests/run-make/target-specs/my-incomplete-platform.json created+10
...@@ -0,0 +1,10 @@
1{
2 "data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32",
3 "linker-flavor": "gcc",
4 "target-endian": "little",
5 "target-pointer-width": "32",
6 "target-c-int-width": "32",
7 "arch": "x86",
8 "os": "foo",
9 "morestack": false
10}
tests/run-make/target-specs/my-invalid-platform.json created+1
...@@ -0,0 +1 @@
1wow this json is really broke!
tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json created+12
...@@ -0,0 +1,12 @@
1{
2 "pre-link-args": {"gcc": ["-m64"]},
3 "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
4 "linker-flavor": "gcc",
5 "llvm-target": "x86_64-unknown-linux-gnu",
6 "target-endian": "little",
7 "target-pointer-width": "64",
8 "target-c-int-width": "32",
9 "arch": "x86_64",
10 "os": "linux",
11 "morestack": false
12}
tests/run-make/target-without-atomic-cas/Makefile created+5
...@@ -0,0 +1,5 @@
1include ../tools.mk
2
3# The target used below doesn't support atomic CAS operations. Verify that's the case
4all:
5 $(RUSTC) --print cfg --target thumbv6m-none-eabi | $(CGREP) -v 'target_has_atomic="ptr"'
tests/run-make/test-benches/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# ignore-cross-compile3# ignore-cross-compile
44
tests/run-make/test-harness/Makefile created+9
...@@ -0,0 +1,9 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 # check that #[cfg_attr(..., ignore)] does the right thing.
6 $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg
7 $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored'
8 $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$"
9 $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should'
tests/run-make/test-harness/test-ignore-cfg.rs created+9
...@@ -0,0 +1,9 @@
1#[test]
2#[cfg_attr(ignorecfg, ignore)]
3fn shouldignore() {
4}
5
6#[test]
7#[cfg_attr(noignorecfg, ignore)]
8fn shouldnotignore() {
9}
tests/run-make/thumb-none-cortex-m/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# How to run this3# How to run this
4# $ ./x.py clean4# $ ./x.py clean
tests/run-make/thumb-none-qemu/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-thumb3# only-thumb
44
tests/run-make/tools.mk created+187
...@@ -0,0 +1,187 @@
1# These deliberately use `=` and not `:=` so that client makefiles can
2# augment HOST_RPATH_DIR / TARGET_RPATH_DIR.
3HOST_RPATH_ENV = \
4 $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
5TARGET_RPATH_ENV = \
6 $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
7
8RUSTC_ORIGINAL := $(RUSTC)
9BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)'
10BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)'
11RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS)
12RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR)
13ifdef RUSTC_LINKER
14RUSTC := $(RUSTC) -Clinker='$(RUSTC_LINKER)'
15RUSTDOC := $(RUSTDOC) -Clinker='$(RUSTC_LINKER)'
16endif
17#CC := $(CC) -L $(TMPDIR)
18HTMLDOCCK := '$(PYTHON)' '$(S)/src/etc/htmldocck.py'
19CGREP := "$(S)/src/etc/cat-and-grep.sh"
20
21# diff with common flags for multi-platform diffs against text output
22DIFF := diff -u --strip-trailing-cr
23
24# Some of the Rust CI platforms use `/bin/dash` to run `shell` script in
25# Makefiles. Other platforms, including many developer platforms, default to
26# `/bin/bash`. (In many cases, `make` is actually using `/bin/sh`, but `sh`
27# is configured to execute one or the other shell binary). `dash` features
28# support only a small subset of `bash` features, so `dash` can be thought of as
29# the lowest common denominator, and tests should be validated against `dash`
30# whenever possible. Most developer platforms include `/bin/dash`, but to ensure
31# tests still work when `/bin/dash`, if not available, this `SHELL` override is
32# conditional:
33ifndef IS_WINDOWS # dash interprets backslashes in executable paths incorrectly
34ifneq (,$(wildcard /bin/dash))
35SHELL := /bin/dash
36endif
37endif
38
39# This is the name of the binary we will generate and run; use this
40# e.g. for `$(CC) -o $(RUN_BINFILE)`.
41RUN_BINFILE = $(TMPDIR)/$(1)
42
43# Invoke the generated binary on the remote machine if compiletest was
44# configured to use a remote test device, otherwise run it on the current host.
45ifdef REMOTE_TEST_CLIENT
46# FIXME: if a test requires additional files, this will need to be changed to
47# also push them (by changing the 0 to the number of additional files, and
48# providing the path of the additional files as the last arguments).
49EXECUTE = $(REMOTE_TEST_CLIENT) run 0 $(RUN_BINFILE)
50else
51EXECUTE = $(RUN_BINFILE)
52endif
53
54# RUN and FAIL are basic way we will invoke the generated binary. On
55# non-windows platforms, they set the LD_LIBRARY_PATH environment
56# variable before running the binary.
57
58RLIB_GLOB = lib$(1)*.rlib
59BIN = $(1)
60
61UNAME = $(shell uname)
62
63ifeq ($(UNAME),Darwin)
64RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
65FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
66DYLIB_GLOB = lib$(1)*.dylib
67DYLIB = $(TMPDIR)/lib$(1).dylib
68STATICLIB = $(TMPDIR)/lib$(1).a
69STATICLIB_GLOB = lib$(1)*.a
70else
71ifdef IS_WINDOWS
72RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE)
73FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE) && exit 1 || exit 0
74DYLIB_GLOB = $(1)*.dll
75DYLIB = $(TMPDIR)/$(1).dll
76ifdef IS_MSVC
77STATICLIB = $(TMPDIR)/$(1).lib
78STATICLIB_GLOB = $(1)*.lib
79else
80IMPLIB = $(TMPDIR)/lib$(1).dll.a
81STATICLIB = $(TMPDIR)/lib$(1).a
82STATICLIB_GLOB = lib$(1)*.a
83endif
84BIN = $(1).exe
85LLVM_FILECHECK := $(shell cygpath -u "$(LLVM_FILECHECK)")
86else
87RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
88FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
89DYLIB_GLOB = lib$(1)*.so
90DYLIB = $(TMPDIR)/lib$(1).so
91STATICLIB = $(TMPDIR)/lib$(1).a
92STATICLIB_GLOB = lib$(1)*.a
93endif
94endif
95
96ifdef IS_MSVC
97COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2)
98COMPILE_OBJ_CXX = $(CXX) -EHs -c -Fo:`cygpath -w $(1)` $(2)
99NATIVE_STATICLIB_FILE = $(1).lib
100NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1))
101OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \
102 -Fo:`cygpath -w $(TMPDIR)/$(1).obj`
103else
104COMPILE_OBJ = $(CC) -v -c -o $(1) $(2)
105COMPILE_OBJ_CXX = $(CXX) -c -o $(1) $(2)
106NATIVE_STATICLIB_FILE = lib$(1).a
107NATIVE_STATICLIB = $(call STATICLIB,$(1))
108OUT_EXE=-o $(TMPDIR)/$(1)
109endif
110
111
112# Extra flags needed to compile a working executable with the standard library
113ifdef IS_WINDOWS
114ifdef IS_MSVC
115 EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib bcrypt.lib ntdll.lib
116else
117 EXTRACFLAGS := -lws2_32 -luserenv -lbcrypt -lntdll
118 EXTRACXXFLAGS := -lstdc++
119 # So this is a bit hacky: we can't use the DLL version of libstdc++ because
120 # it pulls in the DLL version of libgcc, which means that we end up with 2
121 # instances of the DW2 unwinding implementation. This is a problem on
122 # i686-pc-windows-gnu because each module (DLL/EXE) needs to register its
123 # unwind information with the unwinding implementation, and libstdc++'s
124 # __cxa_throw won't see the unwinding info we registered with our statically
125 # linked libgcc.
126 #
127 # Now, simply statically linking libstdc++ would fix this problem, except
128 # that it is compiled with the expectation that pthreads is dynamically
129 # linked as a DLL and will fail to link with a statically linked libpthread.
130 #
131 # So we end up with the following hack: we link use static:-bundle to only
132 # link the parts of libstdc++ that we actually use, which doesn't include
133 # the dependency on the pthreads DLL.
134 EXTRARSCXXFLAGS := -l static:-bundle=stdc++
135endif
136else
137ifeq ($(UNAME),Darwin)
138 EXTRACFLAGS := -lresolv
139 EXTRACXXFLAGS := -lc++
140 EXTRARSCXXFLAGS := -lc++
141else
142ifeq ($(UNAME),FreeBSD)
143 EXTRACFLAGS := -lm -lpthread -lgcc_s
144else
145ifeq ($(UNAME),SunOS)
146 EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv
147else
148ifeq ($(UNAME),OpenBSD)
149 EXTRACFLAGS := -lm -lpthread -lc++abi
150 RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))"
151else
152 EXTRACFLAGS := -lm -lrt -ldl -lpthread
153 EXTRACXXFLAGS := -lstdc++
154 EXTRARSCXXFLAGS := -lstdc++
155endif
156endif
157endif
158endif
159endif
160
161REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1))
162REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1))
163
164%.a: %.o
165 $(AR) crus $@ $<
166ifdef IS_MSVC
167%.lib: lib%.o
168 $(MSVC_LIB) -out:`cygpath -w $@` $<
169else
170%.lib: lib%.o
171 $(AR) crus $@ $<
172endif
173%.dylib: %.o
174 $(CC) -dynamiclib -Wl,-dylib -o $@ $<
175%.so: %.o
176 $(CC) -o $@ $< -shared
177
178ifdef IS_MSVC
179%.dll: lib%.o
180 $(CC) $< -link -dll -out:`cygpath -w $@`
181else
182%.dll: lib%.o
183 $(CC) -o $@ $< -shared -Wl,--out-implib=$@.a
184endif
185
186$(TMPDIR)/lib%.o: %.c
187 $(call COMPILE_OBJ,$@,$<)
tests/run-make/track-path-dep-info/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`3# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`
4# instead of hardcoding them everywhere they're needed.4# instead of hardcoding them everywhere they're needed.
tests/run-make/track-pgo-dep-info/Makefile+1-1
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1# needs-profiler-support1# needs-profiler-support
2# ignore-windows-gnu2# ignore-windows-gnu
33
4-include ../../run-make-fulldeps/tools.mk4include ../tools.mk
55
6# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`6# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC`
7# instead of hardcoding them everywhere they're needed.7# instead of hardcoding them everywhere they're needed.
tests/run-make/translation/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# This test uses `ln -s` rather than copying to save testing time, but its3# This test uses `ln -s` rather than copying to save testing time, but its
4# usage doesn't work on Windows.4# usage doesn't work on Windows.
tests/run-make/type-mismatch-same-crate-name/Makefile created+19
...@@ -0,0 +1,19 @@
1include ../tools.mk
2
3all:
4 # compile two different versions of crateA
5 $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-1 -C extra-filename=-1
6 $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-2 -C extra-filename=-2
7 # make crateB depend on version 1 of crateA
8 $(RUSTC) --crate-type=rlib crateB.rs --extern crateA=$(TMPDIR)/libcrateA-1.rlib
9 # make crateC depend on version 2 of crateA
10 $(RUSTC) crateC.rs --extern crateA=$(TMPDIR)/libcrateA-2.rlib 2>&1 | \
11 tr -d '\r\n' | $(CGREP) -e \
12 "mismatched types.*\
13 crateB::try_foo\(foo2\);.*\
14 expected \`crateA::foo::Foo\`, found \`Foo\`.*\
15 different versions of crate \`crateA\`.*\
16 mismatched types.*\
17 crateB::try_bar\(bar2\);.*\
18 expected trait \`crateA::bar::Bar\`, found trait \`Bar\`.*\
19 different versions of crate \`crateA\`"
tests/run-make/type-mismatch-same-crate-name/crateA.rs created+16
...@@ -0,0 +1,16 @@
1mod foo {
2 pub struct Foo;
3}
4
5mod bar {
6 pub trait Bar{}
7
8 pub fn bar() -> Box<Bar> {
9 unimplemented!()
10 }
11}
12
13// This makes the publicly accessible path
14// differ from the internal one.
15pub use foo::Foo;
16pub use bar::{Bar, bar};
tests/run-make/type-mismatch-same-crate-name/crateB.rs created+4
...@@ -0,0 +1,4 @@
1extern crate crateA;
2
3pub fn try_foo(x: crateA::Foo){}
4pub fn try_bar(x: Box<crateA::Bar>){}
tests/run-make/type-mismatch-same-crate-name/crateC.rs created+25
...@@ -0,0 +1,25 @@
1// This tests the extra note reported when a type error deals with
2// seemingly identical types.
3// The main use case of this error is when there are two crates
4// (generally different versions of the same crate) with the same name
5// causing a type mismatch.
6
7// The test is nearly the same as the one in
8// ui/type/type-mismatch-same-crate-name.rs
9// but deals with the case where one of the crates
10// is only introduced as an indirect dependency.
11// and the type is accessed via a re-export.
12// This is similar to how the error can be introduced
13// when using cargo's automatic dependency resolution.
14
15extern crate crateA;
16
17fn main() {
18 let foo2 = crateA::Foo;
19 let bar2 = crateA::bar();
20 {
21 extern crate crateB;
22 crateB::try_foo(foo2);
23 crateB::try_bar(bar2);
24 }
25}
tests/run-make/unstable-flag-required/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 $(RUSTDOC) --output-format=json x.html 2>&1 | diff - output-format-json.stderr4 $(RUSTDOC) --output-format=json x.html 2>&1 | diff - output-format-json.stderr
tests/run-make/use-extern-for-plugins/Makefile created+17
...@@ -0,0 +1,17 @@
1include ../tools.mk
2
3# ignore-freebsd
4# ignore-openbsd
5# ignore-sunos
6
7HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
8ifeq ($(findstring i686,$(HOST)),i686)
9TARGET := $(subst i686,x86_64,$(HOST))
10else
11TARGET := $(subst x86_64,i686,$(HOST))
12endif
13
14all:
15 $(RUSTC) foo.rs -C extra-filename=-host
16 $(RUSTC) bar.rs -C extra-filename=-targ --target $(TARGET)
17 $(RUSTC) baz.rs --extern a=$(TMPDIR)/liba-targ.rlib --target $(TARGET)
tests/run-make/use-extern-for-plugins/bar.rs created+9
...@@ -0,0 +1,9 @@
1#![feature(no_core)]
2#![no_core]
3#![crate_type = "lib"]
4#![crate_name = "a"]
5
6#[macro_export]
7macro_rules! bar {
8 () => ()
9}
tests/run-make/use-extern-for-plugins/baz.rs created+8
...@@ -0,0 +1,8 @@
1#![feature(no_core)]
2#![no_core]
3#![crate_type = "lib"]
4
5#[macro_use]
6extern crate a;
7
8bar!();
tests/run-make/use-extern-for-plugins/foo.rs created+8
...@@ -0,0 +1,8 @@
1#![no_std]
2#![crate_type = "lib"]
3#![crate_name = "a"]
4
5#[macro_export]
6macro_rules! foo {
7 () => ()
8}
tests/run-make/use-suggestions-rust-2018/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) ep-nested-lib.rs
5
6 $(RUSTC) use-suggestions.rs --edition=2018 --extern ep_nested_lib=$(TMPDIR)/libep_nested_lib.rlib 2>&1 | $(CGREP) "use ep_nested_lib::foo::bar::Baz"
7
tests/run-make/use-suggestions-rust-2018/ep-nested-lib.rs created+7
...@@ -0,0 +1,7 @@
1#![crate_type = "rlib"]
2
3pub mod foo {
4 pub mod bar {
5 pub struct Baz;
6 }
7}
tests/run-make/use-suggestions-rust-2018/use-suggestions.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 let x = Baz{};
3}
tests/run-make/used-cdylib-macos/Makefile created+11
...@@ -0,0 +1,11 @@
1include ../tools.mk
2
3# only-macos
4#
5# This checks that `#[used]` passes through to the linker on
6# darwin. This is subject to change in the future, see
7# https://github.com/rust-lang/rust/pull/93718 for discussion
8
9all:
10 $(RUSTC) -Copt-level=3 dylib_used.rs
11 nm $(TMPDIR)/libdylib_used.dylib | $(CGREP) VERY_IMPORTANT_SYMBOL
tests/run-make/used-cdylib-macos/dylib_used.rs created+4
...@@ -0,0 +1,4 @@
1#![crate_type = "cdylib"]
2
3#[used]
4static VERY_IMPORTANT_SYMBOL: u32 = 12345;
tests/run-make/used/Makefile created+7
...@@ -0,0 +1,7 @@
1include ../tools.mk
2
3# ignore-windows-msvc
4
5all:
6 $(RUSTC) -C opt-level=3 --emit=obj used.rs
7 nm $(TMPDIR)/used.o | $(CGREP) FOO
tests/run-make/used/used.rs created+6
...@@ -0,0 +1,6 @@
1#![crate_type = "lib"]
2
3#[used]
4static FOO: u32 = 0;
5
6static BAR: u32 = 0;
tests/run-make/valid-print-requests/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3all:3all:
4 $(RUSTC) --print uwu 2>&1 | diff - valid-print-requests.stderr4 $(RUSTC) --print uwu 2>&1 | diff - valid-print-requests.stderr
tests/run-make/version/Makefile created+6
...@@ -0,0 +1,6 @@
1include ../tools.mk
2
3all:
4 $(RUSTC) -V
5 $(RUSTC) -vV
6 $(RUSTC) --version --verbose
tests/run-make/volatile-intrinsics/Makefile created+10
...@@ -0,0 +1,10 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 # The tests must pass...
6 $(RUSTC) main.rs
7 $(call RUN,main)
8 # ... and the loads/stores must not be optimized out.
9 $(RUSTC) main.rs --emit=llvm-ir
10 $(CGREP) "load volatile" "store volatile" < $(TMPDIR)/main.ll
tests/run-make/volatile-intrinsics/main.rs created+24
...@@ -0,0 +1,24 @@
1#![feature(core_intrinsics, volatile)]
2
3use std::intrinsics::{
4 unaligned_volatile_load, unaligned_volatile_store, volatile_load, volatile_store,
5};
6use std::ptr::{read_volatile, write_volatile};
7
8pub fn main() {
9 unsafe {
10 let mut i: isize = 1;
11 volatile_store(&mut i, 2);
12 assert_eq!(volatile_load(&i), 2);
13 }
14 unsafe {
15 let mut i: isize = 1;
16 unaligned_volatile_store(&mut i, 2);
17 assert_eq!(unaligned_volatile_load(&i), 2);
18 }
19 unsafe {
20 let mut i: isize = 1;
21 write_volatile(&mut i, 2);
22 assert_eq!(read_volatile(&i), 2);
23 }
24}
tests/run-make/wasm-abi/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/wasm-custom-section/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/wasm-custom-sections-opt/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/wasm-export-all-symbols/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/wasm-import-module/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3 # only-wasm32-bare3 # only-wasm32-bare
44
tests/run-make/wasm-panic-small/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/wasm-spurious-import/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/wasm-stringify-ints-small/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3ifeq ($(TARGET),wasm32-unknown-unknown)3ifeq ($(TARGET),wasm32-unknown-unknown)
4all:4all:
tests/run-make/wasm-symbols-different-module/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/wasm-symbols-not-exported/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/wasm-symbols-not-imported/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3# only-wasm32-bare3# only-wasm32-bare
44
tests/run-make/weird-output-filenames/Makefile created+15
...@@ -0,0 +1,15 @@
1include ../tools.mk
2
3all:
4 cp foo.rs $(TMPDIR)/.foo.rs
5 $(RUSTC) $(TMPDIR)/.foo.rs 2>&1 \
6 | $(CGREP) -e "invalid character.*in crate name:"
7 cp foo.rs $(TMPDIR)/.foo.bar
8 $(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \
9 | $(CGREP) -e "invalid character.*in crate name:"
10 cp foo.rs $(TMPDIR)/+foo+bar.rs
11 $(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \
12 | $(CGREP) -e "invalid character.*in crate name:"
13 cp foo.rs $(TMPDIR)/-foo.rs
14 $(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \
15 | $(CGREP) 'crate names cannot start with a `-`'
tests/run-make/weird-output-filenames/foo.rs created+1
...@@ -0,0 +1 @@
1fn main() {}
tests/run-make/windows-binary-no-external-deps/Makefile created+9
...@@ -0,0 +1,9 @@
1include ../tools.mk
2
3# only-windows
4
5PATH=$(SYSTEMROOT)/system32
6
7all:
8 $(RUSTC) hello.rs
9 $(TMPDIR)/hello.exe
tests/run-make/windows-binary-no-external-deps/hello.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 println!("Hello World!");
3}
tests/run-make/windows-spawn/Makefile created+8
...@@ -0,0 +1,8 @@
1include ../tools.mk
2
3# only-windows
4
5all:
6 $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs
7 $(RUSTC) spawn.rs
8 $(TMPDIR)/spawn.exe
tests/run-make/windows-spawn/hello.rs created+3
...@@ -0,0 +1,3 @@
1fn main() {
2 println!("Hello World!");
3}
tests/run-make/windows-spawn/spawn.rs created+12
...@@ -0,0 +1,12 @@
1use std::io::ErrorKind;
2use std::process::Command;
3
4fn main() {
5 // Make sure it doesn't try to run "hopefullydoesntexist bar.exe".
6 assert_eq!(Command::new("hopefullydoesntexist")
7 .arg("bar")
8 .spawn()
9 .unwrap_err()
10 .kind(),
11 ErrorKind::NotFound);
12}
tests/run-make/windows-subsystem/Makefile created+6
...@@ -0,0 +1,6 @@
1# ignore-cross-compile
2include ../tools.mk
3
4all:
5 $(RUSTC) windows.rs
6 $(RUSTC) console.rs
tests/run-make/windows-subsystem/console.rs created+3
...@@ -0,0 +1,3 @@
1#![windows_subsystem = "console"]
2
3fn main() {}
tests/run-make/windows-subsystem/windows.rs created+3
...@@ -0,0 +1,3 @@
1#![windows_subsystem = "windows"]
2
3fn main() {}
tests/run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile+1-1
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1include ../../run-make-fulldeps/tools.mk1include ../tools.mk
22
3#only-x86_64-fortanix-unknown-sgx3#only-x86_64-fortanix-unknown-sgx
44