crypto/objects/o_names.c problem with Solaris 10 and strict Oracle Studio 12.6 c99

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

crypto/objects/o_names.c problem with Solaris 10 and strict Oracle Studio 12.6 c99

Dennis Clarke-2

Fairly sure I did not run into all these issues with 1.1.1 on the exact
same systems but regardless here we are.  I *know* that I tested every
one of the 'pre' testing versions and have 1.1.1 running fine just about
everywhere.  So here goes the long story with ye strict C99 compiler :

$ env | sort
CC=/opt/developerstudio12.6/bin/c99
CFLAGS=-m64 -xarch=sparc -g -Xc -errfmt=error -erroff=%none
-errshort=full -xstrconst -xildoff -xmemalign=8s -xnolibmil -xcode=pic32
-xregs=no%appl -xlibmieee -mc -ftrap=%none -xbuiltin=%none -xunroll=1
COLUMNS=132
CPPFLAGS=-I/usr/local/include -D_POSIX_PTHREAD_SEMANTICS
-D_LARGEFILE64_SOURCE -D_TS_ERRNO
CXX=/opt/developerstudio12.6/bin/CC
HOME=/export/home/dclarke
LD_OPTIONS=-R/usr/local/lib -L/usr/local/lib
LD_RUN_PATH=/usr/local/lib
LINES=43
LOGNAME=dclarke
MAIL=/var/mail//dclarke
OPENSSL_SOURCE=/usr/local/build/openssl-1.1.1a_SunOS5.10_sparc64vii+.001
PATH=/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/opt/developerstudio12.6/bin:/sbin:/bin:/usr/bin:/usr/sbin
PERL=/usr/local/bin/perl
PWD=/usr/local/build/openssl-1.1.1a_SunOS5.10_sparc64vii+.003
SSH_CLIENT=66.225.151.244 39653 22
SSH_CONNECTION=66.225.151.244 39653 68.179.116.204 22
SSH_TTY=/dev/pts/6
TERM=vt100
TMPDIR=/var/tmp/dclarke
TZ=GMT0
USER=dclarke
_=/usr/xpg4/bin/env



Here we need to modify Configurations/10-main.conf to insert those
CFLAGS for solaris64-sparcv9-cc as well as a few other minor tweaks :


#### Solaris configurations
     "solaris-common" => {
         inherit_from     => [ "BASE_unix" ],
         template         => 1,
         lib_cppflags     => "-DFILIO_H",
         ex_libs          => add("-lsocket -lnsl -ldl -lrt"),
         dso_scheme       => "dlfcn",
         thread_scheme    => "pthreads",
         shared_target    => "self",
         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
         shared_ldflag    => "-Wl,-Bsymbolic",
         shared_defflag   => "-Wl,-M,",
         shared_sonameflag=> "-Wl,-h,",
     },

See ex_libs?  We need -lrt due to a call to a time function embedded
somewhere in the mixture and the easy solution is just add -lrt there.

Really this is a bug that should be filed but I can come back to that.

Now go down to the Solaris with Sun C setups and maybe change that
to "Solaris with Oracle Studio C" setups because it has been almost
a decade.  I want a debug release with all the required symbols and
not stripped.  So let's remove the optimization entirely at line 331
and just have this :


#### SPARC Solaris with Sun C setups
# SC4.0 doesn't pass 'make test', upgrade to SC5.0 or SC4.2.
# SC4.2 is ok, better than gcc even on bn as long as you tell it -xarch=v8
# SC5.0 note: Compiler common patch 107357-01 or later is required!
     "solaris-sparcv7-cc" => {
         inherit_from     => [ "solaris-common" ],
         CC               => "cc",
         CFLAGS           => add_before(picker(debug   => "-g",
                                               release => "-g -xdepend")),
         cflags           => add_before("-xstrconst -Xa"),
         cppflags         => add(threads("-D_REENTRANT")),
         lib_cppflags     => add("-DB_ENDIAN -DBN_DIV2W"),
         lflags           => add(threads("-mt")),
         ex_libs          => add(threads("-lpthread")),
         bn_ops           => "BN_LLONG RC4_CHAR",
         shared_cflag     => "-KPIC",
         shared_ldflag    => add_before("-G -dy -z text"),
     },

Now then, onwards to line 350 or so where we finally find the section
just for solaris64-sparcv9-cc and here we need to throw away that old
deprecated -xarch flag and insert the whole long string :


     "solaris64-sparcv9-cc" => {
         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
         cflags           => add_before("-m64 -xarch=sparc -g -Xc
-errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff -xme
malign=8s -xnolibmil -xcode=pic32 -xregs=no%appl -xlibmieee -mc
-ftrap=%none -xbuiltin=%none -xunroll=1"),
         bn_ops           => "BN_LLONG RC4_CHAR",
         multilib         => "/64",
     },

That works.

We end up with :

corv $ diff -c ./Configurations/10-main.conf.orig
./Configurations/10-main.conf
*** ./Configurations/10-main.conf.orig  Tue Nov 20 13:35:37 2018
--- ./Configurations/10-main.conf       Thu Jan 17 22:24:56 2019
***************
*** 208,214 ****
           inherit_from     => [ "BASE_unix" ],
           template         => 1,
           lib_cppflags     => "-DFILIO_H",
!         ex_libs          => add("-lsocket -lnsl -ldl"),
           dso_scheme       => "dlfcn",
           thread_scheme    => "pthreads",
           shared_target    => "self",
--- 208,214 ----
           inherit_from     => [ "BASE_unix" ],
           template         => 1,
           lib_cppflags     => "-DFILIO_H",
!         ex_libs          => add("-lsocket -lnsl -ldl -lrt"),
           dso_scheme       => "dlfcn",
           thread_scheme    => "pthreads",
           shared_target    => "self",
***************
*** 328,334 ****
           inherit_from     => [ "solaris-common" ],
           CC               => "cc",
           CFLAGS           => add_before(picker(debug   => "-g",
!                                               release => "-xO5
-xdepend")),
           cflags           => add_before("-xstrconst -Xa"),
           cppflags         => add(threads("-D_REENTRANT")),
           lib_cppflags     => add("-DB_ENDIAN -DBN_DIV2W"),
--- 328,334 ----
           inherit_from     => [ "solaris-common" ],
           CC               => "cc",
           CFLAGS           => add_before(picker(debug   => "-g",
!                                               release => "-g -xdepend")),
           cflags           => add_before("-xstrconst -Xa"),
           cppflags         => add(threads("-D_REENTRANT")),
           lib_cppflags     => add("-DB_ENDIAN -DBN_DIV2W"),
***************
*** 349,355 ****
       },
       "solaris64-sparcv9-cc" => {
           inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
!         cflags           => add_before("-xarch=v9"),
           bn_ops           => "BN_LLONG RC4_CHAR",
           multilib         => "/64",
       },
--- 349,355 ----
       },
       "solaris64-sparcv9-cc" => {
           inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
!         cflags           => add_before("-m64 -xarch=sparc -g -Xc
-errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff
-xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl -xlibmieee -mc
-ftrap=%none -xbuiltin=%none -xunroll=1"),
           bn_ops           => "BN_LLONG RC4_CHAR",
           multilib         => "/64",
       },
corv $

Now then nothing works on the old Solaris world without an up to date
perl or at least something not covered in moss and dust thus :

corv $ /usr/local/bin/perl -V | head -1
Summary of my perl5 (revision 5 version 26 subversion 1) configuration:
corv $

Recall that we are going to try strict C99 compliance mode here
therefore CC=/opt/developerstudio12.6/bin/c99 :

corv $ /usr/local/bin/perl ./Configure solaris64-sparcv9-cc 2>&1 | tee
../openssl-1.1.1a_SunOS5.10_sparc64vii+.003.config.log
Configuring OpenSSL version 1.1.1a (0x1010101fL) for solaris64-sparcv9-cc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
corv $

If one tries to view or edit the Makefile then Oracle Solaris 'vi' blows
up because the line length explodes the buffers.  One must use 'vim' or
similar.  Yet another feature of an old old old operating system.  Even
on brand new shiney sparc hardware from Oracle.

Thankfully the Makefile says :

CROSS_COMPILE=
CC=$(CROSS_COMPILE)/opt/developerstudio12.6/bin/c99

CPPFLAGS=-I/usr/local/include -D_POSIX_PTHREAD_SEMANTICS
-D_LARGEFILE64_SOURCE -D_TS_ERRNO
CFLAGS=-m64 -xarch=sparc -g -Xc -errfmt=error -erroff=%none
-errshort=full -xstrconst -xildoff -xmemalign=8s -xnolibmil -xcode=pic32
  -xregs=no%appl -xlibmieee -mc -ftrap=%none -xbuiltin=%none -xunroll=1

PERL=/usr/local/bin/perl


##### Project flags ##################################################

# Variables starting with CNF_ are common variables for all product types

CNF_CPPFLAGS=-D_REENTRANT -DNDEBUG
CNF_CFLAGS=-m64 -xarch=sparc -g -Xc -errfmt=error -erroff=%none
-errshort=full -xstrconst -xildoff -xmemalign=8s -xnolibmil -xcode=p
ic32 -xregs=no%appl -xlibmieee -mc -ftrap=%none -xbuiltin=%none
-xunroll=1 -xstrconst -Xa
CNF_CXXFLAGS=
CNF_LDFLAGS=-mt
CNF_EX_LIBS=-lsocket -lnsl -ldl -lrt -lpthread

We should be okay here.


corv $ echo $PATH
/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/opt/developerstudio12.6/bin:/sbin:/bin:/usr/bin:/usr/sbin
corv $ /usr/xpg4/bin/date '+%Y%m%d%H%M%S'
20190117224215
corv $ /usr/bin/time -p /usr/local/bin/gmake
.
.
.
/opt/developerstudio12.6/bin/c99  -I. -Icrypto/include -Iinclude -KPIC
-m64 -xarch=sparc -g -Xc -errfmt=error -erroff=%none -errshort=full
-xstrconst -xildoff -xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl
-xlibmieee -mc -ftrap=%none -xbuiltin=%none -xunroll=1 -xstrconst -Xa
-m64 -xarch=sparc -g -Xc -errfmt=error -erroff=%none -errshort=full
-xstrconst -xildoff -xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl
-xlibmieee -mc -ftrap=%none -xbuiltin=%none -xunroll=1 -DFILIO_H
-DB_ENDIAN -DBN_DIV2W -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ
-DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM
-DSHA512_ASM -DMD5_ASM -DAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
-DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/ssl\""
-DENGINESDIR="\"/usr/local/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG
-I/usr/local/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE
-D_TS_ERRNO  -c -o crypto/objects/o_names.o crypto/objects/o_names.c
"crypto/objects/o_names.c", line 114: error: undefined symbol: strcasecmp
"crypto/objects/o_names.c", line 114: warning: improper pointer/integer
combination: op "="
"crypto/objects/o_names.c", line 151: warning: implicit function
declaration: strcasecmp
c99: acomp failed for crypto/objects/o_names.c
gmake[1]: *** [Makefile:1642: crypto/objects/o_names.o] Error 2
gmake[1]: Leaving directory
'/usr/local/build/openssl-1.1.1a_SunOS5.10_sparc64vii+.003'
gmake: *** [Makefile:169: all] Error 2

real 513.85
user 408.84
sys 160.27
corv $

Sure enough we see :

    104      for (i = sk_NAME_FUNCS_num(name_funcs_stack); i <
names_type_num; i++) {
    105          CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
    106          name_funcs = OPENSSL_zalloc(sizeof(*name_funcs));
    107          CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
    108          if (name_funcs == NULL) {
    109              OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);
    110              ret = 0;
    111              goto out;
    112          }
    113          name_funcs->hash_func = openssl_lh_strcasehash;
    114          name_funcs->cmp_func = obj_strcasecmp;
    115          CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
    116
    117          push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);
    118          CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
    119
    120          if (!push) {
    121              OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);
    122              OPENSSL_free(name_funcs);
    123              ret = 0;
    124              goto out;
    125          }
    126      }

