Last active
August 29, 2015 13:57
-
-
Save cceckman/9613442 to your computer and use it in GitHub Desktop.
Inconsistency emit bc,link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL=/bin/bash | |
TARGET := arm-linux-noeabi | |
CHIP := arm926ej-s | |
rpi: CHIP := arm1176jzf-s | |
GCC_PREFIX := $(GCC_PREFIX)arm-none-eabi- | |
RUSTC := $(RUST_ROOT)/bin/rustc | |
#RUSTCFLAGS := -O --target $(TARGET) -Z no-landing-pads -Z debug-info -Z extra-debug-info --cfg $(CHIP) | |
RUSTCFLAGS := -O --target $(TARGET) -Z no-landing-pads --cfg target_chip=\"$(CHIP)\" | |
AS := $(GCC_PREFIX)as | |
LD := $(GCC_PREFIX)ld | |
AR := $(GCC_PREFIX)ar | |
LLC := $(LLVM_ROOT)/bin/llc | |
LLCFLAGS := -march=arm -mcpu=$(CHIP) --float-abi=hard -asm-verbose | |
GDB := $(GCC_PREFIX)gdb | |
OBJCOPY := $(GCC_PREFIX)objcopy | |
QEMU := qemu-system-arm | |
QEMUFLAGS := -M versatilepb -m 32M -serial stdio | |
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) | |
#rpi: LINK := $(BDIR)/linker-rpi.ld $(OBJS) | |
MAP := $(BDIR)/kernel.map | |
MODS := $(wildcard */*.rs) $(wildcard ../../kernel/*.rs) $(wildcard ../../kernel/*/*.rs) $(wildcard ../../kernel/*/*/*.rs) | |
-include ./config.mk | |
-include $(BDIR)/core.d | |
-include $(BDIR)/loader.d | |
.PHONY: all run debug clean | |
# Default target: QEMU | |
all: $(BDIR)/kernel.bin | |
@wc -c $^ | |
# Alternate target: raspberry pi | |
rpi: all | |
# Library rust-core | |
$(LCORE): | |
$(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/core.d $(CORE_LIB) --emit bc,link --out-dir $(BDIR) | |
#$(BDIR)/core.bc: $(LCORE) | |
#$(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/core.d $(CORE_LIB) --emit bc --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) | |
# $(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/main.d -L $(BDIR) --emit-llvm ../../lib.rs --out-dir $(BDIR) | |
%.s: %.bc | |
$(LLC) $(LLCFLAGS) $^ -o $@ | |
%.o: %.s | |
$(AS) -MD $*.d -g $< -o $@ | |
# kernel (object) | |
$(BDIR)/kernel.elf: $(LINK) | |
$(LD) -Map $(MAP) -o $@ -T $^ | |
# kernel (binary image) | |
$(BDIR)/kernel.bin: $(BDIR)/kernel.elf | |
$(OBJCOPY) -O binary $^ $@ | |
# running | |
run: $(BDIR)/kernel.bin | |
$(QEMU) $(QEMUFLAGS) -kernel $^ | |
debug: $(BDIR)/kernel.elf | |
ifeq ($(strip $(TMUX)),) | |
tmux new-session -d -s rustboot | |
tmux new-window -t rustboot:1 "$(QEMU) $(QEMUFLAGS) -kernel $^ -s -S" | |
tmux split-window -t rustboot "$(GDB)" | |
tmux a -t rustboot | |
tmux kill-session -t rustboot | |
else | |
# TODO: debug in current window, can't kill panes | |
tmux new-w "$(QEMU) -M versatilepb -m 32M -nographic -kernel $^ -s -S" | |
tmux split-w "$(GDB); tmux kill-w" | |
endif | |
clean: | |
rm -f $(BDIR)/*.{d,o,bc,rlib,so,ll,embed,elf,bin,map} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL=/bin/bash | |
TARGET := arm-linux-noeabi | |
CHIP := arm926ej-s | |
rpi: CHIP := arm1176jzf-s | |
GCC_PREFIX := $(GCC_PREFIX)arm-none-eabi- | |
RUSTC := $(RUST_ROOT)/bin/rustc | |
#RUSTCFLAGS := -O --target $(TARGET) -Z no-landing-pads -Z debug-info -Z extra-debug-info --cfg $(CHIP) | |
RUSTCFLAGS := -O --target $(TARGET) -Z no-landing-pads --cfg target_chip=\"$(CHIP)\" | |
AS := $(GCC_PREFIX)as | |
LD := $(GCC_PREFIX)ld | |
AR := $(GCC_PREFIX)ar | |
LLC := $(LLVM_ROOT)/bin/llc | |
LLCFLAGS := -march=arm -mcpu=$(CHIP) --float-abi=hard -asm-verbose | |
GDB := $(GCC_PREFIX)gdb | |
OBJCOPY := $(GCC_PREFIX)objcopy | |
QEMU := qemu-system-arm | |
QEMUFLAGS := -M versatilepb -m 32M -serial stdio | |
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) | |
#rpi: LINK := $(BDIR)/linker-rpi.ld $(OBJS) | |
MAP := $(BDIR)/kernel.map | |
MODS := $(wildcard */*.rs) $(wildcard ../../kernel/*.rs) $(wildcard ../../kernel/*/*.rs) $(wildcard ../../kernel/*/*/*.rs) | |
-include ./config.mk | |
-include $(BDIR)/core.d | |
-include $(BDIR)/loader.d | |
.PHONY: all run debug clean | |
# Default target: QEMU | |
all: $(BDIR)/kernel.bin | |
@wc -c $^ | |
# Alternate target: raspberry pi | |
rpi: all | |
# Library rust-core | |
$(LCORE): | |
$(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/core.d $(CORE_LIB) --emit bc,link --out-dir $(BDIR) | |
$(BDIR)/core.bc: $(LCORE) | |
$(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/core.d $(CORE_LIB) --emit bc --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) | |
# $(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/main.d -L $(BDIR) --emit-llvm ../../lib.rs --out-dir $(BDIR) | |
%.s: %.bc | |
$(LLC) $(LLCFLAGS) $^ -o $@ | |
%.o: %.s | |
$(AS) -MD $*.d -g $< -o $@ | |
# kernel (object) | |
$(BDIR)/kernel.elf: $(LINK) | |
$(LD) -Map $(MAP) -o $@ -T $^ | |
# kernel (binary image) | |
$(BDIR)/kernel.bin: $(BDIR)/kernel.elf | |
$(OBJCOPY) -O binary $^ $@ | |
# running | |
run: $(BDIR)/kernel.bin | |
$(QEMU) $(QEMUFLAGS) -kernel $^ | |
debug: $(BDIR)/kernel.elf | |
ifeq ($(strip $(TMUX)),) | |
tmux new-session -d -s rustboot | |
tmux new-window -t rustboot:1 "$(QEMU) $(QEMUFLAGS) -kernel $^ -s -S" | |
tmux split-window -t rustboot "$(GDB)" | |
tmux a -t rustboot | |
tmux kill-session -t rustboot | |
else | |
# TODO: debug in current window, can't kill panes | |
tmux new-w "$(QEMU) -M versatilepb -m 32M -nographic -kernel $^ -s -S" | |
tmux split-w "$(GDB); tmux kill-w" | |
endif | |
clean: | |
rm -f $(BDIR)/*.{d,o,bc,rlib,so,ll,embed,elf,bin,map} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using rustc 0.10-pre (0a181a8), cceckman/ironkernel f3147a9.
--emit bc
and another target with for--emit link
.)llc
will fail at producing core.s from core.bc: "expected top-level entity". This has one target with--emit bc,link
, and produces both a libcore*.rlib and a core.bc file.I've diffed the core.bc output from each of the makefiles, and they aren't the same. Unsure if this is expected behavior or not, but it's unexpected to me; the .bc artifact produced depends on what other artifacts (link) are being produced at the same time.
I'm going to see if there's a minimal example that works the same way.