Github messages for voidlinux
 help / color / mirror / Atom feed
From: q66 <q66@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] [RFC] libressl: add assembly for aarch64, ppc*, extra assembly for arm
Date: Sun, 19 Jul 2020 23:46:19 +0200	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-23655@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1612 bytes --]

There is a new pull request by q66 against master on the void-packages repository

https://github.com/void-ppc/void-packages lssl-asm
https://github.com/void-linux/void-packages/pull/23655

[RFC] libressl: add assembly for aarch64, ppc*, extra assembly for arm
This yields significant speedups (20x) in some things (AES/ghash) on platforms with hardware crypto support (e.g. POWER8 and newer, and most aarch64) as well as enhances performance of assorted alogrithms by using optimized assembly implementations instead of portable fallbacks. E.g. on aarch64 https://gist.githubusercontent.com/q66/c75a46fc7d0c27eff21cc9d70639bf95/raw/dde1f60e304ef8f4a4049d41388d9c25e63b4a1e/gistfile1.txt

As it is now, libressl only supports asm for x86(_64) and to a limited degree, 32-bit ARM. The extra support was added by my project: https://github.com/q66/libressl-portable-asm

Everything was tested, test suite passes on all platforms, and benchmarks were run on relevant hardware, confirming the speedups.

I still think we should move back to OpenSSL, since there are many reasons to do so (even disregarding performance) and the performance is still better on it (as there are various algos that don't have optimized implementations under libressl at all) but this could be a decent stopgap solution, enabling at least basic things (like hardware AES on non-x86 systems).

More testing (mainly benchmarking, test suite is known to pass universally) on armv7 and aarch64 is still pending.

@void-linux/pkg-committers

A patch file from https://github.com/void-linux/void-packages/pull/23655.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lssl-asm-23655.patch --]
[-- Type: text/x-diff, Size: 3141 bytes --]

From ca3fce7483c7788e5f1005386152c9404166a280 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Sun, 19 Jul 2020 20:24:23 +0200
Subject: [PATCH] libressl: add assembly for aarch64, ppc*, extra assembly for
 arm

This yields significant speedups (20x) on platforms with hardware
crypto support (e.g. POWER8 and newer, and most aarch64) as well
as enhances performance of assorted alogrithms by using optimized
assembly implementations instead of portable fallbacks.

As it is now, libressl only supports asm for x86(_64) and to a
limited degree, 32-bit ARM.

Everything was tested, test suite passes on all platforms, and
benchmarks were run on relevant hardware, confirming the speedups.
---
 srcpkgs/libressl/template | 54 +++++++++++++++++++++++++++++++--------
 1 file changed, 43 insertions(+), 11 deletions(-)

diff --git a/srcpkgs/libressl/template b/srcpkgs/libressl/template
index f8a201c19b5..4ac72d4e626 100644
--- a/srcpkgs/libressl/template
+++ b/srcpkgs/libressl/template
@@ -1,9 +1,10 @@
 # Template file for 'libressl'
 pkgname=libressl
 version=3.1.3
-revision=1
+revision=2
 bootstrap=yes
 build_style=gnu-configure
+configure_args="$(vopt_enable asm)"
 short_desc="Version of the TLS/crypto stack forked from OpenSSL"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="OpenSSL-License, SSLeay-License, ISC"
@@ -14,21 +15,52 @@ checksum=c76b0316acf612ecb62f5cb014a20d972a663bd9e40abf952a86f3b998b69fa0
 provides="openssl-${version}_${revision}"
 replaces="openssl>=0"
 conf_files="/etc/ssl/openssl.cnf /etc/ssl/x509v3.cnf"
+_lssl_asm_ver="1.0-rc1"
 
-if [ "$XBPS_TARGET_MACHINE" = "i686-musl" ]; then
-	# XXX disable SSP
-	configure_args+=" --disable-hardening"
-elif [ "$XBPS_TARGET_MACHINE" = "armv5tel" ]; then
-	configure_args+=" --disable-asm"
+build_options="asm"
+desc_option_asm="Use platform assembly for faster crypto"
+
+if [ "$build_option_asm" ]; then
+	distfiles+=" https://github.com/q66/libressl-portable-asm/archive/v${_lssl_asm_ver}.tar.gz"
+	checksum+=" f86cc77319835344222f13c223e5cdae882bf2509f64be1762f3b35dda49b572"
 fi
 
-if [ "$CROSS_BUILD" ]; then
-	hostmakedepends="automake libtool"
-	pre_configure() {
-		autoreconf -fi
-	}
+# only enable asm for full chroots by default
+# otherwise we'd be introducing an autotools dependency on the host
+if [ "$CHROOT_READY" ]; then
+	build_options_default="asm"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	# disable ssp
+	i686-musl) configure_args+=" --disable-hardening";;
+	# on armv5 always disable asm as it's not supported
+	armv5*) configure_args+=" --disable-asm";;
+esac
+
+if [ "$CROSS_BUILD" -o "$build_option_asm" ]; then
+	_regen_build=yes
 fi
 
+if [ -n "$_regen_build" ]; then
+	hostmakedepends=" automake libtool"
+fi
+
+post_extract() {
+	[ -z "$build_option_asm" ] && return 0
+	mv ../libressl-portable-asm-${_lssl_asm_ver} .
+}
+
+pre_configure() {
+	[ -z "$_regen_build" ] && return 0
+	if [ "$build_option_asm" ]; then
+		cd libressl-portable-asm-${_lssl_asm_ver}
+		./patch_libressl.sh ..
+		cd ..
+	fi
+	autoreconf -if
+}
+
 post_install() {
 	# Use CA file from ca-certificates instead.
 	rm -f ${DESTDIR}/etc/ssl/cert.pem

             reply	other threads:[~2020-07-19 21:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-19 21:46 q66 [this message]
2020-07-19 22:19 ` [PR PATCH] [Updated] " q66
2020-07-19 22:22 ` q66
2020-07-19 23:29 ` q66
2020-07-20  0:03 ` ahesford
2020-07-23 15:49 ` [PR PATCH] [Updated] " q66
2020-07-23 21:38 ` q66
2020-07-24  1:52 ` [PR PATCH] [Merged]: " q66

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=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-23655@inbox.vuxu.org \
    --to=q66@users.noreply.github.com \
    --cc=ml@inbox.vuxu.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;
as well as URLs for NNTP newsgroup(s).