Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling fails on m1 (MacOS Ventura 13.1) #242

Closed
zuzzurro opened this issue Jan 2, 2023 · 8 comments · Fixed by #254
Closed

Compiling fails on m1 (MacOS Ventura 13.1) #242

zuzzurro opened this issue Jan 2, 2023 · 8 comments · Fixed by #254

Comments

@zuzzurro
Copy link

zuzzurro commented Jan 2, 2023

Expected behaviour

Compiling the sources using the instructions provided for MacOS would result in a compiled package

Actual behaviour

Plenty of errors during linking. I think that arm64 on macos is completely unsupported (I see plenty of messages mentioning -arch i386 and/or -arch x86_64 in the output)

Steps to reproduce

  1. /Applications/Xcode.app/Contents/Developer/usr/bin/make osx

Logs

Some lines from the log:

"_vfprintf", referenced from:
_OPENSSL_showfatal in libcrypto.a(cryptlib.o)
"_write$UNIX2003", referenced from:
_raw_write_stdout in apps.o
_conn_write in libcrypto.a(bss_conn.o)
_conn_puts in libcrypto.a(bss_conn.o)
_dgram_write in libcrypto.a(bss_dgram.o)
_fd_write in libcrypto.a(bss_fd.o)
_sock_write in libcrypto.a(bss_sock.o)
_RAND_query_egd_bytes in libcrypto.a(rand_egd.o)
...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@frankmorgner
Copy link
Owner

frankmorgner commented Jan 4, 2023

You need to supply the same flags as you did for OpenSSL. In your case it seems that CFLAGS="-arch x86_64 -arch arm64" LDFLAGS="-arch x86_64 -arch arm64" could solve the problem

@zuzzurro
Copy link
Author

zuzzurro commented Jan 9, 2023

Sorry for being dense but I don't see how to apply your suggestion. I tried passing it before the "make osx" command line as ENV variables but nothing really changed. I see that some CFLAGS are hardcoded in the Makefile.am and I tried changing it there too, but again it did not improve things much.

I guess my question really was about the support status of vsmartcard on arm macs. Also, would it be possible to provide binaries for macos too as it's done for Windows?

Thanks a lot for your patience..

@frankmorgner
Copy link
Owner

OpenSSL prints the compiler flags when configuring it. What is shown as result of ./config for you? If you're using some binary of, say homebrew, you may want to check their build script...

@zuzzurro
Copy link
Author

zuzzurro commented Jan 9, 2023

From what I can see (I checked the config and the Configure files under openssl) the bundled OpenSSL is from 2019 and it has support for stuff like linux-aarch64 and android but not macos...

Maybe support for apple silicon has been added later ..

@kockas
Copy link

kockas commented Feb 15, 2023

Hi, same for me.

Steps for reproduce:

export CFLAGS="-arch x86_64 -arch arm64"
export LDFLAGS="-arch x86_64 -arch arm64"
export PKG_CONFIG_PATH="/opt/homebrew/opt/pcsc-lite/lib/pkgconfig"

Without using homebrews pcsc-lite, configure phase fails as described in #248

autoreconf --verbose --install
autoupdate
./configure --enable-infoplist
make osx

The result however is:

     (maybe you meant: _X509_STORE_CTX_set_time, _TS_RESP_CTX_set_time_cb , _dtls1_handle_timeout , _err_clear_last_constant_time , _SSL_SESSION_get_timeout , _X509_cmp_time , _SSL_SESSION_set_timeout , _tls1_default_timeout , _PKCS7_add0_attrib_signing_time , _ssl3_default_timeout , _s_time_main , _TS_TST_INFO_set_time , _dtls1_check_timeout_num , _dtls1_double_timeout , _X509_time_adj_ex , _dtls1_default_timeout , _dtls1_stop_timer , _dtls1_start_timer , _TS_TST_INFO_get_time , _SSL_CTX_get_timeout , _SSL_SESSION_set_time , _SSL_CTX_set_timeout , _ASN1_UTCTIME_cmp_time_t , _SSL_SESSION_get_time , _dtls1_is_timer_expired , _dtls1_get_timeout , _X509_VERIFY_PARAM_set_time , _SSL_get_default_timeout , _X509_time_adj , _ssl23_default_timeout , _X509_cmp_current_time )
  "_times", referenced from:
      _app_tminterval in apps.o
  "_vfprintf", referenced from:
      _OPENSSL_showfatal in libcrypto.a(cryptlib.o)
  "_write$UNIX2003", referenced from:
      _raw_write_stdout in apps.o
      _conn_write in libcrypto.a(bss_conn.o)
      _conn_puts in libcrypto.a(bss_conn.o)
      _dgram_write in libcrypto.a(bss_dgram.o)
      _fd_write in libcrypto.a(bss_fd.o)
      _sock_write in libcrypto.a(bss_sock.o)
      _RAND_query_egd_bytes in libcrypto.a(rand_egd.o)
      ...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[6]: *** [link_app.] Error 1

Is there any other way, how to pass CFLAGS & LDFLAGS ?
Also, will the result be compatible with both archs?

Thanks.

@dimitry-a-baranov
Copy link

dimitry-a-baranov commented Feb 18, 2023

Hi Frank,

Same reproduced in my MacOS Ventura.

According to OpenSSL 1.0.2 docs, it does not allow building for arm64 architecture and falls back to i386.
Tried to workaround using https://gist.github.com/felixbuenemann/5f4dcb30ebb3b86e1302e2ec305bac89 but no success in the end unfortunately.
Trying to build virtualsmartcard with OpenSSL 1.1.1 threw two major problems:

  • it requires sudo make osx as long as it attempts to copy built files to /Library/OpenPACE (generally not appreciated at build stage)
  • it finally throws fatal error and stops with message bellow
...
checking for gengetopt... /opt/homebrew/bin/gengetopt
configure: WARNING: libcrypto >= 1.0.2 not found by pkg-config
checking for openssl/obj_mac.h... no
configure: error: Required OpenSSL headers not found
make[3]: *** [osx] Error 1
make[2]: *** [osx] Error 2
make[1]: *** [osx] Error 2
make: *** [osx] Error 2

It says it can't find the header files normally symlinked to openssl/crypto/<header name>/<header_file> from /Library/OpenPACE/include/openssl/ while for OpenSSL 1.1.1 they are copied to same directory, however that is the output of one of the test procedures in openpace ./Configure file, around line 13087.
Can you help with fixing the setup for OpenSSL 1.1.1 further on, pls, in order to proceed for MacOS Ventura?

@andr-04
Copy link

andr-04 commented Apr 11, 2023

A lot of hardcoded x86_64 architecture...

I'm not sure all steps are required, but here they are:

  1. ln -s /opt/homebrew/opt/openssl\@1.1/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig/libcrypto.pc
  2. Patch vsmartcard/virtualsmartcard/MacOSX/Makefile.am
index 846375e..0228638 100644
--- a/virtualsmartcard/MacOSX/Makefile.am
+++ b/virtualsmartcard/MacOSX/Makefile.am
@@ -14,14 +14,14 @@ osx: $(OPENPACE_MAKEFILE)
        rm -rf $(OSX_TARGETDIR) dmg $(top_builddir)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)_osx.dmg
        @echo Configuring virtualsmartcard for IFD bundle
        cd $(top_builddir) && ./configure --enable-infoplist --prefix=/Library/VirtualSmartCard \
-               CFLAGS="-arch x86_64" \
+               CFLAGS="-arch arm64" \
                --enable-serialdropdir=/usr$(OSX_SERIAL_LOCAL_PREFIX)/libexec/SmartCardServices/drivers/ifd-vpcd.bundle/Contents/MacOS \
                --enable-serialconfdir=/usr$(OSX_SERIAL_LOCAL_PREFIX)/libexec/SmartCardServices/drivers/ifd-vpcd.bundle/Contents
        @echo Compiling virtualsmartcard
        make -C $(top_builddir) clean install DESTDIR=$(OSX_TARGETDIR)
        @echo Configuring virtualsmartcard for builtin libpcsclite
        cd $(top_builddir) && ./configure --enable-infoplist --prefix=/Library/VirtualSmartCard \
-               CFLAGS="-arch x86_64" \
+               CFLAGS="-arch arm64" \
                --enable-serialdropdir=/usr$(OSX_SERIAL_LOCAL_PREFIX)/libexec/SmartCardServices/drivers/ifd-vpcd.bundle/Contents/MacOS \
                --enable-serialconfdir=/usr$(OSX_SERIAL_LOCAL_PREFIX)/libexec/SmartCardServices/drivers/ifd-vpcd.bundle/Contents \
                --enable-libpcsclite
  1. Patch vsmartcard/virtualsmartcard/MacOSX/openpace/cross/Makefile.am
index 5b9965f..752f257 100644
--- a/cross/Makefile.am
+++ b/cross/Makefile.am
@@ -19,9 +19,7 @@ osx:
        $(MAKE) -C $(top_builddir)/src/openssl
        $(MAKE) -C $(top_builddir)/src/openssl INSTALL_PREFIX=$(OSX_TARGETDIR) install_sw
        cd $(top_builddir) && ./configure --prefix=/Library/OpenPACE \
-               PKG_CONFIG_SYSROOT_DIR=$(OSX_TARGETDIR) \
-               PKG_CONFIG_PATH=$(OSX_TARGETDIR)/Library/OpenPACE/lib/pkgconfig \
-               --enable-python CFLAGS="-arch x86_64" LIBS="-arch x86_64" --disable-shared
+               --enable-python CFLAGS="-arch arm64" LIBS="-arch arm64" --disable-shared
        make -C $(top_builddir) install DESTDIR=$(OSX_TARGETDIR)
        pkgbuild --root $(OSX_TARGETDIR) --scripts MacOSX_install --identifier com.openpace.mac --version $(PACKAGE_VERSION) --install-location / OpenPACE-$(PACKAGE_VERSION)_install.pkg
        pkgbuild --nopayload --identifier com.openpace.mac.uninstall --scripts MacOSX_uninstall Uninstall_OpenPACE.pkg
  1. Patch vsmartcard/virtualsmartcard/MacOSX/openpace/src/Makefile.am
diff --git a/src/Makefile.am b/src/Makefile.am
index 72f8288..ced1cc8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -124,7 +124,7 @@ OPENSSL_LIBS_PRIVATE  = `grep Libs.private $(OPENSSL_DIR)/libcrypto.pc | $(SED)

 # Fetch OpenSSL
 $(OPENSSL_CONFIGURE):
-       $(GIT) clone --depth=100 https://github.com/openssl/openssl.git -b OpenSSL_1_0_2-stable $(OPENSSL_DIR)
+       $(GIT) clone --depth=100 https://github.com/openssl/openssl.git -b OpenSSL_1_1_1-stable $(OPENSSL_DIR)
 #      $(GIT) -C $(OPENSSL_DIR) checkout f243def213b24256db997bb30f729bc23d2c9d0a

 # Configure OpenSSL (and create $(OPENSSL_OBJ_MAC))
  1. Build
autoreconf --verbose --install --symlink
./configure --enable-infoplist --enable-libpcsclite
make osx

VirtualSmartCard-0.8_M1.zip

frankmorgner added a commit that referenced this issue Apr 12, 2023
for now, don't hassle with creating fat ssl binaries by using lipo. just
remove openpace from the binaries for now.

fixes #242
frankmorgner added a commit that referenced this issue Apr 12, 2023
for now, don't hassle with creating fat ssl binaries by using lipo. just
remove openpace from the binaries for now.

fixes #242
@frankmorgner
Copy link
Owner

thanks for the hint. for now, I've disabled linking against openssl (and openpace) to avoid fiddeling around with lipo to create fat binaries (for arm and intel).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants