]> git.pld-linux.org Git - packages/rust.git/blame - rust.spec
- ugly libdir hack
[packages/rust.git] / rust.spec
CommitLineData
e361528e
ER
1# TODO
2# - consider a rust-std package containing .../rustlib/$target
3# This might allow multilib cross-compilation to work naturally.
e361528e
ER
4#
5# Conditional build:
8a073211 6%bcond_with bootstrap
cace5bf9 7%bcond_with tests # build without tests
e361528e 8
8a073211
JR
9# The channel can be stable, beta, or nightly
10%define channel stable
11
e361528e 12%if "%{channel}" == "stable"
8a073211 13%define rustc_package rustc-%{version}-src
e361528e 14%else
8a073211 15%define rustc_package rustc-%{channel}-src
e361528e
ER
16%endif
17
18# To bootstrap from scratch, set the channel and date from src/stage0.txt
19# e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24
20# or nightly wants some beta-YYYY-MM-DD
8a073211
JR
21%define bootstrap_rust 1.17.0
22%define bootstrap_cargo 0.18.0
23%define bootstrap_date 2017-04-27
e361528e
ER
24
25Summary: The Rust Programming Language
26Name: rust
d6d4cb2b 27Version: 1.18.0
18a1004b 28Release: 0.3
d1b96fd8 29# Licenses: (rust itself) and (bundled libraries)
e361528e 30License: (ASL 2.0 or MIT) and (BSD and ISC and MIT)
e361528e 31Group: Development/Languages
d6d4cb2b
JR
32Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.gz
33# Source0-md5: c37c0cd9d500f6a9d1f2f44401351f88
8a073211 34Source1: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-x86_64-unknown-linux-gnu.tar.gz
d6d4cb2b 35# Source1-md5: 98e8f479515969123b4c203191104a54
8a073211 36Source2: https://static.rust-lang.org/dist/%{bootstrap_date}/rust-%{bootstrap_rust}-i686-unknown-linux-gnu.tar.gz
d6d4cb2b 37# Source2-md5: 2d5de850c32aa8d40c8c21abacf749f8
b5eceb5e 38Patch0: rust-1.16.0-configure-no-override.patch
e361528e
ER
39URL: https://www.rust-lang.org/
40BuildRequires: cmake
41BuildRequires: curl
42BuildRequires: gcc
43BuildRequires: libstdc++-devel
d1b96fd8 44BuildRequires: libstdc++-devel
e361528e 45BuildRequires: llvm-devel
d1b96fd8 46BuildRequires: ncurses-devel
e361528e
ER
47BuildRequires: python
48BuildRequires: zlib-devel
49%if %{without bootstrap}
50BuildRequires: %{name} < %{version}-%{release}
d6d4cb2b 51BuildRequires: %{name} >= %{bootstrap_rust}
d1b96fd8 52BuildRequires: cargo >= %{bootstrap_cargo}
e361528e
ER
53%endif
54# make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs
55BuildRequires: procps
e361528e
ER
56# The C compiler is needed at runtime just for linking. Someday rustc might
57# invoke the linker directly, and then we'll only need binutils.
58# https://github.com/rust-lang/rust/issues/11937
59Requires: gcc
60BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
61# Only x86_64 and i686 are Tier 1 platforms at this time.
62# https://doc.rust-lang.org/stable/book/getting-started.html#tier-1
d36946a0 63ExclusiveArch: %{x8664} %{ix86}
e361528e 64
8a073211 65%define rust_triple %{_target_cpu}-unknown-linux-gnu
e361528e
ER
66
67%if %{without bootstrap}
8a073211 68%define local_rust_root %{_prefix}
e361528e 69%else
8a073211
JR
70%define bootstrap_root rust-%{bootstrap_rust}-%{rust_triple}
71%define local_rust_root %{_builddir}/%{rustc_package}/%{bootstrap_root}
e361528e
ER
72%endif
73
18a1004b
JR
74# We're going to override --libdir when configuring to get rustlib into a
75# common path, but we'll fix the shared libraries during install.
76# Without this ugly hack, rust would not be able to buld itself
77# for non-bootstrap build, lib64 is just too complicated for it.
78%define common_libdir %{_prefix}/lib
79%define rustlibdir %{common_libdir}/rustlib
80
19f98749 81# once_call/once_callable non-function libstdc++ symbols
8a073211 82%define skip_post_check_so 'librustc_llvm-.*\.so.*'
19f98749 83
e361528e 84# ALL Rust libraries are private, because they don't keep an ABI.
8a073211
JR
85%define _noautoreqfiles lib.*-[[:xdigit:]]{8}[.]so.*
86%define _noautoprovfiles lib.*-[[:xdigit:]]{8}[.]so.*
e361528e
ER
87
88%description
89Rust is a systems programming language that runs blazingly fast,
90prevents segfaults, and guarantees thread safety.
91
92This package includes the Rust compiler, standard library, and
93documentation generator.
94
d1b96fd8
JR
95%package debugger-common
96Summary: Common debugger pretty printers for Rust
97Group: Development/Debuggers
98BuildArch: noarch
99
100%description debugger-common
101This package includes the common functionality for %{name}-gdb and
102%{name}-lldb.
103
e361528e
ER
104%package gdb
105Summary: GDB pretty printers for Rust
d1b96fd8
JR
106Group: Development/Debuggers
107Requires: %{name}-debugger-common = %{version}-%{release}
e361528e 108Requires: gdb
e361528e 109BuildArch: noarch
e361528e
ER
110
111%description gdb
112This package includes the rust-gdb script, which allows easier
113debugging of Rust programs.
114
d1b96fd8
JR
115%package lldb
116Summary: LLDB pretty printers for Rust
117Group: Development/Debuggers
118Requires: %{name}-debugger-common = %{version}-%{release}
119Requires: lldb
120Requires: python-lldb
121BuildArch: noarch
122
123%description lldb
124This package includes the rust-lldb script, which allows easier
125debugging of Rust programs.
126
e361528e
ER
127%package doc
128Summary: Documentation for Rust
d1b96fd8
JR
129Group: Documentation
130BuildArch: noarch
e361528e
ER
131
132%description doc
133This package includes HTML documentation for the Rust programming
134language and its standard library.
135
136%prep
137%setup -q -n %{rustc_package}
b5eceb5e
JR
138%patch0 -p1
139
e361528e
ER
140%if %{with bootstrap}
141%ifarch %{x8664}
142tar xf %{SOURCE1}
143%endif
144%ifarch %{ix86}
145tar xf %{SOURCE2}
146%endif
d6d4cb2b
JR
147%{__mv} %{bootstrap_root} %{bootstrap_root}-root
148%{bootstrap_root}-root/install.sh \
149 --components=cargo,rustc,rust-std-%{rust_triple} \
150 --prefix=%{local_rust_root} \
151 --disable-ldconfig
152test -f %{local_rust_root}/bin/cargo
e361528e
ER
153test -f %{local_rust_root}/bin/rustc
154%endif
155
156# unbundle
157rm -r src/jemalloc/
158rm -r src/llvm/
159
160# extract bundled licenses for packaging
161cp -p src/rt/hoedown/LICENSE src/rt/hoedown/LICENSE-hoedown
162sed -e '/*\//q' src/libbacktrace/backtrace.h \
163 >src/libbacktrace/LICENSE-libbacktrace
164
165# rust-gdb has hardcoded SYSROOT/lib -- let's make it noarch
166sed -i -e 's#DIRECTORY=".*"#DIRECTORY="%{_datadir}/%{name}/etc"#' \
167 src/etc/rust-gdb
168
169# These tests assume that alloc_jemalloc is present
170sed -i -e '1i // ignore-test jemalloc is disabled' \
171 src/test/compile-fail/allocator-dylib-is-system.rs \
172 src/test/compile-fail/allocator-rust-dylib-is-jemalloc.rs \
173 src/test/run-pass/allocator-default.rs
174
e361528e
ER
175%build
176%configure \
18a1004b 177 --libdir=%{common_libdir} \
e361528e
ER
178 --disable-option-checking \
179 --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \
180 --enable-local-rust --local-rust-root=%{local_rust_root} \
181 --llvm-root=%{_prefix} --disable-codegen-tests \
b5eceb5e 182 --enable-llvm-link-shared \
e361528e
ER
183 --disable-jemalloc \
184 --disable-rpath \
185 --enable-debuginfo \
d6d4cb2b 186 --enable-vendor \
e361528e
ER
187 --release-channel=%{channel}
188
d6d4cb2b 189./x.py dist
e361528e 190
8a073211
JR
191%{?with_tests:./x.py test}
192
e361528e
ER
193%install
194rm -rf $RPM_BUILD_ROOT
e361528e 195
d1b96fd8 196DESTDIR=$RPM_BUILD_ROOT ./x.py dist --install
e361528e 197
18a1004b
JR
198# Make sure the shared libraries are in the proper libdir
199%if "%{_libdir}" != "%{common_libdir}"
200mkdir -p %{buildroot}%{_libdir}
201find $RPM_BUILD_ROOT%{common_libdir} -maxdepth 1 -type f -name '*.so' \
202 -exec mv -v -t $RPM_BUILD_ROOT%{_libdir} '{}' '+'
203%endif
204
d1b96fd8 205# The shared libraries should be executable for debuginfo extraction.
e361528e
ER
206find $RPM_BUILD_ROOT%{_libdir}/ -type f -name '*.so' -exec chmod -v +x '{}' '+'
207
d1b96fd8
JR
208# The libdir libraries are identical to those under rustlib/. It's easier on
209# library loading if we keep them in libdir, but we do need them in rustlib/
210# to support dynamic linking for compiler plugins, so we'll symlink.
18a1004b 211(cd "$RPM_BUILD_ROOT%{rustlibdir}/%{rust_triple}/lib" &&
d1b96fd8
JR
212 find ../../../../%{_lib} -maxdepth 1 -name '*.so' \
213 -exec ln -v -f -s -t . '{}' '+')
214
215# Remove installer artifacts (manifests, uninstall scripts, etc.)
18a1004b 216find $RPM_BUILD_ROOT%{rustlibdir}/ -maxdepth 1 -type f -exec rm -v '{}' '+'
e361528e
ER
217
218# FIXME: __os_install_post will strip the rlibs
219# -- should we find a way to preserve debuginfo?
220
221# Remove unwanted documentation files (we already package them)
222rm $RPM_BUILD_ROOT%{_docdir}/%{name}/README.md
223rm $RPM_BUILD_ROOT%{_docdir}/%{name}/COPYRIGHT
224rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-APACHE
225rm $RPM_BUILD_ROOT%{_docdir}/%{name}/LICENSE-MIT
226
227# Sanitize the HTML documentation
228find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -empty -delete
229find $RPM_BUILD_ROOT%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
230
231# Move rust-gdb's python scripts so they're noarch
232install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
18a1004b 233mv -v $RPM_BUILD_ROOT%{rustlibdir}/%{_sysconfdir} $RPM_BUILD_ROOT%{_datadir}/%{name}/
e361528e
ER
234
235%clean
236rm -rf $RPM_BUILD_ROOT
237
238%post -p /sbin/ldconfig
239%postun -p /sbin/ldconfig
240
241%files
242%defattr(644,root,root,755)
243%doc COPYRIGHT LICENSE-APACHE LICENSE-MIT
244%doc src/libbacktrace/LICENSE-libbacktrace
245%doc src/rt/hoedown/LICENSE-hoedown
246%doc README.md
247%attr(755,root,root) %{_bindir}/rustc
248%attr(755,root,root) %{_bindir}/rustdoc
18a1004b 249%attr(755,root,root) %{_libdir}/lib*.so
e361528e
ER
250%{_mandir}/man1/rustc.1*
251%{_mandir}/man1/rustdoc.1*
18a1004b
JR
252%dir %{rustlibdir}
253%dir %{rustlibdir}/%{rust_triple}
254%dir %{rustlibdir}/%{rust_triple}/lib
255%attr(755,root,root) %{rustlibdir}/%{rust_triple}/lib/*.so
256%{rustlibdir}/%{rust_triple}/lib/*.rlib
e361528e 257
d1b96fd8
JR
258%files debugger-common
259%defattr(644,root,root,755)
260%dir %{_datadir}/%{name}
261%dir %{_datadir}/%{name}/etc
262%{_datadir}/%{name}/etc/debugger_*.py*
263
264%files lldb
265%defattr(644,root,root,755)
266%attr(755,root,root) %{_bindir}/rust-lldb
267%{_datadir}/%{name}/etc/lldb_*.py*
268
e361528e
ER
269%files gdb
270%defattr(644,root,root,755)
271%attr(755,root,root) %{_bindir}/rust-gdb
d1b96fd8 272%{_datadir}/%{name}/etc/gdb_*.py*
e361528e
ER
273
274%files doc
275%defattr(644,root,root,755)
276%dir %{_docdir}/%{name}
d1b96fd8 277%doc %{_docdir}/%{name}/html
This page took 0.166464 seconds and 4 git commands to generate.