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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# Pull target info so we can type the CPU/CPU_SUBTYPE
target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD)
SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir))))
PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
include $(PLATFORM_DIR)/Makefile
ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
-include $(PLATFORM_SUBDIR)/target.mk
endif
# Rust Environmental Vars
CONFIG_HOST_SUFFIX:=$(shell cut -d"-" -f4 <<<"$(GNU_HOST_NAME)")
RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(CONFIG_HOST_SUFFIX)
RUSTC_TARGET_ARCH:=$(REAL_GNU_TARGET_NAME)
CARGO_HOME:=$(STAGING_DIR_HOST)/.cargo
LLVM_DIR:=$(STAGING_DIR_HOST)/llvm-rust
RUSTC_CPU_TYPE=$(CPU_TYPE)
RUSTFLAGS=
$(warning CPU_TYPE is $(RUSTC_CPU_TYPE))
# ARM Logic
ifeq ($(ARCH),arm)
$(warning Entering ARM)
# Split out ARMv7
ifeq ($(CONFIG_arm_v7),y)
$(warning Target is ARMv7)
RUSTC_TARGET_ARCH:=$(subst arm,armv7,$(RUSTC_TARGET_ARCH))
# Set ARMv7 Soft-Float vs Hard-Float Instruction Sets
ifeq ($(CONFIG_HAS_FPU),y)
RUST_FEATURES += +v7 -d32 +thumb2
else
RUST_FEATURES += +v7 +thumb2 +soft-float
endif
endif
# ARMv5
ifeq ($(RUSTC_CPU_TYPE),arm926ej-s)
RUSTC_TARGET_ARCH:=$(subst arm,armv5tej,$(RUSTC_TARGET_ARCH))
RUST_FEATURES += +soft-float +strict-align
endif
# ARMv6 uses arm-openwrt-linux
ifeq ($(RUSTC_CPU_TYPE),arm1176jzf-s)
$(warning Target is ARMv6)
RUST_FEATURES += +v6 +vfp2 -d32
endif
ifeq ($(RUSTC_CPU_TYPE),mpcore)
$(warning Target is mpcore)
RUSTC_TARGET_ARCH:=$(subst arm,armv6k,$(RUSTC_TARGET_ARCH))
RUST_FEATURES += +v6 +soft-float +strict-align
endif
# Set Hard-Float ABI if TARGET has FPU
ifeq ($(CONFIG_HAS_FPU),y)
RUSTC_TARGET_ARCH:=$(RUSTC_TARGET_ARCH:muslgnueabi=muslgnueabihf)
endif
# CPU_SUBTYPE carries instruction flags in OpenWrt
ifneq ($(CPU_SUBTYPE),)
# NEON Support
ifneq ($(findstring neon,$(CPU_SUBTYPE)),)
RUST_FEATURES += +neon
else
RUST_FEATURES += -neon
endif
###
# vfpv prefix is not recognized by LLVM - convert to vfp and remove the
# hyphen. This is important for CPU_SUBTYPE that use hyphenated CPU_SUBTYPE
# like neon-vfpv4 and vfpv3-d16
RUST_FEATURES += +$(lastword $(subst neon,,$(subst vfpv,vfp,$(subst -,,$(CPU_SUBTYPE)))))
endif
###
# If the RUST_FEATURES is empty or a single word, use as is, otherwise
# split it into a Comma-delimited format for use with target-features
ifneq ($(words $(RUST_FEATURES)),1)
RUST_TARGET_FEATURES = $(subst $(space),$(comma),$(RUST_FEATURES))
else
RUST_TARGET_FEATURES = $(RUST_FEATURES)
endif
ifeq ($(RUSTC_CPU_TYPE),fa526)
RUSTC_TARGET_ARCH:=$(subst arm,armv7,$(RUSTC_TARGET_ARCH))
RUSTC_CPU_TYPE := generic
endif
endif
# ARM Logic
ifeq ($(ARCH),mips64)
RUSTC_CPU_TYPE := octeon+
endif
# AArch64 Flags
ifeq ($(ARCH),aarch64)
RUSTFLAGS += -C link-arg=-lgcc
endif
$(warning RUST_TARGET_FEATURES is $(RUST_TARGET_FEATURES))
|