Recipe to install Tango 9 from source on MacOS X high Sierra

@Reynald,
Ok, thanks.
This is a “background task” I work on from time to time. I already applied a couple of workaround related to (my old friend) log4tango. The associated config.h doesn’t seem to be properly generated under macOS (e.g. LOG4TANGO_HAVE_THREADING is not defined). I’m now facing trickier errors (see attached file for details). Anyway, count on me to report any info that could make sense for you guys.

BTW, could you tell a word about the cmake option “USE_PCH”?

EDIT: the reported errors are related to a tango-9-lts compilation attempt using the following compiler config :

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Thanks Nicolas for trying to compile on Mac.
I don’t have one to test.

There is an issue dedicated to that on cppTango: 9.3-backports: Feedback on compiling on MacOSX Sierra · Issue #705 · tango-controls/cppTango · GitHub

Michal created a new issue this morning to use standard threads in log4tango: Remove log4tango/threading utilities · Issue #712 · tango-controls/cppTango · GitHub
When this issue will be fixed, you will no longer have to deal with the LOG4TANGO_HAVE_THREADING issue.

Set USE_PCH to ON if you want to use precompiled headers during the compilation.
This reduces greatly the compilation time.

This feature was introduced by Michal Liszcz in Add support for precompiling server/tango.h (build time reduction) by mliszcz · Pull Request #526 · tango-controls/cppTango · GitHub

Until we fix this deprecation errors, can you try to compile with this compiler option (if it exists in your case)?

-Wno-error=deprecated-declarations

Edit: Sorry. These were already warnings in your case, Nicolas it seems.

Nicolas for the error reported in your attached file, I think it has been fixed by Giacomo in

Please have a look at the change in cppapi/client/lockthread.h file

This is not yet in tango-9-lts branch.

Could you please try compiling using this branch (the one from cppTango#711 PR):

Hey Reynald,
Bingo! The specified branch (ie. delleceste…) compiles smoothly under macOS 10.15.4 using clang 11.0.3 & cmake. Thanks.
Giacomo did a great job. The associated binary distribution can be downloaded from the provided link (see below).
The test suite also compiles without any problem. I tried to run it be most tests failed. I certainly don’t have the required env. to run the test suite properly. Any doc somewhere?

Download cppTango for macOS 10.15.4<.

@Reynald,

I managed to compile [1] and run the tango DB for macOS but I had a problem creating the tables properly using the provided script (i.e. …/share/tango/db/create_db.sh). Consequently, the database fails at startup. At least, I can confirm that, from a binary point of view, everything is ok and ready to run (no crash or whatever so far) [2].
I’m using mysql 8.0.19 (installed using brew) and I had the following error while trying to setup de tango-db tables (create_db.sh):

ERROR 1071 (42000) at line 257 in file: 'create_db_tables.sql': Specified key was too long; max key length is 1000 bytes

This prevents the “hist” tables from being created. Is this a known issue? The TangoDatabase git page makes reference to a “tango_create.sql” script that doesn’t seem to be present in the git repository. Did I missed something?

EDIT: I brewed mariadb and everything works fine. The mariadb part of the tangodb is ok and the DatabaseDS is up and running.

[1] I had to insert using namespace std; right after the #include directives in update_starter.h and to switch from my_bool to bool in DatabaseUtils.cpp (my_bool is deprecated in mysql >= 8). Note that this might be purely mysql related (no such mod. required with mariadb?). I also had to (manually) remove the following linker options (from ./build/CMakefiles/Databaseds.dir/link.txt): -Wl,-z,now -pie (-z generated an error, -pie is unused).

[2] An export DYLD_LIBRARY_PATH=$IP/lib:$IP/bin is required in order to make DatabaseDS start properly - IP being the path to the tango installation directory.

Hi Reynald,

I finally have the Databaseds and a TangoTest instance running under macOS (see attached screenshot).

The Java part is a hack of a Tango-9.2.2 installation I have on a virtual machine.
Here are the main things I’ve done to make it run on macOS:

  • install Oracle JDK (14.0.1)
  • download jboss-rmi-api_1.0_spec-1.0.6.Final.jar, move it to share/java and add the jar the CLASSPATH in the Astor, Jive and LogViewer shell scripts (got some NoClassDefFoundError: javax/rmi/CORBA/Stub)
  • hardcode DISPLAY=0:0 in the Astor and Pogo shell scripts (quick & dirty hack)
  • change the Tango installation path in the shell scripts to /Users/nicolas/tango (quick & dirty hack)

Here is the resulting package.

Nice work Nicolas!

Hey Thomas,
Thanks but everything was almost straightforward after Giacomo’s mods on the kernel.
I’m glad to be able to maintain a link with the community :wink:
Cheers.
N.

BTW, I spent some time trying to run the test suite. Docker has a “special” implementation under macOS [1] and the Tango scripts don’t work out of the box. My main problem is to be able to reach the database instance running into the tango-cs container. [url= Connection refused? Docker networking and how it impacts your image]This article[/url] might be a good starting point to find a workaround. Will see that later…

“This is because on macOS the docker binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively in OS X. So you have to install docker-machine in order to create VM and attach to it”. See here and there for details

EDIT1: IHMO, we need to be able to bind the database process to all network interfaces (inside the container) in order to be able to reach it from macOS. I opened an issue on GitHub.

EDIT2: Thanks to Michal Liszcz, I discovered that I wasn’t passing the port forwarding option (i.e. -p 10000:10000) in the right order to the docker run command.

Ok, the cpp_test_suite is now running under macOS.
Here are the modifications I had to apply to make it work:

1 - cpp_test_suite/environment/setup_database.sh.cmake has beeb modified to specify the appropriate port forwarding option for the database (-p option):

docker run \
    --name "$tango_container" \
    -p 10000:10000 \
    --rm \
    -e TANGO_HOST=127.0.0.1:10000 \
    -e MYSQL_HOST=mysql_db:3306 \
    -e MYSQL_USER=tango \
    -e MYSQL_PASSWORD=tango \
    -e MYSQL_DATABASE=tango \
    --link "$mysql_container":mysql_db \
    -d tangocs/tango-cs:latest \
    > /dev/null

2 - cpp_test_suite/environment/start_server.sh.cmake must be modified in order to insert the server_path into the DYLD_LYBRARY_PATH env. var:

echo "Starting $server/$instance"

export DYLD_LIBRARY_PATH="@PROJECT_BINARY_DIR@/${server_path}":$DYLD_LIBRARY_PATH

"@PROJECT_BINARY_DIR@/${server_path}/${server}" "$instance" -v5 \
    &> "${TANGO_TEST_CASE_DIRECTORY}/${server}_${instance}.${index}.out" &

BTW, whatever is the Tango device server you want to start on macOS, its path (i.e. its location) must be in the DYLD_LIBRARY_PATH - otherwise the runtime can’t resolve the dserver class_factory method (see. “_ZN5Tango7DServer13class_factoryEv” in cppapi/server/class_factory.cpp).

3 - The port forwarding option has an impact on the test suite timing. We now must be sure that the “previous” database container (i.e. the one instanciated for the previous test) has exited and released the port (port 10000 here) before launching the ‘next’ test - otherwise we get the following error: docker: Error response from daemon: driver failed programming external connectivity on endpoint tango_container (…): Bind for 0.0.0.0:10000 failed: port is already allocated.. I consequently had to remove the background execution option (i.e. “&”) in teardown function located in cpp_test_suite/environment/run_with_fixture.sh.cmake.

Here are the cpp_test_suite results I obtain.
I let you guys comment on the severity of the failures - in terms of “missing features on macOS” it could represent to live with them.

92% tests passed, 7 tests failed out of 93

Total Test time (real) = 2691.39 sec

The following tests FAILED:
	  6 - CXX::cxx_dserver_misc (Failed)
	  8 - CXX::cxx_blackbox (Failed)
	  9 - CXX::cxx_class_dev_signal (Failed)
	 10 - CXX::cxx_class_signal (Failed)
	 21 - CXX::cxx_signal (Failed)
	 23 - CXX::cxx_misc (Failed)
	 58 - old_tests::ds_cache (Failed)