diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 88b70ddec1..0000000000 --- a/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -**/boot/*.o -**/boot/*.bc -**/boot/lib*.rlib -**/boot/*.ll - -**/boot/*.elf -**/boot/*.bin -**/boot/*.img -**/boot/*.embed - -**/boot/*.d -**/boot/linker.map diff --git a/Makefile b/Makefile index c1c9811367..28c081ab74 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,14 @@ arch=x86 RUST_ROOT := /usr LLVM_ROOT := /usr GCC_PREFIX := /usr/bin/ +SHELL := /bin/bash export RUST_ROOT export LLVM_ROOT export GCC_PREFIX all: - @$(MAKE) all -C arch/$(arch)/ + @$(MAKE) all -C arch/$(arch)/ SHELL=$(SHELL) %: - @$(MAKE) $* -C arch/$(arch)/ + @$(MAKE) $* -C arch/$(arch)/ SHELL=$(SHELL) diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 43463a87a4..30d824de88 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -9,7 +9,7 @@ AS := $(GCC_PREFIX)as LD := $(GCC_PREFIX)ld LLC := $(LLVM_ROOT)/bin/llc -LLCFLAGS := -march=arm -mcpu=arm926ej-s --float-abi=hard -asm-verbose +LLCFLAGS := -mtriple=$(TARGET) -march=arm -mcpu=arm926ej-s --float-abi=hard -asm-verbose GDB := $(GCC_PREFIX)gdb OBJCOPY := $(GCC_PREFIX)objcopy @@ -18,14 +18,17 @@ QEMU := qemu-system-arm BDIR := ./boot CORE_LIB := ../../rust-core/core/lib.rs LCORE := $(BDIR)/$(shell $(RUSTC) --crate-file-name $(CORE_LIB)) + OBJS := $(BDIR)/loader.o $(BDIR)/aeabi_runtime.o $(BDIR)/main.o $(BDIR)/core.o LINK := $(BDIR)/linker.ld $(OBJS) $(BDIR)/initram.elf.embed -MODS := $(wildcard */*.rs) $(wildcard ../../kernel/*.rs) $(wildcard ../../kernel/*/*.rs) $(wildcard ../../kernel/*/*/*.rs) +DEP_RM := arch\/ +DEP_KEEP := arch\/arm +DEP_SCRIPT := 's/\($(DEP_KEEP)\)/\n\1/g;s/ \S*$(DEP_RM)\S*//g;s/\n\($(DEP_KEEP)\)/\1/g' -include ./config.mk -include $(BDIR)/core.d --include $(BDIR)/loader.d +-include $(BDIR)/main.d .PHONY: all run debug clean @@ -33,18 +36,20 @@ all: $(BDIR)/kernel.bin @wc -c $^ # Library rust-core -$(LCORE): - $(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/core.d $(CORE_LIB) --emit=bc,link --out-dir $(BDIR) +$(LCORE) $(BDIR)/core.bc: + $(RUSTC) $(RUSTCFLAGS) $(CORE_LIB) --dep-info --emit=bc,link --out-dir $(BDIR) -# Compile rustboot -$(BDIR)/main.bc: ../../lib.rs $(MODS) $(LCORE) - $(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/main.d -L $(BDIR) --emit=bc ../../lib.rs --out-dir $(BDIR) +# Compile rustboot. Produce dependency info +$(BDIR)/main.bc: $(LCORE) + $(RUSTC) $(RUSTCFLAGS) -L $(BDIR) --dep-info --emit=bc ../../lib.rs --out-dir $(BDIR) + @sed -i $(DEP_SCRIPT) $(BDIR)/main.d %.s: %.bc $(LLC) $(LLCFLAGS) $^ -o $@ +# Assemble object files. note: do not overwrite deps with -MD $*.d %.o: %.s - $(AS) -MD $*.d -g $< -o $@ + $(AS) -g $< -o $@ # initram $(BDIR)/%.o: %.s @@ -53,8 +58,8 @@ $(BDIR)/%.o: %.s $(BDIR)/initram.elf: $(BDIR)/module.o $(LD) -s -o $@ $^ -%.embed: % - $(LD) -r -b binary -o $@ $^ +$(BDIR)/%.embed: $(BDIR)/% + cd $(@D); $(LD) $(LDFLAGS) -r -b binary -o $(@F) $( $@ # running -run: boot/floppy.img - $(QEMU) -fda $< +run: all + $(QEMU) -fda $(BDIR)/floppy.img debug: $(BDIR)/kernel.elf $(BDIR)/floppy.img ifeq ($(strip $(TMUX)),) @@ -93,4 +96,4 @@ else endif clean: - rm -f $(BDIR)/*.{d,o,bc,rlib,so,ll,embed,elf,bin,img,map} + @cat $(BDIR)/.gitignore | xargs -I{} find $(BDIR) -name {} | xargs rm -f diff --git a/arch/x86/boot/.gitignore b/arch/x86/boot/.gitignore new file mode 100644 index 0000000000..0ebb2dc3e1 --- /dev/null +++ b/arch/x86/boot/.gitignore @@ -0,0 +1,12 @@ +*.d +linker.map + +lib*.rlib +*.bc + +*.elf +*.o +*.o-* +*.embed +*.bin +*.img diff --git a/kernel/mod.rs b/kernel/mod.rs index 865be0e2d9..710f365eab 100644 --- a/kernel/mod.rs +++ b/kernel/mod.rs @@ -26,5 +26,6 @@ pub fn main() { cpu::init(); drivers::init(); - elf::exec(&_binary_boot_initram_elf_start); + elf::exec(&_binary_initram_elf_start); + extern { static _binary_initram_elf_start: u8; } }