Well what is "obj_strcasecmp" ?

     24  /*
     25   * We define this wrapper for two reasons. Firstly, later
versions of
     26   * DEC C add linkage information to certain functions, which
makes it
     27   * tricky to use them as values to regular function pointers.
     28   * Secondly, in the EDK2 build environment, the strcasecmp
function is
     29   * actually an external function with the Microsoft ABI, so we
can't
     30   * transparently assign function pointers to it.
     31   */
     32  #if defined(OPENSSL_SYS_VMS_DECC) || defined(OPENSSL_SYS_UEFI)
     33  static int obj_strcasecmp(const char *a, const char *b)
     34  {
     35      return strcasecmp(a, b);
     36  }
     37  #else
     38  #define obj_strcasecmp strcasecmp
     39  #endif
     40

More historical computing perhaps.  I know that I can not recall the
last time I had seen a DEC system running but the OPENSSL_SYS_UEFI looks
suspect to me. At the very least it is a more modern idea.  I just want
a trivial tweak here to test "normal" strcasecmp :

corv $ diff -c crypto/objects/o_names.c.orig crypto/objects/o_names.c
*** crypto/objects/o_names.c.orig       Tue Nov 20 13:35:38 2018
--- crypto/objects/o_names.c    Thu Jan 17 23:03:44 2019
***************
*** 10,16 ****
   #include <stdio.h>
   #include <stdlib.h>
   #include <string.h>
