obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
58.82k stars 7.83k forks source link

Linux Build Fails Against 'mbedtls' >=2.18.1 #2261

Closed Chiitoo closed 4 years ago

Chiitoo commented 4 years ago

Expected Behavior

Compiling succeeds.

Current Behavior

FAILED: plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/amf.c.o 
/usr/bin/x86_64-pc-linux-gnu-gcc -DCRYPTO -DHAVE_OBSCONFIG_H -DUSE_MBEDTLS -DUSE_XDG -Dobs_outputs_EXPORTS -Iplugins/obs-outputs/config -I/[...]/libobs -Iconfig  -DNDEBUG -Wall -Wextra -Wvla -Wno-unused-function -Werror-implicit-function-declaration -Wno-missing-braces -Wno-missing-field-initializers -march=znver1 -O2 -fomit-frame-pointer -pipe -mindirect-branch=thunk -std=gnu99 -fno-strict-aliasing -fPIC   -mmmx -msse -msse2 -pthread -fvisibility=hidden -MD -MT plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/amf.c.o -MF plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/amf.c.o.d -o plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/amf.c.o -c /[...]/plugins/obs-outputs/librtmp/amf.c
In file included from /[...]/plugins/obs-outputs/librtmp/amf.c:26:
/[...]/plugins/obs-outputs/librtmp/rtmp_sys.h:110:5: error: unknown type name ‘mbedtls_x509_crt’
  110 |     mbedtls_x509_crt *cacert;
      |     ^~~~~~~~~~~~~~~~
/[...]/plugins/obs-outputs/librtmp/rtmp_sys.h:119:3: error: unknown type name ‘mbedtls_x509_crt’
  119 |   mbedtls_x509_crt cert;
      |   ^~~~~~~~~~~~~~~~

Above can be fixed with a simple '#include <mbedtls/x509_crt.h>', but next there are some -Werror hits:

FAILED: plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/rtmp.c.o 
/usr/bin/x86_64-pc-linux-gnu-gcc -DCRYPTO -DHAVE_OBSCONFIG_H -DUSE_MBEDTLS -DUSE_XDG -Dobs_outputs_EXPORTS -Iplugins/obs-outputs/config -I/[...]/libobs -Iconfig  -DNDEBUG -Wall -Wextra -Wvla -Wno-unused-function -Werror-implicit-function-declaration -Wno-missing-braces -Wno-missing-field-initializers -march=znver1 -O2 -fomit-frame-pointer -pipe -mindirect-branch=thunk -std=gnu99 -fno-strict-aliasing -fPIC   -mmmx -msse -msse2 -pthread -fvisibility=hidden -MD -MT plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/rtmp.c.o -MF plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/rtmp.c.o.d -o plugins/obs-outputs/CMakeFiles/obs-outputs.dir/librtmp/rtmp.c.o -c /[...]/plugins/obs-outputs/librtmp/rtmp.c
In file included from /[...]/plugins/obs-outputs/librtmp/handshake.h:107,
                 from /[...]/plugins/obs-outputs/librtmp/rtmp.c:179:
/[...]/plugins/obs-outputs/librtmp/dh.h: In function ‘DHComputeSharedSecretKey’:
/[...]/plugins/obs-outputs/librtmp/dh.h:360:12: warning: variable ‘len’ set but not used [-Wunused-but-set-variable]
  360 |     size_t len;
      |            ^~~
In file included from /[...]/plugins/obs-outputs/librtmp/rtmp.c:179:
/[...]/plugins/obs-outputs/librtmp/handshake.h: In function ‘HMACsha256’:
/[...]/plugins/obs-outputs/librtmp/handshake.h:311:18: warning: variable ‘digestLen’ set but not used [-Wunused-but-set-variable]
  311 |     unsigned int digestLen;
      |                  ^~~~~~~~~
/[...]/plugins/obs-outputs/librtmp/rtmp.c: In function ‘RTMP_TLS_LoadCerts’:
/[...]/plugins/obs-outputs/librtmp/rtmp.c:291:5: error: implicit declaration of function ‘mbedtls_x509_crt_init’; did you mean ‘mbedtls_x509_crl_init’? [-Werror=implicit-function-declaration]
  291 |     mbedtls_x509_crt_init(chain);
      |     ^~~~~~~~~~~~~~~~~~~~~
      |     mbedtls_x509_crl_init
