2022-04-08 10:20:57 -05:00
|
|
|
# ignore-cross-compile
|
|
|
|
# ignore-windows-msvc
|
|
|
|
|
2023-03-30 07:58:50 -05:00
|
|
|
include ../tools.mk
|
2022-04-08 10:20:57 -05:00
|
|
|
|
2022-06-29 03:41:32 -05:00
|
|
|
# We're using the llvm-nm instead of the system nm to ensure it is compatible
|
|
|
|
# with the LLVM bitcode generated by rustc.
|
2022-08-05 14:08:53 -05:00
|
|
|
# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm.
|
|
|
|
ifndef IS_WINDOWS
|
2022-06-29 03:41:32 -05:00
|
|
|
NM = "$(LLVM_BIN_DIR)"/llvm-nm
|
2022-08-05 14:08:53 -05:00
|
|
|
else
|
|
|
|
NM = nm
|
|
|
|
endif
|
2022-06-29 03:41:32 -05:00
|
|
|
|
2022-04-08 10:20:57 -05:00
|
|
|
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
|
2022-06-29 03:41:32 -05:00
|
|
|
$(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"
|
2022-04-08 10:20:57 -05:00
|
|
|
|
|
|
|
# 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
|
2022-06-29 03:41:32 -05:00
|
|
|
$(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"
|
2022-04-08 10:20:57 -05:00
|
|
|
|
|
|
|
# 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'
|
2022-06-29 03:41:32 -05:00
|
|
|
$(NM) $(call DYLIB,cdylib_bundled) | $(CGREP) -e "[Tt] _*native_func"
|
2022-04-08 10:20:57 -05:00
|
|
|
|
|
|
|
# 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'
|
2022-06-29 03:41:32 -05:00
|
|
|
$(NM) $(call DYLIB,cdylib_non_bundled) | $(CGREP) -e "[Tt] _*native_func"
|