kumquat-buildroot/package/rust/rust.mk

95 lines
2.9 KiB
Makefile
Raw Normal View History

rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
################################################################################
#
# rust
#
################################################################################
package/{rust, rust-bin}: bump to version 1.60.0 Link to Rust 1.60.0: https://blog.rust-lang.org/2022/04/07/Rust-1.60.0.html Packages relying on Rust have been updated to support version 1.60.0: package/rust package/rust-bin Newest version of the source archives have been retrieved with their hash values, and the signature of the .asc files have been verified as follows: $ curl -fsSL https://static.rust-lang.org/rust-key.gpg.ascii | gpg --import $ gpg --verify <filename.asc> <filename> The signatures were recognized but the ownership from https://static.rust-lang.org could not be verified. Because this URL can be trusted, it has been considered to blindly sign the corresponding key: $ gpg --lsign-key 85AB96E6FA1BE5FE There is no typographical error in the packages according to the check-pakage utility: $ ./utils/check-package package/rust-bin/* $ ./utils/check-package package/rust/* The testsuites for the rust-bin and rust packages to test the Rust toolchain under 1.60.0 were successful: $ ./support/testing/run-tests -k -d dl/ -o testsuite tests.package.test_rust.TestRustBin $ ./support/testing/run-tests -k -d dl/ -o testsuite tests.package.test_rust.TestRust In order to verify the compatibility of Rust 1.60.0 with packages relying on it, tests using `./utils/test-pkg` were run. For example, running the following command with `.conf` file enabling the corresponding BR2_PACKAGE: $ ./utils/test-pkg -d test-pkg -c ripgrep.config -p ripgrep Results: package/ripgrep: OK package/librsvg : OK package/suricata: OK package/bat: OK Notes: - For all the mentionned packages, the successful build was made on the toolchain bootlin-armv7-glibc (except package/bat, for which it was bootlin-x86-64-musl). - A redundant build fail was witnessed for the bootlin-x86-64-musl toolchain for all the packages tested (except for package/bat). The same tests were redone in the master branch and it was already the case with Rust 1.58.1. Signed-off-by: Nicolas Tran <nicolas.tran@smile.fr> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2022-04-13 11:50:38 +02:00
RUST_VERSION = 1.60.0
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
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 \
host-pkgconf \
host-python3 \
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
host-rust-bin \
host-openssl \
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
$(BR2_CMAKE_HOST_DEPENDENCY)
HOST_RUST_VERBOSITY = $(if $(VERBOSE),2,0)
# Some vendor crates contain Cargo.toml.orig files. The associated
# .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 = ["$(RUSTC_TARGET_NAME)"]'; \
echo 'cargo = "$(HOST_RUST_BIN_DIR)/cargo/bin/cargo"'; \
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
echo 'rustc = "$(HOST_RUST_BIN_DIR)/rustc/bin/rustc"'; \
echo 'python = "$(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR)"'; \
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
echo 'submodules = false'; \
echo 'vendor = true'; \
echo 'extended = true'; \
echo 'tools = ["cargo"]'; \
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
echo 'compiler-docs = false'; \
echo 'docs = false'; \
echo 'verbose = $(HOST_RUST_VERBOSITY)'; \
echo '[install]'; \
echo 'prefix = "$(HOST_DIR)"'; \
echo 'sysconfdir = "$(HOST_DIR)/etc"'; \
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
echo '[rust]'; \
echo 'channel = "stable"'; \
echo 'musl-root = "$(STAGING_DIR)"' ; \
echo '[target.$(RUSTC_TARGET_NAME)]'; \
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
echo 'cc = "$(TARGET_CROSS)gcc"'; \
echo '[llvm]'; \
echo 'ninja = false'; \
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
) > $(@D)/config.toml
endef
define HOST_RUST_BUILD_CMDS
cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py build
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
endef
package/rust: install rustc and rust-std built by Buildroot The test TestRust is currently broken with ripgrep package with the following error: error[E0514]: found crate `core` compiled by an incompatible version of rustc | = help: please recompile that crate using this compiler (rustc 1.58.1) (consider running `cargo clean` first) = note: the following crate versions were found: crate `core` compiled by rustc 1.58.1 (db9d1b20b 2022-01-20): TestRust/host/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-6cfcec236d576603.rlib error[E0514]: found crate `std` compiled by an incompatible version of rustc The problem is not really a cross-compilation issue (we are building for an armv7 target on x86_64 host) but a problem with rust-std libraries (rlib). We can notice that "rustc 1.58.1 (db9d1b20b 2022-01-20)" is the same version as the prebuilt rustc used to bootstrap the build: TestRust/host/bin/rustc --version rustc 1.58.1 TestRustBin/host/bin/rustc --version rustc 1.58.1 (db9d1b20b 2022-01-20) Indeed we are using host-rust-bin to bootstrap the host-rust compiler package built by Buildroot. The problem is that the libcore-6cfcec236d576603.rlib file come from host-rust-bin (rust-std) and is not removed before installing host-rust built by Buildroot. We actually spent a lot of time to build host-rust with rust-std and forget to install this important library HOST_DIR. Looking at the host-rust build directory we can notice two installer script "install.sh" (the same scripts used to install host-rust-bin): TestRust/build/host-rust-1.58.1/build/tmp/tarball/rust/x86_64-unknown-linux-gnu/rust-1.58.1-x86_64-unknown-linux-gnu/install.sh TestRust/build/host-rust-1.58.1/build/tmp/tarball/rust-std/armv7-unknown-linux-gnueabihf/rust-std-1.58.1-armv7-unknown-linux-gnueabihf/install.sh The "tarball" directory is generated by the "python x.py dist" during the install step, we have to keep it. Replace "python x.py install" by theses two install scripts. Installing rust-std with the install.sh script replace the rust-std libraries installed by host-rust-bin. Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/2116202544 Signed-off-by: Romain Naour <romain.naour@gmail.com> Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr> [Arnout: remove redundant parenthesis; only use a variable for the common install opts] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2022-02-24 16:45:13 +01:00
HOST_RUST_INSTALL_OPTS = \
--prefix=$(HOST_DIR) \
--disable-ldconfig
define HOST_RUST_INSTALL_RUSTC
cd $(@D)/build/tmp/tarball/rust/$(RUSTC_HOST_NAME)/rust-$(RUST_VERSION)-$(RUSTC_HOST_NAME); \
./install.sh $(HOST_RUST_INSTALL_OPTS) --components=rustc,cargo,rust-std-$(RUSTC_HOST_NAME)
endef
ifeq ($(BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS),y)
define HOST_RUST_INSTALL_LIBSTD_TARGET
cd $(@D)/build/tmp/tarball/rust-std/$(RUSTC_TARGET_NAME)/rust-std-$(RUST_VERSION)-$(RUSTC_TARGET_NAME); \
./install.sh $(HOST_RUST_INSTALL_OPTS)
endef
endif
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
define HOST_RUST_INSTALL_CMDS
cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) x.py dist
package/rust: install rustc and rust-std built by Buildroot The test TestRust is currently broken with ripgrep package with the following error: error[E0514]: found crate `core` compiled by an incompatible version of rustc | = help: please recompile that crate using this compiler (rustc 1.58.1) (consider running `cargo clean` first) = note: the following crate versions were found: crate `core` compiled by rustc 1.58.1 (db9d1b20b 2022-01-20): TestRust/host/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-6cfcec236d576603.rlib error[E0514]: found crate `std` compiled by an incompatible version of rustc The problem is not really a cross-compilation issue (we are building for an armv7 target on x86_64 host) but a problem with rust-std libraries (rlib). We can notice that "rustc 1.58.1 (db9d1b20b 2022-01-20)" is the same version as the prebuilt rustc used to bootstrap the build: TestRust/host/bin/rustc --version rustc 1.58.1 TestRustBin/host/bin/rustc --version rustc 1.58.1 (db9d1b20b 2022-01-20) Indeed we are using host-rust-bin to bootstrap the host-rust compiler package built by Buildroot. The problem is that the libcore-6cfcec236d576603.rlib file come from host-rust-bin (rust-std) and is not removed before installing host-rust built by Buildroot. We actually spent a lot of time to build host-rust with rust-std and forget to install this important library HOST_DIR. Looking at the host-rust build directory we can notice two installer script "install.sh" (the same scripts used to install host-rust-bin): TestRust/build/host-rust-1.58.1/build/tmp/tarball/rust/x86_64-unknown-linux-gnu/rust-1.58.1-x86_64-unknown-linux-gnu/install.sh TestRust/build/host-rust-1.58.1/build/tmp/tarball/rust-std/armv7-unknown-linux-gnueabihf/rust-std-1.58.1-armv7-unknown-linux-gnueabihf/install.sh The "tarball" directory is generated by the "python x.py dist" during the install step, we have to keep it. Replace "python x.py install" by theses two install scripts. Installing rust-std with the install.sh script replace the rust-std libraries installed by host-rust-bin. Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/2116202544 Signed-off-by: Romain Naour <romain.naour@gmail.com> Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr> [Arnout: remove redundant parenthesis; only use a variable for the common install opts] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2022-02-24 16:45:13 +01:00
$(HOST_RUST_INSTALL_RUSTC)
$(HOST_RUST_INSTALL_LIBSTD_TARGET)
rust: new package 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. The internal build process is as follows: 1. stage0 compiler, provided by rust-bin, is used to build stage1 compiler. 2. stage1 compiler builds the final Rust compiler (stage2 compiler) 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 Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2018-02-04 19:07:43 +01:00
endef
$(eval $(host-generic-package))