Add support for the Rust programming language
v6 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.
v5 -> v6:
- bump rust to 1.18.0
- bump rust-bootstrap to 1.17.0
- bump rust-bin to 1.18.0
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 | 8 +++ 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, 293 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.4
PATCH v6 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
@@ -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.4
PATCH v6 1/7 pkg-virtual: fix host dependencies handling
Quoted 4 lines · Eric Le Bihan
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.
Signed-off-by Eric Le Bihan <[email protected]>
package/pkg-virtual.mk $(2)_IS_VIRTUAL = YES · line 52
Quoted 13 lines
--- package/pkg-virtual.mk | 4 ++++ 1 file changed, 4 insertions(+)package/pkg-virtual.mk +1
-0@@ -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))),)
This is a bit difficult to grok, so perhaps add
# Inherit from target package BR2_PACKAGE_PROVIDES_FOO
package/pkg-virtual.mk $(2)_IS_VIRTUAL = YES · line 54
Quoted 2 lines
package/pkg-virtual.mk +1
-0$(2)_DEPENDENCIES += host-$$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(3))) +else
# BR2_PACKAGE_PROVIDES_HOST_FOO is explicitly defined
Regards,
Arnout
Quoted 6 lines
package/pkg-virtual.mk +2
-0+$(2)_DEPENDENCIES += $$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))) +endif endif # Call the generic package infrastructure to generate the necessary
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Thomas Petazzoni
AppliedPATCH v6 1/7 pkg-virtual: fix host dependencies handling
In reply to Eric Le BihanHello,
Quoted 7 lines · Eric Le Bihan
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).
Quoted 8 lines
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.
Signed-off-by Eric Le Bihan <[email protected]>--- package/pkg-virtual.mk | 4 ++++ 1 file changed, 4 insertions(+)
Applied to master, after adding the comments suggested by Arnout.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v6 2/7 rustc: new virtual package
In reply to Eric Le BihanThe 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.
--- 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
@@ -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
@@ -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.4
PATCH v6 3/7 rust-bin: new package
In reply to Eric Le BihanThis 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
@@ -483,6 +483,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
@@ -0,0 +1,30 @@ +# From https://static.rust-lang.org/dist/rustc-1.18.0-i686-unknown-linux-gnu.tar.gz.sha256 +sha256 0cb9bb95373cee8ba26e8f517c46f8c58a29e22f2c7c08a4d152306c6ffc7115 rustc-1.18.0-i686-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rustc-1.18.0-x86_64-unknown-linux-gnu.tar.gz.sha256 +sha256 f2a34e20166ccf6eda4de46a9efb02821df5c3f34667e2988284a8eaee408113 rustc-1.18.0-x86_64-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-aarch64-unknown-linux-gnu.tar.gz.sha256 +sha256 1a6b33f8bce7637fe038667cd82dda60a69fe319adf3820f621670ef9d75af2b rust-std-1.18.0-aarch64-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-arm-unknown-linux-gnueabi.tar.gz.sha256 +sha256 8da327ff42cf895ff341bca862f8a235c1bd78e473464183bff85ceccdfa3a91 rust-std-1.18.0-arm-unknown-linux-gnueabi.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-arm-unknown-linux-gnueabihf.tar.gz.sha256 +sha256 8cf92d8a4f6c04f66edafbbfd1ad12839bcc0ee1477b2ccdaeb43fb81788c4fc rust-std-1.18.0-arm-unknown-linux-gnueabihf.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-armv7-unknown-linux-gnueabihf.tar.gz.sha256 +sha256 bafef1cc817fc0b6fcc06d19fc9a28638d7a85dd6c2345a803c4c89d3ed89a9f rust-std-1.18.0-armv7-unknown-linux-gnueabihf.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-i686-unknown-linux-gnu.tar.gz.sha256 +sha256 3b93c7b856b98f61ec0f640bc96373f4762484ab3340866902c8c96933bcf10b rust-std-1.18.0-i686-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-mips-unknown-linux-gnu.tar.gz.sha256 +sha256 312bc9444d3b43a78fc82755f84ccf6b692778233983546c4616e08419a06bb0 rust-std-1.18.0-mips-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-mips64-unknown-linux-gnuabi64.tar.gz.sha256 +sha256 86bd6c2a364359b8c749b31f4ec9a2de0d6d4af72582c4edab80e443b59f06f6 rust-std-1.18.0-mips64-unknown-linux-gnuabi64.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-mips64el-unknown-linux-gnuabi64.tar.gz.sha256 +sha256 d3af657644a6e4a4d2285a522f5189f5722c78f59fc17f36f2b0487e374cf829 rust-std-1.18.0-mips64el-unknown-linux-gnuabi64.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-mipsel-unknown-linux-gnu.tar.gz.sha256 +sha256 76b14be2770bff9945a16f95e23f6bf0bbd921b9529b9cfdb5c7569f312746c8 rust-std-1.18.0-mipsel-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-powerpc-unknown-linux-gnu.tar.gz.sha256 +sha256 8716a44ee1be60500e9cc1460f12f211e1ae84ddf50dd6f05faafe13478962c0 rust-std-1.18.0-powerpc-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-powerpc64-unknown-linux-gnu.tar.gz.sha256 +sha256 3572c3477271c61e816ac030277eb1aa7a948e34af00b8a2d6eb73a367220e66 rust-std-1.18.0-powerpc64-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-powerpc64le-unknown-linux-gnu.tar.gz.sha256 +sha256 60deedd6f61c7460231067bf1e0fbf5aff1666e6be581f8ab73df9016e84e47d rust-std-1.18.0-powerpc64le-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.18.0-x86_64-unknown-linux-gnu.tar.gz.sha256 +sha256 4a66150781e224412ebd9dd6d643ad65ecc5668a7754e4a12e115be6ce7bf527 rust-std-1.18.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.4
PATCH v6 4/7 rustc: expose host variant in menuconfig
In reply to Eric Le BihanNow 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
@@ -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.4
PATCH v6 5/7 rust-bootstrap: new package
In reply to Eric Le BihanThis 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 | 8 ++++++++ package/rust-bootstrap/rust-bootstrap.mk | 27 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 package/rust-bootstrap/rust-bootstrap.hash create mode 100644 package/rust-bootstrap/rust-bootstrap.mk
DEVELOPERS +1 -0
@@ -484,6 +484,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 +8 -0
@@ -0,0 +1,8 @@ +# From https://static.rust-lang.org/dist/rustc-1.17.0-i686-unknown-linux-gnu.tar.gz.sha256 +sha256 9d3e3ff343f22b5288676b40d6749ebeabea863fa9e6009fbc5a018ede83c57c rustc-1.17.0-i686-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rustc-1.17.0-x86_64-unknown-linux-gnu.tar.gz.sha256 +sha256 3eebd92512040baf3c0974c3ce61859646d8cf422cc515d724d857577da0dbd5 rustc-1.17.0-x86_64-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.17.0-x86_64-unknown-linux-gnu.tar.gz.sha256 +sha256 2902bb0da78208f441f1d983aeafcad01ea653d2e062a8192892868e2b41130d rust-std-1.17.0-x86_64-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/rust-std-1.17.0-i686-unknown-linux-gnu.tar.gz.sha256 +sha256 3dbaa44a07b14e5af05633c5f1a7d6b0538c6f8fa404ee6d3f85714d4f2bf39b rust-std-1.17.0-i686-unknown-linux-gnu.tar.gz
package/rust-bootstrap/rust-bootstrap.mk new file +27 -0
@@ -0,0 +1,27 @@ +################################################################################ +# +# rust-bootstrap +# +################################################################################ + +RUST_BOOTSTRAP_VERSION = 1.17.0 +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.4
PATCH v6 6/7 cargo-bootstrap: new package
In reply to Eric Le BihanThis 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
@@ -477,6 +477,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
@@ -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
@@ -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-$(RUST_HOST_NAME).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.4
PATCH v6 7/7 rust: new package
In reply to Eric Le BihanThis 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
@@ -486,6 +486,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
@@ -0,0 +1,2 @@ +# Locally generated +sha256 d2dc36e99b9e2269488b2bcddde43c234e6bde03edf70cba82a027ff49c36111 rustc-1.18.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
@@ -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.4
v6 cover Add support for the Rust programming language
In reply to Eric Le BihanHello Eric (and everybody else :D),
I think it's great that there is work being done to bring Rust support to Buildroot, because the languge has been gaining a lot of traction, and people are now writing very interesting programs in it (I am a fan of RipGrep myself! If you don't know it, take a look at: https://github.com/BurntSushi/ripgrep)
Recently I submitted v2 of a patch to add a LLVM package, and it would be interesting to coordinate to make your Rust patchset use it, instead of the Rust packaging providing its own copy of LLVM. You can see the patch in Patchwork:
https://patchwork.ozlabs.org/patch/777949/
I am addin some comments inline below, please keep reading...
Quoted 9 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.Both providers are able to cross-compile code for ARM, MIPS, PowerPC and
x86_64architectures. Only the host variants are provided.
This means that the ?llvm? package should also provide a host variant of the package. I did a quick try adding ?$(eval $(host-cmake-package))? plus a few minor changs locally and LLVM built just fine.
Regarding the architecture backends to enable, I imagine we would want host variant to have enabled *both* the host-native backend, and the target backend. Example: When building for ARM in x86_64, we would enable the ?ARM? and ?X86? LLVM backends for ?host-llvm?, and only ?ARM? for ?llvm? (the target package). Would this be correct? Do you foresee any situation in which other backends should be enabled for either the host or target variants? Should we allow selecting from menuconfig which backends are compiled for the target ?llvm? package?
Last but not least: Right now my patch for adding LLVM only builds the main libraries and binaries. Is this enough for Rust?
Rgeards,
--
Adri?n ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170628/48dcd059/attachment.asc>
v6 cover Add support for the Rust programming language
Hi!
Quoted 24 lines · Adrian Perez de Castro
Hello Eric (and everybody else :D),
I think it's great that there is work being done to bring Rust support to Buildroot, because the languge has been gaining a lot of traction, and people are now writing very interesting programs in it (I am a fan of RipGrep myself! If you don't know it, take a look at: https://github.com/BurntSushi/ripgrep)
Recently I submitted v2 of a patch to add a LLVM package, and it would be interesting to coordinate to make your Rust patchset use it, instead of the Rust packaging providing its own copy of LLVM. You can see the patch in Patchwork:
https://patchwork.ozlabs.org/patch/777949/
I am addin some comments inline below, please keep reading...
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 6 lines
Quoted 2 lines
Both providers are able to cross-compile code for ARM, MIPS, PowerPC and
x86_64architectures. Only the host variants are provided.This means that the ?llvm? package should also provide a host variant of the package. I did a quick try adding ?$(eval $(host-cmake-package))? plus a few minor changs locally and LLVM built just fine.
Yes. To build host-rust, the libraries from host-llvm would be required. If you could provide a patch adding host-llvm, I'll happily test it.
Quoted 8 lines
Regarding the architecture backends to enable, I imagine we would want host variant to have enabled *both* the host-native backend, and the target backend. Example: When building for ARM in
x86_64, we would enable the ?ARM? and ?X86? LLVM backends for ?host-llvm?, and only ?ARM? for ?llvm? (the target package). Would this be correct? Do you foresee any situation in which other backends should be enabled for either the host or target variants? Should we allow selecting from menuconfig which backends are compiled for the target ?llvm? package?
IMHO, it is best to keep it simple with only the host and the target archs.
Quoted 2 lines
Last but not least: Right now my patch for adding LLVM only builds the main libraries and binaries. Is this enough for Rust?
Yes.
BR,
--
ELB
v6 cover Add support for the Rust programming language
Quoted 9 lines · Eric Le Bihan
Quoted 8 lines
Regarding the architecture backends to enable, I imagine we would want host variant to have enabled *both* the host-native backend, and the target backend. Example: When building for ARM in
x86_64, we would enable the ?ARM? and ?X86? LLVM backends for ?host-llvm?, and only ?ARM? for ?llvm? (the target package). Would this be correct? Do you foresee any situation in which other backends should be enabled for either the host or target variants? Should we allow selecting from menuconfig which backends are compiled for the target ?llvm? package?IMHO, it is best to keep it simple with only the host and the target archs.
+1 to that.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF