Skip to contentSkip to conversation

Add support for the Rust programming language

PATCH Superseded Eric Le Bihan 4 participants 17 messages Dec 17, 2017 – Dec 27, 2017

v8 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v8 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.
- cargo-bin: provides a pre-built version of Rust package manager.
- rust: builds rustc from source.
- cargo: builds Rust package manager from source.
- rust-cargo: a virtual package for the Rust package manager.

Only the host variants are provided.

The rustc and rust-cargo virtual packages are inspired by the mysql one.

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 (9):
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
rust-cargo: new virtual package

 DEVELOPERS                                         |   4 +
 package/Config.in.host                             |   2 +
 package/cargo-bin/cargo-bin.hash                   |   4 +
 package/cargo-bin/cargo-bin.mk                     |  18 +
 package/cargo/cargo.hash                           |   4 +
 package/cargo/cargo.mk                             |  96 +++
 package/cargo/config.in                            |   2 +
 package/libcurl/libcurl.mk                         |  13 +
 package/libhttpparser/libhttpparser.mk             |   9 +
 package/libssh2/libssh2.mk                         |   6 +
 package/rust-bin/rust-bin.hash                     |  30 +
 package/rust-bin/rust-bin.mk                       |  61 ++
 package/rust-cargo/Config.in.host                  |  41 ++
 .../rust/0001-vendor-remove-cargo-toml-orig.patch  | 650 +++++++++++++++++++++
 package/rust/rust.hash                             |   2 +
 package/rust/rust.mk                               |  66 +++
 package/rustc/Config.in.host                       |  62 ++
 package/rustc/rustc.mk                             |  31 +
 18 files changed, 1101 insertions(+)
 create mode 100644 package/cargo-bin/cargo-bin.hash
 create mode 100644 package/cargo-bin/cargo-bin.mk
 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-cargo/Config.in.host
 create mode 100644 package/rust/0001-vendor-remove-cargo-toml-orig.patch
 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.14.3
#1 lore raw

PATCH v8 1/9 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.

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

---
 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
index dd6415bba5..2f20dd0e48 100644
@@ -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
new file mode 100644
index 0000000000..16c95fa0b4
@@ -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
new file mode 100644
index 0000000000..4163a44bc1
@@ -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
#2 lore raw

PATCH v8 2/9 rust-bin: new package

In reply to Eric Le Bihan

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

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

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

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

---
 DEVELOPERS                     |  1 +
 package/rust-bin/rust-bin.hash | 30 +++++++++++++++++++++
 package/rust-bin/rust-bin.mk   | 61 ++++++++++++++++++++++++++++++++++++++++++
 package/rustc/Config.in.host   | 29 ++++++++++++++++++++
 4 files changed, 121 insertions(+)
 create mode 100644 package/rust-bin/rust-bin.hash
 create mode 100644 package/rust-bin/rust-bin.mk
DEVELOPERS +1 -0
index af800d862a..6f7b03ca4a 100644
@@ -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
new file mode 100644
index 0000000000..211f9fbbe0
@@ -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 +61 -0

61 lines not on this page · raw message

package/rustc/Config.in.host +29 -0
index 16c95fa0b4..e42187d477 100644
@@ -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
#3 lore raw

PATCH v8 3/9 cargo-bin: new package

In reply to 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.

---
 DEVELOPERS                       |  1 +
 package/cargo-bin/cargo-bin.hash |  4 ++++
 package/cargo-bin/cargo-bin.mk   | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+)
 create mode 100644 package/cargo-bin/cargo-bin.hash
 create mode 100644 package/cargo-bin/cargo-bin.mk
DEVELOPERS +1 -0
index 6f7b03ca4a..fb0c709861 100644
@@ -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
new file mode 100644
index 0000000000..70fb101be7
@@ -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 +18 -0
new file mode 100644
index 0000000000..5c5d2daca3
@@ -0,0 +1,18 @@
+################################################################################
+#
+# 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
+
+define HOST_CARGO_BIN_INSTALL_CMDS
+	(cd $(@D); ./install.sh --prefix=$(HOST_DIR) --disable-ldconfig)
+endef
+
+$(eval $(host-generic-package))
Signature · 1 line
2.14.3
#4 lore raw

