Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (58 loc) · 1.59 KB
/
Copy pathMakefile
File metadata and controls
70 lines (58 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
ARCH ?= x86_64
SMP ?= 1
MODE ?= release
V ?=
PLATFORM ?=
TARGET_DIR ?= $(PWD)/target
PACKEAGE = vsched
LIB ?= libvsched
RQ_CAP ?= 256
UTEST ?= init_vsched
UTEST_BIN ?= $(TARGET_DIR)/$(TARGET)/$(MODE)/$(UTEST)
SCHED ?= sched-fifo
OBJDUMP = rust-objdump -t -T -r -R -d --print-imm-hex --x86-asm-syntax=intel
OBJCOPY = rust-objcopy -X -g
# Target
ifeq ($(ARCH), x86_64)
TARGET := x86_64-unknown-linux-musl
else ifeq ($(ARCH), aarch64)
TARGET := aarch64-unknown-linux-musl
else ifeq ($(ARCH), riscv64)
TARGET := riscv64gc-unknown-linux-musl
else
$(error "ARCH" must be one of "x86_64", "riscv64" or "aarch64")
endif
OUPUT_SO := $(TARGET_DIR)/$(TARGET)/$(MODE)/$(LIB).so
build_args-release := --release
ifeq ($(V),1)
verbose := -v
else ifeq ($(V),2)
verbose := -vv
else
verbose :=
endif
build_args := \
-p $(PACKEAGE) \
-Z unstable-options \
-Z build-std=core,compiler_builtins \
-Z build-std-features=compiler-builtins-mem \
-F $(SCHED) \
--target $(TARGET) \
--target-dir $(TARGET_DIR) \
$(build_args-$(MODE)) \
$(verbose)
all:
ifeq ($(wildcard $(TARGET_DIR)),)
mkdir $(TARGET_DIR)
endif
ARCH=${ARCH} RQ_CAP=${RQ_CAP} SMP=${SMP} RUSTFLAGS='-C link-arg=-fpie' cargo build $(build_args)
@$(OBJCOPY) $(OUPUT_SO) $(OUPUT_SO)
cp $(OUPUT_SO) $(LIB).so
disasm: all
@$(OBJDUMP) $(OUPUT_SO)
clean:
rm -rf $(TARGET_DIR)
utest: all
RUST_BACKTRACE=1 RUSTFLAGS='-C target-feature=+crt-static' cargo build --bin $(UTEST) --target $(TARGET) --target-dir $(TARGET_DIR) $(build_args-$(MODE))
qemu-$(ARCH) -D qemu.log -d in_asm,int,mmu,pcall,cpu_reset,page,guest_errors $(UTEST_BIN)
.PHONY: all clean