Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt native-link-modifier-bundle test to use llvm-nm #98573

Merged
merged 1 commit into from
Jul 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/test/run-make/native-link-modifier-bundle/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@

-include ../../run-make-fulldeps/tools.mk

# 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-staticlib)
# Build a staticlib and a rlib, the `native_func` symbol will be bundled into them
$(RUSTC) bundled.rs --crate-type=staticlib --crate-type=rlib
nm $(TMPDIR)/libbundled.a | $(CGREP) -e "T _*native_func"
nm $(TMPDIR)/libbundled.a | $(CGREP) -e "U _*native_func"
nm $(TMPDIR)/libbundled.rlib | $(CGREP) -e "T _*native_func"
nm $(TMPDIR)/libbundled.rlib | $(CGREP) -e "U _*native_func"
$(NM) $(TMPDIR)/libbundled.a | $(CGREP) -e "T _*native_func"
$(NM) $(TMPDIR)/libbundled.a | $(CGREP) -e "U _*native_func"
$(NM) $(TMPDIR)/libbundled.rlib | $(CGREP) -e "T _*native_func"
$(NM) $(TMPDIR)/libbundled.rlib | $(CGREP) -e "U _*native_func"

# Build a staticlib and a rlib, the `native_func` symbol will not be bundled into it
$(RUSTC) non-bundled.rs --crate-type=staticlib --crate-type=rlib
nm $(TMPDIR)/libnon_bundled.a | $(CGREP) -ve "T _*native_func"
nm $(TMPDIR)/libnon_bundled.a | $(CGREP) -e "U _*native_func"
nm $(TMPDIR)/libnon_bundled.rlib | $(CGREP) -ve "T _*native_func"
nm $(TMPDIR)/libnon_bundled.rlib | $(CGREP) -e "U _*native_func"
$(NM) $(TMPDIR)/libnon_bundled.a | $(CGREP) -ve "T _*native_func"
$(NM) $(TMPDIR)/libnon_bundled.a | $(CGREP) -e "U _*native_func"
$(NM) $(TMPDIR)/libnon_bundled.rlib | $(CGREP) -ve "T _*native_func"
$(NM) $(TMPDIR)/libnon_bundled.rlib | $(CGREP) -e "U _*native_func"

# Build a cdylib, `native-staticlib` will not appear on the linker line because it was bundled previously
# The cdylib will contain the `native_func` symbol in the end
$(RUSTC) cdylib-bundled.rs --crate-type=cdylib --print link-args | $(CGREP) -ve '-l[" ]*native-staticlib'
nm $(call DYLIB,cdylib_bundled) | $(CGREP) -e "[Tt] _*native_func"
$(NM) $(call DYLIB,cdylib_bundled) | $(CGREP) -e "[Tt] _*native_func"

# Build a cdylib, `native-staticlib` will appear on the linker line because it was not bundled previously
# The cdylib will contain the `native_func` symbol in the end
$(RUSTC) cdylib-non-bundled.rs --crate-type=cdylib --print link-args | $(CGREP) -e '-l[" ]*native-staticlib'
nm $(call DYLIB,cdylib_non_bundled) | $(CGREP) -e "[Tt] _*native_func"
$(NM) $(call DYLIB,cdylib_non_bundled) | $(CGREP) -e "[Tt] _*native_func"