aboutsummaryrefslogtreecommitdiff
path: root/lang/rust/rust-values.mk
Commit message (Collapse)AuthorAge
* rust: Add option to use sccacheJeffery To2023-10-11
| | | | | | | | | Using sccache makes recompilation of rustc and Rust packages faster. This also makes the rust package visible in menuconfig, in order for the sccache options to be accessible. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
* rust: Consolidate cargo environment variablesJeffery To2023-10-11
| | | | | | | | | | | | | | | | | | | | | | | This consolidates all environment variables for cargo into: * CARGO_HOST_CONFIG_VARS / CARGO_PKG_CONFIG_VARS These contain all cargo-specific environment variables, i.e. without "common" variables like CC. * CARGO_HOST_VARS / CARGO_PKG_VARS (renamed from CARGO_VARS) These contain all environment variables to be passed to cargo. This also: * Set the CARGO_BUILD_TARGET environment variable instead of using the --target command-line option * Update Python include files to use CARGO_HOST_CONFIG_VARS / CARGO_PKG_CONFIG_VARS Signed-off-by: Jeffery To <jeffery.to@gmail.com>
* rust: Move CARGO_HOME to $(DL_DIR)/cargoJeffery To2023-10-11
| | | | | | | | | | As CARGO_HOME mainly functions as a download and source cache[1], moving it into $(DL_DIR) allows it to persist and be reused between different buildroots/sdks (when DL_DIR is set to a custom/external location). [1]: https://doc.rust-lang.org/cargo/guide/cargo-home.html Signed-off-by: Jeffery To <jeffery.to@gmail.com>
* rust: Move cargo config options into environment variablesJeffery To2023-10-11
| | | | | | | | | | | | | | | | | | | | | This also: * Modify the "release" profile in place of adding the "stripped" profile Only the profile for target is modified; there are no file size constraints for host. * For host, build with the "release" profile * For target, build with either the "dev" or "release" profile based on CONFIG_DEBUG There is no environment variable to specify the "strip" option, but enabling this option is not necessary as the build system will already strip binaries based on CONFIG_NO_STRIP / CONFIG_USE_STRIP / CONFIG_USE_SSTRIP. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
* rust: Set rustflags by environment variableJeffery To2023-09-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to use $(RUSTC_TARGET_ARCH) in HOST_BUILD_DIR, the line to include rust-values.mk in the Rust makefile was moved in f489e019ac4a15e974518d9928ef913a157d135a, causing it to be included before package.mk is included. This had the side effect of preventing "-lssp_nonshared" from being added to RUSTC_LDFLAGS, because PKG_SSP is indirectly set by package.mk (package.mk includes hardening.mk, hardening.mk sets PKG_SSP). There is a deeper issue; it is the Rust package's PKG_SSP value that causes RUSTC_LDFLAGS to be set and written to the Cargo config file. For packages that use Rust to build, their PKG_SSP value does not affect the linker flag. This sets rustflags with the RUSTFLAGS environment variable, instead of writing the value to the Cargo config file, allowing PKG_SSP from the package being built to be used and for the package being built to modify the rustflags used. This also: * Fix "-lssp_nonshared" being added to TARGET_CFLAGS instead of RUSTC_LDFLAGS, when CONFIG_PKG_CC_STACKPROTECTOR_STRONG is set. * Remove the use of $(RUSTC_TARGET_ARCH) in HOST_BUILD_DIR and move the include line for rust-values.mk back to after package.mk. Since the host build directory was moved under the target build directory in efdbac38dc8b649ca26b49fac27abeb5cf76cd28, it is no longer necessary to separate build directories with RUSTC_TARGET_ARCH; $(BUILD_DIR) already separates build directories by target. * Add BUILDONLY:=1, as the Rust package does not build a target package. * Install the Cargo config file as "config.toml" instead of "config", as this is the preferred form[1]. * Rename RUST_CFLAGS to RUSTC_CFLAGS and CONFIG_HOST_SUFFIX to RUSTC_HOST_SUFFIX, for consistency. * Allow CARGO_VARS to be set before rust-values.mk is included. [1]: https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure Fixes: f489e019ac4a ("rust: compile host package per target") Fixes: 83785a7ce016 ("rust-lang: Add the rust language support") Fixes: https://github.com/openwrt/packages/issues/22133 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
* rust: Move RUST_ARCH_DEPENDS into rust-values.mkJeffery To2023-09-13
| | | | | | | | This allows other packages access to RUST_ARCH_DEPENDS by including rust-values.mk, instead of rust-package.mk which also sets Build/Compile. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
* rust: correct mistake in previous host-build fixJonas Jelonek2023-08-19
| | | | | | | | | | | Fixes the commit 105fa3920e which was intended to make rust/host build on aarch64 darwin working again. However, the fix contains a mistake because it sets RUSTC_TARGET_ARCH instead of RUSTC_HOST_ARCH. Thus, the fix doesn't work. This properly sets the correct variable RUSTC_HOST_ARCH. Fixes: 105fa3920e ("rust: fix host build on aarch64 darwin") Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
* rust: fix host build on aarch64 darwinJonas Jelonek2023-08-17
| | | | | | | | | | | | rust/host failed to compile on macOS running on Apple Silicon M1 Pro because the host target triple is autogenerated to be 'arm64-unknown-linux-'. Rust doesn't have such a target triple, thus the build failes because there are no pre-built artifacts for bootstrapping. Fix this by setting RUSTC_HOST_ARCH to 'aarch64-apple-darwin' in case our host is HOST_ARCH=arm64 and HOST_OS=darwin. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
* rust: compile host package per targetOrne Brocaar2023-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | While the compiled binaries are intended to run on the host system, the rust/host package does include the target matching the configured OpenWrt target. If using (for example) ./scripts/env to switch between different OpenWrt configurations, this will cause issues if the different configuration is for a different target. In such case there will be a mismatch between the available Rust target and OpenWrt target and the following error will be printed: > error[E0463]: can't find crate for `core` > note: the `XXX` target may not be installed This fix will add the RUSTC_TARGET_ARCH as HOST_BUILD_DIR and CARGO_HOME suffix, such that rust/host will be compiled in case an OpenWrt configuration change causes the RUSTC_TARGET_ARCH to change. Fixes: #21530 Signed-off-by: Orne Brocaar <info@brocaar.com> [Applied Jeffery To's suggestion for build and install path] Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
* rust: enable riscv64 supportTianling Shen2023-06-07
| | | | | | rust natively supports riscv64 so let's enable it. Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
* rust: update to 1.68.1Oskari Rauta2023-03-31
| | | | | | | | | also add new variable CARGO_VARS to make it possible to pass environment variables for cargo process. This is necessary when for example, cross-compiling netavark. Signed-off-by: Oskari Rauta <oskari.rauta@gmail.com>
* rust: fix build with glibcTianling Shen2023-03-24
| | | | | | Don't set musl-specific options/ldflags when using glibc. Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
* rust: refactor build helperTianling Shen2023-03-24
Added new RustBinPackage, RustBinHostBuild wrapper. Added new RUST_PKG_FEATURES flag. Moved CARGO_HOME to STAGING_DIR_HOSTPKG. Overrode default Build/Compile and Host/Compile to Cargo build. Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>