From 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:39 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- tests/run-make/link-cfg/Makefile | 23 +++++++++++++++++++++++ tests/run-make/link-cfg/dep-with-staticlib.rs | 8 ++++++++ tests/run-make/link-cfg/dep.rs | 8 ++++++++ tests/run-make/link-cfg/no-deps.rs | 20 ++++++++++++++++++++ tests/run-make/link-cfg/return1.c | 6 ++++++ tests/run-make/link-cfg/return2.c | 6 ++++++ tests/run-make/link-cfg/return3.c | 6 ++++++ tests/run-make/link-cfg/with-deps.rs | 14 ++++++++++++++ tests/run-make/link-cfg/with-staticlib-deps.rs | 14 ++++++++++++++ 9 files changed, 105 insertions(+) create mode 100644 tests/run-make/link-cfg/Makefile create mode 100644 tests/run-make/link-cfg/dep-with-staticlib.rs create mode 100644 tests/run-make/link-cfg/dep.rs create mode 100644 tests/run-make/link-cfg/no-deps.rs create mode 100644 tests/run-make/link-cfg/return1.c create mode 100644 tests/run-make/link-cfg/return2.c create mode 100644 tests/run-make/link-cfg/return3.c create mode 100644 tests/run-make/link-cfg/with-deps.rs create mode 100644 tests/run-make/link-cfg/with-staticlib-deps.rs (limited to 'tests/run-make/link-cfg') diff --git a/tests/run-make/link-cfg/Makefile b/tests/run-make/link-cfg/Makefile new file mode 100644 index 000000000..a40997011 --- /dev/null +++ b/tests/run-make/link-cfg/Makefile @@ -0,0 +1,23 @@ +# ignore-cross-compile +include ../tools.mk + +all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3) + ls $(TMPDIR) + $(BARE_RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static + + $(RUSTC) no-deps.rs --cfg foo + $(call RUN,no-deps) + $(RUSTC) no-deps.rs --cfg bar + $(call RUN,no-deps) + + $(RUSTC) dep.rs + $(RUSTC) with-deps.rs --cfg foo + $(call RUN,with-deps) + $(RUSTC) with-deps.rs --cfg bar + $(call RUN,with-deps) + + $(RUSTC) dep-with-staticlib.rs + $(RUSTC) with-staticlib-deps.rs --cfg foo + $(call RUN,with-staticlib-deps) + $(RUSTC) with-staticlib-deps.rs --cfg bar + $(call RUN,with-staticlib-deps) diff --git a/tests/run-make/link-cfg/dep-with-staticlib.rs b/tests/run-make/link-cfg/dep-with-staticlib.rs new file mode 100644 index 000000000..5ad66475d --- /dev/null +++ b/tests/run-make/link-cfg/dep-with-staticlib.rs @@ -0,0 +1,8 @@ +#![feature(link_cfg)] +#![crate_type = "rlib"] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return3", kind = "static", cfg(bar))] +extern "C" { + pub fn my_function() -> i32; +} diff --git a/tests/run-make/link-cfg/dep.rs b/tests/run-make/link-cfg/dep.rs new file mode 100644 index 000000000..40de77f05 --- /dev/null +++ b/tests/run-make/link-cfg/dep.rs @@ -0,0 +1,8 @@ +#![feature(link_cfg)] +#![crate_type = "rlib"] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return2", cfg(bar))] +extern "C" { + pub fn my_function() -> i32; +} diff --git a/tests/run-make/link-cfg/no-deps.rs b/tests/run-make/link-cfg/no-deps.rs new file mode 100644 index 000000000..ba5a8711a --- /dev/null +++ b/tests/run-make/link-cfg/no-deps.rs @@ -0,0 +1,20 @@ +#![feature(link_cfg)] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return2", cfg(bar))] +extern "C" { + fn my_function() -> i32; +} + +fn main() { + unsafe { + let v = my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 2); + } else { + panic!("unknown"); + } + } +} diff --git a/tests/run-make/link-cfg/return1.c b/tests/run-make/link-cfg/return1.c new file mode 100644 index 000000000..41c2809ad --- /dev/null +++ b/tests/run-make/link-cfg/return1.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 1; +} diff --git a/tests/run-make/link-cfg/return2.c b/tests/run-make/link-cfg/return2.c new file mode 100644 index 000000000..622aeaa29 --- /dev/null +++ b/tests/run-make/link-cfg/return2.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 2; +} diff --git a/tests/run-make/link-cfg/return3.c b/tests/run-make/link-cfg/return3.c new file mode 100644 index 000000000..f29dc60d5 --- /dev/null +++ b/tests/run-make/link-cfg/return3.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 3; +} diff --git a/tests/run-make/link-cfg/with-deps.rs b/tests/run-make/link-cfg/with-deps.rs new file mode 100644 index 000000000..48b782815 --- /dev/null +++ b/tests/run-make/link-cfg/with-deps.rs @@ -0,0 +1,14 @@ +extern crate dep; + +fn main() { + unsafe { + let v = dep::my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 2); + } else { + panic!("unknown"); + } + } +} diff --git a/tests/run-make/link-cfg/with-staticlib-deps.rs b/tests/run-make/link-cfg/with-staticlib-deps.rs new file mode 100644 index 000000000..23e5926a7 --- /dev/null +++ b/tests/run-make/link-cfg/with-staticlib-deps.rs @@ -0,0 +1,14 @@ +extern crate dep_with_staticlib; + +fn main() { + unsafe { + let v = dep_with_staticlib::my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 3); + } else { + panic!("unknown"); + } + } +} -- cgit v1.2.3