[MDEV-28116] Undefined symbol "_SSL_get1_peer_certificate" while building 10.2 and 10.3 on macOS Created: 2022-03-18  Updated: 2022-04-09

Status: Open
Project: MariaDB Server
Component/s: Compiling, SSL
Affects Version/s: 10.2, 10.3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Valerii Kravchuk Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: macos
Environment:

macOS 10.13.6



 Description   

I get the following linking error while building 10.3 from GitHub on macOS 10.13.6 High Sierra:

Yuliyas-MacBook-Air:buildtmp Valerii$ cmake .. -DCMAKE_INSTALL_PREFIX=/Users/Valerii/dbs/maria10.3 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_DTRACE=1 -DWITH_SSL=/opt/local/libexec/openssl11
...
Yuliyas-MacBook-Air:buildtmp Valerii$ time make
...
[ 39%] Building CXX object sql/CMakeFiles/sql.dir/sql_yacc_ora.cc.o
[ 39%] Building CXX object sql/CMakeFiles/sql.dir/threadpool_generic.cc.o
[ 39%] Linking CXX static library libsql.a
[ 40%] Built target sql
[ 40%] Building CXX object unittest/sql/CMakeFiles/explain_filename-t.dir/explain_filename-t.cc.o
[ 40%] Linking CXX executable explain_filename-t
Undefined symbols for architecture x86_64:
  "_SSL_get1_peer_certificate", referenced from:
      acl_authenticate(THD*, unsigned int) in libsql.a(sql_acl.cc.o)
      _send_client_reply_packet in libsql.a(client.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [unittest/sql/explain_filename-t] Error 1
make[1]: *** [unittest/sql/CMakeFiles/explain_filename-t.dir/all] Error 2
make: *** [all] Error 2



 Comments   
Comment by Valerii Kravchuk [ 2022-03-18 ]

Same with 10.2:

...
[ 39%] Building CXX object sql/CMakeFiles/sql.dir/sql_builtin.cc.o
[ 39%] Building CXX object sql/CMakeFiles/sql.dir/sql_yacc.cc.o
[ 39%] Building CXX object sql/CMakeFiles/sql.dir/threadpool_generic.cc.o
[ 39%] Linking CXX static library libsql.a
[ 39%] Built target sql
[ 39%] Building CXX object unittest/sql/CMakeFiles/explain_filename-t.dir/explain_filename-t.cc.o
[ 39%] Linking CXX executable explain_filename-t
Undefined symbols for architecture x86_64:
  "_SSL_get1_peer_certificate", referenced from:
      acl_authenticate(THD*, unsigned int) in libsql.a(sql_acl.cc.o)
      _send_client_reply_packet in libsql.a(client.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [unittest/sql/explain_filename-t] Error 1
make[1]: *** [unittest/sql/CMakeFiles/explain_filename-t.dir/all] Error 2
make: *** [all] Error 2
 
real	14m49.801s
user	12m25.609s
sys	1m19.448s
Yuliyas-MacBook-Air:buildtmp Valerii$ cd ..
Yuliyas-MacBook-Air:server Valerii$ git log -1
commit 22fd31c5883622b5c7451cee74bc5d087d81e112 (HEAD -> 10.2, origin/bb-10.2-bar-MDEV-28078, origin/10.2)
Author: Alexander Barkov <bar@mariadb.com>
Date:   Wed Mar 16 14:37:55 2022 +0400
 
    MDEV-28078 Garbage on multiple equal ENUMs with tricky character sets
    
    TYPELIBs for ENUM/SET columns could erroneously undergo redundant
    hex-unescaping at the table open time.
    
    Fix:
    - Prevent multiple unescaping of the same TYPELIB
    - Prevent sharing TYPELIBs between columns with different mbminlen

Comment by Dmitry Shulga [ 2022-04-09 ]

Didn't manage to reproduce the issue.

It's mentioned in description of the bug report that the linkage error happens
on resolving the symbol _SSL_get1_peer_certificate.

Searching of the function SSL_get1_peer_certificate over every file in the source code repository didn't find any file that contains the symbol SSL_get1_peer_certificate, even as a part of comments.

Attempt to build MariaDB server with the option -DWITH_SSL=/usr/local/opt/openssl on my workstation with macos 12.0.1 (Monterey) has been completed with success.

So, either extra details should be provided to help me reproduce the linking issue in my environment, or close the task.

Comment by Valerii Kravchuk [ 2022-04-09 ]

All I can say is that I still can reproduce in that same environment with current 10.3 from HitHub when this cmake command line is used:

cmake .. -DCMAKE_INSTALL_PREFIX=/Users/Valerii/dbs/maria10.3 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_DTRACE=1 -DWITH_SSL=/opt/local/libexec/openssl11

Indeed, there is no reference to this symbol in the source:

...
[ 39%] Building CXX object sql/CMakeFiles/sql.dir/sql_yacc.cc.o
[ 39%] Building CXX object sql/CMakeFiles/sql.dir/sql_yacc_ora.cc.o
[ 39%] Building CXX object sql/CMakeFiles/sql.dir/threadpool_generic.cc.o
[ 39%] Linking CXX static library libsql.a
[ 40%] Built target sql
[ 40%] Building CXX object unittest/sql/CMakeFiles/explain_filename-t.dir/explain_filename-t.cc.o
[ 40%] Linking CXX executable explain_filename-t
Undefined symbols for architecture x86_64:
  "_SSL_get1_peer_certificate", referenced from:
      acl_authenticate(THD*, unsigned int) in libsql.a(sql_acl.cc.o)
      _send_client_reply_packet in libsql.a(client.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [unittest/sql/explain_filename-t] Error 1
make[1]: *** [unittest/sql/CMakeFiles/explain_filename-t.dir/all] Error 2
make: *** [all] Error 2
 
real	18m41.069s
user	15m1.385s
sys	1m35.073s
Yuliyas-MacBook-Air:buildtmp Valerii$ cd ..
Yuliyas-MacBook-Air:server Valerii$ grep -rni SSL_get1_peer_certificate *
Binary file buildtmp/sql/CMakeFiles/sql.dir/__/sql-common/client.c.o matches
Binary file buildtmp/sql/CMakeFiles/sql.dir/sql_acl.cc.o matches
Binary file buildtmp/sql/libsql.a matches
Yuliyas-MacBook-Air:server Valerii$

So, probably it is from some library linked when building static libsql.a. Maybe opessl3 is linked somehow, as I have both.

Comment by Valerii Kravchuk [ 2022-04-09 ]

There is no problem like this when building with the following cmake command line:

cmake .. -DCMAKE_INSTALL_PREFIX=/Users/Valerii/dbs/maria10.3 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DWITH_EMBEDDED_SERVER=OFF -DPLUGIN_TOKUDB=NO -DWITH_SSL=/opt/local/libexec/openssl11 -DENABLE_DTRACE=1

Generated at Thu Feb 08 09:58:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.