ossrs/srs

M1: Not possible to build on Apple Silicon

eirenik0 opened this issue · 8 comments

描述(Description)

Not possible to compile on Apple Silicon (m1 pro).
openssl installed and has proper PATH:

export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"
  1. SRS版本(Version): 4

  2. SRS的日志如下(Log):

./configure --osx

      ...
     (maybe you meant: _SCT_get_timestamp, _SCT_set_timestamp , _RAND_DRBG_set_reseed_time_interval , _CT_POLICY_EVAL_CTX_get_time , _PKCS7_add0_attrib_signing_time , _X509_STORE_CTX_set_time , _X509_time_adj , _x509_check_cert_time , _TS_TST_INFO_get_time , _TS_RESP_CTX_set_time_cb , _SSL_CTX_get_timeout , _SSL_CTX_set_timeout , _SSL_SESSION_get_time , _SSL_SESSION_get_timeout , _SSL_SESSION_set_timeout , _SSL_get_default_timeout , _TS_TST_INFO_set_time , _dtls1_check_timeout_num , _dtls1_double_timeout , _dtls1_is_timer_expired , _dtls1_handle_timeout , _dtls1_default_timeout , _tls1_default_timeout , _s_time_options , _SSL_SESSION_set_time , _dtls1_get_timeout , _ASN1_UTCTIME_cmp_time_t , _s_time_main , _CT_POLICY_EVAL_CTX_set_time , _asn1_time_from_tm , _err_clear_last_constant_time , _asn1_time_to_tm , _ssl3_default_timeout , _x509_set1_time , _dtls1_start_timer , _SCT_CTX_set_time , _X509_cmp_current_time , _X509_time_adj_ex , _X509_VERIFY_PARAM_set_time , _set_cert_times , _X509_VERIFY_PARAM_get_time , _X509_cmp_time , _ASN1_TIME_cmp_time_t , _DTLS_set_timer_cb , _dtls1_stop_timer )
  "_times", referenced from:
      _app_tminterval in libapps.a(apps.o)
     (maybe you meant: _SCT_get_timestamp, _SCT_set_timestamp , _set_cert_times )
  "_unlink", referenced from:
      _do_dir in rehash.o
      _s_server_main in s_server.o
      _do_server in libapps.a(s_socket.o)
  "_vfprintf", referenced from:
      _OPENSSL_showfatal in libcrypto.a(cryptlib.o)
  "_vsnprintf", referenced from:
      _log_message in ocsp.o
     (maybe you meant: _BIO_vsnprintf)
  "_waitpid$UNIX2003", referenced from:
      _ocsp_main in ocsp.o
  "_write$UNIX2003", referenced from:
      _conn_write in libcrypto.a(bss_conn.o)
      _conn_puts in libcrypto.a(bss_conn.o)
      _dgram_write in libcrypto.a(bss_dgram.o)
      _sock_write in libcrypto.a(bss_sock.o)
      _raw_write_stdout in libapps.a(apps.o)
      _fd_write in libcrypto.a(bss_fd.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [apps/openssl] Error 1
make: *** [all] Error 2
Build openssl-1.1-fit failed.

./configure --osx --use-sys-ssl

checking whether to enable debug logging in all modules... no
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether to leverage OpenSSL crypto... yes
checking whether to leverage NSS crypto... no
checking for user specified OpenSSL directory... no
checking for crypto... no
configure: error: Package requirements (libcrypto >= 1.0.1) were not met:

No package 'libcrypto' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Aside from openssl build issue, we also need to adapt the ST(state-threads) for Apple M1. Apart from the ST(state-threads) adaption, the configure script would need to be update to identify M1. Grossly simplified, Apple M1 does not work definitely right now.

But as the widely use for new Mac Book, it gains importance to adapt SRS/ST for M1. So the only proper way, is to wait for us to fix it, to avoiding any corruptions. We will also do some test to ensure test cases for different realm could run successfully.

While M1 is ARM arch, which is a separated phenomenon from Intel x86 arch and linux arm/aarch which already works. It's possible to run SRS on all these CPU arch, they are not mutually exclusive. Adaption for ST(states-threads) is used to be awkward work, but now it's very easy with some tools, see ossrs/state-threads#22

Ultimately, it's worth to, and we will fix it.

Hey @winlinvip! How it's going? Is there any news about this issue?

@skhalymon We have the docker image for linux/arm/v7 and linux/arm64/v8, it should work on Apple M1 also, see #3058

However, we will adapt ST to M1 in future, for building and debugging from source code.

@winlinvip I can confirm that docker linux/arm64/v8 works on Mac m1! But build from source doesn't as you said.

  "_syslog$DARWIN_EXTSN", referenced from:
      _ocsp_main in ocsp.o
      _log_message in ocsp.o
      _print_syslog in ocsp.o
  "_tcgetattr", referenced from:
      _open_console in libcrypto.a(ui_openssl.o)
  "_tcsetattr", referenced from:
      _read_string_inner in libcrypto.a(ui_openssl.o)
  "_time", referenced from:
      _s_time_main in s_time.o
      _x509_main in x509.o
      _ASN1_TIME_to_generalizedtime in libcrypto.a(a_time.o)
      _ASN1_TIME_to_tm in libcrypto.a(a_time.o)
      _ASN1_TIME_diff in libcrypto.a(a_time.o)
      _ASN1_TIME_cmp_time_t in libcrypto.a(a_time.o)
      _ASN1_TIME_normalize in libcrypto.a(a_time.o)
      ...
     (maybe you meant: _SCT_get_timestamp, _SCT_set_timestamp , _RAND_DRBG_set_reseed_time_interval , _CT_POLICY_EVAL_CTX_get_time , _PKCS7_add0_attrib_signing_time , _X509_STORE_CTX_set_time , _X509_time_adj , _x509_check_cert_time , _TS_TST_INFO_get_time , _TS_RESP_CTX_set_time_cb , _SSL_CTX_get_timeout , _SSL_CTX_set_timeout , _SSL_SESSION_get_time , _SSL_SESSION_get_timeout , _SSL_SESSION_set_timeout , _SSL_get_default_timeout , _TS_TST_INFO_set_time , _dtls1_check_timeout_num , _dtls1_double_timeout , _dtls1_is_timer_expired , _dtls1_handle_timeout , _dtls1_default_timeout , _tls1_default_timeout , _s_time_options , _SSL_SESSION_set_time , _dtls1_get_timeout , _ASN1_UTCTIME_cmp_time_t , _s_time_main , _CT_POLICY_EVAL_CTX_set_time , _asn1_time_from_tm , _err_clear_last_constant_time , _asn1_time_to_tm , _ssl3_default_timeout , _x509_set1_time , _dtls1_start_timer , _SCT_CTX_set_time , _X509_cmp_current_time , _X509_time_adj_ex , _X509_VERIFY_PARAM_set_time , _set_cert_times , _X509_VERIFY_PARAM_get_time , _X509_cmp_time , _ASN1_TIME_cmp_time_t , _DTLS_set_timer_cb , _dtls1_stop_timer )
  "_times", referenced from:
      _app_tminterval in libapps.a(apps.o)
     (maybe you meant: _SCT_get_timestamp, _SCT_set_timestamp , _set_cert_times )
  "_unlink", referenced from:
      _do_dir in rehash.o
      _s_server_main in s_server.o
      _do_server in libapps.a(s_socket.o)
  "_vfprintf", referenced from:
      _OPENSSL_showfatal in libcrypto.a(cryptlib.o)
  "_vsnprintf", referenced from:
      _log_message in ocsp.o
     (maybe you meant: _BIO_vsnprintf)
  "_waitpid$UNIX2003", referenced from:
      _ocsp_main in ocsp.o
  "_write$UNIX2003", referenced from:
      _conn_write in libcrypto.a(bss_conn.o)
      _conn_puts in libcrypto.a(bss_conn.o)
      _dgram_write in libcrypto.a(bss_dgram.o)
      _sock_write in libcrypto.a(bss_sock.o)
      _raw_write_stdout in libapps.a(apps.o)
      _fd_write in libcrypto.a(bss_fd.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [apps/openssl] Error 1
make: *** [all] Error 2
Build openssl-1.1-fit failed.

Fixed in v5.0.41