Skip to contentSkip to conversation

Add support for the Rust programming language

PATCH Superseded Eric Le Bihan 3 participants 10 messages Apr 22, 2017 – May 1, 2017

v5 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add support for the Rust programming language

This series adds support for the Rust programming language by adding the following packages:

- rustc: a virtual package for the Rust compiler.
- rust-bin: provides a pre-built version of rustc.
- rust: builds rustc from source.

Both providers are able to cross-compile code for ARM, MIPS, PowerPC and x86_64 architectures. Only the host variants are provided.

The rustc virtual package is inspired by the mysql one.

As the Rust compiler is written in Rust and uses Cargo, the Rust package manager, as build system, two additional packages are provided: rust-bootstrap and cargo-bootstrap.

v4 -> v5:

- add rustc virtual package
- add rust-bin, provider for rustc
- rework rust to be a provider for rustc
- rework some commit messages

v3 -> v4:

- bump rust to 1.16.0
- bump rust-bootstrap to 1.15.1
- add cargo-bootstrap
- use built-in target specifications
- drop external Python script to generate target specifications
- enable support for PowerPC
- expose host variant in menuconfig

v2 -> v3:

- bump rust to 1.10.0
- rework and bump rust-bootstrap to 1.9.0
- host-rust requires at least GCC 4.7 because of LLVM (suggested by R. Naour)
- rust requires a glibc-based cross-compiler
- rust requires GCC 5.x or above for Aarch64

v1 -> v2:

- bump rust to version 1.9.0.
- drop patch for bzip2 support in host-python.
- add package for jemalloc.
- add dependency on host being a x86 machine.
- add dependency on toolchain.
- use dedicated package to provide bootstrapping binary: rust-bootstrap.
- let ./configure find out host/build on its own.
- remove entry from configuration menu.
- clarify some comments.
Eric Le Bihan (7):
pkg-virtual: fix host dependencies handling
rustc: new virtual package
rust-bin: new package
rustc: expose host variant in menuconfig
rust-bootstrap: new package
cargo-bootstrap: new package
rust: new package

 DEVELOPERS                                   |  4 ++
 package/Config.in.host                       |  1 +
 package/cargo-bootstrap/cargo-bootstrap.hash |  3 ++
 package/cargo-bootstrap/cargo-bootstrap.mk   | 14 +++++
 package/pkg-virtual.mk                       |  4 ++
 package/rust-bin/rust-bin.hash               | 30 +++++++++++
 package/rust-bin/rust-bin.mk                 | 41 +++++++++++++++
 package/rust-bootstrap/rust-bootstrap.hash   |  5 ++
 package/rust-bootstrap/rust-bootstrap.mk     | 27 ++++++++++
 package/rust/rust.hash                       |  2 +
 package/rust/rust.mk                         | 77 ++++++++++++++++++++++++++++
 package/rustc/Config.in.host                 | 61 ++++++++++++++++++++++
 package/rustc/rustc.mk                       | 21 ++++++++
 13 files changed, 290 insertions(+)
 create mode 100644 package/cargo-bootstrap/cargo-bootstrap.hash
 create mode 100644 package/cargo-bootstrap/cargo-bootstrap.mk
 create mode 100644 package/rust-bin/rust-bin.hash
 create mode 100644 package/rust-bin/rust-bin.mk
 create mode 100644 package/rust-bootstrap/rust-bootstrap.hash
 create mode 100644 package/rust-bootstrap/rust-bootstrap.mk
 create mode 100644 package/rust/rust.hash
 create mode 100644 package/rust/rust.mk
 create mode 100644 package/rustc/Config.in.host
 create mode 100644 package/rustc/rustc.mk
Signature · 1 line
2.9.3
#1 lore raw

PATCH v5 1/7 pkg-virtual: fix host dependencies handling

If $(BR2_PACKAGE_HAS_HOST_FOO) is defined, then the pkg-virtual infrastructure will check if $(BR2_PACKAGE_PROVIDES_HOST_FOO) is not empty.

But later, $(BR2_PACKAGE_HOST_FOO_DEPENDENCIES) will be set from $(BR2_PACKAGE_PROVIDES_FOO), ignoring $(BR2_PACKAGE_PROVIDES_HOST_FOO).

So fix this discrepancy by setting $(BR2_PACKAGE_HOST_FOO_DEPENDENCIES) from $(BR2_PACKAGE_PROVIDES_FOO) only if $(BR2_PACKAGE_PROVIDES_HOST_FOO) is empty.