PATCH v8 5/9 libssh2: add host variant

In reply to Eric Le Bihan

Allow 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
index 18e772c722..c5b0bd855e 100644
@@ -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
#5 lore raw

PATCH v8 6/9 libhttpparser: add host variant

In reply to Eric Le Bihan

Allow build of host variant of libhttpparser.

---
 package/libhttpparser/libhttpparser.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
package/libhttpparser/libhttpparser.mk +9 -0
index 8ff0413322..1df26017e7 100644
@@ -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
#6 lore raw

PATCH v8 7/9 libcurl: add host variant

In reply to Eric Le Bihan
---
 package/libcurl/libcurl.mk | 13 +++++++++++++
 1 file changed, 13 insertions(+)
package/libcurl/libcurl.mk +13 -0
index 0aab58a7de..c95b0eea6b 100644
@@ -88,4 +88,17 @@ 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 \
+	--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
#7 lore raw

PATCH 7/9 libcurl: add host variant

Hi Eric,

Quoted 12 lines · Eric Le Bihan
---
 package/libcurl/libcurl.mk | 13 +++++++++++++
 1 file changed, 13 insertions(+)
package/libcurl/libcurl.mk +0 -0
index 0aab58a7de..c95b0eea6b 100644
@@ -88,4 +88,17 @@ endef
 LIBCURL_POST_INSTALL_TARGET_HOOKS += LIBCURL_TARGET_CLEANUP
 endif

package/libcurl/libcurl.mk endef · line 99

Quoted 10 lines
package/libcurl/libcurl.mk +9 -0
 
+HOST_LIBCURL_DEPENDENCIES = host-openssl
+HOST_LIBCURL_CONF_OPTS = \
+	--disable-manual \
+	--disable-ntlm-wb \
+	--disable-curldebug \
+	--without-gnutls \
+	--without-mbedtls \
+	--without-polarssl \
+	--without-nss

What about --with-ssl=...? Isn't that needed for the linking with host-openssl?

baruch

package/libcurl/libcurl.mk endef · line 104

Quoted 5 lines
package/libcurl/libcurl.mk +4 -0
+
+HOST_LIBCURL_POST_PATCH_HOOKS += LIBCURL_FIX_DOT_PC
+
 $(eval $(autotools-package))
+$(eval $(host-autotools-package))

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#8 lore raw

PATCH v8 7/9 libcurl: add host variant

Hi!

Quoted 16 lines · Baruch Siach

Hi Eric,

Quoted 13 lines · Eric Le Bihan
---
 package/libcurl/libcurl.mk | 13 +++++++++++++
 1 file changed, 13 insertions(+)
package/libcurl/libcurl.mk +0 -0
index 0aab58a7de..c95b0eea6b 100644
@@ -88,4 +88,17 @@ endef
 LIBCURL_POST_INSTALL_TARGET_HOOKS += LIBCURL_TARGET_CLEANUP
 endif
 
Quoted 12 lines

package/libcurl/libcurl.mk endef · line 99

Quoted 9 lines
package/libcurl/libcurl.mk +9 -0
+HOST_LIBCURL_DEPENDENCIES = host-openssl
+HOST_LIBCURL_CONF_OPTS = \
+	--disable-manual \
+	--disable-ntlm-wb \
+	--disable-curldebug \
+	--without-gnutls \
+	--without-mbedtls \
+	--without-polarssl \
+	--without-nss

What about --with-ssl=...? Isn't that needed for the linking with host-openssl?

Though the configuration script properly detects the openssl library and enables support for it, it is true that it might be better to explicitly enable it. I'll add this in the next spin. Thanks.

Regards,

--
ELB

#9 lore raw

PATCH v8 8/9 cargo: new package

In reply to 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.

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
index b3c681747c..97ecec4bba 100644
@@ -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
index 2f20dd0e48..199a8e9856 100644
@@ -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
new file mode 100644
index 0000000000..0f1ca305c6
@@ -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
new file mode 100644
index 0000000000..2b2ae43f6b
@@ -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
new file mode 100644
index 0000000000..cc048c71c4
@@ -0,0 +1,2 @@
+[target. at RUST_TARGET_NAME@]
+linker = "@CROSS_PREFIX at gcc"
Signature · 1 line
2.14.3
#10 lore raw

PATCH v8 9/9 rust-cargo: new virtual package

In reply to Eric Le Bihan

Add a new host virtual package to provide Cargo, the package manager for the Rust language.

Currently, two providers are available: host-cargo and host-cargo-bin.

Also remove host-cargo from menuconfig.

---
 package/Config.in.host            |  2 +-
 package/cargo/Config.in.host      |  8 --------
 package/rust-cargo/Config.in.host | 41 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 9 deletions(-)
 delete mode 100644 package/cargo/Config.in.host
 create mode 100644 package/rust-cargo/Config.in.host
package/Config.in.host +1 -1
index 199a8e9856..892e124722 100644
@@ -2,7 +2,6 @@ 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"
@@ -48,6 +47,7 @@ menu "Host utilities"
 	source "package/raspberrypi-usbboot/Config.in.host"
 	source "package/rauc/Config.in.host"
 	source "package/rustc/Config.in.host"
+	source "package/rust-cargo/Config.in.host"
 	source "package/s6-rc/Config.in.host"
 	source "package/sam-ba/Config.in.host"
 	source "package/squashfs/Config.in.host"
package/cargo/Config.in.host deleted +0 -8
deleted file mode 100644
index 0f1ca305c6..0000000000
@@ -1,8 +0,0 @@
-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/rust-cargo/Config.in.host new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.14.3
#11 lore raw

v8 cover Add support for the Rust programming language

In reply to Eric Le Bihan

Hi!

Quoted 16 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.
- rust-cargo: a virtual package for the Rust package manager.

Only the host variants are provided.

The rustc and rust-cargo virtual packages are inspired by the mysql one.

v7 -> v8:

Quoted 7 lines

- 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

One patch of this series adds a package to build rust from source. It contains a patch to remove *.orig files from usptream tarball and patch some checksum files which list these files (used by Cargo).

Unfortunately, one of these checksum files has a line which exceeds 998 characters, which does not make git-send-email happy. I sent the patch series using --no-validate, but this may not make all mail clients (or mailman) happy too!

Should I resent as attachment instead?

Regards,

--
ELB

#12 lore raw

v8 cover Add support for the Rust programming language

In reply to Eric Le Bihan

Hello,

Quoted 5 lines · Eric Le Bihan

Eric Le Bihan (9):
rustc: new virtual package
rust-bin: new package
cargo-bin: new package
rust: new package

This patch didn't make it to the list, because it is too large (2.48 MB). Do we have another option than carrying this use patch in Buildroot ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#13 lore raw

v8 cover Add support for the Rust programming language

Hi!

Quoted 11 lines · Eric Le Bihan
Quoted 6 lines

Eric Le Bihan (9):
rustc: new virtual package
rust-bin: new package
cargo-bin: new package
rust: new package

This patch didn't make it to the list, because it is too large (2.48 MB). Do we have another option than carrying this use patch in Buildroot ?

The patch which adds the package to build Rust from source provides a patch to fix a problem involving files ending with *.orig.

As the Rust compiler is built using Cargo, the tarball contains vendored versions of the crates (e.g. src/vendor/backtrace-sys). Each crate contains a file named Cargo.toml.orig. An associated file named .cargo-checksum.json will contain a checksum for Cargo.toml.orig (and the other source files).

But support/scripts/apply-patches.sh will delete the Cargo.toml.orig files. This will cause the build to fail, as Cargo will not be able to find the file and verify the checksum.

So the patch included in the rust package removes all Cargo.toml.orig entries from the affected .cargo-checksum.json. As these files list all the source files, this results in a huge patch.

Besides, as these are non-indented JSON files, some are one-lined and thus the 998 characters limit enforced by git-send-email is exceeded.

So, if there a way to stop support/scripts/apply-patches.sh from pruning Cargo.toml.orig files, so this patch can be dropped?

Regards,

--
ELB

#14 lore raw

v8 cover Add support for the Rust programming language

