Theseus icon indicating copy to clipboard operation
Theseus copied to clipboard

Move assembly linking and symbol parsing/serialization into the `nano_core` build script

Open kevinaboos opened this issue 3 years ago • 1 comments

(Relevant after #542 lands)

Right now both of these steps are done in the Makefile, specifically the $(nano_core_binary) target. Doing this in the Makefile is okay but it prevents us from using cargo features to control them. Specifically, it'd be nice to have a cargo feature within mod_mgmt and nano_core that selects which kind of nano_core parsing routine we use, since that would allow us to mark dependencies on things like serde and bincode as optional, thereby saving space and compile time.

The linkage step is:

$(CROSS)ld -n -T $(linker_script) -o $(nano_core_binary) $(assembly_object_files) $(nano_core_static_lib)

which only uses files from within the nano_core/src/ directory.

The parsing/serialization step is:

@cargo run --release --manifest-path $(ROOT_DIR)/tools/serialize_nano_core/Cargo.toml \
		<(cargo run --release --manifest-path $(ROOT_DIR)/tools/demangle_readelf_file/Cargo.toml \
		<($(CROSS)readelf -S -s -W $(nano_core_binary) \
		| sed '/OBJECT  LOCAL .* str\./d;/NOTYPE  LOCAL  /d;/FILE    LOCAL  /d;/SECTION LOCAL  /d;')) \
		> $(OBJECT_FILES_BUILD_DIR)/$(KERNEL_PREFIX)nano_core.serde

which needs to change based on what form of nano_core symbol parsing we want to use in the parse_nano_core() function.

kevinaboos avatar Jul 05 '22 23:07 kevinaboos

Note that I'm an idiot and forgot that build scripts can only run before compilation of a crate. So we could do the assembly compilation in a build script, but not the symbol parsing/serialization step because that necessarily has to occur post-compilation.

kevinaboos avatar Aug 04 '22 18:08 kevinaboos

Closed by #732, which moves the compilation of assembly code out of the Makefile and into the nano_core's build script.

kevinaboos avatar Jan 05 '23 20:01 kevinaboos