Merge pull request #22134 from jefferyto/rust-cargo-rustflags
rust: Set rustflags by environment variable
This commit is contained in:
commit
962aa1ab84
4 changed files with 23 additions and 21 deletions
|
@ -3,16 +3,15 @@
|
||||||
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
|
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
include ./rust-values.mk
|
|
||||||
|
|
||||||
PKG_NAME:=rust
|
PKG_NAME:=rust
|
||||||
PKG_VERSION:=1.72.0
|
PKG_VERSION:=1.72.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
|
PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
|
||||||
PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
|
PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
|
||||||
PKG_HASH:=ea9d61bbb51d76b6ea681156f69f0e0596b59722f04414b01c6e100b4b5be3a1
|
PKG_HASH:=ea9d61bbb51d76b6ea681156f69f0e0596b59722f04414b01c6e100b4b5be3a1
|
||||||
HOST_BUILD_DIR:=$(BUILD_DIR)/host/rust-$(RUSTC_TARGET_ARCH)/rustc-$(PKG_VERSION)-src
|
HOST_BUILD_DIR:=$(BUILD_DIR)/host/rustc-$(PKG_VERSION)-src
|
||||||
|
|
||||||
PKG_MAINTAINER:=Luca Barbato <lu_zero@luminem.org>
|
PKG_MAINTAINER:=Luca Barbato <lu_zero@luminem.org>
|
||||||
PKG_LICENSE:=Apache-2.0 MIT
|
PKG_LICENSE:=Apache-2.0 MIT
|
||||||
|
@ -23,6 +22,7 @@ PKG_HOST_ONLY:=1
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/host-build.mk
|
include $(INCLUDE_DIR)/host-build.mk
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include ./rust-values.mk
|
||||||
|
|
||||||
define Package/rust
|
define Package/rust
|
||||||
SECTION:=lang
|
SECTION:=lang
|
||||||
|
@ -31,6 +31,7 @@ define Package/rust
|
||||||
TITLE:=Rust Programming Language Compiler
|
TITLE:=Rust Programming Language Compiler
|
||||||
URL:=https://www.rust-lang.org/
|
URL:=https://www.rust-lang.org/
|
||||||
DEPENDS:=$(RUST_ARCH_DEPENDS)
|
DEPENDS:=$(RUST_ARCH_DEPENDS)
|
||||||
|
BUILDONLY:=1
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/rust/description
|
define Package/rust/description
|
||||||
|
@ -95,8 +96,7 @@ define Host/Install
|
||||||
\
|
\
|
||||||
sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
|
sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
|
||||||
-e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
|
-e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
|
||||||
-e 's|@RUSTC_LDFLAGS@|$(RUSTC_LDFLAGS)|g' \
|
$(CURDIR)/files/cargo-config > $(CARGO_HOME)/config.toml ; \
|
||||||
$(CURDIR)/files/cargo-config > $(CARGO_HOME)/config ; \
|
|
||||||
)
|
)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[target.@RUSTC_TARGET_ARCH@]
|
[target.@RUSTC_TARGET_ARCH@]
|
||||||
linker = "@TARGET_CC_NOCACHE@"
|
linker = "@TARGET_CC_NOCACHE@"
|
||||||
rustflags = ["-Ctarget-feature=-crt-static", "-Clink-args=@RUSTC_LDFLAGS@"]
|
|
||||||
|
|
||||||
[profile.stripped]
|
[profile.stripped]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
|
|
@ -22,9 +22,10 @@ define Build/Compile/Cargo
|
||||||
cd $(PKG_BUILD_DIR) ; \
|
cd $(PKG_BUILD_DIR) ; \
|
||||||
export PATH="$(CARGO_HOME)/bin:$(PATH)" ; \
|
export PATH="$(CARGO_HOME)/bin:$(PATH)" ; \
|
||||||
CARGO_HOME=$(CARGO_HOME) \
|
CARGO_HOME=$(CARGO_HOME) \
|
||||||
TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUST_CFLAGS)" \
|
TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)" \
|
||||||
TARGET_CC=$(TARGET_CC_NOCACHE) \
|
TARGET_CC=$(TARGET_CC_NOCACHE) \
|
||||||
CC=$(HOSTCC_NOCACHE) \
|
CC=$(HOSTCC_NOCACHE) \
|
||||||
|
RUSTFLAGS="$(CARGO_RUSTFLAGS)" \
|
||||||
$(CARGO_VARS) \
|
$(CARGO_VARS) \
|
||||||
cargo install -v \
|
cargo install -v \
|
||||||
--profile stripped \
|
--profile stripped \
|
||||||
|
|
|
@ -3,24 +3,26 @@
|
||||||
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
|
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
|
||||||
|
|
||||||
# Rust Environmental Vars
|
# Rust Environmental Vars
|
||||||
CONFIG_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME)))
|
RUSTC_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME)))
|
||||||
RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(CONFIG_HOST_SUFFIX)
|
RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(RUSTC_HOST_SUFFIX)
|
||||||
CARGO_HOME:=$(STAGING_DIR)/host/cargo
|
CARGO_HOME:=$(STAGING_DIR)/host/cargo
|
||||||
CARGO_VARS:=
|
CARGO_VARS?=
|
||||||
|
|
||||||
ifeq ($(CONFIG_USE_MUSL),y)
|
ifeq ($(CONFIG_USE_MUSL),y)
|
||||||
# Force linking of the SSP library for musl
|
# Force linking of the SSP library for musl
|
||||||
ifdef CONFIG_PKG_CC_STACKPROTECTOR_REGULAR
|
ifdef CONFIG_PKG_CC_STACKPROTECTOR_REGULAR
|
||||||
ifeq ($(strip $(PKG_SSP)),1)
|
ifeq ($(strip $(PKG_SSP)),1)
|
||||||
RUSTC_LDFLAGS += -lssp_nonshared
|
RUSTC_LDFLAGS+=-lssp_nonshared
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG
|
||||||
|
ifeq ($(strip $(PKG_SSP)),1)
|
||||||
|
RUSTC_LDFLAGS+=-lssp_nonshared
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG
|
|
||||||
ifeq ($(strip $(PKG_SSP)),1)
|
CARGO_RUSTFLAGS+=-Ctarget-feature=-crt-static $(RUSTC_LDFLAGS)
|
||||||
TARGET_CFLAGS += -lssp_nonshared
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(HOST_OS),Darwin)
|
ifeq ($(HOST_OS),Darwin)
|
||||||
ifeq ($(HOST_ARCH),arm64)
|
ifeq ($(HOST_ARCH),arm64)
|
||||||
|
@ -55,7 +57,7 @@ ifeq ($(ARCH),arm)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(ARCH),aarch64)
|
ifeq ($(ARCH),aarch64)
|
||||||
RUST_CFLAGS:=-mno-outline-atomics
|
RUSTC_CFLAGS:=-mno-outline-atomics
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Support only a subset for now.
|
# Support only a subset for now.
|
||||||
|
|
Loading…
Reference in a new issue