!
   #include <openssl/err.h>
   #include <openssl/lhash.h>
   #include <openssl/objects.h>
--- 10,16 ----
   #include <stdio.h>
   #include <stdlib.h>
   #include <string.h>
! #include <strings.h>
   #include <openssl/err.h>
   #include <openssl/lhash.h>
   #include <openssl/objects.h>
***************
*** 111,117 ****
               goto out;
           }
           name_funcs->hash_func = openssl_lh_strcasehash;
!         name_funcs->cmp_func = obj_strcasecmp;
           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);

           push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);
--- 111,117 ----
               goto out;
           }
           name_funcs->hash_func = openssl_lh_strcasehash;
!         name_funcs->cmp_func = strcasecmp;
           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);

           push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);
corv $

Manually trying a very verbose compile of just that one file puts me
back in a loop and I find this to be odd at the very least :

corv $
corv $ $CC $CFLAGS -I. -Icrypto/include -Iinclude -KPIC \
 > -DFILIO_H -DB_ENDIAN -DBN_DIV2W -DOPENSSL_PIC \
 > -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT \
 > -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM \
 > -DSHA512_ASM -DMD5_ASM -DAES_ASM -DGHASH_ASM \
 > -DECP_NISTZ256_ASM -DPOLY1305_ASM \
 > -DOPENSSLDIR="\"/usr/local/ssl\"" \
 > -DENGINESDIR="\"/usr/local/lib/engines-1.1\"" \
 > -D_REENTRANT -DNDEBUG -I/usr/local/include \
 > -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE \
 > -D_TS_ERRNO \
 > -H -\# -c -o crypto/objects/o_names.o \
 > crypto/objects/o_names.c
### c99: Note: NLSPATH =
/opt/developerstudio12.6/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/developerstudio12.6/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
### c99: Note: TMPDIR = /var/tmp/dclarke
###     command line files and options (expanded):
### -m64 -xarch=sparc
-xdebuginfo=line,param,variable,tagtype,codetag,decl -xglobalize=yes
-xpatchpadding=fix -xkeep_unref=funcs,vars -Xc -errfmt=error
-erroff=%none -errshort=full -xstrconst -xmemalign=8s -xnolibmil
-xregs=no%appl -xlibmieee -mc -ftrap=%none -xbuiltin=%none -xunroll=1
-I. -Icrypto/include -Iinclude -xcode=pic32 -DFILIO_H -DB_ENDIAN
-DBN_DIV2W -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT
-DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM
-DAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM
-DOPENSSLDIR="/usr/local/ssl" -DENGINESDIR="/usr/local/lib/engines-1.1"
-D_REENTRANT -DNDEBUG -I/usr/local/include -D_POSIX_PTHREAD_SEMANTICS
-D_LARGEFILE64_SOURCE -D_TS_ERRNO -H -# -c -ocrypto/objects/o_names.o
crypto/objects/o_names.c
/opt/developerstudio12.6/lib/compilers/bin/acomp -DFILIO_H -DB_ENDIAN
-DBN_DIV2W -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT
-DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM
-DAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM
-DOPENSSLDIR="/usr/local/ssl" -DENGINESDIR="/usr/local/lib/engines-1.1"
-D_REENTRANT -DNDEBUG -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE
-D_TS_ERRNO -H -Qy -Xc -xc99=%all
-features=no%mergestrings,extinl,no%typeof,no%extensions,conststrings,no%zla,no%iddollar,no%gcc_enums
-i crypto/objects/o_names.c -D__SunOS_5_10 -D__SunOS_RELEASE=0x051000
-D__SUNPRO_C=0x5150 -D__unix -D__SVR4__ -D__svr4__ -D__SVR4 -D__sun
-D__sun__ -D__SunOS -D__sparcv9 -D__sparc_v9__ -D__sparc -D__sparc__
-D_LP64 -D__LP64__ -D__arch64__ -D__ORDER_LITTLE_ENDIAN__=1234
-D__ORDER_BIG_ENDIAN__=4321 -D__BYTE_ORDER__=__ORDER_BIG_ENDIAN__
-D__BUILTIN_VA_ARG_INCR -D__C99FEATURES__ -D__PRAGMA_REDEFINE_EXTNAME
-D__FLT_EVAL_METHOD__=0 -D__SUN_PREFETCH -I. -Icrypto/include -Iinclude
-I/usr/local/include -I-xbuiltin
-I/opt/developerstudio12.6/lib/compilers/include/cc -I/usr/xpg6/include
-I/usr/xpg4/include -2K -errfmt=error -erroff=%none -errshort=full
-errwarn=E_CANT_ACCESS_INCLUDE_DIR -xwarn_include_dir=permission
-xbuiltin=%none -strconst -fsimple=0 -m64 -fparam_ir -fparam_ir
-xglobalize=yes -xdebuginfo=line,param,variable,tagtype,codetag,decl
-xkeep_unref=funcs,vars -xF=%none
-xdbggen=dwarf+usedonly+incl+line+param+variable+tagtype+codetag+decl
-xldscope=global -xivdep=loop -xanalyze=code -c99OS
"-g/opt/developerstudio12.6/bin/c99 -m64 -xarch=sparc -g -Xc
-errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff
-xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl -xlibmieee -mc
-ftrap=%none -xbuiltin=%none -xunroll=1 -I. -Icrypto/include -Iinclude
-KPIC -DFILIO_H -DB_ENDIAN -DBN_DIV2W -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ
-DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM
-DSHA512_ASM -DMD5_ASM -DAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
-DPOLY1305_ASM -DOPENSSLDIR='"/usr/local/ssl"'
-DENGINESDIR='"/usr/local/lib/engines-1.1"' -D_REENTRANT -DNDEBUG
-I/usr/local/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE
-D_TS_ERRNO -H -c " -destination_ir=iropt -r
/var/tmp/dclarke/acomp.1547766424.13382.01.ir
/usr/include/stdio.h
         /usr/include/sys/feature_tests.h
                 /usr/include/sys/ccompile.h
                 /usr/include/sys/isa_defs.h
         /usr/include/iso/stdio_iso.h
                 /usr/include/sys/va_list.h
                 /usr/include/stdio_tag.h
                 /usr/include/stdio_impl.h
         /usr/include/iso/stdio_c99.h
/usr/include/stdlib.h
         /usr/include/iso/stdlib_iso.h
         /usr/include/iso/stdlib_c99.h
/usr/include/string.h
         /usr/include/iso/string_iso.h
/usr/include/strings.h
         /usr/include/sys/types.h
                 /usr/include/sys/machtypes.h
                 /usr/include/sys/int_types.h
                 /usr/include/sys/select.h
                         /usr/include/sys/time_impl.h
                         /usr/include/sys/time.h
                                 /usr/include/sys/types.h
                                 /usr/include/time.h
                                         /usr/include/iso/time_iso.h
                                 /usr/include/sys/select.h
