Bug 226955 - lang/rust: Support LibreSSL 2.7.x
Summary: lang/rust: Support LibreSSL 2.7.x
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: FreeBSD Rust Team
URL: https://github.com/sfackler/rust-open...
Depends on: 227130
Blocks: 226843
  Show dependency treegraph
Reported: 2018-03-26 17:40 UTC by Charlie Li
Modified: 2018-07-23 07:32 UTC (History)
6 users (show)

See Also:
dumbbell: maintainer-feedback+

libressl 2.7 (53.49 KB, patch)
2018-04-09 18:53 UTC, Charlie Li
no flags Details | Diff
rust1.26-libressl2.7.patch (22.75 KB, patch)
2018-05-18 13:55 UTC, Maciej Pasternacki
maciej: maintainer-approval?
Details | Diff
rust-1.27.1-libressl2.7.patch (2.23 KB, patch)
2018-07-21 05:54 UTC, Charlie Li
dumbbell: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Charlie Li 2018-03-26 17:40:45 UTC
Notwithstanding the API changes in libressl 2.7, the current rust release does not support libressl > 2.6. However, upstream has released patches for supporting libressl 2.7.
Comment 1 Jean-Sébastien Pédron freebsd_committer 2018-03-27 09:24:44 UTC

The patch to add LibreSSL 2.7.0 support doesn't apply cleanly to the copy of rust-openssl in Rust 1.24.1. Apparently, the code was significantly modified since the last import of rust-openssl.

I won't have time this week to work on this, but next week should be ok.
Comment 2 Charlie Li 2018-04-01 05:27:04 UTC
Apparently the openssl-sys crate is still v0.9.24 in the new rust 1.25.0. The diff between said tag and git master applies cleanly, and should build in theory.

I took a brief look at the rest of the changes covered in that diff, and we may want to additionally test compatibility with security/openssl-devel 1.1.
Comment 3 Charlie Li 2018-04-09 18:53:35 UTC
Created attachment 192365 [details]
libressl 2.7

Here's a patch to try. Apply this after bdrewery@'s initial patch to update rust to 1.25.0 from bug 227130.

I updated openssl-sys to upstream 0.9.28 but leaving Cargo.toml untouched at 0.9.24 so as to not trigger complaints over inconsistent Cargo.lock files and unnecessary network access that will fail anyway. I also patched the bundled libgit2-sys C portion with the help of brnrd@'s upstream patch to libgit2, although libgit2 upstream moved some files around thus needing to match filenames between new and old locations. I originally wanted to just update the two affected crates to the latest upstream but our integrated .cargo-checksum updater complains about deleted files, though not newly-created files because they weren't in .cargo-checksum to begin with.

