FS#51335 - [rust] Improve build/packaging

Attached to Project: Community Packages
Opened by userwithuid (userwithuid) - Wednesday, 12 October 2016, 06:28 GMT
Last edited by Alexander F. Rødseth (xyproto) - Friday, 02 December 2016, 10:20 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Alexander F. Rødseth (xyproto)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

A couple of improvements for the current rust package:

1. Build against system llvm like most other distros do (fedora [1], gentoo [2], debian, etc.). Faster build, smaller binaries.

rust-depends: add 'llvm-libs'
makedepends: add 'llvm', remove 'libffi' 'perl'
configure: add '--llvm-root=/usr --disable-codegen-tests'

2. Fix jemalloc usage

Option A) --disable-jemalloc like fedora (seems to be not that important either way [3])
Option B) Use system jemalloc. It's already in makedepends, but I think it needs to be specified in configure.

configure: add '--jemalloc-root=/usr/lib'

3. Fix bootstrapping. Currently, the PKGBUILD downloads a stage0 rustc during build(), which I think is suboptimal.

Option A) At least do what gentoo currently does and download the stage0 bin via source.
Option B) Preferably, I suggest we go the fedora way and bootstrap ourselves with the previous version. This is officially supported, rustc version X can be bootstrapped with either X or X-1 [4,5,6]

makedepends: add 'rust'
configure: add '--enable-local-rust --local-rust-root=/usr'

4. Remove accidentally duplicated docs. Currently, both 'rust' and 'rust-docs' contain all the docs in different folders. Remove them from 'rust'.


A PKGBUILD with all those fixes and a few more is a attached for guidance.
   PKGBUILD (2.8 KiB)
This task depends upon

Closed by  Alexander F. Rødseth (xyproto)
Friday, 02 December 2016, 10:20 GMT
Reason for closing:  Implemented
Additional comments about closing:  Implemented most of the suggestions.
Comment by userwithuid (userwithuid) - Wednesday, 12 October 2016, 21:09 GMT Comment by Alexander F. Rødseth (xyproto) - Friday, 14 October 2016, 10:52 GMT
Thanks for reporting! Will look into it.
Comment by Alexander F. Rødseth (xyproto) - Friday, 14 October 2016, 11:16 GMT Comment by Alexander F. Rødseth (xyproto) - Saturday, 22 October 2016, 13:24 GMT
The suggested PKGBUILD above does not work when building the latest version of rust 1.12.1 and bootstrapping with the current version. The error is:

/bin/sh: /build/rust/src/rustc-1.12.1/src/libbacktrace/missing: No such file or directory
configure: WARNING: `missing' script is too old or missing
Comment by userwithuid (userwithuid) - Tuesday, 25 October 2016, 12:58 GMT
Sorry for the late reply.

With regards to the libbacktrack error: Hmm, I don't know why you would get that error. Looks like a missing makedep, how are you building?


Anyway, attached is a revised PKGBUILD for 1.12.1.

The referenced patch is from upstream, see here: https://users.rust-lang.org/t/bootstrapping-1-12-1-from-1-12-0/7715
Fedora also uses it: http://pkgs.fedoraproject.org/cgit/rpms/rust.git/commit/rust.spec?id=6050c3a1b2df417ed4b51ec830477506078f4dee

For me, this builds successfully both for i686 and x86_64. I'm not a packager, so I don't know how you build, but I used the clean chroot approach as described in the developer wiki: https://wiki.archlinux.org/index.php/DeveloperWiki:Building_in_a_Clean_Chroot
   PKGBUILD (3.6 KiB)
Comment by Alexander F. Rødseth (xyproto) - Tuesday, 25 October 2016, 19:22 GMT
I updated the package before I discovered your (informative!) reply. LLVM is now enabled (but links with ffi). I also fixed the documentation split, as suggested. So point 1 and 4 above should be covered, hopefully.

Please test the latest version from [community].

If that package looks okay, I'll move forward with implementing point 2 and 3 above now that the time pressure of releasing version 1.12.1 quickly is over.

Thanks for the insights and for collecting the best ideas for how to package rust.
Comment by userwithuid (userwithuid) - Wednesday, 26 October 2016, 07:47 GMT
Looks good so far.

Yeah, I'm mostly just trying to relay what upstream is dicussing with regards to distro-packaging (looks like they are still figuring things out themselves :-) ).


Looks like once we get llvm 3.9 in arch, llvm-config will allow dynamic linking even if static libs are present [1], so no ffi hack and way smaller pkg. We'll see.
[1] https://github.com/llvm-mirror/llvm/commit/93083d498658f4c6da98e8950bd9f58c76080299
Comment by Alexander F. Rødseth (xyproto) - Saturday, 29 October 2016, 16:09 GMT
Enabled jmalloc too.

I'm a bit concerned that bootstrapping rust with rust will have problems in the future (like the transition from 1.12.0 to 1.12.1). I suspect that packaging rust without depending on rust will have a higher likelihood of working effortlessly (without patches or sed replacements) for future updates. Thoughts?
Comment by userwithuid (userwithuid) - Sunday, 30 October 2016, 04:04 GMT
@point release transition: Well, I mean that's exactly what is currently being discussed/improved upstream as linked above [1]. Be sure to check out the links, in particular this commit [2]; it shouldn't require any patching in the future (to be verified when the next point release after 1.14 comes out ;-) ).

@self-bootstrap approach: imho, having to download a vendored compiler binary during build is sooooo ugly that I felt the need to look for alternatives, and 'bootstrap from old version' seems to be the way to go.
1. It is actively discussed and used [3] upstream.
2. Since the fedora packager (cuviper) is involved, it should be pretty easy to use from here on out (also, easy to look at their fixes for potential future transition problems :-) ).

Then again, I totally understand that, from a maintainer's perspective, everything beyond configure && make is additional burden during every version upgrade; KISS and all. You could always delay the decision and see whether debian/gentoo/... follow fedora or stick to their current 'pre-download stage0'-approach. In the end, it's not exactly high priority, the final package should be the same either way.


[1] https://users.rust-lang.org/t/bootstrapping-1-12-1-from-1-12-0/7715
[2] https://github.com/rust-lang/rust/commit/81d97957a7807d3ac1a9defde037c6e504e3d797
[3] https://github.com/rust-lang/rust/pull/32942 ; I linked to this before. To be clear, the background-downloaded stage0 binary at build is just a previous major version rustc since this commit from 2016-04.
Comment by Andrea Scarpino (BaSh) - Saturday, 26 November 2016, 09:24 GMT
Please could you also add rust-src package?
Comment by Alexander F. Rødseth (xyproto) - Friday, 02 December 2016, 10:19 GMT
Postponing boostrapping rust with the previous version of rust since there were transition issues.

Loading...