Commit 15910ad44a for openssl.org

commit 15910ad44aa470feaf38a8f984cbb81e31079e86
Author: Nikola Pajkovsky <nikolap@openssl.org>
Date:   Wed Dec 2 09:29:14 2026 +0100

    Configurations: pass -B 8192 to m4 on Solaris

    Commit a1e8bb9c428e ("Configurations: drop legacy SVR4 -B flag
    from m4 generated-assembly rules") removed "-B 8192" from the m4
    command used to generate crypto/des/des_enc-sparc.S, so that BSD m4
    could process des_enc.m4.  However, the System V m4 shipped with Solaris
    limits macro arguments to 4096 bytes by default, and rounds_macro
    in des_enc.m4 is about 6.8 KB, so the Solaris SPARC build now fails
    with:

        m4:crypto/des/asm/des_enc.m4:424 more than 4096 chars of argument
        text

    Introduce a per-target "m4flags" attribute, which is passed to m4
    by the Makefile (as M4FLAGS) and Ninja generators, and set it
    to "-B 8192" for Solaris targets only.  Other targets keep calling m4
    without any flag.

    Fixes: a1e8bb9c428e "Configurations: drop legacy SVR4 -B flag from m4 generated-assembly rules"
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Reviewed-by: Saša NedvÄ›dický <sashan@openssl.org>
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Merge-date: Fri Dec  4 04:48:29 2026
    Merged-from: https://github.com/openssl/openssl/pull/34142

diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
index b9be2737d2..6a9ffe58d0 100644
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -155,6 +155,10 @@ my %targets = (
         ex_libs          => add("-lsocket -lnsl -ldl"),
         dso_scheme       => "dlfcn",
         thread_scheme    => "pthreads",
+        # The System V m4 shipped with Solaris limits macro arguments
+        # to 4096 bytes by default, which is too small for
+        # crypto/des/asm/des_enc.m4.
+        m4flags          => "-B 8192",
     },
 #### Solaris common with Sun C setups
     "solaris-common-cc" => {
diff --git a/Configurations/README.md b/Configurations/README.md
index 0af73fc9c1..3057c3a7af 100644
--- a/Configurations/README.md
+++ b/Configurations/README.md
@@ -174,6 +174,8 @@ In each table entry, the following keys are significant:
         perlasm_scheme  => The perlasm method used to create the
                            assembler files used when compiling with
                            assembler implementations.
+        m4flags         => Extra flags passed to m4 when generating
+                           assembler files from .m4 sources.
         shared_target   => The shared library building method used.
                            This serves multiple purposes:
                            - as index for targets found in shared_info.pl.
diff --git a/Configurations/build.ninja.tmpl b/Configurations/build.ninja.tmpl
index 25db47b1a9..1100d5b14f 100644
--- a/Configurations/build.ninja.tmpl
+++ b/Configurations/build.ninja.tmpl
@@ -795,7 +795,9 @@ build reconfigure reconf: run_console
                      .$cppflags.$defs.' '.$config{processor}.' '
                      .cmd_quote($args{src});
           } elsif ($gen0 =~ /\.m4$/) {
-              $cmd = 'm4'.$gen_incs.' '.cmd_quote($gen0).$gen_args
+              $cmd = 'm4'
+                     .($target{m4flags} ? ' '.$target{m4flags} : '')
+                     .$gen_incs.' '.cmd_quote($gen0).$gen_args
                      .' > '.cmd_quote($args{src});
           } elsif ($gen0 =~ /\.S$/) {
               $cmd = $cc.' '.$incs.' '.$cppflags.$defs.' -E '
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index d1fc35908c..7f1a0bd7be 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -586,6 +586,8 @@ CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;

 PERLASM_SCHEME= {- $target{perlasm_scheme} -}

+M4FLAGS= {- $target{m4flags} // '' -}
+
 # For x86 assembler: Set PROCESSOR to 386 if you want to support
 # the 80386.
 PROCESSOR= {- $config{processor} -}
@@ -1755,7 +1757,7 @@ EOF
               $generator = 'CC="$(CC)" $(PERL)'.$gen_incs.' '.$gen0.$gen_args
                   .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)';
           } elsif ($gen0 =~ /\.m4$/) {
-              $generator = 'm4'.$gen_incs.' '.$gen0.$gen_args;
+              $generator = 'm4 $(M4FLAGS)'.$gen_incs.' '.$gen0.$gen_args;
               $to_stdout = 1;
           } elsif ($gen0 =~ /\.S$/) {
               $generator = undef;
diff --git a/Configure b/Configure
index 3bba7dab65..f773a0356c 100755
--- a/Configure
+++ b/Configure
@@ -3816,6 +3816,7 @@ sub print_table_entry
         "poly1035_asm_src",
         "thread_scheme",
         "perlasm_scheme",
+        "m4flags",
         "dso_scheme",
         "shared_target",
         "shared_cflag",
diff --git a/crypto/des/asm/des_enc.m4 b/crypto/des/asm/des_enc.m4
index 8365578a19..1dd61bc768 100644
--- a/crypto/des/asm/des_enc.m4
+++ b/crypto/des/asm/des_enc.m4
@@ -6,6 +6,7 @@
 ! https://www.openssl.org/source/license.html
 !
 !  To expand the m4 macros: m4 des_enc.m4 > des_enc.S
+!  (the System V m4 on Solaris needs -B 8192 to handle rounds_macro)
 !
 !  Global registers 1 to 5 are used. This is the same as done by the
 !  cc compiler. The UltraSPARC load/store little endian feature is used.