1# All host rust packages should depend on this option
2config BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
3	bool
4	default y if BR2_HOSTARCH = "aarch64"
5	default y if BR2_HOSTARCH = "powerpc"
6	default y if BR2_HOSTARCH = "powerpc64"
7	default y if BR2_HOSTARCH = "powerpc64le"
8	default y if BR2_HOSTARCH = "riscv64"
9	default y if BR2_HOSTARCH = "s390x"
10	default y if BR2_HOSTARCH = "x86"
11	default y if BR2_HOSTARCH = "x86_64"
12
13# The pre-built Rust standard library is only available for a number
14# of architectures/C libraries combinations, with different levels of
15# support: Tier 1 platforms, Tier 2 platforms with host tools, Tier 2
16# platforms, Tier 3 platforms. Below, we support Tier 1, Tier 2 with
17# host tools and Tier 2 platforms.
18
19# The below entries match Tier 1 platforms as described at
20# https://doc.rust-lang.org/nightly/rustc/platform-support.html.
21config BR2_PACKAGE_HOST_RUSTC_TARGET_TIER1_PLATFORMS
22	bool
23	# aarch64-unknown-linux-gnu
24	default y if BR2_aarch64 && BR2_TOOLCHAIN_USES_GLIBC
25	# i686-unknown-linux-gnu
26	default y if (BR2_x86_i686 || BR2_x86_pentiumpro || BR2_X86_CPU_HAS_MMX) && BR2_TOOLCHAIN_USES_GLIBC
27	# x86_64-unknown-linux-gnu
28	default y if BR2_x86_64 && BR2_TOOLCHAIN_USES_GLIBC
29
30# The below entries match Tier 2 platforms with host tools as
31# described at
32# https://doc.rust-lang.org/nightly/rustc/platform-support.html.
33config BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_HOST_TOOLS_PLATFORMS
34	bool
35	# aarch64-unknown-linux-musl
36	default y if BR2_aarch64 && BR2_TOOLCHAIN_USES_MUSL
37	# arm-unknown-linux-gnueabi
38	default y if BR2_ARM_CPU_ARMV6 && BR2_ARM_EABI && BR2_TOOLCHAIN_USES_GLIBC
39	# arm-unknown-linux-gnueabihf
40	default y if BR2_ARM_CPU_ARMV6 && BR2_ARM_EABIHF && BR2_TOOLCHAIN_USES_GLIBC
41	# armv7-unknown-linux-gnueabihf
42	default y if BR2_ARM_CPU_ARMV7A && BR2_ARM_EABIHF && BR2_TOOLCHAIN_USES_GLIBC
43	# armv7-unknown-linux-gnueabihf for armv8 hardware with 32-bit
44	# userspace
45	default y if BR2_arm && BR2_ARM_CPU_ARMV8A && BR2_ARM_EABIHF && BR2_TOOLCHAIN_USES_GLIBC
46	# powerpc-unknown-linux-gnu
47	default y if BR2_powerpc && BR2_TOOLCHAIN_USES_GLIBC
48	# powerpc64-unknown-linux-gnu
49	default y if BR2_powerpc64 && BR2_TOOLCHAIN_USES_GLIBC
50	# powerpc64le-unknown-linux-gnu
51	default y if BR2_powerpc64le && BR2_TOOLCHAIN_USES_GLIBC
52	# riscv64gc-unknown-linux-gnu
53	# "g" stands for imafd, and we also need "c".
54	default y if BR2_RISCV_64 && BR2_RISCV_ISA_RVI && BR2_RISCV_ISA_RVM && \
55			BR2_RISCV_ISA_RVA && BR2_RISCV_ISA_RVF && \
56			BR2_RISCV_ISA_RVD && BR2_RISCV_ISA_RVC && \
57			BR2_TOOLCHAIN_USES_GLIBC
58	# s390x-unknown-linux-gnu
59	default y if BR2_s390x && BR2_TOOLCHAIN_USES_GLIBC
60	# x86_64-unknown-linux-musl
61	default y if BR2_x86_64 && BR2_TOOLCHAIN_USES_MUSL
62
63# The below entries match Tier 2 platforms without host tools as
64# described at
65# https://doc.rust-lang.org/nightly/rustc/platform-support.html.
66config BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS
67	bool
68	# arm-unknown-linux-musleabi
69	default y if BR2_ARM_CPU_ARMV6 && BR2_ARM_EABI && BR2_TOOLCHAIN_USES_MUSL
70	# arm-unknown-linux-musleabihf
71	default y if BR2_ARM_CPU_ARMV6 && BR2_ARM_EABIHF && BR2_TOOLCHAIN_USES_MUSL
72	# armv5te-unknown-linux-gnueabi
73	default y if BR2_ARM_CPU_ARMV5 && BR2_ARM_EABI && BR2_TOOLCHAIN_USES_GLIBC
74	# armv5te-unknown-linux-musleabi
75	default y if BR2_ARM_CPU_ARMV5 && BR2_ARM_EABI && BR2_TOOLCHAIN_USES_MUSL
76	# armv7-unknown-linux-gnueabi
77	default y if BR2_ARM_CPU_ARMV7A && BR2_ARM_EABI && BR2_TOOLCHAIN_USES_GLIBC
78	# armv7-unknown-linux-musleabi
79	default y if BR2_ARM_CPU_ARMV7A && BR2_ARM_EABI && BR2_TOOLCHAIN_USES_MUSL
80	# armv7-unknown-linux-musleabihf
81	default y if BR2_ARM_CPU_ARMV7A && BR2_ARM_EABIHF && BR2_TOOLCHAIN_USES_MUSL
82	# armv7-unknown-linux-musleabihf for armv8 hardware with 32-bit
83	# userspace
84	default y if BR2_arm && BR2_ARM_CPU_ARMV8A && BR2_ARM_EABIHF && BR2_TOOLCHAIN_USES_MUSL
85	# i586-unknown-linux-gnu
86	default y if BR2_x86_i586 && BR2_TOOLCHAIN_USES_GLIBC
87	# i586-unknown-linux-musl
88	default y if BR2_x86_i586 && BR2_TOOLCHAIN_USES_MUSL
89	# i686-unknown-linux-musl
90	default y if (BR2_x86_i686 || BR2_x86_pentiumpro || BR2_X86_CPU_HAS_MMX) && BR2_TOOLCHAIN_USES_MUSL
91	# mips-unknown-linux-musl
92	default y if BR2_mips && BR2_TOOLCHAIN_USES_MUSL && !BR2_MIPS_CPU_MIPS32R6
93	# mips64-unknown-linux-muslabi64
94	default y if BR2_mips64 && BR2_TOOLCHAIN_USES_MUSL && BR2_MIPS_NABI64 && !BR2_MIPS_CPU_MIPS64R6
95	# mips64el-unknown-linux-muslabi64
96	default y if BR2_mips64el && BR2_TOOLCHAIN_USES_MUSL && BR2_MIPS_NABI64 && !BR2_MIPS_CPU_MIPS64R6
97	# mipsel-unknown-linux-musl
98	default y if BR2_mipsel && BR2_TOOLCHAIN_USES_MUSL && !BR2_MIPS_CPU_MIPS32R6
99	# sparc64-unknown-linux-gnu
100	default y if BR2_sparc64 && BR2_TOOLCHAIN_USES_GLIBC
101
102# All target rust packages should depend on this option
103# Note: With musl based toolchain, we need a C++ cross compiler to
104# build host-rust some target libraries (libunwind) from llvm source
105# code bundled in rust sources.
106config BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
107	bool
108	default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER1_PLATFORMS
109	default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_HOST_TOOLS_PLATFORMS
110	default y if BR2_PACKAGE_HOST_RUSTC_TARGET_TIER2_PLATFORMS
111	depends on BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_USES_MUSL
112	depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
113
114config BR2_PACKAGE_HOST_RUSTC_ARCH
115	string
116	default "armv5te" if BR2_ARM_CPU_ARMV5
117	default "arm" if BR2_ARM_CPU_ARMV6
118	default "armv7"  if BR2_ARM_CPU_ARMV7A
119	default "armv7"  if BR2_ARM_CPU_ARMV7A || (BR2_arm && BR2_ARM_CPU_ARMV8A)
120	default "riscv64gc" if BR2_RISCV_64
121	default BR2_ARCH
122
123config BR2_PACKAGE_HOST_RUSTC_ABI
124	string
125	default "eabi"   if BR2_ARM_EABI
126	default "eabihf" if BR2_ARM_EABIHF
127	default "abi64"  if BR2_MIPS_NABI64
128
129config BR2_PACKAGE_HOST_RUSTC
130	bool "host rustc"
131	depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
132	help
133	  Compiler for the Rust language
134
135	  http://www.rust-lang.org
136
137if BR2_PACKAGE_HOST_RUSTC
138
139choice
140	prompt "Rust compiler variant"
141	default BR2_PACKAGE_HOST_RUST_BIN
142	help
143	  Select a Rust compiler
144
145config BR2_PACKAGE_HOST_RUST
146	bool "host rust"
147	# RUSTC_TARGET_NAME must be set for building host-rust
148	# otherwise config.toml is broken.
149	depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
150	# triggers ICE on trunc_int_for_mode, at explow.c:56
151	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 || !BR2_aarch64
152	# rust uses llvm >= 17 since 1.73.0
153	select BR2_HOST_CMAKE_AT_LEAST_3_20
154	help
155	  This package will build the compiler for the host as well as
156	  two flavors of the standard library: one for the host, another
157	  for the target. Both are installed in the host directory.
158
159comment "host-rust needs a toolchain w/ gcc >= 5"
160	depends on BR2_aarch64
161	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5
162
163config BR2_PACKAGE_HOST_RUST_BIN
164	bool "host rust (pre-built)"
165	help
166	  This package will install pre-built versions of the compiler
167	  for the host and the Rust standard library for the target.
168
169endchoice
170
171endif
172
173config BR2_PACKAGE_PROVIDES_HOST_RUSTC
174	string
175	default "host-rust" if BR2_PACKAGE_HOST_RUST
176	# Default to host-rust-bin as long as host arch supports it
177	default "host-rust-bin" if !BR2_PACKAGE_HOST_RUST
178	depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
179