This passes testport on my amd64 machine.
Comment 4 rozhuk.im 2018-05-02 01:09:20 UTC
Build ok.
Comment 5 jakub_lach 2018-05-03 23:03:49 UTC
(In reply to Charlie Li from comment #3)

After applying -

--- stderr
thread 'main' panicked at '

This crate is only compatible with OpenSSL 1.0.1, 1.0.2, and 1.1.0, or LibreSSL
2.5 and 2.6.0, but a different version of OpenSSL was found. The build is now
aborting due to this version mismatch.

', vendor/openssl-sys/build.rs:486:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed
command did not execute successfully: "/usr/obj/usr/ports/lang/rust/work/rustc-1.25.0-src/build/x86_64-unknown-freebsd/stage0/bin/cargo" "build" "--target" "x86_64-unknown-freebsd" "--release" "--frozen" "--manifest-path" "/usr/obj/usr/ports/lang/rust/work/rustc-1.25.0-src/src/tools/cargo/Cargo.toml"
expected success, got: exit code: 101
Comment 6 Charlie Li 2018-05-05 18:52:20 UTC
(In reply to jakub_lach from comment #5)
Are you sure you actually applied the patch by running patch(1) before building? There should be additional files within lang/rust/files, specifically those that modify the vendor/openssl-sys crate, among others.
Comment 7 jakub_lach 2018-05-05 19:43:43 UTC
(In reply to Charlie Li from comment #6)

It looked like it have applied cleanly, 

 $ ls -a
.               distinfo        Makefile        pkg-descr
..              files           Makefile.orig

yet indeed, I'm missing those new files under files/, thanks!
Comment 8 Maciej Pasternacki 2018-05-18 13:55:26 UTC
Created attachment 193508 [details]

Patch adapted for rust-1.26.0 (currently in ports head). Rust-1.26 vendors openssl-sys-0.9.27, bumped to 0.9.28 without patching Cargo.toml as earlier patch. Files in libgit2-sys that needed patching have moved, but patch is basically the same.
Comment 9 Charlie Li 2018-05-18 13:58:17 UTC
Comment on attachment 192365 [details]
libressl 2.7

I have this exactly in my tree and was about to post myself, but you beat me to it.
Comment 10 Jean-Sébastien Pédron freebsd_committer 2018-05-26 15:43:04 UTC

Thank you for providing a patch!

How can I test it in Poudriere? I.e. any options beside `DEFAULT_VERSIONS+=ssl=libressl`?
Comment 11 Charlie Li 2018-06-02 17:19:34 UTC
(In reply to Jean-Sébastien Pédron from comment #10)
Only option needed to set in make.conf.
Comment 12 Charlie Li 2018-06-17 20:24:33 UTC
These patches are still needed for the current version in the ports tree, 1.26.2.
Comment 13 Jean-Sébastien Pédron freebsd_committer 2018-06-25 10:13:19 UTC

Something else didn't build for me when I tried to build Rust with LibreSSL in Poudriere, but I don't remember what it was...

Anyway, Rust 1.27.0 was released and it looks like it includes support for LibreSSL 2.7.x and OpenSSL 1.1.x. I'm preparing the update right now. It may take some time because there is a regression with Rust on FreeBSD/aarch64 (the compiler crashes, see bug 228892).

Sorry for all the time it takes to integrate a patch...
Comment 14 Charlie Li 2018-07-21 03:57:38 UTC
(In reply to Jean-Sébastien Pédron from comment #13)
> Something else didn't build for me when I tried to build Rust with LibreSSL in Poudriere, but I don't remember what it was...

That is probably the libgit2-sys crate. The patch for that is still needed, as the crate didn't get updated from the last rust releases and thus still does not have a newer libgit2 that includes libressl 2.7 fixes.

The openssl-sys crate is updated to 0.9.28, which is the first version with libressl 2.7 support. Patches for that crate can now be tossed.

I'm currently building 1.27.1 with just the libgit2-sys patches; will upload the updated patch after poudriere-bulk -t succeeds.
Comment 15 Charlie Li 2018-07-21 05:54:04 UTC
Created attachment 195318 [details]

This patch only patches the libgit2-sys crate in addition to the libc crate. openssl-sys crate patches removed because no longer needed.
Comment 16 Jean-Sébastien Pédron freebsd_committer 2018-07-21 14:58:01 UTC
It was another port before which failed to build, not Rust itself.

Anyway, I will trust what you tested and commit the patch. It took already way too much time, I'm sorry.
Comment 17 commit-hook freebsd_committer 2018-07-21 15:05:04 UTC
A commit references this bug:

Author: dumbbell
Date: Sat Jul 21 15:04:14 UTC 2018
New revision: 475069
URL: https://svnweb.freebsd.org/changeset/ports/475069

  lang/rust: Add patches to fix the build with LibreSSL 2.7

  PR:		226955
  Submitted by:	Charlie Li <ml+freebsd@vishwin.info>

Comment 18 Jean-Sébastien Pédron freebsd_committer 2018-07-21 15:07:16 UTC
I committed the patches. However, I kept the Makefile unmodified because we would probably have to restore it in the future for the next versions of LibreSSL or OpenSSL.

Thank you for the patches and your patience!
Comment 19 Charlie Li 2018-07-23 00:31:27 UTC
Not applying the Makefile patch continues to fail the build because the libgit2-sys crate checksums are not regenerated. Someone posting in ports@ has already piped up about this. Please apply the full patch as posted, but retain (or not) the openssl-sys part as you wish should a new LibreSSL or OpenSSL breaks things again.
Comment 20 commit-hook freebsd_committer 2018-07-23 07:32:38 UTC
A commit references this bug:

Author: dumbbell
Date: Mon Jul 23 07:32:23 UTC 2018
New revision: 475150
URL: https://svnweb.freebsd.org/changeset/ports/475150

  lang/rust: Udpate checksums in libgit2-sys/.cargo-checksum.json

  It was part of the initial patch from Charlie Li to support LibreSSL
  2.7. However, I misread it and though he was only removing bits
  which were not needed anymore (updating checksums for openssl and

  Now, we update all three: libgit2-sys, openssl and openssl-sys.

  PR:		226955
  Submitted by:	Charlie Li <ml+freebsd@vishwin.info>
  Reported by:	Charlie Li <ml+freebsd@vishwin.info>