From: Stefan Schantl <stefan.schantl@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH 1/2] Rust: New package.
Date: Mon, 02 Sep 2019 14:44:30 +0200 [thread overview]
Message-ID: <20190902124431.8237-1-stefan.schantl@ipfire.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 5788 bytes --]
Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
---
rust/rust.nm | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 175 insertions(+)
create mode 100644 rust/rust.nm
diff --git a/rust/rust.nm b/rust/rust.nm
new file mode 100644
index 000000000..96f198f85
--- /dev/null
+++ b/rust/rust.nm
@@ -0,0 +1,175 @@
+###############################################################################
+# 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 =
+summary = A language empowering everyone to build reliable and efficient software.
+
+description
+
+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
+ 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
next reply other threads:[~2019-09-02 12:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-02 12:44 Stefan Schantl [this message]
2019-09-02 12:44 ` [PATCH 2/2] suricata: Update to 4.1.4 Stefan Schantl
2019-09-02 13:16 ` [PATCH 1/2] Rust: New package Stefan Schantl
2019-10-07 18:44 [PATCH 1/2] rust: " Stefan Schantl
2019-10-08 9:06 ` Michael Tremer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190902124431.8237-1-stefan.schantl@ipfire.org \
--to=stefan.schantl@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox