Topic: "Size of unsigned long long not detected"

Hello.
I am using the TI CCS environment, the GCC compiler (linero) version 7.3

When compiling a "C" file, I get no errors.
When compiling a "CPP" file, I get the following:

In file included from C:/../projects/WolfSSL-4-7/Wolf/wolfssl/wolfcrypt/ecc.h:56:0,
                 from C:/../projects/WolfSSL-4-7/Wolf/wolfssl/openssl/ec.h:19,
                 from C:/../projects/WolfSSL-4-7/Wolf/wolfssl/openssl/evp.h:40,
                 from C:/../projects/WolfSSL-4-7/Wolf/wolfssl/openssl/hmac.h:28,
                 from C:/../projects/WolfSSL-4-7/Wolf/wolfssl/ssl.h:80,
                 from ../filename.cpp:22:
C:/../projects/WolfSSL-4-7/Wolf/wolfssl/wolfcrypt/sp_int.h:127:6: error: #error "Size of unsigned long long not detected"
     #error "Size of unsigned long long not detected"
      ^~~~~
C:/../projects/WolfSSL-4-7/Wolf/wolfssl/wolfcrypt/sp_int.h:236:14: error: 'sp_uint64' does not name a type; did you mean 'sp_uint32'?
     typedef  sp_uint64  sp_int_word;
              ^~~~~~~~~
              sp_uint32
C:/../projects/WolfSSL-4-7/Wolf/wolfssl/wolfcrypt/sp_int.h:237:15: error: 'sp_int64' does not name a type; did you mean 'sp_int32'?
     typedef   sp_int64  sp_int_sword;
               ^~~~~~~~
               sp_int32

Among all the other settings I have in "user_settings.h" there are these:

#define OPENSSL_EXTRA        /*   */
    #define NO_64BIT

    #define SIZEOF_LONG_LONG 8
    #define NO_ERROR_STRINGS
    #define FP_MAX_BITS 8192        /*  Increase for 4096 bit key */
    #define HAVE_ECC
    #define HAVE_ALPN
    #define USE_WOLF_STRTOK /* use with HAVE_ALPN */

If the compiler doesn't know what a type sp_int64 is, and the #define NO_64BIT doesn't solve it, what is the solution?

-Scott
<Code shown is not to scale>

Share

Re: "Size of unsigned long long not detected"

Hi Scott,

Does the source file include `wolfssl/wolfcrypt/settings.h`?

3 (edited by Scotty2541 2021-05-27 11:41:16)

Re: "Size of unsigned long long not detected"

embhorn wrote:

Hi Scott,

Does the source file include `wolfssl/wolfcrypt/settings.h`?

Yes.  I've been going down these rabbit hopes for days...

Now, here's the latest:
I MODIFED your "sp_int.h" files at line 104 as follows:

#ifdef ULLONG_MAX
    #warning "It IS defined"
#else
    #warning "It IS NOT defined"
#endif


#if ULLONG_MAX == 18446744073709551615ULL
    #define SP_ULLONG_BITS    64

    #if SP_ULLONG_BITS > SP_ULONG_BITS
    ...

And guess what...?
When I compile a "C" files, I get:

C:/.../projects/WolfSSL-4-7/Wolf/wolfssl/wolfcrypt/sp_int.h:106:3: warning: #warning "It IS defined" [-Wcpp]
  #warning "It IS defined"

But when I compile a CPP file I get:

C:/.../projects/WolfSSL-4-7/Wolf/wolfssl/wolfcrypt/sp_int.h:108:3: warning: #warning "It IS NOT defined" [-Wcpp]
  #warning "It IS NOT defined"

Somehow, the GCC Linaro compiler that TI distributes with CCS is not finding the ULLONG_MAX

Both files simply use

#include <wolfssl/ssl.h>
-Scott
<Code shown is not to scale>

Share

Re: "Size of unsigned long long not detected"

Hi Scott,

There is some logic in SP to try and determine the type sizes. They depend on the system checking the *_MAX values. Please try adding define

    #undef ULLONG_MAX
    #define ULLONG_MAX 18446744073709551615ULL

Re: "Size of unsigned long long not detected"

embhorn wrote:

Hi Scott,

There is some logic in SP to try and determine the type sizes. They depend on the system checking the *_MAX values. Please try adding define

    #undef ULLONG_MAX
    #define ULLONG_MAX 18446744073709551615ULL

Yeah, I was thinking of doing a hack this way, but I want to fix it properly...  It works for a C file, not for a CPP file, in the same project.

I'm going down that rat-hole too... 
It's spaghetti trying to follow all the #include <limits.h> which are all over the place,
and which have #include_next <limits.h> all over the place.

Because your sp_int.h directive to #include <limits.h> is not pulling in the header that it's supposed to. It's pulling in one that is not in any -I path.

No idea how THAT is happening in the TI SYSBIOS world using the linaro compiler...  Wasted a day already trying to figure out how it's been broken.

-Scott
<Code shown is not to scale>

Share

Re: "Size of unsigned long long not detected"

Hi Scotty2541

The file sp_int.h has been updated in the latest master.

Please let me know if the changes help.

Thanks,
Sean

--
Sean Parkinson, wolfSSL
Senior Software Engineer

Share

Re: "Size of unsigned long long not detected"

Sean,
Updated to what?

Just "grabbing the latest" is not a solution. It takes months of integrating and regression testing.  I can't just drop a new package in during the middle of that process.

I added my own definition in the user_settings.h file because the limits.h file that GCC Linaro uses (which TI distributes) is broken.  It doesn't have ANY definition for ULLONG_MAX under the C++, while it does under C

Both C and C++ do, however, have a definition for __UINT64_MAX__ , so I used it to define ULLONG_MAX

Of course, the TI 17.3 compiler freaks out at that...  Sheesh.
(we are trying to migrate off the TI unsupported compiler to GCC)

-Scott
<Code shown is not to scale>

Share