---
 package/pkg-virtual.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/pkg-virtual.mk +4 -0
index 2e83e07..b8878ad 100644
@@ -49,7 +49,11 @@ $(2)_IS_VIRTUAL = YES
 ifeq ($(4),target)
 $(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
 else
+ifeq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),)
 $(2)_DEPENDENCIES += host-$$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(3)))
+else
+$(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
+endif
 endif
 
 # Call the generic package infrastructure to generate the necessary
Signature · 1 line
2.9.3
#2 lore raw

PATCH v5 1/7 pkg-virtual: fix host dependencies handling

Eric, All,

On 2017-04-22 19:38 +0200, Eric Le Bihan spake thusly:

Quoted 4 lines

If $(BR2_PACKAGE_HAS_HOST_FOO) is defined, then the pkg-virtual infrastructure will check if $(BR2_PACKAGE_PROVIDES_HOST_FOO) is not empty.

Quoted 8 lines

But later, $(BR2_PACKAGE_HOST_FOO_DEPENDENCIES) will be set from $(BR2_PACKAGE_PROVIDES_FOO), ignoring $(BR2_PACKAGE_PROVIDES_HOST_FOO).

So fix this discrepancy by setting $(BR2_PACKAGE_HOST_FOO_DEPENDENCIES) from $(BR2_PACKAGE_PROVIDES_FOO) only if $(BR2_PACKAGE_PROVIDES_HOST_FOO) is empty.

Regards,
Yann E. MORIN.

Quoted 27 lines
---
 package/pkg-virtual.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/pkg-virtual.mk +4 -0
index 2e83e07..b8878ad 100644
@@ -49,7 +49,11 @@ $(2)_IS_VIRTUAL = YES
 ifeq ($(4),target)
 $(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
 else
+ifeq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),)
 $(2)_DEPENDENCIES += host-$$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(3)))
+else
+$(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2)))
+endif
 endif
 
 # Call the generic package infrastructure to generate the necessary
Signature · 6 lines
2.9.3

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v5 2/7 rustc: new virtual package

In reply to Eric Le Bihan

The compiler for the Rust programming language is called rustc.

There is only one reference implementation for it, based on LLVM, from the Rust project [1]. It can generate code for various architectures so it can be labeled as a cross-compiler. But, as for GCC, building it from source takes time.

So it would be sensible to have at least one package which provides it as a pre-built version, fetched from the upstream project. Later another package can be added, to build it from source code.

In addition to the compiler, the standard library for the host and/or the target should also be fetched/built.

So, add a virtual package named rustc to enable support for multiple providers.

Currently, only the host variant will be available to allow the user to cross-compile Rust programs for the target.

[1] http://rust-lang.org

---
 package/rustc/Config.in.host |  5 +++++
 package/rustc/rustc.mk       | 21 +++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 package/rustc/Config.in.host
 create mode 100644 package/rustc/rustc.mk
package/rustc/Config.in.host new file +5 -0
new file mode 100644
index 0000000..fef78a7
@@ -0,0 +1,5 @@
+config BR2_PACKAGE_HAS_HOST_RUSTC
+	bool
+
+config BR2_PACKAGE_PROVIDES_HOST_RUSTC
+	string
package/rustc/rustc.mk new file +21 -0
new file mode 100644
index 0000000..fc743fa
@@ -0,0 +1,21 @@
+################################################################################
+#
+# rustc
+#
+################################################################################
+
+RUST_TARGET_NAME := $(subst buildroot,unknown,$(GNU_TARGET_NAME))
+
+ifeq ($(BR2_ARM_CPU_ARMV7A),y)
+RUST_TARGET_NAME := $(subst arm-,armv7-,$(RUST_TARGET_NAME))
+endif
+
+ifeq ($(HOSTARCH),x86_64)
+RUST_HOST_ARCH = x86_64
+else ifeq ($(HOSTARCH),x86)
+RUST_HOST_ARCH = i686
+endif
+
+RUST_HOST_NAME = $(RUST_HOST_ARCH)-unknown-linux-gnu
+
+$(eval $(host-virtual-package))
Signature · 1 line
2.9.3
#4 lore raw

PATCH v5 3/7 rust-bin: new package

In reply to Eric Le Bihan

This package provides a pre-built version of rustc, the compiler for the Rust programming language, fetched from the upstream project.

A pre-built version of the standard library for the host as well as one for the chosen target are also fetched and installed.

Only the host variant is provided to allow the user to cross-compile Rust programs and run them on the target.

The menuconfig entry for rustc is also updated to expose this provider.