include/openssl/err.h
         include/openssl/e_os2.h
                 include/openssl/opensslconf.h
                         include/openssl/opensslv.h
                 /usr/include/inttypes.h
                         /usr/include/sys/inttypes.h
                                 /usr/include/sys/int_limits.h
                                 /usr/include/sys/int_const.h
                                 /usr/include/sys/int_fmtio.h
                         /usr/include/sys/stdint.h
         include/openssl/ossl_typ.h
                 /usr/include/limits.h
                         /usr/include/iso/limits_iso.h
         include/openssl/bio.h
                 /usr/include/stdarg.h
                         /usr/include/iso/stdarg_iso.h
                                 /usr/include/sys/va_impl.h
                         /usr/include/iso/stdarg_c99.h
                 include/openssl/crypto.h
                         include/openssl/safestack.h
                                 include/openssl/stack.h
                         include/openssl/opensslconf.h
                         include/openssl/cryptoerr.h
                                 include/openssl/symhacks.h
                         /usr/include/pthread.h
                                 /usr/include/sched.h
                 include/openssl/bioerr.h
         include/openssl/lhash.h
         /usr/include/errno.h
                 /usr/include/sys/errno.h
include/openssl/objects.h
         include/openssl/obj_mac.h
         include/openssl/asn1.h
                 include/openssl/opensslconf.h
                 include/openssl/asn1err.h
                 include/openssl/bn.h
                         include/openssl/opensslconf.h
                         include/openssl/bnerr.h
         include/openssl/objectserr.h
include/internal/thread_once.h
crypto/include/internal/lhash.h
crypto/objects/obj_lcl.h
./e_os.h
         include/openssl/opensslconf.h
         include/internal/nelem.h
         /usr/include/unistd.h
                 /usr/include/sys/unistd.h
"crypto/objects/o_names.c", line 114: error: undefined symbol: strcasecmp
"crypto/objects/o_names.c", line 114: warning: improper pointer/integer
combination: op "="
"crypto/objects/o_names.c", line 151: warning: implicit function
declaration: strcasecmp
c99: acomp failed for crypto/objects/o_names.c
corv $

The beauty of that flag -H is simply to show every header file involved.
So would love to hear someones thoughts on why strcasecmp suddenly went
missing?

Dennis

ps: even looking through the pre-processed source I see only two lines
     with strcasecmp so I am guessing the real issue is the horrific
     monster typedef struct name_funcs_st NAME_FUNCS;
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: crypto/objects/o_names.c problem with Solaris 10 and strict Oracle Studio 12.6 c99

Michael Wojcik
> From: openssl-users [mailto:[hidden email]] On Behalf Of
> Dennis Clarke
> Sent: Thursday, January 17, 2019 18:23
>
> "crypto/objects/o_names.c", line 114: error: undefined symbol: strcasecmp
> "crypto/objects/o_names.c", line 114: warning: improper pointer/integer
> combination: op "="
> "crypto/objects/o_names.c", line 151: warning: implicit function
> declaration: strcasecmp

Note the issue here is an undefined symbol, which consequently has an implicit definition as an int with external linkage and static duration. So we're talking about a header problem, not a library problem.

> So would love to hear someones thoughts on why strcasecmp suddenly went
> missing?

Well...

strcasecmp is a heresy. The C specification (ISO 9899) does not include strcasecmp, and reserves all identifiers with external linkage beginning with "str" for the library.