/[...]/plugins/obs-outputs/librtmp/rtmp.c:347:9: error: implicit declaration of function ‘mbedtls_x509_crt_parse_path’; did you mean ‘mbedtls_x509_crl_parse_file’? [-Werror=implicit-function-declaration]
  347 |     if (mbedtls_x509_crt_parse_path(chain, "/etc/ssl/certs/") != 0) {
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         mbedtls_x509_crl_parse_file
/[...]/plugins/obs-outputs/librtmp/rtmp.c:352:5: error: implicit declaration of function ‘mbedtls_ssl_conf_ca_chain’; did you mean ‘mbedtls_ssl_config_init’? [-Werror=implicit-function-declaration]
  352 |     mbedtls_ssl_conf_ca_chain(&RTMP_TLS_ctx->conf, chain, NULL);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
      |     mbedtls_ssl_config_init
/[...]/plugins/obs-outputs/librtmp/rtmp.c:356:5: error: implicit declaration of function ‘mbedtls_x509_crt_free’; did you mean ‘mbedtls_x509_crl_free’? [-Werror=implicit-function-declaration]
  356 |     mbedtls_x509_crt_free(chain);
      |     ^~~~~~~~~~~~~~~~~~~~~
      |     mbedtls_x509_crl_free
/[...]/plugins/obs-outputs/librtmp/rtmp.c: In function ‘RTMP_TLS_AllocServerContext’:
/[...]/plugins/obs-outputs/librtmp/rtmp.c:441:9: error: implicit declaration of function ‘mbedtls_x509_crt_parse_file’; did you mean ‘mbedtls_x509_crl_parse_file’? [-Werror=implicit-function-declaration]
  441 |     if (mbedtls_x509_crt_parse_file(&tc->cert, cert))
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         mbedtls_x509_crl_parse_file
In file included from /[...]/plugins/obs-outputs/librtmp/rtmp.c:32:
/[...]/plugins/obs-outputs/librtmp/rtmp.c: In function ‘RTMP_TLS_Accept’:
/[...]/plugins/obs-outputs/librtmp/rtmp_sys.h:140:2: error: implicit declaration of function ‘mbedtls_ssl_conf_own_cert’; did you mean ‘mbedtls_ssl_conf_transport’? [-Werror=implicit-function-declaration]
  140 |  mbedtls_ssl_conf_own_cert(ctx->conf, &ctx->cert, &ctx->key);\
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~
/[...]/plugins/obs-outputs/librtmp/rtmp.c:1016:5: note: in expansion of macro ‘TLS_server’
 1016 |     TLS_server(srv_ctx, r->m_sb.sb_ssl);
      |     ^~~~~~~~~~
/[...]/plugins/obs-outputs/librtmp/rtmp_sys.h:141:2: error: implicit declaration of function ‘mbedtls_ssl_conf_dh_param_bin’ [-Werror=implicit-function-declaration]
  141 |  mbedtls_ssl_conf_dh_param_bin(ctx->conf,\
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/[...]/plugins/obs-outputs/librtmp/rtmp.c:1016:5: note: in expansion of macro ‘TLS_server’
 1016 |     TLS_server(srv_ctx, r->m_sb.sb_ssl);
      |     ^~~~~~~~~~
/[...]/plugins/obs-outputs/librtmp/rtmp.c: In function ‘RTMP_Connect1’:
/[...]/plugins/obs-outputs/librtmp/rtmp.c:1063:13: error: implicit declaration of function ‘mbedtls_ssl_set_hostname’; did you mean ‘mbedtls_ssl_session_save’? [-Werror=implicit-function-declaration]
 1063 |         if (mbedtls_ssl_set_hostname(r->m_sb.sb_ssl, hostname))
      |             ^~~~~~~~~~~~~~~~~~~~~~~~
      |             mbedtls_ssl_session_save
/[...]/plugins/obs-outputs/librtmp/rtmp.c:1082:25: error: implicit declaration of function ‘mbedtls_x509_crt_verify_info’; did you mean ‘mbedtls_x509_crl_info’? [-Werror=implicit-function-declaration]
 1082 |                     if (mbedtls_x509_crt_verify_info(err, sizeof(err), "", verify_result) > 0)
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                         mbedtls_x509_crl_info
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.

There's a patch in Gentoo bug 703426 [1], but it looks more like a workaround to me, though I'm not entirely sure about the details.

Steps to Reproduce

  1. Compile OBS Studio against mbedtls >=2.18.1 (2.19.1 also fails).

Additional information

  1. https://bugs.gentoo.org/703426
Xaymar commented 4 years ago

I've encountered this exact problem in #2149. The reason for this error is that when you built mbedtls, you let mbedcrypto overwrite the mbedtls headers with its own version. The mbedcrypto headers are meant as a reference implementation, not as a replacement for mbedtls.

This only appears if you build mbedtls with CMake, and should work fine if mbedtls is built with Make.

Chiitoo commented 4 years ago

A-ha!

So this seems to be an mbedtls upstream issue, and it looks like it's reported there already:

https://github.com/ARMmbed/mbedtls/issues/2965

I guess that leaves the missing include, unless that will also be fixed upstream.

Thanks!

derrod commented 4 years ago

Given that this seems to be an issue with a dependencies upstream I will close this for now. Feel free to reopen if the issue still persists after they fix things.