---
 DEVELOPERS                     |  1 +
 package/rust-bin/rust-bin.hash | 30 ++++++++++++++++++++++++++++++
 package/rust-bin/rust-bin.mk   | 41 +++++++++++++++++++++++++++++++++++++++++
 package/rustc/Config.in.host   | 41 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 113 insertions(+)
 create mode 100644 package/rust-bin/rust-bin.hash
 create mode 100644 package/rust-bin/rust-bin.mk
DEVELOPERS +1 -0
index 123a8f9..b352042 100644
@@ -451,6 +451,7 @@ F:	package/execline/
 F:	package/hicolor-icon-theme/
 F:	package/jemalloc/
 F:	package/ninja/
+F:	package/rust-bin/
 F:	package/s6/
 F:	package/s6-dns/
 F:	package/s6-linux-init/
package/rust-bin/rust-bin.hash new file +30 -0
new file mode 100644
index 0000000..42988f8
@@ -0,0 +1,30 @@
+# From https://static.rust-lang.org/dist/rustc-1.16.0-i686-unknown-linux-gnu.tar.gz.sha256
+sha256 f8e0f96c17d8345be7818035e9bcae8e809a1b13635fe9a322df4a82d6dd1275  rustc-1.16.0-i686-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rustc-1.16.0-x86_64-unknown-linux-gnu.tar.gz.sha256
+sha256 b1dc3f754eeaf03891a3bd398c8c5024404c0078a334e5d8795e9dc419d147b3  rustc-1.16.0-x86_64-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-aarch64-unknown-linux-gnu.tar.gz.sha256
+sha256 dafe92282dd5ca67f95c5b8cc2a729b2f8cb04d6e30c6d790819a27f0119d8ca  rust-std-1.16.0-aarch64-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-arm-unknown-linux-gnueabi.tar.gz.sha256
+sha256 b220d8c0fd1a5039b91181fd083e96c9b48c71fb5892e98ec99e60e4ac4bb29d  rust-std-1.16.0-arm-unknown-linux-gnueabi.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-arm-unknown-linux-gnueabihf.tar.gz.sha256
+sha256 bc7846a432d672995bf7ef349a79ee422a003b808579996fe0a30f335dce16f4  rust-std-1.16.0-arm-unknown-linux-gnueabihf.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-armv7-unknown-linux-gnueabihf.tar.gz.sha256
+sha256 dd6869bf2d2f31711d327ac9a5e42667a65b3fa9476e36a4c6418cb1cc5109fb  rust-std-1.16.0-armv7-unknown-linux-gnueabihf.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-i686-unknown-linux-gnu.tar.gz.sha256
+sha256 5a74e3661f4b300bf73353389acab097f3e07813b0f3073007830a549656054a  rust-std-1.16.0-i686-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-mips-unknown-linux-gnu.tar.gz.sha256
+sha256 0d2f91ce61e261e11f44732ea3bdf04c2dd498f441b89b3ab1cf0eebc6d0b8cb  rust-std-1.16.0-mips-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-mips64-unknown-linux-gnuabi64.tar.gz.sha256
+sha256 2c0cca2d97f79b4027c9ff0ebde611fae527b2c6ce1accddd6b4b3936a4c8a8c  rust-std-1.16.0-mips64-unknown-linux-gnuabi64.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-mips64el-unknown-linux-gnuabi64.tar.gz.sha256
+sha256 5396748787b81e2d136bcd3ed8a86ca1b0b77b469e0065d14002815000fb6c42  rust-std-1.16.0-mips64el-unknown-linux-gnuabi64.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-mipsel-unknown-linux-gnu.tar.gz.sha256
+sha256 deeade93a16fa3c2258fb11ca2cbc31fa22e721c89f5db7457ac233351efe073  rust-std-1.16.0-mipsel-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-powerpc-unknown-linux-gnu.tar.gz.sha256
+sha256 a8faf140202c3ad35fd335b32c4b0ce14aad0ef5b9485b9a542b1bb8aa495a7a  rust-std-1.16.0-powerpc-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-powerpc64-unknown-linux-gnu.tar.gz.sha256
+sha256 b8d1e47adaef06a05fb021071e4dca1469422056352ad77a74be2a5a3a95099e  rust-std-1.16.0-powerpc64-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-powerpc64le-unknown-linux-gnu.tar.gz.sha256
+sha256 0cd7f99ef3e620865781bd13a89a1de3dc46593f9de6927d52c47f8d44a31d26  rust-std-1.16.0-powerpc64le-unknown-linux-gnu.tar.gz
+# From https://static.rust-lang.org/dist/rust-std-1.16.0-x86_64-unknown-linux-gnu.tar.gz.sha256
+sha256 cbd43de2ab819d3332ce309046f3b5d715c1b47877a237791b99c96b1fe0d555  rust-std-1.16.0-x86_64-unknown-linux-gnu.tar.gz
package/rust-bin/rust-bin.mk new file +41 -0

