summaryrefslogtreecommitdiffstats
path: root/tests/run-make/extern-flag-pathless
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /tests/run-make/extern-flag-pathless
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/extern-flag-pathless')
-rw-r--r--tests/run-make/extern-flag-pathless/Makefile27
-rw-r--r--tests/run-make/extern-flag-pathless/bar-dynamic.rs3
-rw-r--r--tests/run-make/extern-flag-pathless/bar-static.rs3
-rw-r--r--tests/run-make/extern-flag-pathless/bar.rs1
4 files changed, 22 insertions, 12 deletions
diff --git a/tests/run-make/extern-flag-pathless/Makefile b/tests/run-make/extern-flag-pathless/Makefile
index 701bfcd28..36b374e0d 100644
--- a/tests/run-make/extern-flag-pathless/Makefile
+++ b/tests/run-make/extern-flag-pathless/Makefile
@@ -3,17 +3,32 @@ include ../tools.mk
# Test mixing pathless --extern with paths.
+# Test for static linking by checking that the binary runs if the dylib
+# is removed and test for dynamic linking by checking that the binary
+# fails to run if the dylib is removed.
+
all:
- $(RUSTC) bar-static.rs --crate-name=bar --crate-type=rlib
- $(RUSTC) bar-dynamic.rs --crate-name=bar --crate-type=dylib -C prefer-dynamic
+ $(RUSTC) bar.rs --crate-type=rlib --crate-type=dylib -Cprefer-dynamic
+
# rlib preferred over dylib
$(RUSTC) foo.rs --extern bar
- $(call RUN,foo) | $(CGREP) 'static'
+ mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
+ $(call RUN,foo)
+ mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
+
$(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar
- $(call RUN,foo) | $(CGREP) 'static'
+ mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
+ $(call RUN,foo)
+ mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
+
# explicit --extern overrides pathless
$(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar
- $(call RUN,foo) | $(CGREP) 'dynamic'
+ mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
+ $(call FAIL,foo)
+ mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
+
# prefer-dynamic does what it says
$(RUSTC) foo.rs --extern bar -C prefer-dynamic
- $(call RUN,foo) | $(CGREP) 'dynamic'
+ mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
+ $(call FAIL,foo)
+ mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
diff --git a/tests/run-make/extern-flag-pathless/bar-dynamic.rs b/tests/run-make/extern-flag-pathless/bar-dynamic.rs
deleted file mode 100644
index e2d68d517..000000000
--- a/tests/run-make/extern-flag-pathless/bar-dynamic.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-pub fn f() {
- println!("dynamic");
-}
diff --git a/tests/run-make/extern-flag-pathless/bar-static.rs b/tests/run-make/extern-flag-pathless/bar-static.rs
deleted file mode 100644
index 240d8bde4..000000000
--- a/tests/run-make/extern-flag-pathless/bar-static.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-pub fn f() {
- println!("static");
-}
diff --git a/tests/run-make/extern-flag-pathless/bar.rs b/tests/run-make/extern-flag-pathless/bar.rs
new file mode 100644
index 000000000..cdc6c27d8
--- /dev/null
+++ b/tests/run-make/extern-flag-pathless/bar.rs
@@ -0,0 +1 @@
+pub fn f() {}