New release portability issue
Dennis Clarke
dclarke at blastwave.org
Fri Feb 21 03:19:22 AEDT 2025
--------------------- apology ---------------
Sorry for the resend, myself and Thunderbird are having problems also.
---------------------------------------------
|
| Initially sent 19 Feb 2025 :
|
| On an old Fujitsu SPARC64 server running Solaris 10 there is
| no builtin compiler function for __builtin_popcount. This seems to
| be something new in libcrux_mlkem768_sha3.h header. There was no
| issue with openssh-9.8p1.
|
| The LLVM folks have neat little bit of code that can do the bit
| shifting and adding :
|
|
|
https://github.com/llvm-mirror/compiler-rt/blob/master/lib/builtins/popcountdi2.c
|
| It would be better to use inline asm where the SPARC64 hardware
| does indeed have the popc instruction.
---------------------------------------------
|
| There was a reply from Damien Miller 20 Feb 2025
|
|
| This is weird, because this code has not changed significantly
| since 9.8p1. It's possible that configure might be behaving
| differently, could you try comparing the output of ./configure
| run on each version?
|
================= once more from the top ================
Thank you for the reply and that is a good idea. I shall do that this
morning once the coffee machine begins to work.
In the meanwhile there is the problem with libcrux_mlkem768_sha3.h
which is new. It did not exist in 9.8p1 at all. Neither did the need
for that GCC builtin function.
I have the two versions code extracted here :
sparc64$ ls -lad openssh-9.8p1 openssh-9.9p2
drwxr-xr-x 7 1000 1000 331 Jul 1 2024 openssh-9.8p1
drwxr-xr-x 7 1000 1000 334 Feb 18 08:15 openssh-9.9p2
That new header does not exist in 9.9p2 :
sparc64$ grep -n '__builtin_popcount' openssh-9.8p1/libcrux_mlkem768_sha3.h
grep: openssh-9.8p1/libcrux_mlkem768_sha3.h: No such file or directory
sparc64$
The need for that GCC builting does not exist in 9.8p1 :
sparc64$ find ./openssh-9.8p1 -type f | xargs grep '__builtin_popcount'
sparc64$
It certainly does exist in 9.9p2 :
sparc64$ find ./openssh-9.9p2 -type f | xargs grep '__builtin_popcount'
./openssh-9.9p2/libcrux_mlkem768_sha3.h: return __builtin_popcount(x0);
sparc64$
That can be a bit of a show stopper for a platform without a modern GCC
and in fact, to be even more of a problem, there is no reasonable GCC
version released in half a decade or more. I may be able to port version
gcc-9.5.0 onto the old Fujitsu SPARC64 server. Maybe. However the vendor
Oracle Studio 12.6 developer tools certainly does not recognize that GCC
specific builtin function.
I can easily write a bit-shift and count routine but it would be orders
of magnitude slower than the popc opcode asm inline. Which is likely
what is needed on SPARC64. For example we have this in the GMP math lib
code :
https://gmplib.org/repo/gmp/file/tip/mpn/sparc64/ultrasparct3/popcount.asm
000001 dnl SPARC v9 mpn_popcount for T3/T4.
000002
000003 dnl Contributed to the GNU project by David Miller.
000004
000005 dnl Copyright 2013 Free Software Foundation, Inc.
000006
000007 dnl This file is part of the GNU MP Library.
000008 dnl
000009 dnl The GNU MP Library is free software; you can redistribute
it and/or modify
000010 dnl it under the terms of either:
000011 dnl
000012 dnl * the GNU Lesser General Public License as published by
the Free
000013 dnl Software Foundation; either version 3 of the License,
or (at your
000014 dnl option) any later version.
000015 dnl
000016 dnl or
000017 dnl
000018 dnl * the GNU General Public License as published by the Free
Software
000019 dnl Foundation; either version 2 of the License, or (at
your option) any
000020 dnl later version.
000021 dnl
000022 dnl or both in parallel, as here.
000023 dnl
000024 dnl The GNU MP Library is distributed in the hope that it will
be useful, but
000025 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY
000026 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
000027 dnl for more details.
000028 dnl
000029 dnl You should have received copies of the GNU General Public
License and the
000030 dnl GNU Lesser General Public License along with the GNU MP
Library. If not,
000031 dnl see https://www.gnu.org/licenses/.
000032
000033 include(`../config.m4')
000034
000035 C cycles/limb
000036 C UltraSPARC T3: 15
000037 C UltraSPARC T4: 2.5
000038
000039 C INPUT PARAMETERS
000040 define(`up', `%o0')
000041 define(`n', `%o1')
000042 define(`pcnt', `%o5')
000043
000044 ASM_START()
000045 REGISTER(%g2,#scratch)
000046 REGISTER(%g3,#scratch)
000047 PROLOGUE(mpn_popcount)
000048 subcc n, 1, n
000049 be L(final_one)
000050 clr pcnt
000051 L(top):
000052 ldx [up + 0], %g1
000053 sub n, 2, n
000054 ldx [up + 8], %o4
000055 add up, 16, up
000056 popc %g1, %g2
000057 popc %o4, %g3
000058 add pcnt, %g2, pcnt
000059 brgz n, L(top)
000060 add pcnt, %g3, pcnt
000061 brlz,pt n, L(done)
000062 nop
000063 L(final_one):
000064 ldx [up + 0], %g1
000065 popc %g1, %g2
000066 add pcnt, %g2, pcnt
000067 L(done):
000068 retl
000069 mov pcnt, %o0
000070 EPILOGUE()
However a bit shift and count process in old C90 would get the job done
also. Very very slowly.
--
--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
More information about the openssh-unix-dev
mailing list