openssl: Strict C90 CFLAGS results in sha.h:91 ISO C90 does not support long long

Somewhat loosely related to https://github.com/openssl/openssl/issues/8048 wherein we all agree that the codebase is compliant with C90. However while trying a build with strict C90 flags I see :

titan# make 
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" crypto/include/internal/bn_conf.h.in > crypto/include/internal/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" crypto/include/internal/dso_conf.h.in > crypto/include/internal/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
/usr/bin/make depend && /usr/bin/make _all
make[1]: Entering directory '/opt/bw/build/openssl-1.1.1d_debian_sid_i686_5.3.7-genunix.001'
make[1]: Leaving directory '/opt/bw/build/openssl-1.1.1d_debian_sid_i686_5.3.7-genunix.001'
make[1]: Entering directory '/opt/bw/build/openssl-1.1.1d_debian_sid_i686_5.3.7-genunix.001'
/usr/bin/gcc-9  -I. -Iinclude -fPIC -std=c90 -pedantic -pedantic-errors -Wpedantic -fno-builtin -march=i686 -mtune=i686 -Wl,-rpath=/opt/bw/lib,--enable-new-dtags -mpc80 -pthread -Wa,--noexecstack -std=c90 -pedantic -pedantic-errors -Wpedantic -fno-builtin -march=i686 -mtune=i686 -Wl,-rpath=/opt/bw/lib,--enable-new-dtags -mpc80 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSLDIR="\"/opt/bw/ssl\"" -DENGINESDIR="\"/opt/bw/lib/engines-1.1\"" -DNDEBUG -I/opt/bw/include -D_POSIX_PTHREAD_SEMANTICS -D_TS_ERRNO -D_LARGEFILE64_SOURCE -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
In file included from include/openssl/x509.h:30,
                 from apps/apps.h:26,
                 from apps/app_rand.c:10:
include/openssl/sha.h:91:36: error: ISO C90 does not support 'long long' [-Wlong-long]
   91 | #  define SHA_LONG64 unsigned long long
      |                                    ^~~~
include/openssl/sha.h:96:5: note: in expansion of macro 'SHA_LONG64'
   96 |     SHA_LONG64 h[8];
      |     ^~~~~~~~~~
include/openssl/sha.h:91:36: error: ISO C90 does not support 'long long' [-Wlong-long]
   91 | #  define SHA_LONG64 unsigned long long
      |                                    ^~~~
include/openssl/sha.h:97:5: note: in expansion of macro 'SHA_LONG64'
   97 |     SHA_LONG64 Nl, Nh;
      |     ^~~~~~~~~~
include/openssl/sha.h:91:36: error: ISO C90 does not support 'long long' [-Wlong-long]
   91 | #  define SHA_LONG64 unsigned long long
      |                                    ^~~~
include/openssl/sha.h:99:9: note: in expansion of macro 'SHA_LONG64'
   99 |         SHA_LONG64 d[SHA_LBLOCK];
      |         ^~~~~~~~~~
make[1]: *** [Makefile:708: apps/app_rand.o] Error 1
make[1]: Leaving directory '/opt/bw/build/openssl-1.1.1d_debian_sid_i686_5.3.7-genunix.001'
make: *** [Makefile:174: all] Error 2
Command exited with non-zero status 2

titan#

Seems reasonable to re-try that build with no CFLAGS of any particular compliance flavour however I am curious why C90 clean code would have any issue whatsoever?

Dennis

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I think the underlying discussion here is whether or not you have an actual system where we have an issue compiling that we need to address or if this is simply an academic exercise to see what is in place.

We do stick to C90 with certain “extensions” on various platforms to support things like an 8-byte data type as you have noted.

If there is a platform which we aren’t able to compile on to support we are interested in being aware of that and will look at whether or not something needs addressing. We do not have a policy of strict C90 conformance - we stick to the C90 dialect of C for the main code - but do support extensions to allow beyond C90 usage on the range of platforms without adopting the general language extensions of C99.

no response, marking as inactive, to be closed at the end of 3.4 dev barring further input

I have been told repeatedly by various OpenSSL project folks that no one
really cares about the C90 compliance anymore. There are so very many
place where the code veers way far away from C90 and well into some
Brave New World called gnu17. So while I would like to use memcpy to
move around 8-byte data into something that looks like a "long long" or
some other old school way ... no one seems to care. Regardless what the
Project Code Policy clearly states : 

see https://www.openssl.org/policies/technical/coding-style.html

    Chapter 14: Portability

        To maximise portability the version of C defined in
        ISO/IEC 9899:1990 should be used. This is more commonly
        referred to as C90. ISO/IEC 9899:1999 (also known as C99)
        is not supported on some platforms that OpenSSL is
        used on and therefore should be avoided.

However we pretty much know that the project is well outside that spec
in many places.

It would take a lot of effort to get the latest releases to compile and
actually work on some old system where the GCC compiler does not exist.

I know. I have tried over and over and failed over and over. 

If I suggest a strict compliance to a C standard then I get shot at and
told what a terrible person I am to even think that way. 
    https://github.com/openssl/openssl/issues/21718

I would be happy with C99 but that is a no-go no-way also.

So you tell me what the real answer is here?

-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken