[[
Fix build on macOS 11

This serf's commit added headers that I'm now removing:
  r1833227 by Branko Čibej, 2018-06-09 12:05:32
  Fix building with OpenSSL on Windows with non-source layout.

It is unclear why it claims to fix Windows build:
* For me, windows builds just fine, and I'm using OpenSSL 1.1
  with installed layout.
* When header is given, SCons's 'CheckFunc()' doesn't declare function
  This causes "implicit function declaration", which is an error on
  macOS 11 and warning otherwise.
* For everything except 'CRYPTO_set_locking_callback' the provided
  header was a wrong one.
* 'BIO_set_init' is a function with 2 arguments.
  If header was correct, build would fail anyway due to arguments.
  It only succeeds because header is wrong. Windows compiler warns:
        warning C4013: 'BIO_set_init' undefined; assuming extern returning int'

To summarize:
* On Windows/Linux, detection worked with warnings despite wrong header
* On macOS 11, detection failed due to wrong header

Fix this by removing incorrect headers, letting detection work again.
In absence of header, SCons's 'CheckFunc()' injects a function
declaration with 0 arguments.

This fixes the following build error on macOS 11:
buckets/ssl_buckets.c:345:8: error: incomplete definition of type 'struct bio_st'

The build was tested with OpenSSL 1.1.1l (installed layout) on
Win8.1 (VS2013), Ubuntu 21.04, macOS 11

* SConstruct:
  - Add code comments
  - Remove headers from functions with arguments
]]
Index: SConstruct
===================================================================
--- SConstruct  (revision 1893403)
+++ SConstruct  (working copy)
@@ -501,29 +501,56 @@
 
 # Check for OpenSSL functions which are only available in some of
 # the versions we support. Also handles forks like LibreSSL.
+# Note that 'CheckFunc' in scons has the following limitations:
+# * If header is not given, it can't detect function-like macro
+# * If header is given, and function has any arguments, it will fail
+# * If wrong header is given, it will fail on macOS 11 because implicit
+#   function declaration is considered an error there.
 conf = Configure(env)
 if conf.CheckCHeader('openssl/applink.c'):
   env.Append(CPPDEFINES=['SERF_HAVE_OPENSSL_APPLINK_C'])
-if not conf.CheckFunc('BIO_set_init', '#include <openssl/crypto.h>'):
+# OpenSSL 1.1: 2 arg function;    #include <openssl/bio.h>
+# OpenSSL 1.0: Missing
+if not conf.CheckFunc('BIO_set_init'):
   env.Append(CPPDEFINES=['SERF_NO_SSL_BIO_WRAPPERS'])
-if not conf.CheckFunc('X509_STORE_get0_param', '#include <openssl/crypto.h>'):
+# OpenSSL 1.1: 1 arg function;    #include <openssl/x509_vfy.h>
+# OpenSSL 1.0: Missing
+if not conf.CheckFunc('X509_STORE_get0_param'):
   env.Append(CPPDEFINES=['SERF_NO_SSL_X509_STORE_WRAPPERS'])
-if not conf.CheckFunc('X509_get0_notBefore', '#include <openssl/crypto.h>'):
+# OpenSSL 1.1: 1 arg function;    #include <openssl/x509.h>
+# OpenSSL 1.0: Missing
+if not conf.CheckFunc('X509_get0_notBefore'):
   env.Append(CPPDEFINES=['SERF_NO_SSL_X509_GET0_NOTBEFORE'])
-if not conf.CheckFunc('X509_get0_notAfter', '#include <openssl/crypto.h>'):
+# OpenSSL 1.1: 1 arg function;    #include <openssl/x509.h>
+# OpenSSL 1.0: Missing
+if not conf.CheckFunc('X509_get0_notAfter'):
   env.Append(CPPDEFINES=['SERF_NO_SSL_X509_GET0_NOTAFTER'])
-if not conf.CheckFunc('X509_STORE_CTX_get0_chain', '#include 
<openssl/crypto.h>'):
+# OpenSSL 1.1: 1 arg function;    #include <openssl/x509_vfy.h>
+# OpenSSL 1.0: Missing
+if not conf.CheckFunc('X509_STORE_CTX_get0_chain'):
   env.Append(CPPDEFINES=['SERF_NO_SSL_X509_GET0_CHAIN'])
-if not conf.CheckFunc('ASN1_STRING_get0_data', '#include <openssl/crypto.h>'):
+# OpenSSL 1.1: 1 arg function;    #include <openssl/asn1.h>
+# OpenSSL 1.0: Missing
+if not conf.CheckFunc('ASN1_STRING_get0_data'):
   env.Append(CPPDEFINES=['SERF_NO_SSL_ASN1_STRING_GET0_DATA'])
-if conf.CheckFunc('CRYPTO_set_locking_callback', '#include 
<openssl/crypto.h>'):
+# OpenSSL 1.1: 1 arg empty macro; #include <openssl/crypto.h>
+# OpenSSL 1.0: 1 arg function;    #include <openssl/crypto.h>
+if conf.CheckFunc('CRYPTO_set_locking_callback'):
   env.Append(CPPDEFINES=['SERF_HAVE_SSL_LOCKING_CALLBACKS'])
+# OpenSSL 1.1: 0 arg empty macro; #include <openssl/crypto.h>
+# OpenSSL 1.0: Missing
 if conf.CheckFunc('OPENSSL_malloc_init', '#include <openssl/crypto.h>'):
   env.Append(CPPDEFINES=['SERF_HAVE_OPENSSL_MALLOC_INIT'])
+# OpenSSL 1.1: 0 arg macro;       #include <openssl/ssl.h>; requires 
(OPENSSL_API_COMPAT < 0x10100000)
+# OpenSSL 1.0: 0 arg function;    #include <openssl/ssl.h>
 if conf.CheckFunc('SSL_library_init', '#include <openssl/crypto.h>'):
   env.Append(CPPDEFINES=['SERF_HAVE_OPENSSL_SSL_LIBRARY_INIT'])
+# OpenSSL 1.1: 0 arg function;    #include <openssl/crypto.h>
+# OpenSSL 1.0: Missing
 if conf.CheckFunc('OpenSSL_version_num', '#include <openssl/crypto.h>'):
   env.Append(CPPDEFINES=['SERF_HAVE_OPENSSL_VERSION_NUM'])
+# OpenSSL 1.1: 3 arg function;    #include <openssl/ssl.h>
+# OpenSSL 1.0: 3 arg function;    #include <openssl/ssl.h>
 if conf.CheckFunc('SSL_set_alpn_protos'):
   env.Append(CPPDEFINES=['SERF_HAVE_OPENSSL_ALPN'])
 if conf.CheckType('OSSL_HANDSHAKE_STATE', '#include <openssl/ssl.h>'):

Reply via email to