rust: bump libc to 0.2.146
[feed/packages.git] / lang / rust / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2023 Luca Barbato and Donald Hoskins
4
5 include $(TOPDIR)/rules.mk
6
7 PKG_NAME:=rust
8 PKG_VERSION:=1.70.0
9 PKG_RELEASE:=2
10
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
15
16 PKG_MAINTAINER:=Luca Barbato <lu_zero@luminem.org>
17 PKG_LICENSE:=Apache-2.0 MIT
18 PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT
19
20 HOST_BUILD_DEPENDS:=python3/host
21 PKG_HOST_ONLY:=1
22
23 include $(INCLUDE_DIR)/host-build.mk
24 include $(INCLUDE_DIR)/package.mk
25 include ./rust-values.mk
26
27 define Package/rust
28 SECTION:=lang
29 CATEGORY:=Languages
30 SUBMENU:=Rust
31 TITLE:=Rust Programming Language Compiler
32 URL:=https://www.rust-lang.org/
33 DEPENDS:=$(RUST_ARCH_DEPENDS)
34 endef
35
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.
40 endef
41
42 # Rust-lang has an uninstall script
43 RUST_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh
44
45 # Target Flags
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))
53
54 # CARGO_HOME is an environmental
55 HOST_CONFIGURE_OPTS += CARGO_HOME="$(CARGO_HOME)"
56
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)
75
76 define Host/Uninstall
77 # Call the Uninstall script
78 [ -f $(RUST_UNINSTALL) ] && \
79 $(BASH) $(RUST_UNINSTALL) || echo No Uninstall
80 endef
81
82 define Host/Compile
83 ( \
84 cd $(HOST_BUILD_DIR) ; \
85 $(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
86 rustc rust-std rust-src ; \
87 )
88 endef
89
90 define Host/Install
91 ( \
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 \; ; \
95 \
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 ; \
100 )
101 endef
102
103 $(eval $(call HostBuild))
104 $(eval $(call BuildPackage,rust))