2022-08-22 19:00:00 -05:00
|
|
|
include ../tools.mk
|
2016-03-29 11:12:12 -05:00
|
|
|
|
2016-09-29 02:24:14 -05:00
|
|
|
# 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`
|
2019-04-13 11:03:02 -05:00
|
|
|
# 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)
|
2016-09-29 02:24:14 -05:00
|
|
|
# 4. sort those symbol names for deterministic comparison
|
|
|
|
# 5. write the result into a file
|
2016-03-29 11:12:12 -05:00
|
|
|
|
|
|
|
dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \
|
2017-01-09 08:52:08 -06:00
|
|
|
| grep -E "$(2)" \
|
2019-04-13 11:03:02 -05:00
|
|
|
| sed -E "s/.*(_ZN.*E|_R[a-zA-Z0-9_]*).*/\1/" \
|
2016-03-29 11:12:12 -05:00
|
|
|
| sort \
|
2017-01-09 08:52:08 -06:00
|
|
|
> "$(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
|
2016-03-29 11:12:12 -05:00
|
|
|
|
|
|
|
all:
|
|
|
|
$(RUSTC) stable-symbol-names1.rs
|
2017-01-09 08:52:08 -06:00
|
|
|
$(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"
|
|
|
|
|
2016-03-29 11:12:12 -05:00
|
|
|
$(RUSTC) stable-symbol-names2.rs
|
2017-01-09 08:52:08 -06:00
|
|
|
$(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"
|