41 lines not on this page · raw message

package/rustc/Config.in.host +41 -0

46 lines not on this page · raw message

Signature · 1 line
2.9.3
#5 lore raw

PATCH v5 4/7 rustc: expose host variant in menuconfig

In reply to Eric Le Bihan

Now that one provider is available for rustc, expose the host variant in menuconfig.

---
 package/Config.in.host | 1 +
 1 file changed, 1 insertion(+)
package/Config.in.host +1 -0
index 38f919a..49fcdb0 100644
@@ -39,6 +39,7 @@ menu "Host utilities"
 	source "package/python-lxml/Config.in.host"
 	source "package/qemu/Config.in.host"
 	source "package/raspberrypi-usbboot/Config.in.host"
+	source "package/rustc/Config.in.host"
 	source "package/s6-rc/Config.in.host"
 	source "package/sam-ba/Config.in.host"
 	source "package/squashfs/Config.in.host"
Signature · 1 line
2.9.3
#6 lore raw

PATCH v5 5/7 rust-bootstrap: new package

In reply to Eric Le Bihan

This new package fetches a binary snapshot of the Rust compiler, suitable to bootstrap the host variant of the Rust compiler.

To bootstrap rustc version N, rustc N-1 is used.

---
 DEVELOPERS                                 |  1 +
 package/rust-bootstrap/rust-bootstrap.hash |  5 +++++
 package/rust-bootstrap/rust-bootstrap.mk   | 27 +++++++++++++++++++++++++++
 3 files changed, 33 insertions(+)
 create mode 100644 package/rust-bootstrap/rust-bootstrap.hash
 create mode 100644 package/rust-bootstrap/rust-bootstrap.mk
DEVELOPERS +1 -0
index b352042..f707f2d 100644
@@ -452,6 +452,7 @@ F:	package/hicolor-icon-theme/
 F:	package/jemalloc/
 F:	package/ninja/
 F:	package/rust-bin/
+F:	package/rust-bootstrap/
 F:	package/s6/
 F:	package/s6-dns/
 F:	package/s6-linux-init/
package/rust-bootstrap/rust-bootstrap.hash new file +5 -0
new file mode 100644
index 0000000..b418ea0
@@ -0,0 +1,5 @@
+# Locally calculated
+sha256 a833304f99071600c72ecd868c1c7bd5ce49d1102332637a8eb7adb942f349ab  rustc-1.15.1-i686-unknown-linux-gnu.tar.gz
+sha256 33ff44672b731fc71145974ce84194a1a9bafe6da3a74fd1e7543f12467f8894  rustc-1.15.1-x86_64-unknown-linux-gnu.tar.gz
+sha256 eff452a54b208a83b35432f226cb7de046d27b5e43edfc31d71ff340af686db0  rust-std-1.15.1-i686-unknown-linux-gnu.tar.gz
+sha256 69b251b478e284dfcaefc1153183f26f41d504ae213a81224f2101d8dbd52bb0  rust-std-1.15.1-x86_64-unknown-linux-gnu.tar.gz
package/rust-bootstrap/rust-bootstrap.mk new file +27 -0
new file mode 100644
index 0000000..a49ac25
@@ -0,0 +1,27 @@
+################################################################################
+#
+# rust-bootstrap
+#
+################################################################################
+
+RUST_BOOTSTRAP_VERSION = 1.15.1
+RUST_BOOTSTRAP_SITE = https://static.rust-lang.org/dist
+
+RUST_BOOTSTRAP_SOURCE = rustc-$(RUST_BOOTSTRAP_VERSION)-$(RUST_HOST_NAME).tar.gz
+RUST_BOOTSTRAP_LICENSE = Apache-2.0 or MIT
+RUST_BOOTSTRAP_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+RUST_BOOTSTRAP_LIBSTD_SOURCE= rust-std-$(RUST_BOOTSTRAP_VERSION)-$(RUST_HOST_NAME).tar.gz
+RUST_BOOTSTRAP_LIBSTD_ROOT = rust-std-$(RUST_BOOTSTRAP_VERSION)-$(RUST_HOST_NAME)/rust-std-$(RUST_HOST_NAME)
+RUST_BOOTSTRAP_EXTRA_DOWNLOADS = $(RUST_BOOTSTRAP_SITE)/$(RUST_BOOTSTRAP_LIBSTD_SOURCE)
+
+define RUST_BOOTSTRAP_LIBSTD_EXTRACT
+	$(call suitable-extractor,$(RUST_BOOTSTRAP_LIBSTD_SOURCE)) \
+		$(DL_DIR)/$(RUST_BOOTSTRAP_LIBSTD_SOURCE) | \
+		$(TAR) --strip-components=2 -C $(@D)/rustc $(TAR_OPTIONS) - \
+			$(RUST_BOOTSTRAP_LIBSTD_ROOT)/lib
+endef
+
+HOST_RUST_BOOTSTRAP_EXTRA_DOWNLOADS = $(RUST_BOOTSTRAP_EXTRA_DOWNLOADS)
+HOST_RUST_BOOTSTRAP_POST_EXTRACT_HOOKS += RUST_BOOTSTRAP_LIBSTD_EXTRACT
+
+$(eval $(host-generic-package))
Signature · 1 line
2.9.3
#7 lore raw

