* [PATCHv2] Rust: New package.
@ 2019-09-02 12:49 Stefan Schantl
0 siblings, 0 replies; only message in thread
From: Stefan Schantl @ 2019-09-02 12:49 UTC (permalink / raw)
To: development
[-- Attachment #1: Type: text/plain, Size: 5948 bytes --]
Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
---
rust/rust.nm | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 176 insertions(+)
create mode 100644 rust/rust.nm
diff --git a/rust/rust.nm b/rust/rust.nm
new file mode 100644
index 000000000..d4740bff2
--- /dev/null
+++ b/rust/rust.nm
@@ -0,0 +1,176 @@
+###############################################################################
+# IPFire.org - An Open Source Firewall Solution #
+# Copyright (C) - IPFire Development Team <info(a)ipfire.org> #
+###############################################################################
+
+name = rust
+version = 1.37.0
+release = 1
+
+groups = Applications/System
+url = https://www.rust-lang.org/
+license = (ASL 2.0 or MIT) and (BSD and MIT)
+summary = A language empowering everyone to build reliable and efficient software.
+
+description
+ Rust is a systems programming language that runs blazingly fast, prevents
+ segfaults, and guarantees thread safety.
+end
+
+source_dl = https://static.rust-lang.org/dist/
+sources = rustc-%{version}-src.tar.gz
+
+# For building rustc a bootstrapped rust toolchain has to be downloaded and used.
+if %{DISTRO_ARCH} == "armv7hl"
+ rust_bootstrap = armv7-unknown-linux-gnueabihf
+elif %{DISTRO_ARCH} == "armv5tel"
+ rust_bootstrap = arm-unknown-linux-gnueabi
+else
+ rust_bootstrap = %{DISTRO_ARCH}-unknown-linux-gnu
+end
+
+sources += rust-%{version}-%{rust_bootstrap}.tar.gz
+
+build
+ requires
+ /usr/bin/llvm-config
+ /usr/bin/FileCheck
+ cmake
+ libcurl-devel >= 7.65.3
+ llvm >= 8.0.1
+ libffi-devel
+ libgit2-devel
+ libssh2-devel
+ openssl-devel
+ pakfire >= 0.9.27-3
+ python3
+ xz-devel
+ zlib-devel
+ end
+
+ local_rust_root = "/opt"
+ rustlibdir = "%{libdir}/rustlib"
+
+ DIR_APP = %{DIR_SRC}/rustc-%{version}-src
+ DIR_BOOTSTRAPPED = %{DIR_SRC}/rust-%{version}-%{rust_bootstrap}
+
+ configure_options +=\
+ --build=%{rust_bootstrap} \
+ --host=%{rust_bootstrap} \
+ --target=%{rust_bootstrap} \
+ --disable-option-checking \
+ --local-rust-root=%{local_rust_root} \
+ --llvm-root=%{prefix} \
+ --enable-llvm-link-shared \
+ --disable-rpath \
+ --enable-extended \
+ --enable-vendor \
+ --release-channel="stable"
+
+ prepare_cmds
+ # Install precompiled rust toolchain.
+ cd %{DIR_BOOTSTRAPPED}
+
+ ./install.sh --components=cargo,rustc,rust-std-%{rust_bootstrap} \
+ --prefix=%{local_rust_root} --disable-ldconfig
+
+ # Test if the bootstrapped tools correctly have been installed.
+ test -f %{local_rust_root}/bin/cargo
+ test -f %{local_rust_root}/bin/rustc
+ end
+
+ build
+ # Change into main rust source directory.
+ cd %{DIR_APP}
+
+ # Do not build with shipped llvm and llvm-emscripten.
+ rm -rf src/llvm-project/
+ rm -rf src/llvm-emscripten/
+
+ # Remove other unused vendored libraries
+ rm -rf vendor/curl-sys/curl/
+ rm -rf vendor/jemalloc-sys/jemalloc/
+ rm -rf vendor/libz-sys/src/zlib/
+ rm -rf vendor/lzma-sys/xz-*/
+ rm -rf vendor/openssl-src/openssl/
+
+ # Use the distro libgit2
+ export LIBGIT2_SYS_USE_PKG_CONFIG=1
+ rm -rf vendor/libgit2-sys/libgit2/
+
+ # Use the distro libssh2
+ export LIBSSH2_SYS_USE_PKG_CONFIG=1
+ rm -rf vendor/libssh2-sys/libssh2/
+
+ # Use the dynamic xz-libs
+ sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/tool.rs
+
+ # The configure macro will modify some autoconf-related files, which upsets
+ # cargo when it tries to verify checksums in those files. If we just truncate
+ # that file list, cargo won't have anything to complain about.
+ find vendor -name .cargo-checksum.json \
+ -exec sed -i.uncheck -e 's/"files":{[^}]*}/"files":{ }/' '{}' '+'
+
+ # Launch configure script
+ ./configure %{configure_options}
+
+ # Build rust.
+ %{python3} ./x.py build --exclude src/tools/miri
+ end
+
+ install
+ DESTDIR=%{BUILDROOT} %{python3} ./x.py install
+
+ # The shared libraries should be executable for debuginfo extraction.
+ find %{BUILDROOT}%{libdir} -maxdepth 1 -type f -name '*.so' -exec chmod -v +x '{}' '+'
+
+ # The libdir libraries are identical to those under rustlib/. It's easier on
+ # library loading if we keep them in libdir, but we do need them in rustlib/
+ # to support dynamic linking for compiler plugins, so we'll symlink.
+ (
+ cd %{BUILDROOT}%{rustlibdir}/%{rust_bootstrap}/lib
+
+ for i in *.so; do
+ [ -f %{BUILDROOT}%{rustlibdir}/%{rust_bootstrap}/lib/${i} ] && ln -svf ../../../${i} \
+ %{BUILDROOT}%{rustlibdir}/%{rust_bootstrap}/lib/${i};
+ done
+ )
+
+ # Remove installer artifacts (manifests, uninstall scripts, etc.)
+ find %{BUILDROOT}%{rustlibdir} -maxdepth 1 -type f -exec rm -v '{}' '+'
+
+ # Remove backup files from %%configure munging
+ find %{BUILDROOT}%{rustlibdir} -type f -name '*.orig' -exec rm -v '{}' '+'
+
+ # Remove documentation files.
+ rm -rvf %{BUILDROOT}%{docdir}%{name}
+
+ # Remove rust source.
+ rm -rvf %{BUILDROOT}%{rustlibdir}/src
+
+ # Create the path for crate-devel packages
+ mkdir -pv %{BUILDROOT}%{datadir}/cargo/registry
+
+ # Remove zsh related files.
+ rm -rvf %{BUILDROOT}%{datadir}/zsh/
+ end
+
+
+ # While we don't want to encourage dynamic linking to Rust shared libraries, as
+ # there's no stable ABI, we still need the unallocated metadata (.rustc) to
+ # support custom-derive plugins like #[proc_macro_derive(Foo)]. But eu-strip is
+ # very eager by default, so it has to be limited to keep the rustc sections.
+ debuginfo_options = --keep-section .rustc
+end
+
+packages
+ package %{name}
+ provides += \
+ bundled(libbacktrace) = 8.1.0 \
+ bundled(miniz) = 2.0.7
+ end
+
+ package %{name}-debuginfo
+ template DEBUGINFO
+ end
+end
--
2.20.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-09-02 12:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-02 12:49 [PATCHv2] Rust: New package Stefan Schantl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox