Page MenuHomeFreeBSD

libcrypto: Further improve Makefile.asm to avoid temporary files
AbandonedPublic

Authored by khorben_defora.org on Aug 31 2023, 11:13 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 28, 12:38 PM
Unknown Object (File)
Apr 29 2024, 7:59 PM
Unknown Object (File)
Apr 28 2024, 12:19 PM
Unknown Object (File)
Apr 5 2024, 3:43 PM
Unknown Object (File)
Jan 28 2024, 7:45 PM
Unknown Object (File)
Dec 20 2023, 4:30 AM
Unknown Object (File)
Dec 10 2023, 8:41 PM
Unknown Object (File)
Nov 6 2023, 7:20 PM
Subscribers

Details

Reviewers
jhb
emaste
Summary

This avoids generating temporary *.s files in all of the architectures supported, to the only exception of the SHA implementation.

This is a follow-up to D41589.

Sponsored by: The FreeBSD Foundation

Test Plan
#!/bin/sh

srcdir="$HOME/Projects/FreeBSD/src"
objdir="/usr/obj/usr$srcdir"

_genasm() {
        _genasm_arch "arm64" "arm64" "aarch64" &&
                _genasm_arch "arm" &&
                _genasm_arch "amd64" &&
                _genasm_arch "i386" &&
                _genasm_arch "powerpc" "powerpc64" &&
                _genasm_arch "powerpc" "powerpc64le" &&
                _genasm_arch "powerpc"
}

_genasm_arch() {
        t="$1"

        if [ $# -eq 3 ]; then
                ta="$2"
                tasm="$3"
        elif [ $# -eq 2 ]; then
                ta="$2"
                tasm="$2"
        else
                ta="$1"
                tasm="$1"
        fi
        make -f Makefile.asm TARGET="$t" TARGET_ARCH="$ta" "-DASM_$tasm" &&
                mkdir -p "arch/$tasm" &&
                mv -f "$objdir/$t.$ta/secure/lib/libcrypto/"*.S "arch/$tasm/"
}

_genasm

And also now that it's been introduced:

src$ (cd secure/lib/libcrypto && make cleanasm buildasm)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

secure/lib/libcrypto/Makefile.asm
54

Hmm, when I tried this, it generated sha256 versions for both. In particular, the perl script checks for '512' in the output filename to decide if it should generate sha512 vs sha256:

if ($output =~ /512/) {
	$BITS=512;
	$SZ=8;
	@Sigma0=(28,34,39);
	@Sigma1=(14,18,41);
	@sigma0=(1,  8, 7);
	@sigma1=(19,61, 6);
	$rounds=80;
	$reg_t="x";
} else {
	$BITS=256;
	$SZ=4;
	@Sigma0=( 2,13,22);
	@Sigma1=( 6,11,25);
	@sigma0=( 7,18, 3);
	@sigma1=(17,19,10);
	$rounds=64;
	$reg_t="w";
}

This is also why the generic .pl.S rule below still uses a temporary file to handle the sha512-armv8.S file via the implicit rule.

190

I ran into differences in the generated files when I tried this as well.

327

The same for all of these, I had differences in output. Certainly for sha256/sha512, but i think for others as well.

You are right, with a better look I also see differences with the SHA512 files.