Re: Can OpenSSL 3.1.0 be compiled without atomic.h ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/31/23 03:58, Matt Caswell wrote:

.
.
.

Hmmm. Most of the Solaris atomics code in the crypto/threads_pthread.c file seems to be conditioned on detecting Solaris 10 or 11:


Sure enough that is the case. In an old old machine running Solaris 8
one may find that __sun is defined by there is no such thing as
__SunOS_5_8. Not so far as I can detect.


#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{

#if defined(__sun)
    printf("Yes \"__sun\" is defined here.\n");
#endif

#if defined(__SunOS_5_8)
    printf("Yes \"__SunOS_5_8\" is defined here.\n");
#endif

    printf("Did anything work?\n");

    return EXIT_SUCCESS;

}


nix$ /var/tmp/dclarke/foo
Yes "__sun" is defined here.
Did anything work?
nix$

If one were to find __sun but NOT Solaris 10 or Solaris 11 then there
does exist a strange /usr/include/sys/atomic.h which even has the nifty
looking :

    extern uint32_t atomic_add_32_nv(uint32_t *target, int32_t delta);

That would almost fit the bill to perform the atomic delta addition.
However there is no libatomic.so anywhere in the system and I thought
that atomics were well into the C11 world anyways. So yes ... may as
well just walk past that #include <atomic.h> entirely :


# elif defined(__sun) && (defined(__SunOS_5_10) || defined(__SunOS_5_11))

But the include of atomics.h at the top of the file just looks like this:

#if defined(__sun)
# include <atomic.h>
#endif


My guess is modifying that include to have the same check for Solaris 10/11 as used elsewhere might force it through.

$ diff -u ./crypto/threads_pthread.c.orig ./crypto/threads_pthread.c
--- ./crypto/threads_pthread.c.orig     2023-03-14 12:59:07.000000000 +0000
+++ ./crypto/threads_pthread.c  2023-04-03 16:14:14.759595000 +0000
@@ -13,7 +13,7 @@
 #include <openssl/crypto.h>
 #include "internal/cryptlib.h"

-#if defined(__sun)
+#if defined(__sun) && (defined(__SunOS_5_10) || defined(__SunOS_5_11))
 # include <atomic.h>
 #endif

@@ -206,7 +206,7 @@
         return 1;
     }
 # elif defined(__sun) && (defined(__SunOS_5_10) || defined(__SunOS_5_11))
-    /* This will work for all future Solaris versions. */
+    /* This will work for some Solaris versions. */
     if (ret != NULL) {
         *ret = atomic_add_int_nv((volatile unsigned int *)val, amount);
         return 1;
$

So then everything compiles. A whole bucket of tests fail and most of them look like timeouts on this old old machine :

Test Summary Report
-------------------
80-test_ca.t (Wstat: 1280 (exited 5) Tests: 15 Failed: 5)
  Failed tests:  7, 9-10, 12-13
  Non-zero exit status: 5
80-test_cmp_http.t               (Wstat: 1280 (exited 5) Tests: 6 Failed: 5)
  Failed tests:  1-5
  Non-zero exit status: 5
80-test_ssl_new.t (Wstat: 1280 (exited 5) Tests: 30 Failed: 5)
  Failed tests:  4, 7, 11, 16, 18
  Non-zero exit status: 5
Files=250, Tests=2920, 290455 wallclock secs (750.73 usr 26.64 sys + 285107.14 cusr 5006.51 csys = 290891.02 CPU)
Result: FAIL
gmake[1]: *** [Makefile:2448: run_tests] Error 1
gmake[1]: Leaving directory '/opt/bw/build/openssl-3.1.0_SunOS5.8_sun4m.002'
gmake: *** [Makefile:2444: tests] Error 2

So it may not be possible with any gcc from the last decade. Was worth a try.

--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux