1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2023 Luca Barbato and Donald Hoskins
5 include $(TOPDIR
)/rules.mk
11 PKG_SOURCE
:=rustc-
$(PKG_VERSION
)-src.
tar.gz
12 PKG_SOURCE_URL
:=https
://static.rust-lang.org
/dist/
13 PKG_HASH
:=b2bfae000b7a5040e4ec4bbc50a09f21548190cb7570b0ed77358368413bd27c
14 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/rustc-
$(PKG_VERSION
)-src
16 PKG_MAINTAINER
:=Luca Barbato
<lu_zero@luminem.org
>
17 PKG_LICENSE
:=Apache-2.0 MIT
18 PKG_LICENSE_FILES
:=LICENSE-APACHE LICENSE-MIT
20 HOST_BUILD_DEPENDS
:=python3
/host
23 include $(INCLUDE_DIR
)/host-build.mk
24 include $(INCLUDE_DIR
)/package.mk
25 include .
/rust-values.mk
31 TITLE
:=Rust Programming Language Compiler
32 URL
:=https
://www.rust-lang.org
/
33 DEPENDS
:=$(RUST_ARCH_DEPENDS
)
36 define Package
/rust
/description
37 Rust is a multi-paradigm
, general-purpose programming language designed for performance
38 and safety
, especially safe concurrency. Rust is syntactically similar to C
++, but can
39 guarantee memory safety by using a borrow checker to validate references.
42 # Rust-lang has an uninstall script
43 RUST_UNINSTALL
:=$(CARGO_HOME
)/lib
/rustlib
/uninstall.sh
46 TARGET_CONFIGURE_ARGS
= \
47 --set
=target.
$(RUSTC_TARGET_ARCH
).
ar=$(TARGET_AR
) \
48 --set
=target.
$(RUSTC_TARGET_ARCH
).
cc=$(TARGET_CC_NOCACHE
) \
49 --set
=target.
$(RUSTC_TARGET_ARCH
).
cxx=$(TARGET_CXX_NOCACHE
) \
50 --set
=target.
$(RUSTC_TARGET_ARCH
).linker
=$(TARGET_CC_NOCACHE
) \
51 --set
=target.
$(RUSTC_TARGET_ARCH
).ranlib
=$(TARGET_RANLIB
) \
52 $(if
$(CONFIG_USE_MUSL
),--set
=target.
$(RUSTC_TARGET_ARCH
).musl-root
=$(TOOLCHAIN_DIR
))
54 # CARGO_HOME is an environmental
55 HOST_CONFIGURE_OPTS
+= CARGO_HOME
="$(CARGO_HOME)"
57 # Rust Configuration Arguments
58 HOST_CONFIGURE_ARGS
= \
59 --build
=$(RUSTC_HOST_ARCH
) \
60 --target
=$(RUSTC_TARGET_ARCH
),$(RUSTC_HOST_ARCH
) \
61 --host
=$(RUSTC_HOST_ARCH
) \
62 --prefix=$(CARGO_HOME
) \
63 --bindir=$(CARGO_HOME
)/bin \
64 --libdir=$(CARGO_HOME
)/lib \
65 --sysconfdir
=$(CARGO_HOME
)/etc \
66 --datadir=$(CARGO_HOME
)/share \
67 --mandir=$(CARGO_HOME
)/man \
68 --dist-compression-formats
=xz \
69 --enable-missing-tools \
70 --disable-sanitizers \
71 --release-channel
=stable \
72 --enable-cargo-native-static \
73 --set
=llvm.download-ci-llvm
=true \
74 $(TARGET_CONFIGURE_ARGS
)
77 # Call the Uninstall script
78 [ -f
$(RUST_UNINSTALL
) ] && \
79 $(BASH
) $(RUST_UNINSTALL
) || echo No Uninstall
84 cd
$(HOST_BUILD_DIR
) ; \
85 $(PYTHON
) x.py
--config .
/config.toml
dist build-manifest cargo llvm-tools \
86 rustc rust-std rust-src
; \
92 cd
$(HOST_BUILD_DIR
)/build
/dist ; \
93 find
-iname
"*.xz" -exec
tar -xJf
{} \
; ; \
94 find .
/* -type f
-name
install.sh
-execdir sh
{} --prefix=$(CARGO_HOME
) --disable-ldconfig \
; ; \
96 sed
-e
's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
97 -e
's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
98 -e
's|@RUSTC_LDFLAGS@|$(RUSTC_LDFLAGS)|g' \
99 $(CURDIR
)/files
/cargo-config
> $(CARGO_HOME
)/config
; \
103 $(eval
$(call HostBuild
))
104 $(eval
$(call BuildPackage
,rust
))