Page MenuHomeFreeBSD

libcrypto: Refactor Makefile.asm so it can be run outside of buildenv
ClosedPublic

Authored by jhb on Aug 24 2023, 7:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 9 2024, 7:39 AM
Unknown Object (File)
Sep 5 2024, 8:20 PM
Unknown Object (File)
Aug 6 2024, 9:11 AM
Unknown Object (File)
Aug 6 2024, 9:11 AM
Unknown Object (File)
Aug 6 2024, 9:11 AM
Unknown Object (File)
Aug 5 2024, 7:43 AM
Unknown Object (File)
Aug 1 2024, 12:09 AM
Unknown Object (File)
Jul 28 2024, 2:15 PM
Subscribers

Details

Summary

Currently Makefile.asm relies on the current buildenv to set CFLAGS
for i386. The current approach also leaves various temporary *.s
files around in the current directory. To make this a bit better:

  • Instead of using CFLAGS from buildenv for i386, define the actual flags the perl scripts need: -DOPENSSL_IA32_SSE2 to enable SSE2.
  • Change i386 to have the perl scripts write to /dev/stdout to avoid creating temporaries. Previously i386 was generating the temporary files in the OpenSSL contrib src.
  • Cleanup temporary *.s files in the all target after generating the real *.S files for architectures which need them.
  • Remove a duplicate rule for aes-armv4.S.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

secure/lib/libcrypto/Makefile.asm
285

Do you actually need to specify /dev/stdout here? The scripts I've dealt with write to stdout by default, but maybe they're not consistent.

secure/lib/libcrypto/Makefile.asm
285

Yes, x86asm.pl assumes the last argument is a destination filename. :(

(And yes, this behavior varies by arch in these perl scripts and is inconsistent which is very annoying.)

This revision is now accepted and ready to land.Aug 29 2023, 1:43 PM

In my tests the output is identical with and without this revision, except for avoiding the generation of temporary files on i386.
ISTM that the same optimization is possible on arm64, arm, and powerpc{,64,64le} as well by the way; would you consider applying it there as well?
Here is how I test locally: (from secure/lib/libcrypto)

#!/bin/sh

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

_genasm() {
        _genasm_arch "amd64" &&
                _genasm_arch "arm64" "arm64" "aarch64" &&
                _genasm_arch "arm" &&
                _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

For this to work I have to temporarily move the amd64 section to the bottom of Makefile.asm though, since -DASM_amd64 is always set. (Or whichever architecture is native to you)

This revision now requires changes to proceed.Aug 29 2023, 9:39 PM
This revision was not accepted when it landed; it landed in state Needs Revision.Aug 29 2023, 9:47 PM
This revision was automatically updated to reflect the committed changes.