From b9cbedceb1c2b63d9da7a29713b6b5944c85d941 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 3 Feb 2017 12:53:25 +0000 Subject: [PATCH] firmware: migrate last vestiges of the old runtime build system. --- MANIFEST.in | 1 - artiq/firmware/ksupport/Makefile | 37 ++++++++ .../ksupport}/artiq_personality.c | 0 .../ksupport}/artiq_personality.h | 0 .../ksupport/glue.c} | 0 .../ksupport}/ksupport.ld | 0 artiq/firmware/runtime/Makefile | 32 +++++++ artiq/firmware/runtime/kernel.rs | 8 +- artiq/{ => firmware}/runtime/runtime.ld | 0 artiq/gateware/amp/soc.py | 3 +- artiq/runtime/Makefile | 86 ------------------- artiq/test/libartiq_support/Makefile | 4 +- conda/artiq-dev/meta.yaml | 2 +- 13 files changed, 78 insertions(+), 95 deletions(-) create mode 100644 artiq/firmware/ksupport/Makefile rename artiq/{runtime => firmware/ksupport}/artiq_personality.c (100%) rename artiq/{runtime => firmware/ksupport}/artiq_personality.h (100%) rename artiq/{runtime/ksupport_glue.c => firmware/ksupport/glue.c} (100%) rename artiq/{runtime => firmware/ksupport}/ksupport.ld (100%) create mode 100644 artiq/firmware/runtime/Makefile rename artiq/{ => firmware}/runtime/runtime.ld (100%) delete mode 100644 artiq/runtime/Makefile diff --git a/MANIFEST.in b/MANIFEST.in index 5f0c4245c..159e4d9ed 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ -graft artiq/runtime graft artiq/firmware graft artiq/examples include artiq/gui/logo*.svg diff --git a/artiq/firmware/ksupport/Makefile b/artiq/firmware/ksupport/Makefile new file mode 100644 index 000000000..d62932b1d --- /dev/null +++ b/artiq/firmware/ksupport/Makefile @@ -0,0 +1,37 @@ +include ../include/generated/variables.mak +include $(MISOC_DIRECTORY)/software/common.mak + +CFLAGS += \ + -I$(LIBUNWIND_DIRECTORY) \ + -I$(LIBUNWIND_DIRECTORY)/../unwinder/include \ + -I$(MISOC_DIRECTORY)/software/include/dyld +CFLAGS += -DNDEBUG + +LDFLAGS += --eh-frame-hdr \ + -L../libcompiler-rt \ + -L../libbase \ + -L../libm \ + -L../libunwind \ + -L../libdyld + +RUSTFLAGS += -Cpanic=unwind + +all: ksupport.elf + +.PHONY: $(RUSTOUT)/libksupport.a +$(RUSTOUT)/libksupport.a: + $(cargo) --manifest-path $(KSUPPORT_DIRECTORY)/Cargo.toml + +ksupport.elf: $(RUSTOUT)/libksupport.a glue.o artiq_personality.o + $(LD) $(LDFLAGS) -T $(KSUPPORT_DIRECTORY)/ksupport.ld -o $@ $^ \ + -lbase -lm -lcompiler-rt -ldyld -lunwind + @chmod -x $@ + +%.o: $(KSUPPORT_DIRECTORY)/%.c + $(compile) + +clean: + $(RM) *.o ksupport.elf + $(RM) -rf cargo + +.PHONY: all clean diff --git a/artiq/runtime/artiq_personality.c b/artiq/firmware/ksupport/artiq_personality.c similarity index 100% rename from artiq/runtime/artiq_personality.c rename to artiq/firmware/ksupport/artiq_personality.c diff --git a/artiq/runtime/artiq_personality.h b/artiq/firmware/ksupport/artiq_personality.h similarity index 100% rename from artiq/runtime/artiq_personality.h rename to artiq/firmware/ksupport/artiq_personality.h diff --git a/artiq/runtime/ksupport_glue.c b/artiq/firmware/ksupport/glue.c similarity index 100% rename from artiq/runtime/ksupport_glue.c rename to artiq/firmware/ksupport/glue.c diff --git a/artiq/runtime/ksupport.ld b/artiq/firmware/ksupport/ksupport.ld similarity index 100% rename from artiq/runtime/ksupport.ld rename to artiq/firmware/ksupport/ksupport.ld diff --git a/artiq/firmware/runtime/Makefile b/artiq/firmware/runtime/Makefile new file mode 100644 index 000000000..94cd87cbe --- /dev/null +++ b/artiq/firmware/runtime/Makefile @@ -0,0 +1,32 @@ +include ../include/generated/variables.mak +include $(MISOC_DIRECTORY)/software/common.mak + +LDFLAGS += -L../libbase + +RUSTFLAGS += -Cpanic=abort + +all: runtime.bin runtime.fbi + +.PHONY: $(RUSTOUT)/libruntime.a +$(RUSTOUT)/libruntime.a: + $(cargo) --manifest-path $(RUNTIME_DIRECTORY)/Cargo.toml + +runtime.elf: $(RUSTOUT)/libruntime.a ksupport_data.o + $(LD) $(LDFLAGS) -T $(RUNTIME_DIRECTORY)/runtime.ld -o $@ $^ + @chmod -x $@ + +ksupport_data.o: ../ksupport/ksupport.elf + $(LD) -r -b binary -o $@ $< + +%.bin: %.elf + $(OBJCOPY) -O binary $< $@ + @chmod -x $@ + +%.fbi: %.bin + @echo " MSCIMG " $@ && $(PYTHON) -m misoc.tools.mkmscimg -f -o $@ $< + +clean: + $(RM) *.o runtime.elf runtime.bin runtime.fbi + $(RM) -rf cargo + +.PHONY: all clean diff --git a/artiq/firmware/runtime/kernel.rs b/artiq/firmware/runtime/kernel.rs index dc36dfacc..d6122d4d5 100644 --- a/artiq/firmware/runtime/kernel.rs +++ b/artiq/firmware/runtime/kernel.rs @@ -13,11 +13,11 @@ pub unsafe fn start() { stop(); extern { - static _binary_ksupport_elf_start: u8; - static _binary_ksupport_elf_end: u8; + static _binary____ksupport_ksupport_elf_start: u8; + static _binary____ksupport_ksupport_elf_end: u8; } - let ksupport_start = &_binary_ksupport_elf_start as *const _; - let ksupport_end = &_binary_ksupport_elf_end as *const _; + let ksupport_start = &_binary____ksupport_ksupport_elf_start as *const _; + let ksupport_end = &_binary____ksupport_ksupport_elf_end as *const _; ptr::copy_nonoverlapping(ksupport_start, (KERNELCPU_EXEC_ADDRESS - KSUPPORT_HEADER_SIZE) as *mut u8, ksupport_end as usize - ksupport_start as usize); diff --git a/artiq/runtime/runtime.ld b/artiq/firmware/runtime/runtime.ld similarity index 100% rename from artiq/runtime/runtime.ld rename to artiq/firmware/runtime/runtime.ld diff --git a/artiq/gateware/amp/soc.py b/artiq/gateware/amp/soc.py index 6924e2548..7314bd935 100644 --- a/artiq/gateware/amp/soc.py +++ b/artiq/gateware/amp/soc.py @@ -48,5 +48,6 @@ def build_artiq_soc(soc, argdict): builder.add_software_package("libm") builder.add_software_package("libdyld") builder.add_software_package("libunwind") - builder.add_software_package("runtime", os.path.join(artiq_dir, "runtime")) + builder.add_software_package("ksupport", os.path.join(artiq_dir, "firmware", "ksupport")) + builder.add_software_package("runtime", os.path.join(artiq_dir, "firmware", "runtime")) builder.build() diff --git a/artiq/runtime/Makefile b/artiq/runtime/Makefile deleted file mode 100644 index b2ba78794..000000000 --- a/artiq/runtime/Makefile +++ /dev/null @@ -1,86 +0,0 @@ -include ../include/generated/variables.mak -include $(MISOC_DIRECTORY)/software/common.mak - -PYTHON ?= python3 - -CARGO_normal := env -CARGO_quiet = @echo " CARGO " $@ && $(CARGO_normal) - -ifeq ($(V),1) - CARGO = $(CARGO_normal) -else - CARGO = $(CARGO_quiet) -endif - -RUSTOUT := cargo/or1k-unknown-none/debug -RUSTOUT_KSUPPORT := cargo-ksupport/or1k-unknown-none/debug - -CFLAGS += \ - -I$(LIBUNWIND_DIRECTORY) \ - -I$(LIBUNWIND_DIRECTORY)/../unwinder/include \ - -I$(MISOC_DIRECTORY)/software/include/dyld -CFLAGS += -DNDEBUG - -LDFLAGS += --gc-sections \ - -L../libcompiler-rt \ - -L../libbase \ - -L../libm \ - -L../libunwind \ - -L../libdyld - -RUSTFLAGS = \ - -C target-feature=+mul,+div,+ffl1,+cmov,+addc \ - -C relocation-model=static \ - -C opt-level=s \ - -C panic=abort -export RUSTFLAGS - -all: runtime.bin runtime.fbi - -.PHONY: $(RUSTOUT)/libruntime.a -$(RUSTOUT)/libruntime.a: - $(CARGO) \ - CARGO_TARGET_DIR=$(realpath .)/cargo \ - cargo build --target=or1k-unknown-none \ - --manifest-path $(realpath $(RUNTIME_DIRECTORY)/../firmware/runtime/Cargo.toml) - -runtime.elf: $(RUSTOUT)/libruntime.a ksupport_data.o - $(LD) $(LDFLAGS) -T $(RUNTIME_DIRECTORY)/runtime.ld -o $@ $^ - @chmod -x $@ - -.PHONY: $(RUSTOUT_KSUPPORT)/libksupport.a -$(RUSTOUT_KSUPPORT)/libksupport.a: - $(CARGO) \ - CARGO_TARGET_DIR=$(realpath .)/cargo-ksupport \ - cargo build --target=or1k-unknown-none \ - --manifest-path $(realpath $(RUNTIME_DIRECTORY)/../firmware/ksupport/Cargo.toml) - -ksupport.elf: $(RUSTOUT_KSUPPORT)/libksupport.a ksupport_glue.o artiq_personality.o - $(LD) $(LDFLAGS) \ - --eh-frame-hdr \ - -T $(RUNTIME_DIRECTORY)/ksupport.ld \ - -o $@ \ - $^ \ - -lbase -lm -lcompiler-rt -ldyld -lunwind - @chmod -x $@ - -%.o: $(RUNTIME_DIRECTORY)/%.c - $(compile) - -%.bin: %.elf - $(OBJCOPY) -O binary $< $@ - @chmod -x $@ - -%_data.o: %.elf - $(LD) -r -b binary -o $@ $< - -%.fbi: %.bin - @echo " MSCIMG " $@ && $(PYTHON) -m misoc.tools.mkmscimg -f -o $@ $< - -clean: - $(RM) $(OBJECTS) $(OBJECTS_KSUPPORT) - $(RM) runtime.elf runtime.bin runtime.fbi .*~ *~ - $(RM) ksupport.elf ksupport.bin - $(RM) -rf cargo - -.PHONY: all clean diff --git a/artiq/test/libartiq_support/Makefile b/artiq/test/libartiq_support/Makefile index 889b5558f..0eca4569c 100644 --- a/artiq/test/libartiq_support/Makefile +++ b/artiq/test/libartiq_support/Makefile @@ -1,4 +1,4 @@ CC ?= clang -libartiq_support.so: ../../runtime/artiq_personality.c artiq_terminate.c artiq_time.c - $(CC) -std=c99 -Wall -Werror -I. -I../../runtime -g -fPIC -shared -o $@ $^ +libartiq_support.so: ../../firmware/ksupport/artiq_personality.c artiq_terminate.c artiq_time.c + $(CC) -std=c99 -Wall -Werror -I. -I../../firmware/ksupport -g -fPIC -shared -o $@ $^ diff --git a/conda/artiq-dev/meta.yaml b/conda/artiq-dev/meta.yaml index b5b336cf2..4539384b4 100644 --- a/conda/artiq-dev/meta.yaml +++ b/conda/artiq-dev/meta.yaml @@ -15,7 +15,7 @@ requirements: - python 3.5.2 - setuptools - migen 0.5.dev py_54+git58e8f45 - - misoc 0.6.dev py_2+git02884fe + - misoc 0.6.dev py_4+git40e9940 - jesd204b 0.2 - binutils-or1k-linux >=2.27 - llvm-or1k