PATCH v5 6/7 cargo-bootstrap: new package

In reply to Eric Le Bihan

This new package fetches a binary snapshot of Cargo, suitable to bootstrap the host variants of the Rust compiler and Cargo, the package manager.

Note that, contrary to rust-bootstrap which fetches version N-1 of the rustc binary, this package fetches a nightly version of the cargo binary, as upstream does not provide binaries for stable releases.

---
 DEVELOPERS                                   |  1 +
 package/cargo-bootstrap/cargo-bootstrap.hash |  3 +++
 package/cargo-bootstrap/cargo-bootstrap.mk   | 14 ++++++++++++++
 3 files changed, 18 insertions(+)
 create mode 100644 package/cargo-bootstrap/cargo-bootstrap.hash
 create mode 100644 package/cargo-bootstrap/cargo-bootstrap.mk
DEVELOPERS +1 -0
index f707f2d..b323efd 100644
@@ -445,6 +445,7 @@ F:	package/xxhash/
 
 N:	Eric Le Bihan <[email protected]>
 F:	package/adwaita-icon-theme/
+F:	package/cargo-bootstrap/
 F:	package/darkhttpd/
 F:	package/eudev/
 F:	package/execline/
package/cargo-bootstrap/cargo-bootstrap.hash new file +3 -0
new file mode 100644
index 0000000..b193c6f
@@ -0,0 +1,3 @@
+# Locally generated
+sha256 0655713cacab054e8e5a33e742081eebec8531a8c77d28a4294e6496123e8ab1  cargo-nightly-x86_64-unknown-linux-gnu.tar.gz
+sha256 f20adfdcd6fb61c1252034e998998ec349c8a6b05c0320e47a539b0f6d1c76fa  cargo-nightly-i686-unknown-linux-gnu.tar.gz
package/cargo-bootstrap/cargo-bootstrap.mk new file +14 -0
new file mode 100644
index 0000000..8a11e6e
@@ -0,0 +1,14 @@
+################################################################################
+#
+# cargo-bootstrap
+#
+################################################################################
+
+CARGO_BOOTSTRAP_VERSION = 6e0c18cccc8b0c06fba8a8d76486f81a792fb420
+CARGO_BOOTSTRAP_SITE = https://s3.amazonaws.com/rust-lang-ci/cargo-builds/$(CARGO_BOOTSTRAP_VERSION)
+CARGO_BOOTSTRAP_SOURCE = cargo-nightly-$(HOSTARCH)-unknown-linux-gnu.tar.gz
+CARGO_BOOTSTRAP_LICENSE = Apache-2.0 or MIT
+CARGO_BOOTSTRAP_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+CARGO_BOOTSTRAP_STRIP_COMPONENTS = 1
+
+$(eval $(host-generic-package))
Signature · 1 line
2.9.3
#8 lore raw

PATCH v5 7/7 rust: new package

In reply to Eric Le Bihan

This new package provides rustc, the compiler for the Rust programming language, built from source.

Currently, only the host variant is built.

The Rust compiler uses LLVM as its backend: a copy of LLVM source code is provided and CMake is used to build it. It is possible to use a pre-built external copy. When LLVM/clang will be available in Buildroot, it would be possible to benefit from this feature and thus decrease build time.