Hello,

Quoted 17 lines · Eric Le Bihan

The patch which adds the package to build Rust from source provides a patch to fix a problem involving files ending with *.orig.

As the Rust compiler is built using Cargo, the tarball contains vendored versions of the crates (e.g. src/vendor/backtrace-sys). Each crate contains a file named Cargo.toml.orig. An associated file named .cargo-checksum.json will contain a checksum for Cargo.toml.orig (and the other source files).

But support/scripts/apply-patches.sh will delete the Cargo.toml.orig files. This will cause the build to fail, as Cargo will not be able to find the file and verify the checksum.

So the patch included in the rust package removes all Cargo.toml.orig entries from the affected .cargo-checksum.json. As these files list all the source files, this results in a huge patch.

Quoted 5 lines

Besides, as these are non-indented JSON files, some are one-lined and thus the 998 characters limit enforced by git-send-email is exceeded.

So, if there a way to stop support/scripts/apply-patches.sh from pruning Cargo.toml.orig files, so this patch can be dropped?

Do we really have a reason to remove *.orig files in apply-patches.sh ? .orig backup files are only produced if -b is passed to patch, which we are not using.

Are there other cases where .orig files are produced by patch *and* we really need to remove them?

Peter, Arnout, Yann?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#15 lore raw

v8 cover Add support for the Rust programming language

Thomas, Eric, All,

On 2017-12-18 11:31 +0100, Thomas Petazzoni spake thusly:

Quoted 24 lines · Eric Le Bihan
Quoted 17 lines

The patch which adds the package to build Rust from source provides a patch to fix a problem involving files ending with *.orig.

As the Rust compiler is built using Cargo, the tarball contains vendored versions of the crates (e.g. src/vendor/backtrace-sys). Each crate contains a file named Cargo.toml.orig. An associated file named .cargo-checksum.json will contain a checksum for Cargo.toml.orig (and the other source files).

But support/scripts/apply-patches.sh will delete the Cargo.toml.orig files. This will cause the build to fail, as Cargo will not be able to find the file and verify the checksum.

So the patch included in the rust package removes all Cargo.toml.orig entries from the affected .cargo-checksum.json. As these files list all the source files, this results in a huge patch.

Quoted 5 lines

Besides, as these are non-indented JSON files, some are one-lined and thus the 998 characters limit enforced by git-send-email is exceeded.

So, if there a way to stop support/scripts/apply-patches.sh from pruning Cargo.toml.orig files, so this patch can be dropped?

Quoted 8 lines

Do we really have a reason to remove *.orig files in apply-patches.sh ? .orig backup files are only produced if -b is passed to patch, which we are not using.

Are there other cases where .orig files are produced by patch *and* we really need to remove them?

Peter, Arnout, Yann?

I have no idea about this, but the removal of .orig file has been there since the dawn of ages, more than 15 years ago now, and the reason is not explained.

I think we could very well live with .orig files, though.

Alternatively, we could set and export SIMPLE_BACKUP_SUFFIX=.orig.br (or to any other singling-out value) which will force the backup suffix just in case, and then we only remove those files.

Yet, this is adding a bit of complexity, when we could probably lives happy with .orig files.

Except I suspect some badly-behaving packages could very well do things like:

    data:
        call_my_tool $(wildcard #(top_srcdir)/data/*)

and thus, if we happen to patch a file in the data/ subdir, we'd break the build of that package.

So, I would go for not removing .orig files, and in case there is one package where this causes a problem, either we fix it, or we add a post-patch hook to remove the .orig files, or we switch to using the SIMPLE_BACKUP_SUFFIX variable if too many packages are impacted.

Deal? ;-)

Regards,
Yann E. MORIN.

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

v8 cover Add support for the Rust programming language

In reply to Eric Le Bihan
Quoted 3 lines

So, if there a way to stop support/scripts/apply-patches.sh from pruning Cargo.toml.orig files, so this patch can be dropped?

Now that I think of it, adding a post-extract hook to remove the Cargo.toml.orig entries from .cargo-checksum.json files may do the trick... No more big patch nor apply-patches.sh modifications.

--
ELB