smanders / externpro

build external projects with cmake
MIT License
13 stars 12 forks source link

libgit2 update supporting openssl 1.1 #252

Closed smanders closed 5 years ago

smanders commented 5 years ago

to move to OpenSSL 1.1.1c (and away from 1.0.2a) libgit2 (which depends on OpenSSL) need to be updated to a version that supports the new OpenSSL API

OpenSSL 1.1.1c (and 1.0.2a) are both available with https://github.com/smanders/externpro/issues/36

smanders commented 5 years ago

attempting to build the current version of libgit2 (0.22.2) against openssl 1.1.1c with the OPENSSL_API_COMPAT=0x10100000L definition

[  0%] Building C object CMakeFiles/libgit2_clar.dir/src/global.c.o
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c: In function ‘git__shutdown’:
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c:44:3: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing]
   git_global_shutdown_fn cb = git__swap(git__shutdown_callbacks[pos - 1], NULL);
   ^~~~~~~~~~~~~~~~~~~~~~
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c: In function ‘openssl_locking_function’:
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c:59:16: error: ‘CRYPTO_LOCK’ undeclared (first use in this function); did you mean ‘CRYPTO_RWLOCK’?
  lock = mode & CRYPTO_LOCK;
                ^~~~~~~~~~~
                CRYPTO_RWLOCK
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c:59:16: note: each undeclared identifier is reported only once for each function it appears in
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c: In function ‘shutdown_ssl_locking’:
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c:72:14: warning: implicit declaration of function ‘CRYPTO_num_locks’; did you mean ‘CRYPTO_realloc’? [-Wimplicit-function-declaration]
  num_locks = CRYPTO_num_locks();
              ^~~~~~~~~~~~~~~~
              CRYPTO_realloc
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c:73:2: warning: implicit declaration of function ‘CRYPTO_set_locking_callback’; did you mean ‘BIO_set_info_callback’? [-Wimplicit-function-declaration]
  CRYPTO_set_locking_callback(NULL);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  BIO_set_info_callback
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c: In function ‘init_ssl’:
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c:91:2: warning: implicit declaration of function ‘SSL_load_error_strings’; did you mean ‘ERR_load_SSL_strings’? [-Wimplicit-function-declaration]
  SSL_load_error_strings();
  ^~~~~~~~~~~~~~~~~~~~~~
  ERR_load_SSL_strings
/home/smanders/src/tmp/externpro/_bld/xpbase/Source/libgit2/src/global.c:92:2: warning: implicit declaration of function ‘OpenSSL_add_ssl_algorithms’; did you mean ‘SN_id_tc26_algorithms’? [-Wimplicit-function-declaration]
  OpenSSL_add_ssl_algorithms();
  ^~~~~~~~~~~~~~~~~~~~~~~~~~
  SN_id_tc26_algorithms
CMakeFiles/libgit2_clar.dir/build.make:892: recipe for target 'CMakeFiles/libgit2_clar.dir/src/global.c.o' failed
make[2]: *** [CMakeFiles/libgit2_clar.dir/src/global.c.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/libgit2_clar.dir/all' failed
make[1]: *** [CMakeFiles/libgit2_clar.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
smanders commented 5 years ago

changelogs (since v0.22.2)

for information in moving to the newer APIs (API removals and Breaking API changes are especially useful)

smanders commented 5 years ago

completed with commits to dev branch referenced above

smanders commented 5 years ago

link errors using new libgit2

/home/smanders/src/externpro/_bld/externpro_19.06.1-60-gd61e02b-gcc740-64/lib/libgit2_0.28.3.a(openssl.c.o): In function `shutdown_ssl_locking':
openssl.c:(.text+0x145): undefined reference to `CRYPTO_num_locks'
openssl.c:(.text+0x14e): undefined reference to `CRYPTO_set_locking_callback'
/home/smanders/src/externpro/_bld/externpro_19.06.1-60-gd61e02b-gcc740-64/lib/libgit2_0.28.3.a(openssl.c.o): In function `openssl_connect':
openssl.c:(.text+0x6a7): undefined reference to `sk_num'
openssl.c:(.text+0x6f7): undefined reference to `sk_value'
/home/smanders/src/externpro/_bld/externpro_19.06.1-60-gd61e02b-gcc740-64/lib/libgit2_0.28.3.a(openssl.c.o): In function `git_openssl_stream_global_init':
openssl.c:(.text+0xa5f): undefined reference to `SSL_load_error_strings'
openssl.c:(.text+0xa64): undefined reference to `SSL_library_init'
openssl.c:(.text+0xa69): undefined reference to `SSLv23_method'
/home/smanders/src/externpro/_bld/externpro_19.06.1-60-gd61e02b-gcc740-64/lib/libgit2_0.28.3.a(openssl.c.o): In function `git_openssl_set_locking':
openssl.c:(.text+0xbee): undefined reference to `CRYPTO_THREADID_set_callback'
openssl.c:(.text+0xbf3): undefined reference to `CRYPTO_num_locks'
openssl.c:(.text+0xc88): undefined reference to `CRYPTO_set_locking_callback'
/home/smanders/src/externpro/_bld/externpro_19.06.1-60-gd61e02b-gcc740-64/lib/libgit2_0.28.3.a(openssl.c.o): In function `threadid_cb':
openssl.c:(.text+0x1b1): undefined reference to `CRYPTO_THREADID_set_numeric'
collect2: error: ld returned 1 exit status
smanders commented 5 years ago

OpenSSL is added to LIBGIT2_[SYSTEM_INCLUDES|LIBS] https://github.com/libgit2/libgit2/blob/v0.28.3/src/CMakeLists.txt#L197-L198

LIBGIT2_SYSTEM_INCLUDES is used by git2internal target https://github.com/libgit2/libgit2/blob/v0.28.3/src/CMakeLists.txt#L467-L468

LIBGIT2_LIBS isn't used by git2internal target, it is only used in the git2 target https://github.com/libgit2/libgit2/blob/v0.28.3/src/CMakeLists.txt#L485

so the problem is that the git2internal target finds the system openssl (an old version) since the OPENSSL_INCLUDE_DIR is empty now that the include directory is bundled with the externpro::crypto library https://github.com/smanders/externpro/commit/f80241e5618b0ab6087a117f8cd6185d8ef43645

smanders commented 5 years ago

completed with commits to dev branch referenced above