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

Install robotology-superbuild natively on macOS arm64 (so-called "Apple Silicon") #916

Closed
traversaro opened this issue Nov 6, 2021 · 15 comments · Fixed by #1589
Closed

Comments

@traversaro
Copy link
Member

In the future, the amount of members of the lab or external contributors that may be arm-based mac computers will increase. It will be ideal to get ready for that point, with instructions that explain how to install the robotology-superbuild on macOS arm64 natively. In the mean time, it probably could make sense to clearly document how to install the robotology-superbuild on Rosetta2, but this is tracked in another issue: #915 .

@traversaro
Copy link
Member Author

traversaro commented Nov 6, 2021

First of all, we should track which dependencies are available on macOS on arm64. Due to #842, we are going to track this on conda, even if also Homebrew can install packages on macOS arm64 . We got the dependencies from https://github.com/robotology/robotology-superbuild/blob/8c81b4e310358db602c4fe834d19bf2aed8effa7/doc/conda-forge.md#create-an-environment-and-install-dependencies :

Open source dependencies (provided by conda-forge):
(note: this is checked by going to the https://github.com/conda-forge/<package>-feedstock repo and see if osx-arm64 the listed Platforms)

  • ❌ ace (Add build for macOS arm64 (osx-arm64) conda-forge/ace-feedstock#29)
  • ✔️ asio
  • ✔️ assimp
  • ✔️ boost
  • ✔️ eigen
  • ✔️ gazebo
  • ✔️ glew
  • ✔️ glfw
  • ✔️ gsl
  • ✔️ ipopt
  • ✔️ irrlicht
  • ✔️ libjpeg-turbo
  • ✔️ libmatio
  • ✔️ libode
  • ✔️ libxml2
  • ✔️ nlohmann_json
  • ✔️ opencv
  • ✔️ pkg-config
  • ✔️ portaudio
  • ✔️ qt/qt-main
  • ✔️ sdl
  • ✔️ sdl2
  • ✔️ sqlite
  • ✔️ tinyxml
  • ✔️ spdlog

Closed source dependencies:

@traversaro
Copy link
Member Author

Graph of missing dependencies as of 2021/11/06 from https://conda-forge.org/status/#armosxaddition :
idyntree

@traversaro
Copy link
Member Author

❌ ace (conda-forge/ace-feedstock#29)

As described in the related issue, getting ace to work on osx-arm64 may not be trivial. As most of YARP (except for the serial device and the shmem device) works also without ace, we could just add a ROBOTOLOGY_USES_ACE to disable the use of ACE, that by default is OFF on Apple Silicon.

@traversaro
Copy link
Member Author

The only two missing dependencies are ACE (not a problem as the dependency on ACE of YARP can be skipped) and MATLAB/Simulink.

@traversaro
Copy link
Member Author

Branch that adds ROBOTOLOGY_USES_ACE option that should set to OFF : https://github.com/robotology/robotology-superbuild/tree/skipace .

Deps to install:

mamba install -c conda-forge asio assimp boost eigen gazebo glew glfw graphviz gsl ipopt irrlicht libjpeg-turbo libmatio libode libxml2 nlohmann_json opencv pkg-config portaudio qt-main sdl sdl2 sqlite tinyxml spdlog lua

@traversaro
Copy link
Member Author

I am trying compiling on Apple Silicon, and SKIP_ACE compilation of YARP fails with:

[  2%] Building CXX object src/libYARP_os/src/CMakeFiles/YARP_os.dir/yarp/os/Carrier.cpp.o
In file included from /Users/icub/src/robotology-superbuild/src/YARP/src/libYARP_os/src/yarp/os/Carrier.cpp:8:
In file included from /Users/icub/src/robotology-superbuild/src/YARP/src/libYARP_os/src/yarp/os/impl/TcpFace.h:14:
/Users/icub/src/robotology-superbuild/src/YARP/src/libYARP_os/src/yarp/os/impl/TcpAcceptor.h:19:1: error: Cannot implement TcpAcceptor on this platform
YARP_COMPILER_ERROR(Cannot implement TcpAcceptor on this platform)
^
/Users/icub/src/robotology-superbuild/build/src/YARP/src/libYARP_conf/src/yarp/conf/system.h:108:35: note: expanded from macro 'YARP_COMPILER_ERROR'
  #define YARP_COMPILER_ERROR(x)  __YARP_DO_PRAGMA(GCC error #x)
                                  ^
/Users/icub/src/robotology-superbuild/build/src/YARP/src/libYARP_conf/src/yarp/conf/system.h:105:31: note: expanded from macro '__YARP_DO_PRAGMA'
  #define __YARP_DO_PRAGMA(x) _Pragma (#x)
                              ^
<scratch space>:499:6: note: expanded from here
 GCC error "Cannot implement TcpAcceptor on this platform"
     ^
In file included from /Users/icub/src/robotology-superbuild/src/YARP/src/libYARP_os/src/yarp/os/Carrier.cpp:8:
/Users/icub/src/robotology-superbuild/src/YARP/src/libYARP_os/src/yarp/os/impl/TcpFace.h:46:21: error: no type named 'TcpAcceptor' in namespace 'yarp::os::impl'
    yarp::os::impl::TcpAcceptor peerAcceptor;
    ~~~~~~~~~~~~~~~~^
/Users/icub/src/robotology-superbuild/src/YARP/src/libYARP_os/src/yarp/os/Carrier.cpp:134:12: error: cannot initialize return object of type 'yarp::os::Face *' with an rvalue of type 'yarp::os::impl::TcpFace *'
    return new yarp::os::impl::TcpFace();
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
make[5]: *** [src/libYARP_os/src/CMakeFiles/YARP_os.dir/build.make:132: src/libYARP_os/src/CMakeFiles/YARP_os.dir/yarp/os/Carrier.cpp.o] Error 1
make[4]: *** [CMakeFiles/Makefile2:4198: src/libYARP_os/src/CMakeFiles/YARP_os.dir/all] Error 2
make[3]: *** [Makefile:156: all] Error 2
make[2]: *** [CMakeFiles/YARP.dir/build.make:85: src/YARP/CMakeFiles/YCMStamp/YARP-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:942: CMakeFiles/YARP.dir/all] Error 2
make: *** [Makefile:101: all] Error 2

@traversaro
Copy link
Member Author

The above problem was solved by adding a few || defined(__APPLE__) , however after that I reached the error described in #955 . While not Apple Silicon-specific, any Apple Silicon user will have a recent Xcode, so to actually test Apple Silicon compatibility we need to solve that one first.

@traversaro
Copy link
Member Author

Even by commenting that part, I tried to compile YARP but spawning models based on gazebo-yarp-plugins result in model never being spawned, so it appears that there are still a few problems.

@traversaro
Copy link
Member Author

Fix for CMake:

diff --git a/cmake/RobotologySuperbuildOptions.cmake b/cmake/RobotologySuperbuildOptions.cmake
index 2ddd9fe..a58a8b3 100644
--- a/cmake/RobotologySuperbuildOptions.cmake
+++ b/cmake/RobotologySuperbuildOptions.cmake
@@ -16,8 +16,13 @@ option(ROBOTOLOGY_USES_OCTAVE "Enable compilation of software that depend on Oct
 option(ROBOTOLOGY_USES_LUA "Enable compilation of software that depend on Lua" FALSE)
 mark_as_advanced(ROBOTOLOGY_USES_LUA)
 option(ROBOTOLOGY_USES_PYTHON "Enable compilation of software that depend on Python" FALSE)
-# TODO: set to OFF on macOS on arm64 Apple Silicon
-set(ROBOTOLOGY_USES_ACE_DEFAULT ON)
+# macOS on arm64 Apple Silicon does not support ACE by default, see
+# https://github.com/robotology/robotology-superbuild/issues/916s
+if(APPLE AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
+  set(ROBOTOLOGY_USES_ACE_DEFAULT OFF)
+else()
+  set(ROBOTOLOGY_USES_ACE_DEFAULT ON)
+endif()
 option(ROBOTOLOGY_USES_ACE "Enable compilation of software that depend on ACE" ${ROBOTOLOGY_USES_ACE_DEFAULT})
 mark_as_advanced(ROBOTOLOGY_USES_ACE)

@traversaro
Copy link
Member Author

As clear from https://github.com/robotology/robotology-superbuild/runs/5627657694, the SKIP_ACE + macOS problem is not specific to Apple Silicon but it happens also on macOS + amd64.

@traversaro
Copy link
Member Author

traversaro commented Apr 7, 2022

Beta version available: https://twitter.com/walkingrandomly/status/1512103862198484998?s=20&t=Zw773YISc03-wZuY-nq3rg, MATLAB only for now, no Simulink.

@traversaro
Copy link
Member Author

The above problem was solved by adding a few || defined(__APPLE__) , however after that I reached the error described in #955 . While not Apple Silicon-specific, any Apple Silicon user will have a recent Xcode, so to actually test Apple Silicon compatibility we need to solve that one first.

I submitted a PR upstream in robotology/yarp#2934 .

@traversaro
Copy link
Member Author

@DanielePucci was able to run a iCub simulation on Gazebo Classic, so robotology/yarp#2934 worked fine.

@traversaro
Copy link
Member Author

❌ ace (

This was finally fix in conda-forge/ace-feedstock#29 .

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.

1 participant