xref: /DragonOS/kernel/env.mk (revision c635d8a9cfe25bc11779f323ef0c7d7a0f597d4a)
1include ../env.mk
2
3# 设置编译器
4ifeq ($(ARCH), x86_64)
5
6# 如果 x86_64时,DragonOS_GCC 为空,那么设置为默认值
7export DragonOS_GCC?=$(HOME)/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin
8
9export CC=$(DragonOS_GCC)/x86_64-elf-gcc
10export LD=ld
11export AS=$(DragonOS_GCC)/x86_64-elf-as
12export NM=$(DragonOS_GCC)/x86_64-elf-nm
13export AR=$(DragonOS_GCC)/x86_64-elf-ar
14export OBJCOPY=$(DragonOS_GCC)/x86_64-elf-objcopy
15
16else ifeq ($(ARCH), riscv64)
17
18export CC=riscv64-unknown-elf-gcc
19# binutils版本需要>=2.38
20# 而ubuntu的unknown-elf的版本比较旧,所以使用了riscv64-linux-gnu-ld
21export LD=riscv64-linux-gnu-ld
22export AS=riscv64-unknown-elf-as
23export NM=riscv64-unknown-elf-nm
24export AR=riscv64-unknown-elf-ar
25export OBJCOPY=riscv64-unknown-elf-objcopy
26
27endif
28
29
30export DEBUG=DEBUG
31
32export CFLAGS_DEFINE_ARCH="__$(ARCH)__"
33
34export GLOBAL_CFLAGS := -fno-builtin -fno-stack-protector -D $(CFLAGS_DEFINE_ARCH) -D $(EMULATOR) -O1
35
36ifeq ($(ARCH), x86_64)
37GLOBAL_CFLAGS += -mcmodel=large -m64
38else ifeq ($(ARCH), riscv64)
39GLOBAL_CFLAGS += -mcmodel=medany -march=rv64gc -mabi=lp64d
40endif
41
42ifeq ($(DEBUG), DEBUG)
43GLOBAL_CFLAGS += -g
44endif
45
46export RUSTFLAGS := -C link-args=-znostart-stop-gc
47export RUSTDOCFLAGS := -C link-args=-znostart-stop-gc