summaryrefslogtreecommitdiffstats
path: root/tests/run-make/rlib-format-packed-bundled-libs-3
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:50 +0000
commit2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch)
treed325add32978dbdc1db975a438b3a77d571b1ab8 /tests/run-make/rlib-format-packed-bundled-libs-3
parentReleasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff)
downloadrustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz
rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/rlib-format-packed-bundled-libs-3')
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/Makefile35
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/main.rs5
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c1
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c1
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c1
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c1
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs16
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs10
8 files changed, 70 insertions, 0 deletions
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile
new file mode 100644
index 000000000..62dc1b5f6
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile
@@ -0,0 +1,35 @@
+-include ../../run-make-fulldeps/tools.mk
+
+# ignore-cross-compile
+# only-linux
+
+# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive.
+
+# We're using the llvm-nm instead of the system nm to ensure it is compatible
+# with the LLVM bitcode generated by rustc.
+NM = "$(LLVM_BIN_DIR)"/llvm-nm
+
+all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(call NATIVE_STATICLIB,native_dep_4)
+ # test cfg with packed bundle
+ $(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs
+ $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add
+ $(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a"
+ $(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a"
+ $(AR) t $(TMPDIR)/libmain.a | $(CGREP) -e "libnative_dep_1.o"
+ $(AR) t $(TMPDIR)/libmain.a | $(CGREP) -ev "libnative_dep_2.o"
+
+
+ # test bundle with whole_archive
+ $(RUSTC) rust_dep.rs --crate-type=rlib
+ $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_1"
+ $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_3"
+ $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_2"
+ $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_4"
+
+ # Make sure compiler doesn't use files, that it shouldn't know about.
+ rm $(TMPDIR)/libnative_dep_1.a
+ rm $(TMPDIR)/libnative_dep_3.a
+
+ $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib --print link-args > $(TMPDIR)/link_args
+ cat $(TMPDIR)/link_args | $(CGREP) -ev "native_dep_3"
+ cat $(TMPDIR)/link_args | $(CGREP) -e "--whole-archive.*native_dep_1.*--whole-archive.*lnative_dep_2.*no-whole-archive.*lnative_dep_4"
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs
new file mode 100644
index 000000000..8d2b8a285
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs
@@ -0,0 +1,5 @@
+extern crate rust_dep;
+
+pub fn main() {
+ rust_dep::rust_dep();
+}
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c
new file mode 100644
index 000000000..07be8562c
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c
@@ -0,0 +1 @@
+int native_f1() { return 1; }
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c
new file mode 100644
index 000000000..a1b94e40d
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c
@@ -0,0 +1 @@
+int native_f2() { return 2; }
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c
new file mode 100644
index 000000000..f81f397a4
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c
@@ -0,0 +1 @@
+int native_f3() { return 3; }
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c
new file mode 100644
index 000000000..14d41d60b
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c
@@ -0,0 +1 @@
+int native_f4() { return 4; }
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs
new file mode 100644
index 000000000..abd846b68
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs
@@ -0,0 +1,16 @@
+#![feature(packed_bundled_libs)]
+
+#[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")]
+extern "C" {}
+
+#[link(name = "native_dep_2", kind = "static", modifiers = "+whole-archive,-bundle")]
+extern "C" {}
+
+#[link(name = "native_dep_3", kind = "static", modifiers = "+bundle")]
+extern "C" {}
+
+#[link(name = "native_dep_4", kind = "static", modifiers = "-bundle")]
+extern "C" {}
+
+#[no_mangle]
+pub fn rust_dep() {}
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs
new file mode 100644
index 000000000..506ca62a8
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs
@@ -0,0 +1,10 @@
+#![feature(link_cfg)]
+
+#[link(name = "native_dep_1", kind = "static", cfg(should_add))]
+extern "C" {}
+
+#[link(name = "native_dep_2", kind = "static", cfg(should_not_add))]
+extern "C" {}
+
+#[no_mangle]
+pub fn rust_dep() {}