From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../run-make-fulldeps/stable-symbol-names/Makefile | 41 ++++++++++++++++++++++ .../stable-symbol-names/stable-symbol-names1.rs | 31 ++++++++++++++++ .../stable-symbol-names/stable-symbol-names2.rs | 17 +++++++++ 3 files changed, 89 insertions(+) create mode 100644 tests/run-make-fulldeps/stable-symbol-names/Makefile create mode 100644 tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs create mode 100644 tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs (limited to 'tests/run-make-fulldeps/stable-symbol-names') diff --git a/tests/run-make-fulldeps/stable-symbol-names/Makefile b/tests/run-make-fulldeps/stable-symbol-names/Makefile new file mode 100644 index 000000000..bbfb8e388 --- /dev/null +++ b/tests/run-make-fulldeps/stable-symbol-names/Makefile @@ -0,0 +1,41 @@ +include ../tools.mk + +# The following command will: +# 1. dump the symbols of a library using `nm` +# 2. extract only those lines that we are interested in via `grep` +# 3. from those lines, extract just the symbol name via `sed`, which: +# * always starts with "_ZN" and ends with "E" (`legacy` mangling) +# * always starts with "_R" (`v0` mangling) +# 4. sort those symbol names for deterministic comparison +# 5. write the result into a file + +dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \ + | grep -E "$(2)" \ + | sed -E "s/.*(_ZN.*E|_R[a-zA-Z0-9_]*).*/\1/" \ + | sort \ + > "$(TMPDIR)/$(1)$(3).nm" + +# This test +# - compiles each of the two crates 2 times and makes sure each time we get +# exactly the same symbol names +# - makes sure that both crates agree on the same symbol names for monomorphic +# functions + +all: + $(RUSTC) stable-symbol-names1.rs + $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v1) + rm $(TMPDIR)/libstable_symbol_names1.rlib + $(RUSTC) stable-symbol-names1.rs + $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v2) + cmp "$(TMPDIR)/stable_symbol_names1_v1.nm" "$(TMPDIR)/stable_symbol_names1_v2.nm" + + $(RUSTC) stable-symbol-names2.rs + $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v1) + rm $(TMPDIR)/libstable_symbol_names2.rlib + $(RUSTC) stable-symbol-names2.rs + $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v2) + cmp "$(TMPDIR)/stable_symbol_names2_v1.nm" "$(TMPDIR)/stable_symbol_names2_v2.nm" + + $(call dump-symbols,stable_symbol_names1,mono_,_cross) + $(call dump-symbols,stable_symbol_names2,mono_,_cross) + cmp "$(TMPDIR)/stable_symbol_names1_cross.nm" "$(TMPDIR)/stable_symbol_names2_cross.nm" diff --git a/tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs b/tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs new file mode 100644 index 000000000..b85a42827 --- /dev/null +++ b/tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs @@ -0,0 +1,31 @@ +#![crate_type="rlib"] + +pub trait Foo { + fn generic_method(); +} + +pub struct Bar; + +impl Foo for Bar { + fn generic_method() {} +} + +pub fn mono_function() { + Bar::generic_method::(); +} + +pub fn mono_function_lifetime<'a>(x: &'a u64) -> u64 { + *x +} + +pub fn generic_function(t: T) -> T { + t +} + +pub fn user() { + generic_function(0u32); + generic_function("abc"); + let x = 2u64; + generic_function(&x); + let _ = mono_function_lifetime(&x); +} diff --git a/tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs b/tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs new file mode 100644 index 000000000..33df9d6c6 --- /dev/null +++ b/tests/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs @@ -0,0 +1,17 @@ +#![crate_type="rlib"] + +extern crate stable_symbol_names1; + +pub fn user() { + stable_symbol_names1::generic_function(1u32); + stable_symbol_names1::generic_function("def"); + let x = 2u64; + stable_symbol_names1::generic_function(&x); + stable_symbol_names1::mono_function(); + stable_symbol_names1::mono_function_lifetime(&0); +} + +pub fn trait_impl_test_function() { + use stable_symbol_names1::*; + Bar::generic_method::(); +} -- cgit v1.2.3