Move bn_asm_src file information to build.info files
authorRichard Levitte <levitte@openssl.org>
Sun, 16 Jun 2019 14:56:25 +0000 (16:56 +0200)
committerRichard Levitte <levitte@openssl.org>
Mon, 17 Jun 2019 14:08:52 +0000 (16:08 +0200)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9166)

Configurations/00-base-templates.conf
Configurations/10-main.conf
Configurations/50-masm.conf
Configurations/README
Configure
crypto/bn/build.info

index 08782c6..4a0bc5a 100644 (file)
@@ -15,7 +15,6 @@ my %targets=(
        thread_defines  => [],
 
        cpuid_asm_src   => "mem_clr.c",
-       bn_asm_src      => "bn_asm.c",
        ec_asm_src      => "",
        des_asm_src     => "des_enc.c fcrypt_b.c",
        aes_asm_src     => "aes_core.c aes_cbc.c",
@@ -169,7 +168,6 @@ my %targets=(
     x86_asm => {
        template        => 1,
        cpuid_asm_src   => "x86cpuid.s",
-       bn_asm_src      => "bn-586.s co-586.s x86-mont.s x86-gf2m.s",
        ec_asm_src      => "ecp_nistz256.c ecp_nistz256-x86.s",
        des_asm_src     => "des-586.s crypt586.s",
        aes_asm_src     => "aes-586.s vpaes-x86.s aesni-x86.s",
@@ -194,7 +192,6 @@ my %targets=(
     x86_64_asm => {
        template        => 1,
        cpuid_asm_src   => "x86_64cpuid.s",
-       bn_asm_src      => "asm/x86_64-gcc.c x86_64-mont.s x86_64-mont5.s x86_64-gf2m.s rsaz_exp.c rsaz-x86_64.s rsaz-avx2.s",
        ec_asm_src      => "ecp_nistz256.c ecp_nistz256-x86_64.s x25519-x86_64.s",
        aes_asm_src     => "aes-x86_64.s vpaes-x86_64.s bsaes-x86_64.s aesni-x86_64.s aesni-sha1-x86_64.s aesni-sha256-x86_64.s aesni-mb-x86_64.s",
        md5_asm_src     => "md5-x86_64.s",
@@ -211,7 +208,6 @@ my %targets=(
     ia64_asm => {
        template        => 1,
        cpuid_asm_src   => "ia64cpuid.s",
-       bn_asm_src      => "bn-ia64.s ia64-mont.s",
        aes_asm_src     => "aes_core.c aes_cbc.c aes-ia64.s",
        sha1_asm_src    => "sha1-ia64.s sha256-ia64.s sha512-ia64.s",
        modes_asm_src   => "ghash-ia64.s",
@@ -221,7 +217,6 @@ my %targets=(
     sparcv9_asm => {
        template        => 1,
        cpuid_asm_src   => "sparcv9cap.c sparccpuid.S",
-       bn_asm_src      => "asm/sparcv8plus.S sparcv9-mont.S sparcv9a-mont.S vis3-mont.S sparct4-mont.S sparcv9-gf2m.S",
        ec_asm_src      => "ecp_nistz256.c ecp_nistz256-sparcv9.S",
        des_asm_src     => "des_enc-sparc.S fcrypt_b.c dest4-sparcv9.S",
        aes_asm_src     => "aes_core.c aes_cbc.c aes-sparcv9.S aest4-sparcv9.S aesfx-sparcv9.S",
@@ -234,19 +229,16 @@ my %targets=(
     sparcv8_asm => {
        template        => 1,
        cpuid_asm_src   => "",
-       bn_asm_src      => "asm/sparcv8.S",
        des_asm_src     => "des_enc-sparc.S fcrypt_b.c",
     },
     alpha_asm => {
        template        => 1,
        cpuid_asm_src   => "alphacpuid.s",
-       bn_asm_src      => "bn_asm.c alpha-mont.S",
        sha1_asm_src    => "sha1-alpha.S",
        modes_asm_src   => "ghash-alpha.S",
     },
     mips32_asm => {
        template        => 1,
-       bn_asm_src      => "bn-mips.S mips-mont.S",
        aes_asm_src     => "aes_cbc.c aes-mips.S",
        sha1_asm_src    => "sha1-mips.S sha256-mips.S",
     },
@@ -259,7 +251,6 @@ my %targets=(
     s390x_asm => {
        template        => 1,
        cpuid_asm_src   => "s390xcap.c s390xcpuid.S",
-       bn_asm_src      => "asm/s390x.S s390x-mont.S s390x-gf2m.s",
        aes_asm_src     => "aes-s390x.S aes-ctr.fake aes-xts.fake",
        sha1_asm_src    => "sha1-s390x.S sha256-s390x.S sha512-s390x.S",
        rc4_asm_src     => "rc4-s390x.s",
@@ -271,7 +262,6 @@ my %targets=(
     armv4_asm => {
        template        => 1,
        cpuid_asm_src   => "armcap.c armv4cpuid.S",
-       bn_asm_src      => "bn_asm.c armv4-mont.S armv4-gf2m.S",
        ec_asm_src      => "ecp_nistz256.c ecp_nistz256-armv4.S",
        aes_asm_src     => "aes_cbc.c aes-armv4.S bsaes-armv7.S aesv8-armx.S",
        sha1_asm_src    => "sha1-armv4-large.S sha256-armv4.S sha512-armv4.S",
@@ -284,7 +274,6 @@ my %targets=(
        template        => 1,
        cpuid_asm_src   => "armcap.c arm64cpuid.S",
        ec_asm_src      => "ecp_nistz256.c ecp_nistz256-armv8.S",
-       bn_asm_src      => "bn_asm.c armv8-mont.S",
        aes_asm_src     => "aes_core.c aes_cbc.c aesv8-armx.S vpaes-armv8.S",
        sha1_asm_src    => "sha1-armv8.S sha256-armv8.S sha512-armv8.S",
        modes_asm_src   => "ghashv8-armx.S",
@@ -295,7 +284,6 @@ my %targets=(
     parisc11_asm => {
        template        => 1,
        cpuid_asm_src   => "pariscid.s",
-       bn_asm_src      => "bn_asm.c parisc-mont.s",
        aes_asm_src     => "aes_core.c aes_cbc.c aes-parisc.s",
        sha1_asm_src    => "sha1-parisc.s sha256-parisc.s sha512-parisc.s",
        rc4_asm_src     => "rc4-parisc.s",
@@ -308,7 +296,6 @@ my %targets=(
     ppc32_asm => {
        template        => 1,
        cpuid_asm_src   => "ppccpuid.s ppccap.c",
-       bn_asm_src      => "bn-ppc.s ppc-mont.s",
        aes_asm_src     => "aes_core.c aes_cbc.c aes-ppc.s vpaes-ppc.s aesp8-ppc.s",
        sha1_asm_src    => "sha1-ppc.s sha256-ppc.s sha512-ppc.s sha256p8-ppc.s sha512p8-ppc.s",
        modes_asm_src   => "ghashp8-ppc.s",
index 27d02e2..e824187 100644 (file)
@@ -896,7 +896,6 @@ my %targets = (
         cflags           => add("-m31 -Wa,-mzarch"),
         cxxflags         => add("-m31 -Wa,-mzarch"),
         lib_cppflags     => add("-DB_ENDIAN"),
-        bn_asm_src       => sub { my $r=join(" ",@_); $r=~s|asm/s390x\.S|bn_asm.c|; $r; },
         asm_arch         => 's390x',
         perlasm_scheme   => "31",
         multilib         => "/highgprs",
@@ -951,7 +950,6 @@ my %targets = (
                                     threads("-D_REENTRANT")),
         bn_ops           => "BN_LLONG",
         cpuid_asm_src    => "c64xpluscpuid.s",
-        bn_asm_src       => "asm/bn-c64xplus.asm c64xplus-gf2m.s",
         aes_asm_src      => "aes-c64xplus.s aes_cbc.c aes-ctr.fake",
         sha1_asm_src     => "sha1-c64xplus.s sha256-c64xplus.s sha512-c64xplus.s",
         rc4_asm_src      => "rc4-c64xplus.s",
@@ -1360,8 +1358,6 @@ my %targets = (
         ASFLAGS          => "-d debug",
         asoutflag        => "-o ",
         sys_id           => "WIN64I",
-        bn_asm_src       => sub { return undef unless @_;
-                                  my $r=join(" ",@_); $r=~s|bn-ia64.s|bn_asm.c|; $r; },
         uplink_arch      => 'ia64',
         asm_arch         => 'ia64',
         perlasm_scheme   => "ias",
@@ -1374,8 +1370,6 @@ my %targets = (
         asoutflag        => sub { vc_win64a_info()->{asoutflag} },
         asflags          => sub { vc_win64a_info()->{asflags} },
         sys_id           => "WIN64A",
-        bn_asm_src       => sub { return undef unless @_;
-                                  my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; },
         uplink_arch      => 'x86_64',
         asm_arch         => 'x86_64',
         perlasm_scheme   => "auto",
index 9120d53..3ef38e5 100644 (file)
@@ -15,8 +15,6 @@ my %targets = (
         asoutflag       => "/Fo",
         asflags         => "/c /Cp /Cx",
         sys_id          => "WIN64A",
-        bn_asm_src      => sub { return undef unless @_;
-                                 my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; },
         uplink_arch      => 'x86_64',
         asm_arch         => 'x86_64',
         perlasm_scheme   => "masm",
index eaf5164..db02a9e 100644 (file)
@@ -243,9 +243,6 @@ In each table entry, the following keys are significant:
         cpuid_asm_src   => assembler implementation of cpuid code as
                            well as OPENSSL_cleanse().
                            Default to mem_clr.c
-        bn_asm_src      => Assembler implementation of core bignum
-                           functions.
-                           Defaults to bn_asm.c
         ec_asm_src      => Assembler implementation of core EC
                            functions.
         des_asm_src     => Assembler implementation of core DES
index 4cb331f..d577e40 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1410,35 +1410,6 @@ unless ($disabled{asm}) {
         push @{$config{module_defines}}, "OPENSSL_CPUID_OBJ";
     }
 
-    $target{bn_asm_src} =~ s/\w+-gf2m.c// if (defined($disabled{ec2m}));
-
-    # bn-586 is the only one implementing bn_*_part_words
-    if ($target{bn_asm_src} =~ /bn-586/) {
-        push @{$config{lib_defines}}, "OPENSSL_BN_ASM_PART_WORDS";
-        push @{$config{module_defines}}, "OPENSSL_BN_ASM_PART_WORDS";
-    }
-    if (!$disabled{sse2} && $target{bn_asm_src} =~ /86/) {
-        push @{$config{lib_defines}}, "OPENSSL_IA32_SSE2";
-        push @{$config{module_defines}}, "OPENSSL_IA32_SSE2";
-    }
-
-    if ($target{bn_asm_src} =~ /-mont/) {
-        push @{$config{lib_defines}}, "OPENSSL_BN_ASM_MONT";
-        push @{$config{module_defines}}, "OPENSSL_BN_ASM_MONT";
-    }
-    if ($target{bn_asm_src} =~ /-mont5/) {
-        push @{$config{lib_defines}}, "OPENSSL_BN_ASM_MONT5";
-        push @{$config{module_defines}}, "OPENSSL_BN_ASM_MONT5";
-    }
-    if ($target{bn_asm_src} =~ /-gf2m/) {
-        push @{$config{lib_defines}}, "OPENSSL_BN_ASM_GF2m";
-        push @{$config{module_defines}}, "OPENSSL_BN_ASM_GF2m";
-    }
-    if ($target{bn_asm_src} =~ /-div3w/) {
-        push @{$config{lib_defines}}, "BN_DIV3W";
-        push @{$config{module_defines}}, "BN_DIV3W";
-    }
-
     if ($target{sha1_asm_src}) {
         push @{$config{lib_defines}}, "SHA1_ASM"   if ($target{sha1_asm_src} =~ /sx86/ || $target{sha1_asm_src} =~ /sha1/);
         push @{$config{lib_defines}}, "SHA256_ASM" if ($target{sha1_asm_src} =~ /sha256/);
@@ -3434,7 +3405,6 @@ sub print_table_entry
         "ex_libs",
         "bn_ops",
         "cpuid_asm_src",
-        "bn_asm_src",
         "ec_asm_src",
         "des_asm_src",
         "aes_asm_src",
index 362a2da..8353b32 100644 (file)
 LIBS=../../libcrypto
 
+$BNASM=bn_asm.c
+IF[{- !$disabled{asm} -}]
+  # Define source files and macros per asm architecture
+  # Known macros are:
+  #
+  # OPENSSL_BN_ASM_PART_WORDS     For any collection with /-586/ file names
+  # OPENSSL_BN_ASM_MONT           For any collection with /-mont/ file names
+  # OPENSSL_BN_ASM_MONT5          For any collection with /-mont5/ file names
+  # OPENSSL_BN_ASM_GF2m           For any collection with /-gf2m/ file names
+  # OPENSSL_IA32_SSE2             For any collection with /86/ file names
+  #                               when sse2 is enabled
+  # BN_DIV3W                      For any collection with /-div3w/ file names
+  #
+  # All variables are named in such a way that they can be "indexed" with
+  # $target{asm_arch}
+
+  $BNASM_x86=bn-586.s co-586.s x86-mont.s x86-gf2m.s
+  # bn-586 is the only one implementing bn_*_part_words
+  # => OPENSSL_BN_ASM_PART_WORDS
+  $BNDEF_x86=OPENSSL_BN_ASM_PART_WORDS OPENSSL_BN_ASM_MONT OPENSSL_BN_ASM_GF2m
+  $BNDEF_x86_sse2=OPENSSL_IA32_SSE2
+
+  $BNASM_x86_64=\
+          x86_64-mont.s x86_64-mont5.s x86_64-gf2m.s rsaz_exp.c rsaz-x86_64.s \
+          rsaz-avx2.s
+  IF[{- $config{target} !~ /^VC/ -}]
+    $BNASM_x86_64=asm/x86_64-gcc.c $BNASM_x86_64
+  ELSE
+    $BNASM_x86_64=bn_asm.c $BNASM_x86_64
+  ENDIF
+  $BNDEF_x86_64=OPENSSL_BN_ASM_MONT OPENSSL_BN_ASM_MONT5 OPENSSL_BN_ASM_GF2m
+  $BNDEF_x86_64_sse2=OPENSSL_IA32_SSE2
+
+  IF[{- $config{target} !~ /^VC/ -}]
+    $BNASM_ia64=bn-ia64.s ia64-mont.s
+  ELSE
+    $BNASM_ia64=bn_asm.c ia64-mont.s
+  ENDIF
+
+  $BNASM_sparcv9=asm/sparcv8plus.S sparcv9-mont.S sparcv9a-mont.S vis3-mont.S \
+          sparct4-mont.S
+  $BNDEF_sparcv9=OPENSSL_BN_ASM_MONT
+  $BNASM_sparcv9_ec2m=sparcv9-gf2m.S
+  $BNDEF_sparcv9_ec2m=OPENSSL_BN_ASM_GF2m
+
+  $BNASM_sparcv8=asm/sparcv8.S
+
+  $BNASM_alpha=bn_asm.c alpha-mont.S
+  $BNDEF_alpha=OPENSSL_BN_ASM_MONT
+
+  $BNASM_mips32=bn-mips.S mips-mont.S
+  $BNDEF_mips32=OPENSSL_BN_ASM_MONT
+  $BNASM_mips64=$BNASM_mips32
+  $BNDEF_mips64=$BNDEF_mips32
+
+  IF[{- ($target{perlasm_scheme} // '') eq '31' -}]
+    $BNASM_s390x=bn_asm.c s390x-mont.S
+  ELSE
+    $BNASM_s390x=asm/s390x.S s390x-mont.S
+  ENDIF
+  $BNDEF_s390x=OPENSSL_BN_ASM_MONT
+  $BNASM_s390x_ec2m=s390x-gf2m.s
+  $BNDEF_s390x_ec2m=OPENSSL_BN_ASM_GF2m
+
+  $BNASM_armv4=bn_asm.c armv4-mont.S
+  $BNDEF_armv4=OPENSSL_BN_ASM_MONT
+  $BNASM_armv4_ec2m=armv4-gf2m.S
+  $BNDEF_armv4_ec2m=OPENSSL_BN_ASM_GF2m
+
+  $BNASM_aarch64=bn_asm.c armv8-mont.S
+  $BNDEF_aarch64=OPENSSL_BN_ASM_MONT
+
+  $BNASM_parisc11=bn_asm.c parisc-mont.s
+  $BNDEF_parisc11=OPENSSL_BN_ASM_MONT
+  $BNASM_parisc20_64=$BNASM_parisc11
+  $BNDEF_parisc20_64=$BNDEF_parisc11
+
+  $BNASM_ppc32=bn-ppc.s ppc-mont.s
+  $BNDEF_ppc32=OPENSSL_BN_ASM_MONT
+  $BNASM_ppc64=$BNASM_ppc32
+  $BNDEF_ppc64=$BNDEF_ppc32
+
+  $BNASM_c64xplus=asm/bn-c64xplus.asm
+  $BNASM_c64xplus_ec2m=c64xplus-gf2m.s
+  $BNDEF_c64xplus_ec2m=OPENSSL_BN_ASM_GF2m
+
+  # Now that we have defined all the arch specific variables, use the
+  # appropriate ones, and define the appropriate macros
+  IF[$BNASM_{- $target{asm_arch} -}]
+    $BNASM=$BNASM_{- $target{asm_arch} -}
+    $BNDEF=$BNDEF_{- $target{asm_arch} -}
+    IF[{- !$disabled{ec2m} -}]
+      $BNASM=$BNASM $BNASM_{- $target{asm_arch} -}_ec2m
+      $BNDEF=$BNDEF $BNDEF_{- $target{asm_arch} -}_ec2m
+    ENDIF
+    IF[{- !$disabled{sse2} -}]
+      $BNDEF_sse2=$BNDEF $BNDEF_{- $target{asm_arch} -}_sse2
+    ENDIF
+  ENDIF
+ENDIF
+
 $COMMON=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c \
         bn_mod.c bn_conv.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
         bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_sqr.c \
         bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \
         bn_const.c bn_x931p.c bn_intern.c bn_dh.c \
-        bn_rsa_fips186_4.c {- $target{bn_asm_src} -}
+        bn_rsa_fips186_4.c $BNASM
 SOURCE[../../libcrypto]=$COMMON bn_print.c bn_err.c bn_depr.c bn_srp.c
+DEFINE[../../libcrypto]=$BNDEF
 SOURCE[../../providers/fips]=$COMMON
-
+DEFINE[../../providers/fips]=$BNDEF
 
 INCLUDE[../../libcrypto]=../../crypto/include