Add support for the Rust programming
v9 cover Add support for the Rust programming
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.
- cargo-bin: provides a pre-built version of Rust package manager.
- rust: builds rustc from source.
- cargo: builds Rust package manager from source.
Only the host variants are provided.
The rustc virtual package is inspired by the mysql one.
v8 -> v9:
- replace giant patch by post-extract hook
- drop rust-cargo virtual package
- explicitly enable SSL support in host-libcurl
v7 -> v8:
- replace cargo-bootstrap by cargo-bin
- drop rust-bootstrap and use rust-bin instead
- rust-bin and rust versions are the same
- cargo-bin and cargo versions are the same
- bump cargo to 0.23.0
- bump rust to 1.22.1
- add rust-cargo virtual package
v6 -> v7:
- add cargo 0.20.0
- bump rust to 1.19.0
- bump rust-bootstrap to 1.18.0
- bump cargo-bootstrap to 0.19.0
- bump rust-bin to 1.19.0
- fix mips64 target name in rustc
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.
Eric Le Bihan (8):
rustc: new virtual package
rust-bin: new package
cargo-bin: new package
rust: new package
libssh2: add host variant
libhttpparser: add host variant
libcurl: add host variant
cargo: new package
DEVELOPERS | 4 ++ package/Config.in.host | 2 + package/cargo-bin/cargo-bin.hash | 4 ++ package/cargo-bin/cargo-bin.mk | 14 +++++ package/cargo/Config.in.host | 8 +++ package/cargo/cargo.hash | 4 ++ package/cargo/cargo.mk | 96 ++++++++++++++++++++++++++++++++++ package/cargo/config.in | 2 + package/libcurl/libcurl.mk | 14 +++++ package/libhttpparser/libhttpparser.mk | 9 ++++ package/libssh2/libssh2.mk | 6 +++ package/rust-bin/rust-bin.hash | 30 +++++++++++ package/rust-bin/rust-bin.mk | 63 ++++++++++++++++++++++ package/rust/rust.hash | 2 + package/rust/rust.mk | 82 +++++++++++++++++++++++++++++ package/rustc/Config.in.host | 62 ++++++++++++++++++++++ package/rustc/rustc.mk | 31 +++++++++++ 17 files changed, 433 insertions(+) create mode 100644 package/cargo-bin/cargo-bin.hash create mode 100644 package/cargo-bin/cargo-bin.mk create mode 100644 package/cargo/Config.in.host create mode 100644 package/cargo/cargo.hash create mode 100644 package/cargo/cargo.mk create mode 100644 package/cargo/config.in create mode 100644 package/rust-bin/rust-bin.hash create mode 100644 package/rust-bin/rust-bin.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
--
2.14.3
PATCH v9 1/8 rustc: new virtual package
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.
--- package/Config.in.host | 1 + package/rustc/Config.in.host | 17 +++++++++++++++++ package/rustc/rustc.mk | 31 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 package/rustc/Config.in.host create mode 100644 package/rustc/rustc.mk
package/Config.in.host +1 -0
@@ -46,6 +46,7 @@ menu "Host utilities" source "package/qemu/Config.in.host" source "package/raspberrypi-usbboot/Config.in.host" source "package/rauc/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"
package/rustc/Config.in.host new file +17 -0
@@ -0,0 +1,17 @@ +config BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS + bool + default y + depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86" + depends on BR2_i386 || BR2_x86_64 \ + || BR2_arm || BR2_aarch64 \ + || BR2_powerpc || BR2_powerpc64 \ + || BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el + depends on !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 + depends on !BR2_MIPS_NABI32 + depends on BR2_TOOLCHAIN_USES_GLIBC + +config BR2_PACKAGE_HAS_HOST_RUSTC + bool + +config BR2_PACKAGE_PROVIDES_HOST_RUSTC + string
package/rustc/rustc.mk new file +31 -0
@@ -0,0 +1,31 @@ +################################################################################ +# +# rustc +# +################################################################################ + +RUST_ARCH := $(call qstrip,$(BR2_ARCH)) + +ifeq ($(BR2_ARM_CPU_ARMV7A),y) +RUST_ARCH := armv7 +endif + +ifeq ($(BR2_ARM_EABI),y) +RUST_ABI := eabi +else ifeq ($(BR2_ARM_EABIHF),y) +RUST_ABI := eabihf +else ifeq ($(BR2_mips64)$(BR2_mips64el),y) +RUST_ABI := abi64 +endif + +RUST_TARGET_NAME := $(RUST_ARCH)-unknown-linux-gnu$(RUST_ABI) + +ifeq ($(HOSTARCH),x86) +RUST_HOST_ARCH = i686 +else +RUST_HOST_ARCH = $(HOSTARCH) +endif + +RUST_HOST_NAME = $(RUST_HOST_ARCH)-unknown-linux-gnu + +$(eval $(host-virtual-package))
Signature · 1 line
2.14.3
PATCH v9 1/8 rustc: new virtual package
Hello,
Quoted 6 lines · Eric Le Bihan
package/rustc/Config.in.host new file +0
-0
package/rustc/Config.in.host line 8
Quoted 8 lines
package/rustc/Config.in.host new file +8
-0@@ -0,0 +1,17 @@ +config BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS + bool + default y + depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86" + depends on BR2_i386 || BR2_x86_64 \ + || BR2_arm || BR2_aarch64 \ + || BR2_powerpc || BR2_powerpc64 \ + || BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el
This would be more readable as:
default y if BR2_aarch64 default y if BR2_arm && !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 default y if BR2_i386 default y if ... default y if BR2_mips || BR2_mipsel default y if (BR2_mips64 || BR2_mips64el) && BR2_MIPS_NABI64 default y if BR2_x86_64
package/rustc/Config.in.host line 11
Quoted 3 lines
package/rustc/Config.in.host new file +3
-0+ depends on !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 + depends on !BR2_MIPS_NABI32 + depends on BR2_TOOLCHAIN_USES_GLIBC
Since it's weird for a host package to have a target architecture dependency and target C library dependency, it would be good to have a comment that explains this. I assume it's because of the Rust standard library, so something like:
# The pre-built Rust standard library is only available for the # following architectures/ABIs, and is built against glibc.
Quoted 15 lines
package/rustc/rustc.mk new file +9
-0@@ -0,0 +1,31 @@ +################################################################################ +# +# rustc +# +################################################################################ + +RUST_ARCH := $(call qstrip,$(BR2_ARCH)) + +ifeq ($(BR2_ARM_CPU_ARMV7A),y)
package/rustc/rustc.mk line 19
Quoted 10 lines
package/rustc/rustc.mk new file +10
-0+RUST_ARCH := armv7 +endif + +ifeq ($(BR2_ARM_EABI),y) +RUST_ABI := eabi +else ifeq ($(BR2_ARM_EABIHF),y) +RUST_ABI := eabihf +else ifeq ($(BR2_mips64)$(BR2_mips64el),y) +RUST_ABI := abi64 +endif
Perhaps this could be defined in the Config.in file as well ?
config BR2_PACKAGE_HOST_RUSTC_ARCH
string
default "armv7" if BR2_ARM_CPU_ARMV7A
default BR2_ARCH if !BR2_ARM_CPU_ARMV7A
config BR2_PACKAGE_HOST_RUSTC_ABI
string
default "eabi" if BR2_ARM_EABI
default "eabihf" if BR2_ARM_EABIHF
default "abi64" if BR2_MIPS_NABI64
package/rustc/rustc.mk line 21
Quoted 1 line
package/rustc/rustc.mk new file +1
-0+RUST_TARGET_NAME := $(RUST_ARCH)-unknown-linux-gnu$(RUST_ABI)
Why are you using := in this file instead of = ?
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v9 1/8 rustc: new virtual package
Hi!
Quoted 21 lines · Thomas Petazzoni
Hello,
Quoted 6 lines · Eric Le Bihan
package/rustc/Config.in.host new file +0
-0package/rustc/Config.in.host line 8
Quoted 8 lines
package/rustc/Config.in.host new file +8
-0@@ -0,0 +1,17 @@ +config BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS + bool + default y + depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86" + depends on BR2_i386 || BR2_x86_64 \ + || BR2_arm || BR2_aarch64 \ + || BR2_powerpc || BR2_powerpc64 \ + || BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64elThis would be more readable as:
Quoted 8 lines
default y if BR2_aarch64 default y if BR2_arm && !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 default y if BR2_i386 default y if ... default y if BR2_mips || BR2_mipsel default y if (BR2_mips64 || BR2_mips64el) && BR2_MIPS_NABI64 default y if BR2_x86_64
OK.
Quoted 11 lines
package/rustc/Config.in.host line 11
Quoted 3 lines
package/rustc/Config.in.host new file +3
-0+ depends on !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5 + depends on !BR2_MIPS_NABI32 + depends on BR2_TOOLCHAIN_USES_GLIBCSince it's weird for a host package to have a target architecture dependency and target C library dependency, it would be good to have a comment that explains this. I assume it's because of the Rust standard library, so something like:
# The pre-built Rust standard library is only available for the # following architectures/ABIs, and is built against glibc.
OK.
Quoted 33 lines
Quoted 15 lines
package/rustc/rustc.mk new file +9
-0@@ -0,0 +1,31 @@ +################################################################################ +# +# rustc +# +################################################################################ + +RUST_ARCH := $(call qstrip,$(BR2_ARCH)) + +ifeq ($(BR2_ARM_CPU_ARMV7A),y)package/rustc/rustc.mk line 19
Quoted 10 lines
package/rustc/rustc.mk new file +10
-0+RUST_ARCH := armv7 +endif + +ifeq ($(BR2_ARM_EABI),y) +RUST_ABI := eabi +else ifeq ($(BR2_ARM_EABIHF),y) +RUST_ABI := eabihf +else ifeq ($(BR2_mips64)$(BR2_mips64el),y) +RUST_ABI := abi64 +endifPerhaps this could be defined in the Config.in file as well ?
config
BR2_PACKAGE_HOST_RUSTC_ARCH
string
default "armv7" ifBR2_ARM_CPU_ARMV7A
defaultBR2_ARCHif !BR2_ARM_CPU_ARMV7A
Quoted 5 lines
config
BR2_PACKAGE_HOST_RUSTC_ABI
string
default "eabi" ifBR2_ARM_EABI
default "eabihf" ifBR2_ARM_EABIHF
default "abi64" ifBR2_MIPS_NABI64
OK.
Quoted 3 lines
package/rustc/rustc.mk line 21
Quoted 1 line
package/rustc/rustc.mk new file +1
-0+RUST_TARGET_NAME := $(RUST_ARCH)-unknown-linux-gnu$(RUST_ABI)Why are you using := in this file instead of = ?
A long time ago, I ran into an error about $(RUST_TARGET_NAME) not being defined, hence the simply expanded variable. I'll check this again.
Regards,
--
ELB
PATCH v9 2/8 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.
This package could also be used to provide a bootstrap compiler when building Rust from source. So, in order to add it as a build dependency, the compiler and standard libraries are only installed in $(HOST_DIR) if the package is explicitly selected.
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 | 63 ++++++++++++++++++++++++++++++++++++++++++ package/rustc/Config.in.host | 29 +++++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 package/rust-bin/rust-bin.hash create mode 100644 package/rust-bin/rust-bin.mk
DEVELOPERS +1 -0
@@ -543,6 +543,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.22.1-i686-unknown-linux-gnu.tar.xz.sha256 +sha256 d87e15a8f8b3d53270866076824559926d01145733144c4a5905affff3819b47 rustc-1.22.1-i686-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rustc-1.22.1-x86_64-unknown-linux-gnu.tar.xz.sha256 +sha256 9730e46b2301417a5c5e1410f8ab8b8b6979f448b7fffc5e63221bd1bdaa15a3 rustc-1.22.1-x86_64-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-aarch64-unknown-linux-gnu.tar.xz.sha256 +sha256 b9c004288c5516dae88e325d24f26c10702dc617268e35b51b4bc83f4f2fc30d rust-std-1.22.1-aarch64-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-arm-unknown-linux-gnueabi.tar.xz.sha256 +sha256 d48e918af118cacd2074c1c357cea46f2db73d42510c54fdfdcdf0ff60ba58ec rust-std-1.22.1-arm-unknown-linux-gnueabi.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-arm-unknown-linux-gnueabihf.tar.xz.sha256 +sha256 b64b4047dcdfa4aa617f7606a92320c95cdd44cadadac72d3e7d162addc62c92 rust-std-1.22.1-arm-unknown-linux-gnueabihf.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-armv7-unknown-linux-gnueabihf.tar.xz.sha256 +sha256 e85b649aa18e1903e3c9c899ded55652713017a1e3a35e6fd58a7f40738805be rust-std-1.22.1-armv7-unknown-linux-gnueabihf.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-i686-unknown-linux-gnu.tar.xz.sha256 +sha256 112e17646bc5c513e81396b2c8042a44071a268b0d77810e378bdc9122abedc1 rust-std-1.22.1-i686-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-mips-unknown-linux-gnu.tar.xz.sha256 +sha256 80f0bc95273805e1ffe424b004b71a23d6d36acac2999d7361ce3cd3b17f39e9 rust-std-1.22.1-mips-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-mips64-unknown-linux-gnuabi64.tar.xz.sha256 +sha256 d50e4b52133b58235ff6f2c9de18d2ca81647fc2ef50aeaf9c1df5d726b3b2a3 rust-std-1.22.1-mips64-unknown-linux-gnuabi64.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-mips64el-unknown-linux-gnuabi64.tar.xz.sha256 +sha256 6f61b30cd54c24fcdffddb67eb4073b2199dbea487c7be2c9ab6dd4bab46dabf rust-std-1.22.1-mips64el-unknown-linux-gnuabi64.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-mipsel-unknown-linux-gnu.tar.xz.sha256 +sha256 01278fa6596d8193bff76ddaacb78c339d610c5dbe035a38f7d0d9ebcf2bcce7 rust-std-1.22.1-mipsel-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-powerpc-unknown-linux-gnu.tar.xz.sha256 +sha256 39b26eaa3006aea11539d63bffdeada7078d79a4a06916cc8e6f6d66434e0a91 rust-std-1.22.1-powerpc-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-powerpc64-unknown-linux-gnu.tar.xz.sha256 +sha256 dcaf8f636ad4290bc761566d5fac77f4d6757046fe0ee539417fc6543246877b rust-std-1.22.1-powerpc64-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-powerpc64le-unknown-linux-gnu.tar.xz.sha256 +sha256 9f5f047c8817b9c9bb45465fdccf55be9a551ebae5859100fdfa2c429f9d0574 rust-std-1.22.1-powerpc64le-unknown-linux-gnu.tar.xz +# From https://static.rust-lang.org/dist/rust-std-1.22.1-x86_64-unknown-linux-gnu.tar.xz.sha256 +sha256 edd3313eb6523b2c08c84fc9cd7a80e4fb14c32168639d1833fd1b46e088a9a1 rust-std-1.22.1-x86_64-unknown-linux-gnu.tar.xz
package/rust-bin/rust-bin.mk new file +63 -0
63 lines not on this page · raw message
package/rustc/Config.in.host +29 -0
@@ -10,8 +10,37 @@ config BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS depends on !BR2_MIPS_NABI32 depends on BR2_TOOLCHAIN_USES_GLIBC +config BR2_PACKAGE_HOST_RUSTC + bool "host rustc" + depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS + help + Compiler for the Rust language + + http://www.rust-lang.org + +if BR2_PACKAGE_HOST_RUSTC + +choice + prompt "Rust compiler variant" + default BR2_PACKAGE_HOST_RUST_BIN + help + Select a Rust compiler + +config BR2_PACKAGE_HOST_RUST_BIN + bool "host rust (pre-built)" + select BR2_PACKAGE_HAS_HOST_RUSTC + help + This package will install pre-built versions of the compiler + for the host and the Rust standard library for the target. + +endchoice + config BR2_PACKAGE_HAS_HOST_RUSTC bool config BR2_PACKAGE_PROVIDES_HOST_RUSTC string + default "host-rust-bin" if BR2_PACKAGE_HOST_RUST_BIN + +endif +
Signature · 1 line
2.14.3
PATCH v9 2/8 rust-bin: new package
Hello,
Quoted 5 lines · 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.
I was wondering if a separate package could be used to install the standard library, in order to avoid the extra downloads and custom extract step.
One possibility would be to have a rust-std-bin package, which rust-bin depends on. The target version of rust-std-bin would install the target libraries, while the host version would install the host libraries. The weird thing is that the target libraries are installed in $(HOST_DIR), while one would expect them to be in $(STAGING_DIR). Is this something we can tell rustc about perhaps ?
Even if we keep the single package approach, having the target libraries in $(STAGING_DIR) would be more logical. But that's a soft requirement, so if it's too tedious to achieve with rustc, we can live with them being in HOST_DIR.
Quoted 15 lines
package/rust-bin/rust-bin.mk new file +9
-0@@ -0,0 +1,63 @@ +################################################################################ +# +# rust-bin +# +################################################################################ + +RUST_BIN_VERSION = 1.22.1 +RUST_BIN_SITE = https://static.rust-lang.org/dist +RUST_BIN_LICENSE = Apache-2.0 or MIT
package/rust-bin/rust-bin.mk line 19
Quoted 10 lines
package/rust-bin/rust-bin.mk new file +10
-0+RUST_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT + +HOST_RUST_BIN_PROVIDES = host-rustc + +HOST_RUST_BIN_SOURCE = rustc-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz +HOST_RUST_BIN_LIBSTD_SOURCES = \ + rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz \ + rust-std-$(RUST_BIN_VERSION)-$(RUST_TARGET_NAME).tar.xz + +HOST_RUST_BIN_EXTRA_DOWNLOADS = $(HOST_RUST_BIN_LIBSTD_SOURCES)
Assuming we keep the single package approach, then why not use HOST_RUST_BIN_EXTRA_DOWNLOADS directly ? HOST_RUST_BIN_LIBSTD_SOURCES looks a bit useless.
package/rust-bin/rust-bin.mk line 26
Quoted 6 lines
package/rust-bin/rust-bin.mk new file +6
-0+HOST_RUST_BIN_LIBSTD_HOST_PREFIX = rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME)/rust-std-$(RUST_HOST_NAME) + +define HOST_RUST_BIN_LIBSTD_EXTRACT + mkdir -p $(@D)/std + for file in $(addprefix $(DL_DIR)/,$(HOST_RUST_BIN_LIBSTD_SOURCES)); do \ + $(TAR) -C $(@D)/std -xJf $${file}; \
This would benefit from using $(foreach ...) and should use suitable-extractor. Something like (untested):
$(foreach f,$(HOST_RUST_BIN_EXTRA_DOWNLOADS), \ $(call suitable-extractor,$(f)) $(DL_DIR)/$(f) | \ $(TAR) -C $(@D)/std $(TAR_OPTIONS) - )
package/rust-bin/rust-bin.mk line 31
Quoted 5 lines
package/rust-bin/rust-bin.mk new file +5
-0+ done + (\ + cd $(@D)/rustc/lib/rustlib; \ + ln -sf ../../../std/$(HOST_RUST_BIN_LIBSTD_HOST_PREFIX)/lib/rustlib/$(RUST_HOST_NAME) \ + )
There's no need for this command to run in a sub-shell, so:
cd $(@D)/rustc/lib/rustlib; \ ln -sf ../../../std/$(HOST_RUST_BIN_LIBSTD_HOST_PREFIX)/lib/rustlib/$(RUST_HOST_NAME)
should be sufficient.
package/rust-bin/rust-bin.mk line 40
Quoted 9 lines
package/rust-bin/rust-bin.mk new file +9
-0+endef + +HOST_RUST_BIN_POST_EXTRACT_HOOKS += HOST_RUST_BIN_LIBSTD_EXTRACT + +HOST_RUST_BIN_INSTALL_OPTS = \ + --prefix=$(HOST_DIR) \ + --disable-ldconfig + +ifeq ($(BR2_PACKAGE_HOST_RUST_BIN),y)
Why do you have this conditional ? If the package isn't built, then those definitions aren't used anyway.
The rest looks good to me. Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v9 2/8 rust-bin: new package
Hi!
Quoted 13 lines · Thomas Petazzoni
Hello,
Quoted 5 lines · 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.
I was wondering if a separate package could be used to install the standard library, in order to avoid the extra downloads and custom extract step.
Quoted 6 lines
One possibility would be to have a rust-std-bin package, which rust-bin depends on. The target version of rust-std-bin would install the target libraries, while the host version would install the host libraries. The weird thing is that the target libraries are installed in $(HOST_DIR), while one would expect them to be in $(STAGING_DIR). Is this something we can tell rustc about perhaps ?
The idea of having a separate package for the standard library was previously mentionned. The pros for it were the following:
- smaller/cleaner packages
- as Rust programs can be built without the standard library (e.g. for bare metal and microcontrollers), allowing the user to select the standard library separately looks sensible.
However, as a virtual package is used for the host Rust compiler (with host-rust and host-rust-bin as its providers), does adding a separate package for the binary standard library implies adding a virtual package for the standard library too?
We would have:
- host-rustc: virtual package for Rust compiler
- host-rust-std: virtual package for Rust standard library
- host-rustc-bin: provider for host-rustc (binary)
- host-rust-std-bin: provider for host-rust-std (binary)
- host-rust: provider for host-rustc and host-rust-std (built from source)
Would not that lead to too many compiler/library combinations?
Besides, compiling a program without standard library relies on a compiler directive in the source code, so having a selectable standard library package does not look that necessary from a user point of view.
So, to me, there are two options:
a) the current one:
- host-rustc: virtual package for the compiler
- host-rust-bin: provides host-rustc and standard library (binary)
- host-rust: provides host-rustc and standard library (built from source)
b) a potentially cleaner version:
- host-rustc: virtual package for the compiler
- host-rustc-bin: provides host-rustc (binary), formerly known as host-rust-bin (renamed for clarity)
- host-rust-std-bin: provides standard library (binary), a new dependency for host-rustc-bin, not selectable at user level.
- host-rust: provides host-rustc and standard library (built from source)
Quoted 4 lines
Even if we keep the single package approach, having the target libraries in $(STAGING_DIR) would be more logical. But that's a soft requirement, so if it's too tedious to achieve with rustc, we can live with them being in
HOST_DIR.
The standard library tarball provides *.rlib (static Rust libraries) and *.so (dynamic Rust libraries) files. The path to these files can be passed to rustc using the --sysroot command line option, which can be passed to Cargo (Rust package manager) by using the environment variable RUSTFLAGS or the "rustflags" parameter in $(HOST_DIR)/share/cargo/config.
So it should be possible to relocate files from
$(HOST_DIR)/lib/rustlib/$(RUST_TARGET_NAME) to
$(STAGING_DIR)/lib/rustlib/$(RUST_TARGET_NAME):
- host-rust(-std)-bin: straightforward (change command line option to installation script).
- host-rust: install everything to $(HOST_DIR), then move target libraries to $(STAGING_DIR)
By default, all Rust programs are statically linked with the standard library. It is possible to link dynamically [1] and in that case the *.so files should indeed be copied to $(TARGET_DIR). So maybe in the future support for $(BR2_SHARED_LIBS) should be added to handle this.
IMHO, the standard library should be managed more like libgcc.so than glibc/uclibc/musl. (Things would have been simpler if there has been an easy way to build the cross-compiled standard library separately from the compiler).
Quoted 21 lines
Quoted 21 lines
package/rust-bin/rust-bin.mk new file +15
-0@@ -0,0 +1,63 @@ +################################################################################ +# +# rust-bin +# +################################################################################ + +RUST_BIN_VERSION = 1.22.1 +RUST_BIN_SITE = https://static.rust-lang.org/dist +RUST_BIN_LICENSE = Apache-2.0 or MIT +RUST_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT + +HOST_RUST_BIN_PROVIDES = host-rustc + +HOST_RUST_BIN_SOURCE = rustc-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz +HOST_RUST_BIN_LIBSTD_SOURCES = \
Quoted 8 lines
package/rust-bin/rust-bin.mk line 19
Quoted 4 lines
package/rust-bin/rust-bin.mk new file +4
-0+ rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz \ + rust-std-$(RUST_BIN_VERSION)-$(RUST_TARGET_NAME).tar.xz + +HOST_RUST_BIN_EXTRA_DOWNLOADS = $(HOST_RUST_BIN_LIBSTD_SOURCES)Assuming we keep the single package approach, then why not use
HOST_RUST_BIN_EXTRA_DOWNLOADSdirectly ?HOST_RUST_BIN_LIBSTD_SOURCESlooks a bit useless.
OK.
Quoted 10 lines
package/rust-bin/rust-bin.mk line 26
Quoted 6 lines
package/rust-bin/rust-bin.mk new file +6
-0+HOST_RUST_BIN_LIBSTD_HOST_PREFIX = rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME)/rust-std-$(RUST_HOST_NAME) + +define HOST_RUST_BIN_LIBSTD_EXTRACT + mkdir -p $(@D)/std + for file in $(addprefix $(DL_DIR)/,$(HOST_RUST_BIN_LIBSTD_SOURCES)); do \ + $(TAR) -C $(@D)/std -xJf $${file}; \This would benefit from using $(foreach ...) and should use suitable-extractor. Something like (untested):
Quoted 4 lines
$(foreach f,$(HOST_RUST_BIN_EXTRA_DOWNLOADS), \ $(call suitable-extractor,$(f)) $(DL_DIR)/$(f) | \ $(TAR) -C $(@D)/std $(TAR_OPTIONS) - )
OK.
Quoted 8 lines
package/rust-bin/rust-bin.mk line 31
Quoted 5 lines
package/rust-bin/rust-bin.mk new file +5
-0+ done + (\ + cd $(@D)/rustc/lib/rustlib; \ + ln -sf ../../../std/$(HOST_RUST_BIN_LIBSTD_HOST_PREFIX)/lib/rustlib/$(RUST_HOST_NAME) \ + )There's no need for this command to run in a sub-shell, so:
Quoted 4 lines
cd $(@D)/rustc/lib/rustlib; \ ln -sf ../../../std/$(HOST_RUST_BIN_LIBSTD_HOST_PREFIX)/lib/rustlib/$(RUST_HOST_NAME)should be sufficient.
OK.
Quoted 13 lines
package/rust-bin/rust-bin.mk line 40
Quoted 9 lines
package/rust-bin/rust-bin.mk new file +9
-0+endef + +HOST_RUST_BIN_POST_EXTRACT_HOOKS += HOST_RUST_BIN_LIBSTD_EXTRACT + +HOST_RUST_BIN_INSTALL_OPTS = \ + --prefix=$(HOST_DIR) \ + --disable-ldconfig + +ifeq ($(BR2_PACKAGE_HOST_RUST_BIN),y)Why do you have this conditional ? If the package isn't built, then those definitions aren't used anyway.
Quoted 1 line
The rest looks good to me. Thanks!
The idea is to define the installation commands only if the package is selected at user level. This is the trick to use this package as a bootstrap compiler to build Rust from source: in that case, this package is added as a dependency and not selected at user level, so it is downloaded and extracted but not installed in $(HOST_DIR). This prevents polluting $(HOST_DIR) by installing rust-bin then rust on top of it.
[1] http://www.elebihan.com/posts/generating-dynamically-linked-programs-with-cargo.html
Regards,
--
ELB
PATCH v9 3/8 cargo-bin: new package
In reply to Eric Le BihanThis new package fetches a binary version of Cargo, suitable to bootstrap the host variants of the Rust compiler and Cargo, the package manager.
--- DEVELOPERS | 1 + package/cargo-bin/cargo-bin.hash | 4 ++++ package/cargo-bin/cargo-bin.mk | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 package/cargo-bin/cargo-bin.hash create mode 100644 package/cargo-bin/cargo-bin.mk
DEVELOPERS +1 -0
@@ -537,6 +537,7 @@ F: package/xxhash/ N: Eric Le Bihan <[email protected]> F: package/adwaita-icon-theme/ +F: package/cargo-bin/ F: package/darkhttpd/ F: package/eudev/ F: package/execline/
package/cargo-bin/cargo-bin.hash new file +4 -0
@@ -0,0 +1,4 @@ +# From https://static.rust-lang.org/dist/cargo-0.23.0-i686-unknown-linux-gnu.tar.gz.sha256 +sha256 7ebe231e5da2a06370f17050285ee694cf09ac2010d87dab334ae7eb7fb2d975 cargo-0.23.0-i686-unknown-linux-gnu.tar.gz +# From https://static.rust-lang.org/dist/cargo-0.23.0-x86_64-unknown-linux-gnu.tar.xz.sha256 +sha256 4f33d9e511cfcbb370f470d3813e4877da10761d5f75460e538503fa07fa64f8 cargo-0.23.0-x86_64-unknown-linux-gnu.tar.xz
package/cargo-bin/cargo-bin.mk new file +14 -0
@@ -0,0 +1,14 @@ +################################################################################ +# +# cargo-bin +# +################################################################################ + +CARGO_BIN_VERSION = 0.23.0 +CARGO_BIN_SITE = https://static.rust-lang.org/dist +CARGO_BIN_SOURCE = cargo-$(CARGO_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz +CARGO_BIN_LICENSE = Apache-2.0 or MIT +CARGO_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT +CARGO_BIN_STRIP_COMPONENTS = 1 + +$(eval $(host-generic-package))
Signature · 1 line
2.14.3
PATCH v9 3/8 cargo-bin: new package
Hello,
Quoted 5 lines · Eric Le Bihan
This new package fetches a binary version of Cargo, suitable to bootstrap the host variants of the Rust compiler and Cargo, the package manager.
Signed-off-by Eric Le Bihan <[email protected]>
Looks good, just one comment below.
Quoted 8 lines
package/cargo-bin/cargo-bin.mk new file +2
-0@@ -0,0 +1,14 @@ +################################################################################ +#
package/cargo-bin/cargo-bin.mk line 12
Quoted 10 lines
package/cargo-bin/cargo-bin.mk new file +10
-0+# cargo-bin +# +################################################################################ + +CARGO_BIN_VERSION = 0.23.0 +CARGO_BIN_SITE = https://static.rust-lang.org/dist +CARGO_BIN_SOURCE = cargo-$(CARGO_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz +CARGO_BIN_LICENSE = Apache-2.0 or MIT +CARGO_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT +CARGO_BIN_STRIP_COMPONENTS = 1
This is the default, so why do you need this ?
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v9 3/8 cargo-bin: new package
Quoted 23 lines · Thomas Petazzoni
Hello,
Quoted 5 lines · Eric Le Bihan
This new package fetches a binary version of Cargo, suitable to bootstrap the host variants of the Rust compiler and Cargo, the package manager.
Signed-off-by Eric Le Bihan <[email protected]>Looks good, just one comment below.
Quoted 12 lines
package/cargo-bin/cargo-bin.mk new file +6
-0@@ -0,0 +1,14 @@ +################################################################################ +# +# cargo-bin +# +################################################################################ +
Quoted 8 lines
package/cargo-bin/cargo-bin.mk line 12
Quoted 6 lines
package/cargo-bin/cargo-bin.mk new file +6
-0+CARGO_BIN_VERSION = 0.23.0 +CARGO_BIN_SITE = https://static.rust-lang.org/dist +CARGO_BIN_SOURCE = cargo-$(CARGO_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz +CARGO_BIN_LICENSE = Apache-2.0 or MIT +CARGO_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT +CARGO_BIN_STRIP_COMPONENTS = 1This is the default, so why do you need this ?
Leftover from previous patch version. I'll remove it.
Regards,
--
ELB
PATCH v9 4/8 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-bin and rust-bin.
The internal build process is as follows:
1. rustc-stage0, provided by rust-bin, 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 | 82 ++++++++++++++++++++++++++++++++++++++++++++ package/rustc/Config.in.host | 16 +++++++++ 4 files changed, 101 insertions(+) create mode 100644 package/rust/rust.hash create mode 100644 package/rust/rust.mk
DEVELOPERS +1 -0
@@ -545,6 +545,7 @@ F: package/hicolor-icon-theme/ F: package/jemalloc/ F: package/ninja/ F: package/rust-bin/ +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 @@ +# From https://static.rust-lang.org/dist/rustc-1.22.1-src.tar.xz.sha256 +sha256 80ee9ecc1e03ee63ea13c2612b61fc04fce9240476836f70c553ebaebd58fed6 rustc-1.22.1-src.tar.xz
package/rust/rust.mk new file +82 -0
82 lines not on this page · raw message
package/rustc/Config.in.host +16 -0
@@ -26,6 +26,21 @@ choice help Select a 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 + two flavors of the standard library: one for the host, another + for the target. Both are installed in the host directory. + +comment "host-rust needs a toolchain w/ gcc >= 5" + depends on BR2_aarch64 + depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5 + config BR2_PACKAGE_HOST_RUST_BIN bool "host rust (pre-built)" select BR2_PACKAGE_HAS_HOST_RUSTC
@@ -40,6 +55,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.14.3
PATCH v9 4/8 rust: new package
Hello,
Quoted 14 lines · 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.
Quoted 8 lines
The Rust compiler uses Cargo as its build system and is written in Rust. Therefore this package depends on cargo-bin and rust-bin.
The internal build process is as follows:
1. rustc-stage0, provided by rust-bin, is used to build rustc-stage1.
2. rust-stage1 builds the final Rust compiler (rust-stage2) and the standard library for the host architecture.
You're sometimes using rustc-stageX, sometimes just rust-stageX. Is this intentional ?
Quoted 12 lines
package/rust/rust.mk new file +6
-0@@ -0,0 +1,82 @@ +################################################################################ +# +# rust +# +################################################################################ +
package/rust/rust.mk line 16
Quoted 10 lines
package/rust/rust.mk new file +10
-0+RUST_VERSION = 1.22.1 +RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.xz +RUST_SITE = https://static.rust-lang.org/dist +RUST_LICENSE = Apache-2.0 or MIT +RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT + +HOST_RUST_PROVIDES = host-rustc + +HOST_RUST_DEPENDENCIES = \ + toolchain \
It is somewhat unusual to have a host package depend on the target toolchain. I'm not sure we have any other host package in the tree doing this. I do understand why you're doing this, I'm just a little bit concerned that this special situation may be forgotten in the future. But there isn't much other solution, so it's probably good as it is.
package/rust/rust.mk line 19
Quoted 3 lines
package/rust/rust.mk new file +3
-0+ host-rust-bin \ + host-cargo-bin \ + host-python \
So you absolutely need python2 ? The build system is not python3 compliant ?
package/rust/rust.mk line 20
Quoted 1 line
package/rust/rust.mk new file +1
-0+ host-cmake
Could you use $(BR2_CMAKE_HOST_DEPENDENCY) instead ? This way, it would only build host-cmake if CMake is not already present on the system. This would save a bit of build time.
package/rust/rust.mk line 32
Quoted 11 lines
package/rust/rust.mk new file +11
-0+ifeq ($(BR2_PACKAGE_JEMALLOC),y) +HOST_RUST_DEPENDENCIES += jemalloc +HOST_RUST_JEMALLOC_ENABLED = true +HOST_RUST_JEMALLOC_CONF = 'jemalloc = "$(STAGING_DIR)/usr/lib/libjemalloc_pic.a"' +else +HOST_RUST_JEMALLOC_ENABLED = false +endif + +HOST_RUST_VERBOSITY = $(if $(VERBOSE),2,0) + +# Some vendored crates contain Cargo.toml.orig files. The associated
vendored -> vendor ?
Quoted 62 lines
package/rust/rust.mk new file +50
-0+# .cargo-checksum.json file will contain a checksum for Cargo.toml.orig but +# support/scripts/apply-patches.sh will delete them. This will cause the build +# to fail, as Cargo will not be able to find the file and verify the checksum. +# So, remove all Cargo.toml.orig entries from the affected .cargo-checksum.json +# files +define HOST_RUST_EXCLUDE_ORIG_FILES + for file in $$(find $(@D) -name '*.orig'); do \ + crate=$$(dirname $${file}); \ + fn=$${crate}/.cargo-checksum.json; \ + sed -i -e 's/"Cargo.toml.orig":"[a-z0-9]\+",//g' $${fn}; \ + done +endef + +HOST_RUST_POST_EXTRACT_HOOKS += HOST_RUST_EXCLUDE_ORIG_FILES + +define HOST_RUST_CONFIGURE_CMDS + ( \ + echo '[build]'; \ + echo 'target = ["$(RUST_TARGET_NAME)"]'; \ + echo 'cargo = "$(HOST_CARGO_BIN_DIR)/cargo/bin/cargo"'; \ + echo 'rustc = "$(HOST_RUST_BIN_DIR)/rustc/bin/rustc"'; \ + echo 'python = "$(HOST_DIR)/bin/python2"'; \ + echo 'submodules = false'; \ + echo 'vendor = true'; \ + echo 'compiler-docs = false'; \ + echo 'docs = false'; \ + echo 'verbose = $(HOST_RUST_VERBOSITY)'; \ + echo '[install]'; \ + echo 'prefix = "$(HOST_DIR)"'; \ + echo '[rust]'; \ + echo 'use-jemalloc = $(HOST_RUST_JEMALLOC_ENABLED)'; \ + echo '[target.$(RUST_TARGET_NAME)]'; \ + echo 'cc = "$(TARGET_CROSS)gcc"'; \ + echo $(HOST_RUST_JEMALLOC_CONF); \ + ) > $(@D)/config.toml +endef + +define HOST_RUST_BUILD_CMDS + (cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py \ + build $(HOST_RUST_BUILD_OPTS)) +endef + +define HOST_RUST_INSTALL_CMDS + (cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py \ + dist $(HOST_RUST_BUILD_OPTS)) + (cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py \ + install $(HOST_RUST_BUILD_OPTS)) +endef + +$(eval $(host-generic-package))package/rustc/Config.in.host +4
-0@@ -26,6 +26,21 @@ choice help Select a 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
package/rustc/Config.in.host choice · line 42
Quoted 10 lines
package/rustc/Config.in.host +10
-0+ 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 + two flavors of the standard library: one for the host, another + for the target. Both are installed in the host directory. + +comment "host-rust needs a toolchain w/ gcc >= 5" + depends on BR2_aarch64 + depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5
What about the gcc 4.7 dependency? It would also need a comment.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v9 4/8 rust: new package
Hi!
Quoted 20 lines · Thomas Petazzoni
Hello,
Quoted 17 lines · 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-bin and rust-bin.
Quoted 8 lines
Quoted 5 lines
The internal build process is as follows:
1. rustc-stage0, provided by rust-bin, is used to build rustc-stage1.
2. rust-stage1 builds the final Rust compiler (rust-stage2) and the standard library for the host architecture.You're sometimes using rustc-stageX, sometimes just rust-stageX. Is this intentional ?
No, just a typo. I'll rephrase using "stageX compiler".
Quoted 30 lines
Quoted 12 lines
package/rust/rust.mk new file +6
-0@@ -0,0 +1,82 @@ +################################################################################ +# +# rust +# +################################################################################ +package/rust/rust.mk line 16
Quoted 10 lines
package/rust/rust.mk new file +10
-0+RUST_VERSION = 1.22.1 +RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.xz +RUST_SITE = https://static.rust-lang.org/dist +RUST_LICENSE = Apache-2.0 or MIT +RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT + +HOST_RUST_PROVIDES = host-rustc + +HOST_RUST_DEPENDENCIES = \ + toolchain \It is somewhat unusual to have a host package depend on the target toolchain. I'm not sure we have any other host package in the tree doing this. I do understand why you're doing this, I'm just a little bit concerned that this special situation may be forgotten in the future. But there isn't much other solution, so it's probably good as it is.
Quoted 6 lines
package/rust/rust.mk line 19
Quoted 3 lines
package/rust/rust.mk new file +3
-0+ host-rust-bin \ + host-cargo-bin \ + host-python \So you absolutely need python2 ? The build system is not python3 compliant ?
The README explicitly states "python 2.7 (but not 3.x)", though it may not need much work to port to Python3. Should I try to patch this?
Quoted 5 lines
package/rust/rust.mk line 20
Quoted 1 line
package/rust/rust.mk new file +1
-0+ host-cmakeCould you use $(BR2_CMAKE_HOST_DEPENDENCY) instead ? This way, it would only build host-cmake if CMake is not already present on the system. This would save a bit of build time.
OK.
Quoted 5 lines
Quoted 5 lines
package/rust/rust.mk new file +5
-0+ifeq ($(BR2_PACKAGE_JEMALLOC),y) +HOST_RUST_DEPENDENCIES += jemalloc +HOST_RUST_JEMALLOC_ENABLED = true +HOST_RUST_JEMALLOC_CONF = 'jemalloc = "$(STAGING_DIR)/usr/lib/libjemalloc_pic.a"' +else
Quoted 8 lines
package/rust/rust.mk line 32
Quoted 6 lines
package/rust/rust.mk new file +6
-0+HOST_RUST_JEMALLOC_ENABLED = false +endif + +HOST_RUST_VERBOSITY = $(if $(VERBOSE),2,0) + +# Some vendored crates contain Cargo.toml.orig files. The associatedvendored -> vendor ?
Of course!
Quoted 58 lines
Quoted 58 lines
package/rust/rust.mk new file +50
-0+# .cargo-checksum.json file will contain a checksum for Cargo.toml.orig but +# support/scripts/apply-patches.sh will delete them. This will cause the build +# to fail, as Cargo will not be able to find the file and verify the checksum. +# So, remove all Cargo.toml.orig entries from the affected .cargo-checksum.json +# files +define HOST_RUST_EXCLUDE_ORIG_FILES + for file in $$(find $(@D) -name '*.orig'); do \ + crate=$$(dirname $${file}); \ + fn=$${crate}/.cargo-checksum.json; \ + sed -i -e 's/"Cargo.toml.orig":"[a-z0-9]\+",//g' $${fn}; \ + done +endef + +HOST_RUST_POST_EXTRACT_HOOKS += HOST_RUST_EXCLUDE_ORIG_FILES + +define HOST_RUST_CONFIGURE_CMDS + ( \ + echo '[build]'; \ + echo 'target = ["$(RUST_TARGET_NAME)"]'; \ + echo 'cargo = "$(HOST_CARGO_BIN_DIR)/cargo/bin/cargo"'; \ + echo 'rustc = "$(HOST_RUST_BIN_DIR)/rustc/bin/rustc"'; \ + echo 'python = "$(HOST_DIR)/bin/python2"'; \ + echo 'submodules = false'; \ + echo 'vendor = true'; \ + echo 'compiler-docs = false'; \ + echo 'docs = false'; \ + echo 'verbose = $(HOST_RUST_VERBOSITY)'; \ + echo '[install]'; \ + echo 'prefix = "$(HOST_DIR)"'; \ + echo '[rust]'; \ + echo 'use-jemalloc = $(HOST_RUST_JEMALLOC_ENABLED)'; \ + echo '[target.$(RUST_TARGET_NAME)]'; \ + echo 'cc = "$(TARGET_CROSS)gcc"'; \ + echo $(HOST_RUST_JEMALLOC_CONF); \ + ) > $(@D)/config.toml +endef + +define HOST_RUST_BUILD_CMDS + (cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py \ + build $(HOST_RUST_BUILD_OPTS)) +endef + +define HOST_RUST_INSTALL_CMDS + (cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py \ + dist $(HOST_RUST_BUILD_OPTS)) + (cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py \ + install $(HOST_RUST_BUILD_OPTS)) +endef + +$(eval $(host-generic-package))package/rustc/Config.in.host +0
-0@@ -26,6 +26,21 @@ choice help Select a Rust compiler
Quoted 16 lines
Quoted 4 lines
package/rustc/Config.in.host +4
-0+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:56package/rustc/Config.in.host choice · line 42
Quoted 10 lines
package/rustc/Config.in.host +10
-0+ 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 + two flavors of the standard library: one for the host, another + for the target. Both are installed in the host directory. + +comment "host-rust needs a toolchain w/ gcc >= 5" + depends on BR2_aarch64 + depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5What about the gcc 4.7 dependency? It would also need a comment.
OK.
Regards,
--
ELB
PATCH v9 5/8 libssh2: add host variant
In reply to Eric Le BihanAllow build of host variant of libssh2, which depends on host-openssl.
--- package/libssh2/libssh2.mk | 6 ++++++ 1 file changed, 6 insertions(+)
package/libssh2/libssh2.mk +6 -0
@@ -40,4 +40,10 @@ else LIBSSH2_CONF_OPTS += --without-libz endif +HOST_LIBSSH2_DEPENDENCIES += host-openssl +HOST_LIBSSH2_CONF_OPTS += --with-openssl \ + --with-libssl-prefix=$(HOST_DIR)/usr \ + --without-libgcrypt + $(eval $(autotools-package)) +$(eval $(host-autotools-package))
Signature · 1 line
2.14.3
PATCH v9 5/8 libssh2: add host variant
Hello,
Quoted 3 lines · Eric Le Bihan
Allow build of host variant of libssh2, which depends on host-openssl.
Signed-off-by Eric Le Bihan <[email protected]>
Long-term, it would be nice to have Config.in options for host packages, so that we don't forcefully build openssl support in host-libssh2, but since you're the only user for now, that's fine.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v9 6/8 libhttpparser: add host variant
In reply to Eric Le BihanAllow build of host variant of libhttpparser.
--- package/libhttpparser/libhttpparser.mk | 9 +++++++++ 1 file changed, 9 insertions(+)
package/libhttpparser/libhttpparser.mk +9 -0
@@ -23,4 +23,13 @@ define LIBHTTPPARSER_INSTALL_TARGET_CMDS $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) PREFIX=$(TARGET_DIR)/usr install endef +define HOST_LIBHTTPPARSER_BUILD_CMDS + $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D) library package +endef + +define HOST_LIBHTTPPARSER_INSTALL_CMDS + $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D) PREFIX=$(HOST_DIR)/usr install +endef + $(eval $(generic-package)) +$(eval $(host-generic-package))
Signature · 1 line
2.14.3
PATCH v9 6/8 libhttpparser: add host variant
Hello,
Quoted 3 lines · Eric Le Bihan
Allow build of host variant of libhttpparser.
Signed-off-by Eric Le Bihan <[email protected]>
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v9 7/8 libcurl: add host variant
In reply to Eric Le Bihan--- package/libcurl/libcurl.mk | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
package/libcurl/libcurl.mk +14 -0
@@ -88,4 +88,18 @@ endef LIBCURL_POST_INSTALL_TARGET_HOOKS += LIBCURL_TARGET_CLEANUP endif +HOST_LIBCURL_DEPENDENCIES = host-openssl +HOST_LIBCURL_CONF_OPTS = \ + --disable-manual \ + --disable-ntlm-wb \ + --disable-curldebug \ + --with-ssl \ + --without-gnutls \ + --without-mbedtls \ + --without-polarssl \ + --without-nss + +HOST_LIBCURL_POST_PATCH_HOOKS += LIBCURL_FIX_DOT_PC + $(eval $(autotools-package)) +$(eval $(host-autotools-package))
Signature · 1 line
2.14.3
PATCH v9 7/8 libcurl: add host variant
Hello,
Quoted 1 line · Eric Le Bihan
Signed-off-by Eric Le Bihan <[email protected]>
Same as host-libssh2, it's a bit annoying to force the dependency on host-openssl, but we don't have much choice today, and you are anyway the only user of host-libcurl at this point.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v9 8/8 cargo: new package
In reply to Eric Le BihanThis new package provides Cargo, the Rust official package manager. Cargo is written in Rust and uses Cargo as its build system. It also depends on other Rust packages.
Normally, a previously installed version of Cargo would be used to:
1. Fetch the dependencies.
2. Build the new version of Cargo, using the available Rust compiler.
But the fetching step prevents offline builds. So instead two features of Cargo are levelled: vendoring [1] and local registry.
First, a tarball of the build dependencies generated using cargo vendor is fetched along with Cargo source code.
Then, the build process is as follows:
1. The tarball of the build dependencies is uncompressed in a local registry.
2. A snapshot of Cargo, provided by cargo-bin, builds the final version of Cargo.
3. A configuration file telling Cargo how to cross-compile programs for the target is generated and installed.
Currently, only the host variant is provided.
[1] https://github.com/alexcrichton/cargo-vendor
--- DEVELOPERS | 1 + package/Config.in.host | 1 + package/cargo/Config.in.host | 8 ++++ package/cargo/cargo.hash | 4 ++ package/cargo/cargo.mk | 96 ++++++++++++++++++++++++++++++++++++++++++++ package/cargo/config.in | 2 + 6 files changed, 112 insertions(+) create mode 100644 package/cargo/Config.in.host create mode 100644 package/cargo/cargo.hash create mode 100644 package/cargo/cargo.mk create mode 100644 package/cargo/config.in
DEVELOPERS +1 -0
@@ -538,6 +538,7 @@ F: package/xxhash/ N: Eric Le Bihan <[email protected]> F: package/adwaita-icon-theme/ F: package/cargo-bin/ +F: package/cargo/ F: package/darkhttpd/ F: package/eudev/ F: package/execline/
package/Config.in.host +1 -0
@@ -2,6 +2,7 @@ menu "Host utilities" source "package/aespipe/Config.in.host" source "package/android-tools/Config.in.host" + source "package/cargo/Config.in.host" source "package/cbootimage/Config.in.host" source "package/checkpolicy/Config.in.host" source "package/cmake/Config.in.host"
package/cargo/Config.in.host new file +8 -0
@@ -0,0 +1,8 @@ +config BR2_PACKAGE_HOST_CARGO + bool "host cargo" + depends on BR2_PACKAGE_HAS_HOST_RUSTC + help + Cargo is the package manager for the Rust programming + language. + + https://crates.io/
package/cargo/cargo.hash new file +4 -0
@@ -0,0 +1,4 @@ +# Locally generated +sha256 f4bbe2a8719dbb8da20842235093f7f70f034d01633189e83f75897d68cd274f cargo-0.23.0.tar.gz +sha512 9060ec6e67b54f7fad7da8dd8450dd051d62b3f8ed4606196fc238a98beba1c3b43087c787f35d012d9b641c8572e70f50b95b0e01fdd75ed82932b6e6efbbf0 cargo-0.23.0-vendor.tar.xz +sha256 dc7240d60a869fa24a68c8734fb7c810c27cca0a6dad52df6279865e4e8e7fae rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gz
package/cargo/cargo.mk new file +96 -0
96 lines not on this page · raw message
package/cargo/config.in new file +2 -0
@@ -0,0 +1,2 @@ +[target. at RUST_TARGET_NAME@] +linker = "@CROSS_PREFIX at gcc"
Signature · 1 line
2.14.3
PATCH v9 8/8 cargo: new package
Hello,
Quoted 11 lines · Eric Le Bihan
This new package provides Cargo, the Rust official package manager. Cargo is written in Rust and uses Cargo as its build system. It also depends on other Rust packages.
Normally, a previously installed version of Cargo would be used to:
1. Fetch the dependencies.
2. Build the new version of Cargo, using the available Rust compiler.But the fetching step prevents offline builds. So instead two features of Cargo are levelled: vendoring [1] and local registry.
Did you want to say "leveraged" instead of "levelled" ?
Quoted 6 lines
package/cargo/Config.in.host new file +0
-0
package/cargo/Config.in.host line 8
Quoted 8 lines
package/cargo/Config.in.host new file +8
-0@@ -0,0 +1,8 @@ +config BR2_PACKAGE_HOST_CARGO + bool "host cargo" + depends on BR2_PACKAGE_HAS_HOST_RUSTC + help + Cargo is the package manager for the Rust programming + language. + + https://crates.io/
How would "host cargo" be used in the context of Buildroot ? Would it be used by packages that are written in Rust as part of their build process ? What would such packages look like ?
package/cargo/cargo.hash line 4
Quoted 10 lines
package/cargo/cargo.hash new file +4
-0@@ -0,0 +1,4 @@ +# Locally generated +sha256 f4bbe2a8719dbb8da20842235093f7f70f034d01633189e83f75897d68cd274f cargo-0.23.0.tar.gz +sha512 9060ec6e67b54f7fad7da8dd8450dd051d62b3f8ed4606196fc238a98beba1c3b43087c787f35d012d9b641c8572e70f50b95b0e01fdd75ed82932b6e6efbbf0 cargo-0.23.0-vendor.tar.xz +sha256 dc7240d60a869fa24a68c8734fb7c810c27cca0a6dad52df6279865e4e8e7fae rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gz
Why are you using sha256 sometimes, and sha512 sometimes? Seems like for the cargo-0.23.0-vendor tarball, the hash is not exactly locally generated, but really comes from upstream.
package/cargo/cargo.hash
Quoted 2 lines
package/cargo/cargo.hash new file +2
-0+HOST_CARGO_DEPENDENCIES = \ + host-cmake \
Do you need host-cmake absolutely here, or can you use $(BR2_CMAKE_HOST_DEPENDENCY) instead ?
Quoted 34 lines
package/cargo/cargo.hash new file +34
-0+ host-pkgconf \ + host-openssl \ + host-libhttpparser \ + host-libssh2 \ + host-libcurl \ + host-rustc \ + host-cargo-bin + +HOST_CARGO_SNAP_BIN = $(HOST_CARGO_BIN_DIR)/cargo/bin/cargo +HOST_CARGO_HOME = $(HOST_DIR)/share/cargo + +define HOST_CARGO_EXTRACT_DEPS + @mkdir -p $(@D)/vendor + $(call suitable-extractor,$(CARGO_DEPS_SOURCE)) \ + $(DL_DIR)/$(CARGO_DEPS_SOURCE) | \ + $(TAR) --strip-components=1 -C $(@D)/vendor $(TAR_OPTIONS) - +endef + +HOST_CARGO_POST_EXTRACT_HOOKS += HOST_CARGO_EXTRACT_DEPS + +define HOST_CARGO_EXTRACT_INSTALLER + @mkdir -p $(@D)/src/rust-installer + $(call suitable-extractor,$(CARGO_INSTALLER_SOURCE)) \ + $(DL_DIR)/$(CARGO_INSTALLER_SOURCE) | \ + $(TAR) --strip-components=1 -C $(@D)/src/rust-installer $(TAR_OPTIONS) - +endef + +HOST_CARGO_POST_EXTRACT_HOOKS += HOST_CARGO_EXTRACT_INSTALLER + +define HOST_CARGO_SETUP_DEPS + mkdir -p $(@D)/.cargo + ( \ + echo "[source.crates-io]"; \ + echo "registry = 'https://github.com/rust-lang/crates.io-index'"; \
package/cargo/cargo.hash
Quoted 10 lines
package/cargo/cargo.hash new file +10
-0+ echo "replace-with = 'vendored-sources'"; \ + echo "[source.vendored-sources]"; \ + echo "directory = '$(@D)/vendor'"; \ + ) > $(@D)/.cargo/config +endef + +HOST_CARGO_PRE_CONFIGURE_HOOKS += HOST_CARGO_SETUP_DEPS + +HOST_CARGO_SNAP_OPTS = --release +HOST_CARGO_SNAP_OPTS += $(if $(VERBOSE),--verbose)
A single assignment would be prettier:
HOST_CARGO_SNAP_OPTS = \ --release \ $(if $(VERBOSE),--verbose)
package/cargo/cargo.hash
Quoted 3 lines
package/cargo/cargo.hash new file +3
-0+HOST_CARGO_ENV = \ + RUSTFLAGS="-Clink-arg=-Wl,-rpath,$(HOST_DIR)/lib" \ + CARGO_HOME=$(HOST_DIR)/share/cargo
Why don't you use $(HOST_CARGO_HOME) here ?
package/cargo/cargo.hash
Quoted 7 lines
package/cargo/cargo.hash new file +7
-0+define HOST_CARGO_BUILD_CMDS + (cd $(@D); $(HOST_MAKE_ENV) $(HOST_CARGO_ENV) $(HOST_CARGO_SNAP_BIN) \ + build $(HOST_CARGO_SNAP_OPTS)) +endef + +define HOST_CARGO_INSTALL_CMDS + $(INSTALL) -d -m 0755 $(HOST_DIR)/bin
This is not needed, just use the -D option in the command command installing the cargo binary.
package/cargo/cargo.hash
Quoted 10 lines
package/cargo/cargo.hash new file +10
-0+ $(INSTALL) -m 0755 $(@D)/target/release/cargo $(HOST_DIR)/bin/cargo +endef + +define HOST_CARGO_INSTALL_CONF_FILE + $(INSTALL) -D package/cargo/config.in \ + $(HOST_DIR)/share/cargo/config + $(SED) 's/@RUST_TARGET_NAME@/$(RUST_TARGET_NAME)/' \ + $(HOST_DIR)/share/cargo/config + $(SED) 's/@CROSS_PREFIX@/$(notdir $(TARGET_CROSS))/' \ + $(HOST_DIR)/share/cargo/config
This should be moved inside HOST_CARGO_INSTALL_CMDS, there is no need for a separate post-install hook.
Also, I'm wondering of your choice between generating config files from the .mk file, or having a template that gets tweaked using SED. In this cargo.mk, you are producing a 5 lines file in HOST_CARGO_SETUP_DEPS where only a single value varies (and would need to be tweaked with sed). But on the other hand, you create a two lines share/cargo/config file from a template. Perhaps we should settle on one or the other solution ?
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v9 8/8 cargo: new package
Hi!
Quoted 9 lines · Thomas Petazzoni
Hello,
Quoted 6 lines · Eric Le Bihan
This new package provides Cargo, the Rust official package manager. Cargo is written in Rust and uses Cargo as its build system. It also depends on other Rust packages.
Normally, a previously installed version of Cargo would be used to:
Quoted 7 lines
Quoted 5 lines
1. Fetch the dependencies.
2. Build the new version of Cargo, using the available Rust compiler.But the fetching step prevents offline builds. So instead two features of Cargo are levelled: vendoring [1] and local registry.
Did you want to say "leveraged" instead of "levelled" ?
That's the word I was looking for!
Quoted 10 lines
Quoted 10 lines
package/cargo/Config.in.host new file +4
-0@@ -0,0 +1,8 @@ +config BR2_PACKAGE_HOST_CARGO + bool "host cargo" + depends on BR2_PACKAGE_HAS_HOST_RUSTC + help
Quoted 8 lines
package/cargo/Config.in.host line 8
Quoted 4 lines
package/cargo/Config.in.host new file +4
-0+ Cargo is the package manager for the Rust programming + language. + + https://crates.io/How would "host cargo" be used in the context of Buildroot ? Would it be used by packages that are written in Rust as part of their build process ? What would such packages look like ?
I will add a new file named docs/manual/adding-packages-rust.txt to document Cargo usage, with an example for adding a package for a Rust program.
Quoted 6 lines
Quoted 6 lines
package/cargo/cargo.hash new file +0
-0@@ -0,0 +1,4 @@
Quoted 8 lines
package/cargo/cargo.hash line 4
Quoted 4 lines
package/cargo/cargo.hash new file +4
-0+# Locally generated +sha256 f4bbe2a8719dbb8da20842235093f7f70f034d01633189e83f75897d68cd274f cargo-0.23.0.tar.gz +sha512 9060ec6e67b54f7fad7da8dd8450dd051d62b3f8ed4606196fc238a98beba1c3b43087c787f35d012d9b641c8572e70f50b95b0e01fdd75ed82932b6e6efbbf0 cargo-0.23.0-vendor.tar.xz +sha256 dc7240d60a869fa24a68c8734fb7c810c27cca0a6dad52df6279865e4e8e7fae rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gzWhy are you using sha256 sometimes, and sha512 sometimes? Seems like for the cargo-0.23.0-vendor tarball, the hash is not exactly locally generated, but really comes from upstream.
Yes, the SHA512 comes from upstream, so I'll add its source URL and keep SHA256 for the locally generated ones.
Quoted 5 lines
package/cargo/cargo.hash
Quoted 2 lines
package/cargo/cargo.hash new file +2
-0+HOST_CARGO_DEPENDENCIES = \ + host-cmake \Do you need host-cmake absolutely here, or can you use $(BR2_CMAKE_HOST_DEPENDENCY) instead ?
$(BR2_CMAKE_HOST_DEPENDENCY) should do the trick.
Quoted 47 lines
Quoted 34 lines
package/cargo/cargo.hash new file +34
-0+ host-pkgconf \ + host-openssl \ + host-libhttpparser \ + host-libssh2 \ + host-libcurl \ + host-rustc \ + host-cargo-bin + +HOST_CARGO_SNAP_BIN = $(HOST_CARGO_BIN_DIR)/cargo/bin/cargo +HOST_CARGO_HOME = $(HOST_DIR)/share/cargo + +define HOST_CARGO_EXTRACT_DEPS + @mkdir -p $(@D)/vendor + $(call suitable-extractor,$(CARGO_DEPS_SOURCE)) \ + $(DL_DIR)/$(CARGO_DEPS_SOURCE) | \ + $(TAR) --strip-components=1 -C $(@D)/vendor $(TAR_OPTIONS) - +endef + +HOST_CARGO_POST_EXTRACT_HOOKS += HOST_CARGO_EXTRACT_DEPS + +define HOST_CARGO_EXTRACT_INSTALLER + @mkdir -p $(@D)/src/rust-installer + $(call suitable-extractor,$(CARGO_INSTALLER_SOURCE)) \ + $(DL_DIR)/$(CARGO_INSTALLER_SOURCE) | \ + $(TAR) --strip-components=1 -C $(@D)/src/rust-installer $(TAR_OPTIONS) - +endef + +HOST_CARGO_POST_EXTRACT_HOOKS += HOST_CARGO_EXTRACT_INSTALLER + +define HOST_CARGO_SETUP_DEPS + mkdir -p $(@D)/.cargo + ( \ + echo "[source.crates-io]"; \ + echo "registry = 'https://github.com/rust-lang/crates.io-index'"; \package/cargo/cargo.hash
Quoted 10 lines
package/cargo/cargo.hash new file +10
-0+ echo "replace-with = 'vendored-sources'"; \ + echo "[source.vendored-sources]"; \ + echo "directory = '$(@D)/vendor'"; \ + ) > $(@D)/.cargo/config +endef + +HOST_CARGO_PRE_CONFIGURE_HOOKS += HOST_CARGO_SETUP_DEPS + +HOST_CARGO_SNAP_OPTS = --release +HOST_CARGO_SNAP_OPTS += $(if $(VERBOSE),--verbose)A single assignment would be prettier:
Quoted 3 lines
HOST_CARGO_SNAP_OPTS = \ --release \ $(if $(VERBOSE),--verbose)
OK.
Quoted 5 lines
package/cargo/cargo.hash
Quoted 3 lines
package/cargo/cargo.hash new file +3
-0+HOST_CARGO_ENV = \ + RUSTFLAGS="-Clink-arg=-Wl,-rpath,$(HOST_DIR)/lib" \ + CARGO_HOME=$(HOST_DIR)/share/cargoWhy don't you use $(HOST_CARGO_HOME) here ?
Leftover for previous patch version.
Quoted 10 lines
package/cargo/cargo.hash
Quoted 7 lines
package/cargo/cargo.hash new file +7
-0+define HOST_CARGO_BUILD_CMDS + (cd $(@D); $(HOST_MAKE_ENV) $(HOST_CARGO_ENV) $(HOST_CARGO_SNAP_BIN) \ + build $(HOST_CARGO_SNAP_OPTS)) +endef + +define HOST_CARGO_INSTALL_CMDS + $(INSTALL) -d -m 0755 $(HOST_DIR)/binThis is not needed, just use the -D option in the command command installing the cargo binary.
Of course!
Quoted 14 lines
package/cargo/cargo.hash
Quoted 10 lines
package/cargo/cargo.hash new file +10
-0+ $(INSTALL) -m 0755 $(@D)/target/release/cargo $(HOST_DIR)/bin/cargo +endef + +define HOST_CARGO_INSTALL_CONF_FILE + $(INSTALL) -D package/cargo/config.in \ + $(HOST_DIR)/share/cargo/config + $(SED) 's/@RUST_TARGET_NAME@/$(RUST_TARGET_NAME)/' \ + $(HOST_DIR)/share/cargo/config + $(SED) 's/@CROSS_PREFIX@/$(notdir $(TARGET_CROSS))/' \ + $(HOST_DIR)/share/cargo/configThis should be moved inside
HOST_CARGO_INSTALL_CMDS, there is no need for a separate post-install hook.
Quoted 7 lines
Also, I'm wondering of your choice between generating config files from the .mk file, or having a template that gets tweaked using SED. In this cargo.mk, you are producing a 5 lines file in
HOST_CARGO_SETUP_DEPSwhere only a single value varies (and would need to be tweaked with sed). But on the other hand, you create a two lines share/cargo/config file from a template. Perhaps we should settle on one or the other solution ?
For the Meson cross-compilation configuration file, I used a template/sed combination as some values were used multiple times. So generating it from the .mk file would have decreased its readability. Besides it is a file to be installed in $(HOST_DIR), so it is "important".
As $(HOST_DIR)/share/cargo/config belongs to the same category, I used the same method, though the file is (currently?) less complex.
On the other side $(@D)/.cargo/config file is just some kind of build artefact, with a limited lifetime. Hence the generation from the .mk file.
Is there a general rule?
Regards,
--
ELB
v9 cover Add support for the Rust programming
In reply to Eric Le BihanHello,
Quoted 8 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.
- cargo-bin: provides a pre-built version of Rust package manager.
- rust: builds rustc from source.
- cargo: builds Rust package manager from source.
One question: with your series, one can therefore chose whether he wants to build its own Rust compiler and standard library ("rust" package) or use the pre-built Rust compiler and standard library ("rustc-bin" package) ?
In other words, does this means that there are two options:
- User chooses rustc-bin, every Rust package is built using the pre-built compiler, and the pre-built standard library is used.
- User chooses rust. In this case, rust is built using rustc-bin, but every other Rust package will be built with the Rust compiler we have built from source, and will be using the Rust standard library we have built from source.
Is this correct ?
(I'm just trying to understand the overall series.)
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
v9 cover Add support for the Rust programming
Hi!
Quoted 22 lines · Thomas Petazzoni
Hello,
Quoted 8 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.
- cargo-bin: provides a pre-built version of Rust package manager.
- rust: builds rustc from source.
- cargo: builds Rust package manager from source.One question: with your series, one can therefore chose whether he wants to build its own Rust compiler and standard library ("rust" package) or use the pre-built Rust compiler and standard library ("rustc-bin" package) ?
In other words, does this means that there are two options:
- User chooses rustc-bin, every Rust package is built using the pre-built compiler, and the pre-built standard library is used.
Quoted 8 lines
- User chooses rust. In this case, rust is built using rustc-bin, but every other Rust package will be built with the Rust compiler we have built from source, and will be using the Rust standard library we have built from source.
Is this correct ?
(I'm just trying to understand the overall series.)
Yes, this is correct. The introduction of a virtual package for the Rust compiler was suggested in the mail thread about version v4 of this series [1], as building the compiler from source takes time and using the available pre-built version would speed things up (as done for GCC).
[1] http://lists.busybox.net/pipermail/buildroot/2017-April/189451.html
Regards,
--
ELB
v9 cover Add support for the Rust programming
Hello,
Quoted 4 lines · Eric Le Bihan
Yes, this is correct. The introduction of a virtual package for the Rust compiler was suggested in the mail thread about version v4 of this series [1], as building the compiler from source takes time and using the available pre-built version would speed things up (as done for GCC).
OK, thanks for the additional explanation, makes sense.
I reviewed the different patches in your series, and I think it's really close to a state where it can be merged. If you can take care of the few comments/questions in the near future, it would definitely help, as I would still have the context in mind.
Two other things that would be nice to do is:
- Add two test cases in support/testing/. One that builds a system with rust-bin, builds a hello world program in Rust, and run it on the target. And another that does the same, but by building the rust compiler from source. Perhaps additional test cases can be added for Cargo, but I'm not sure how it's supposed to be used.
- Add a short section in the documentation that explains how the Rust support in Buildroot is working. This would help people trying to do stuff with Rust to understand how things work.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
v9 cover Add support for the Rust programming
Hi!
Quoted 13 lines · Thomas Petazzoni
I reviewed the different patches in your series, and I think it's really close to a state where it can be merged. If you can take care of the few comments/questions in the near future, it would definitely help, as I would still have the context in mind.
Two other things that would be nice to do is:
- Add two test cases in support/testing/. One that builds a system with rust-bin, builds a hello world program in Rust, and run it on the target. And another that does the same, but by building the rust compiler from source. Perhaps additional test cases can be added for Cargo, but I'm not sure how it's supposed to be used.
Quoted 3 lines
- Add a short section in the documentation that explains how the Rust support in Buildroot is working. This would help people trying to do stuff with Rust to understand how things work.
I'll add these. Thanks for the review!
Regards,
--
ELB
v9 cover Add support for the Rust programming
In reply to Thomas PetazzoniHi!
Quoted 8 lines · Thomas Petazzoni
Two other things that would be nice to do is:
- Add two test cases in support/testing/. One that builds a system with rust-bin, builds a hello world program in Rust, and run it on the target. And another that does the same, but by building the rust compiler from source. Perhaps additional test cases can be added for Cargo, but I'm not sure how it's supposed to be used.
Is there a glibc-based toolchain suitable for arm vexpress available on
http://autobuild.buildroot.org/toolchains/tarballs/?
I see br-aarch64-glibc-2017.05-1078-g95b1dae.tar.bz2, but there is no support for Aarch64 in testing and no artefacts are available.
Regards,
--
ELB
v9 cover Add support for the Rust programming
Hello Eric,
Quoted 4 lines · Eric Le Bihan
Quoted 3 lines · Thomas Petazzoni
Two other things that would be nice to do is:
Quoted 8 lines
Quoted 5 lines
- Add two test cases in support/testing/. One that builds a system with rust-bin, builds a hello world program in Rust, and run it on the target. And another that does the same, but by building the rust compiler from source. Perhaps additional test cases can be added for Cargo, but I'm not sure how it's supposed to be used.
Is there a glibc-based toolchain suitable for arm vexpress available on
http://autobuild.buildroot.org/toolchains/tarballs/?
Use the Linaro ARM toolchain ?
Quoted 2 lines
I see br-aarch64-glibc-2017.05-1078-g95b1dae.tar.bz2, but there is no support for Aarch64 in testing
I'm not sure what you mean by "no support for AArch64 in testing". The testing infrastructure can test any arbitrary configuration, so there is nothing like "support for architecture <foo> in testing". Perhaps you are confused by BASIC_TOOLCHAIN_CONFIG being an ARM toolchain configuration. But this BASIC_TOOLCHAIN_CONFIG is not mandatory, it is just one toolchain configuration that you can use if your test doesn't really care about the architecture/toolchain.
We have tests like support/testing/tests/fs/test_iso9660.py that don't use BASIC_TOOLCHAIN_CONFIG.
Quoted 1 line
and no artefacts are available.
I'm not sure what "artefacts" you are looking for here.
If you need an ARM or AArcH64 glibc toolchain, just use the Linaro external toolchains I'd say.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
v9 cover Add support for the Rust programming
Hi!
Quoted 15 lines · Thomas Petazzoni
Hello Eric,
Quoted 2 lines · Eric Le Bihan
I see br-aarch64-glibc-2017.05-1078-g95b1dae.tar.bz2, but there is no support for Aarch64 in testing
I'm not sure what you mean by "no support for AArch64 in testing". The testing infrastructure can test any arbitrary configuration, so there is nothing like "support for architecture <foo> in testing". Perhaps you are confused by
BASIC_TOOLCHAIN_CONFIGbeing an ARM toolchain configuration. But thisBASIC_TOOLCHAIN_CONFIGis not mandatory, it is just one toolchain configuration that you can use if your test doesn't really care about the architecture/toolchain.
Quoted 3 lines
We have tests like
support/testing/tests/fs/test_iso9660.pythat don't useBASIC_TOOLCHAIN_CONFIG.
Looking at the existing tests, I thought it was a requirement to use toolchains hosted at http://autobuild.buildroot.org/.
Quoted 3 lines
Quoted 1 line
and no artefacts are available.
I'm not sure what "artefacts" you are looking for here.
I was referring to ARTIFACTS_URL, where ARM versatile/vexpress kernels are available. As I thought I should have used br-aarch64-glibc-2017.05-1078-g95b1dae.tar.bz2 to get a glibc-based toolchain, adding Aarch64 support to the emulator seemed necessary.
I'll go with the Linaro toolchain, using ARM vexpress as target.
Thanks for the clarification.
Regards,
--
ELB
v9 cover Add support for the Rust programming
Hello,
Quoted 5 lines · Eric Le Bihan
Quoted 2 lines
We have tests like
support/testing/tests/fs/test_iso9660.pythat don't useBASIC_TOOLCHAIN_CONFIG.Looking at the existing tests, I thought it was a requirement to use toolchains hosted at http://autobuild.buildroot.org/.
Not at all. We do have some tests that don't use those toolchains. Look at support/testing/tests/boot/test_atf.py, the tests use Linaro toolchains.
Quoted 8 lines
Quoted 1 line
I'm not sure what "artefacts" you are looking for here.
I was referring to
ARTIFACTS_URL, where ARM versatile/vexpress kernels are available. As I thought I should have used br-aarch64-glibc-2017.05-1078-g95b1dae.tar.bz2 to get a glibc-based toolchain, adding Aarch64 support to the emulator seemed necessary.I'll go with the Linaro toolchain, using ARM vexpress as target.
If you want to do runtime test on an AArch64 platform without building the kernel as part of your test configuration, then yes, we would have to add an artifact on http://autobuild.buildroot.net/artefacts/. I can definitely do that if needed.
I'm not super happy with this artefacts solution, but I wanted to avoid putting all those binary files under version control inside the Buildroot repository. If people have better proposals, I'm definitely interested.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
v9 cover Add support for the Rust programming
Quoted 28 lines · Thomas Petazzoni
Hello,
Quoted 5 lines · Eric Le Bihan
Quoted 2 lines
We have tests like
support/testing/tests/fs/test_iso9660.pythat don't useBASIC_TOOLCHAIN_CONFIG.Looking at the existing tests, I thought it was a requirement to use toolchains hosted at http://autobuild.buildroot.org/.
Not at all. We do have some tests that don't use those toolchains. Look at
support/testing/tests/boot/test_atf.py, the tests use Linaro toolchains.Quoted 8 lines
Quoted 1 line
I'm not sure what "artefacts" you are looking for here.
I was referring to
ARTIFACTS_URL, where ARM versatile/vexpress kernels are available. As I thought I should have used br-aarch64-glibc-2017.05-1078-g95b1dae.tar.bz2 to get a glibc-based toolchain, adding Aarch64 support to the emulator seemed necessary.I'll go with the Linaro toolchain, using ARM vexpress as target.
If you want to do runtime test on an AArch64 platform without building the kernel as part of your test configuration, then yes, we would have to add an artifact on http://autobuild.buildroot.net/artefacts/. I can definitely do that if needed.
Quoted 4 lines
I'm not super happy with this artefacts solution, but I wanted to avoid putting all those binary files under version control inside the Buildroot repository. If people have better proposals, I'm definitely interested.
We could have the artefacts produced by gitlab-CI, and use the gitlab pipeline
feature to make sure the most recently built one is used. Well, that's the theory, I haven't looked at the details :-)
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