LLVM is configured to generate code for x86, ARM, PowerPC and MIPS architectures.

The Rust compiler uses Cargo as its build system and is written in Rust. Therefore this package depends on cargo-bootstrap and rust-bootstrap.

The internal build process is as follows:

1. rustc-stage0, provided by rust-bootstrap, is used to build rustc-stage1.
2. rust-stage1 builds the final Rust compiler (rust-stage2) and the standard library for the host architecture.
3. the standard library for the target architecture is built.

The target architecture to support is given by the GNU/LLVM target triple. Rust supports some predefined targets [1]. As the build system expects the triple to be in the form of <arch>-unknown-<system> and Buildroot toolchain wrapper uses <arch>-buildroot-<system>, the package Makefile uses $(RUST_TARGET_NAME) defined in the rustc package and uses it instead of $(GNU_TARGET_NAME).

When compiling Rust code with this compiler, the generated program only depends on the target C library, as it is statically linked to the Rust standard library and any other code from Rust packages (a.k.a. "crates").

If the jemalloc package is selected, support for this memory allocator will be enabled in the target standard library.

The menuconfig entry for rustc is also updated to expose this provider.

[1] https://forge.rust-lang.org/platform-support.html

---
 DEVELOPERS                   |  1 +
 package/rust/rust.hash       |  2 ++
 package/rust/rust.mk         | 77 ++++++++++++++++++++++++++++++++++++++++++++
 package/rustc/Config.in.host | 15 +++++++++
 4 files changed, 95 insertions(+)
 create mode 100644 package/rust/rust.hash
 create mode 100644 package/rust/rust.mk
DEVELOPERS +1 -0
index b323efd..57af5ed 100644
@@ -454,6 +454,7 @@ F:	package/jemalloc/
 F:	package/ninja/
 F:	package/rust-bin/
 F:	package/rust-bootstrap/
+F:	package/rust/
 F:	package/s6/
 F:	package/s6-dns/
 F:	package/s6-linux-init/
package/rust/rust.hash new file +2 -0
new file mode 100644
index 0000000..3b04dfd
@@ -0,0 +1,2 @@
+# Locally calculated
+sha256 f966b31eb1cd9bd2df817c391a338eeb5b9253ae0a19bf8a11960c560f96e8b4  rustc-1.16.0-src.tar.gz
package/rust/rust.mk new file +77 -0

77 lines not on this page · raw message

package/rustc/Config.in.host +15 -0
index 7f2c276..30bab8f 100644
@@ -26,6 +26,20 @@ choice
 	help
 	  Choose a provider for the Rust compiler.
 
+config BR2_PACKAGE_HOST_RUST
+	bool "host rust"
+	depends on BR2_HOST_GCC_AT_LEAST_4_7 # required by LLVM
+	# triggers ICE on trunc_int_for_mode, at explow.c:56
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 || !BR2_aarch64
+	select BR2_PACKAGE_HAS_HOST_RUSTC
+	help
+	  This package will build the compiler for the host as well as
+	  a cross-compiled version of the Rust standard library for the
+	  target.
+
+comment "host-rust needs a toolchain w/ gcc >= 5"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5 && BR2_aarch64
+
 config BR2_PACKAGE_HOST_RUST_BIN
 	bool "host rust (pre-built)"
 	select BR2_PACKAGE_HAS_HOST_RUSTC
@@ -40,6 +54,7 @@ config BR2_PACKAGE_HAS_HOST_RUSTC
 
 config BR2_PACKAGE_PROVIDES_HOST_RUSTC
 	string
+	default "host-rust" if BR2_PACKAGE_HOST_RUST
 	default "host-rust-bin" if BR2_PACKAGE_HOST_RUST_BIN
 
 endif
Signature · 1 line
2.9.3
#9 lore raw

v5 cover Add support for the Rust programming language

In reply to Eric Le Bihan

Hi Eric,

Quoted 7 lines · Eric Le Bihan

This series adds support for the Rust programming language by adding the following packages:

- rustc: a virtual package for the Rust compiler.
- rust-bin: provides a pre-built version of rustc.
- rust: builds rustc from source.

Quoted 8 lines

Both providers are able to cross-compile code for ARM, MIPS, PowerPC and x86_64 architectures. Only the host variants are provided.

The rustc virtual package is inspired by the mysql one.

As the Rust compiler is written in Rust and uses Cargo, the Rust package manager, as build system, two additional packages are provided: rust-bootstrap and cargo-bootstrap.

Many thanks for the work! I'll look into it, when I've some spare time.

J?rg