The *correct* way to do case-insensitive string comparisons in C is to write your own using the ctype.h functions (though it's tricky to get this right, due to the signed-char Undefined Behavior problem), with a name that doesn't infringe on a reserved part of the namespace. Or use a library which provides the same.

Unfortunately, strcasecmp was invented before C was standardized (as part of the BSD 4.something implementation, maybe?), and consequently gained too much traction to ever go away. Then it was standardized by XPG4, just to make things more difficult. And thus it's part of the Single UNIX Specification, even though the SUS has language about not conflicting with ISO 9899. Everyone just looks the other way and whistles quietly to themselves when they come across it.

*Consequently*, under Open Group Base Specifications Issue 7 (the latest version of SUS), to get a definition for strcasecmp you have to include <strings.h>. Note the second "s". <string.h> is the ISO C header for things like strcmp; <strings.h> is the SUS header for strcasecmp and other look-like-standard-C-but-aren't string functions. There's no way anyone would ever confuse the two.

Normally, the Solaris headers (at least for 10.2, which is what I'm logged into at the moment) include string.h in strings.h and vice versa, to hide this abomination from the eyes of the innocent. But those inclusions are wrapped in all manner of ifdeffery which I am not about to try to untangle.

Now, we see in the output you included in your note that you are getting strings.h in o_names.c. So that should be OK, yes?

But of course the declaration of strcasecmp in strings.h is itself ifdeffed. To get it, _XPG4_2 must be defined, and __EXTENSIONS__ must NOT be defined.

My guess is you're falling foul of one of those two conditions, when you compile in strict mode.

The simplest fix would be to whack a declaration of strcasecmp into the source file itself, but that's inelegant and hard to maintain - presumably you'd rather do something through the OpenSSL configure process. As for that, well... the only thing that comes to mind is something like:

1. Add -Dstrcasecmp=cmpstrci to the compiler flags
2. Add -lcmpstrci to the link flags
3. Create a little libcmpstrci.a (no need for it to be a shared object) with a case-insensitive string comparison function named cmpstrci. It can use strcasecmp if it must, or you can implement your own.

Or the problem might be something else, of course, but the fact that strings.h does appear in the output but strcasecmp isn't declared does suggest the conditional-compilation in strings.h is to blame.

--
Michael Wojcik
Distinguished Engineer, Micro Focus


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: crypto/objects/o_names.c problem with Solaris 10 and strict Oracle Studio 12.6 c99

Dennis Clarke-2
On 1/17/19 8:25 PM, Michael Wojcik wrote:

>> From: openssl-users [mailto:[hidden email]] On Behalf Of
>> Dennis Clarke
>> Sent: Thursday, January 17, 2019 18:23
>>
>> "crypto/objects/o_names.c", line 114: error: undefined symbol: strcasecmp
>> "crypto/objects/o_names.c", line 114: warning: improper pointer/integer
>> combination: op "="
>> "crypto/objects/o_names.c", line 151: warning: implicit function
>> declaration: strcasecmp
>
> Note the issue here is an undefined symbol, which consequently has an implicit definition as an int with external linkage and static duration. So we're talking about a header problem, not a library problem.
>
>> So would love to hear someones thoughts on why strcasecmp suddenly went
>> missing?
>
> Well...
>
> strcasecmp is a heresy.

Love it.

I knew something like this was in the air and I could smell it :-)

<snip>
>
> But of course the declaration of strcasecmp in strings.h is itself ifdeffed.
To get it, _XPG4_2 must be defined, and __EXTENSIONS__ must NOT be defined.

Full moon black cat ifdeffery crud here we go.

>
> My guess is you're falling foul of one of those two conditions, when you compile in strict mode.
>
> The simplest fix would be to whack a declaration of strcasecmp into the source file itself

Yeah .. that's icky.

> but that's inelegant and hard to maintain - presumably you'd rather do something through the OpenSSL configure process. As for that, well... the only thing that comes to mind is something like:
>
> 1. Add -Dstrcasecmp=cmpstrci to the compiler flags
> 2. Add -lcmpstrci to the link flags
> 3. Create a little libcmpstrci.a (no need for it to be a shared object) with a case-insensitive string comparison function named cmpstrci. It can use strcasecmp if it must, or you can implement your own.
>
> Or the problem might be something else, of course, but the fact that strings.h does appear in the output but strcasecmp isn't declared does suggest the conditional-compilation in strings.h is to blame.
>

Thank you for the great reply where clearly you have seen ifdeffery
nonsense bite you.  I get caught between a rock and a hrd place here
every time because if I try to go with just ordinary cc and just some
transition loosey goosey not-really-compliant or strict CFLAGS then I
arrive in a different ugly place :


${LDCMD:-/opt/developerstudio12.6/bin/cc} -m64 -xarch=sparc -g -Xa
-errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff
-xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl -xlibmieee -mc
-ftrap=%none -xbuiltin=%none -xunroll=1 -xstrconst -Xa -m64 -xarch=sparc
-g -Xa -errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff
-xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl -xlibmieee -mc
-ftrap=%none -xbuiltin=%none -xunroll=1 -L. -mt  \
         -o test/rsa_complex test/rsa_complex.o \
          -lsocket -lnsl -ldl -lrt -lpthread
Undefined                       first referenced
  symbol                             in file
OPENSSL_sk_pop_free                 test/rsa_complex.o
OPENSSL_sk_dup                      test/rsa_complex.o
OPENSSL_sk_pop                      test/rsa_complex.o
OPENSSL_sk_num                      test/rsa_complex.o
OPENSSL_sk_new                      test/rsa_complex.o
OPENSSL_sk_set                      test/rsa_complex.o
OPENSSL_sk_free                     test/rsa_complex.o
OPENSSL_sk_find                     test/rsa_complex.o
OPENSSL_sk_push                     test/rsa_complex.o
OPENSSL_sk_sort                     test/rsa_complex.o
OPENSSL_sk_zero                     test/rsa_complex.o
OPENSSL_sk_is_sorted                test/rsa_complex.o
OPENSSL_sk_shift                    test/rsa_complex.o
OPENSSL_sk_value                    test/rsa_complex.o
OPENSSL_sk_delete_ptr               test/rsa_complex.o
OPENSSL_sk_unshift                  test/rsa_complex.o
OPENSSL_sk_new_null                 test/rsa_complex.o
OPENSSL_sk_set_cmp_func             test/rsa_complex.o
OPENSSL_sk_reserve                  test/rsa_complex.o
OPENSSL_sk_new_reserve              test/rsa_complex.o
OPENSSL_sk_delete                   test/rsa_complex.o
OPENSSL_sk_insert                   test/rsa_complex.o
OPENSSL_sk_deep_copy                test/rsa_complex.o
OPENSSL_sk_find_ex                  test/rsa_complex.o
ld: fatal: symbol referencing errors. No output written to test/rsa_complex
gmake[1]: *** [Makefile:3561: test/rsa_complex] Error 2
gmake[1]: Leaving directory
'/usr/local/build/openssl-1.1.1a_SunOS5.10_sparc64vii+.004'
gmake: *** [Makefile:169: all] Error 2

Looks like getting a debug non-optimized library will be a major pain.

Dennis
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: crypto/objects/o_names.c problem with Solaris 10 and strict Oracle Studio 12.6 c99

Michael Wojcik
> From: openssl-users [mailto:[hidden email]] On Behalf Of
> Dennis Clarke
> Sent: Thursday, January 17, 2019 23:56
>
> Thank you for the great reply where clearly you have seen ifdeffery
> nonsense bite you.  I get caught between a rock and a hrd place here
> every time because if I try to go with just ordinary cc and just some
> transition loosey goosey not-really-compliant or strict CFLAGS then I
> arrive in a different ugly place :
>
>
> ${LDCMD:-/opt/developerstudio12.6/bin/cc} -m64 -xarch=sparc -g -Xa
> -errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff
> -xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl -xlibmieee -mc
> -ftrap=%none -xbuiltin=%none -xunroll=1 -xstrconst -Xa -m64 -xarch=sparc
> -g -Xa -errfmt=error -erroff=%none -errshort=full -xstrconst -xildoff
> -xmemalign=8s -xnolibmil -xcode=pic32 -xregs=no%appl -xlibmieee -mc
> -ftrap=%none -xbuiltin=%none -xunroll=1 -L. -mt  \
>          -o test/rsa_complex test/rsa_complex.o \
>           -lsocket -lnsl -ldl -lrt -lpthread
> Undefined                       first referenced
>   symbol                             in file
> OPENSSL_sk_pop_free                 test/rsa_complex.o [etc]

Am I missing something, or is this just because Configure somehow gave you a makefile for the tests that doesn't actually link the OpenSSL libraries? There's just libsocket, libnsl, libdl, librt, and libpthread there.

I don't know how that would have happened, but I haven't looked at the Configure for 1.1.1 as closely as I have the 1.0.2. (I was primarily responsible for hacking my team's OpenSSL builds for the 1.0.2 line, but a different developer for 1.1.1 implemented our move to that release.)

It appears for our Solaris 11 SPARC build of 1.1.1 we're using stock OpenSSL Configure with "solaris-sparcv9-gcc" as the target (or solaris64-sparcv9-gcc for 64-bit builds). If memory serves, we used to use the Sun/Oracle implementation (SUNWspro) in older products, but that would have been with OpenSSL 1.0.2 or possibly earlier. I'm not sure when we switched to gcc on Solaris. So unfortunately I don't have any more-specific advice for building 1.1.1 using the Developer Studio toolchain.

--
Michael Wojcik
Distinguished Engineer, Micro Focus



--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users