7df6f4161c
This commit is an implementation of adding custom sections to wasm artifacts in rustc. The intention here is to expose the ability of the wasm binary format to contain custom sections with arbitrary user-defined data. Currently neither our version of LLVM nor LLD supports this so the implementation is currently custom to rustc itself. The implementation here is to attach a `#[wasm_custom_section = "foo"]` attribute to any `const` which has a type like `[u8; N]`. Other types of constants aren't supported yet but may be added one day! This should hopefully be enough to get off the ground with *some* custom section support. The current semantics are that any constant tagged with `#[wasm_custom_section]` section will be *appended* to the corresponding section in the final output wasm artifact (and this affects dependencies linked in as well, not just the final crate). This means that whatever is interpreting the contents must be able to interpret binary-concatenated sections (or each constant needs to be in its own custom section). To test this change the existing `run-make` test suite was moved to a `run-make-fulldeps` folder and a new `run-make` test suite was added which applies to all targets by default. This test suite currently only has one test which only runs for the wasm target (using a node.js script to use `WebAssembly` in JS to parse the wasm output).
35 lines
743 B
Makefile
35 lines
743 B
Makefile
-include ../tools.mk
|
|
|
|
# FIXME: ignore freebsd/windows
|
|
# on windows `rustc --dep-info` produces Makefile dependency with
|
|
# windows native paths (e.g. `c:\path\to\libfoo.a`)
|
|
# but msys make seems to fail to recognize such paths, so test fails.
|
|
ifneq ($(shell uname),FreeBSD)
|
|
ifndef IS_WINDOWS
|
|
all:
|
|
cp *.rs $(TMPDIR)
|
|
$(RUSTC) --emit dep-info,link --crate-type=lib $(TMPDIR)/lib.rs
|
|
sleep 2
|
|
touch $(TMPDIR)/foo.rs
|
|
-rm -f $(TMPDIR)/done
|
|
$(MAKE) -drf Makefile.foo
|
|
sleep 2
|
|
rm $(TMPDIR)/done
|
|
pwd
|
|
$(MAKE) -drf Makefile.foo
|
|
rm $(TMPDIR)/done && exit 1 || exit 0
|
|
|
|
# When a source file is deleted `make` should still work
|
|
rm $(TMPDIR)/bar.rs
|
|
cp $(TMPDIR)/lib2.rs $(TMPDIR)/lib.rs
|
|
$(MAKE) -drf Makefile.foo
|
|
else
|
|
all:
|
|
|
|
endif
|
|
|
|
else
|
|
all:
|
|
|
|
endif
|