Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Allow turning shared library building off #758

Merged

Conversation

t-b
Copy link
Collaborator

@t-b t-b commented Aug 28, 2020

Close #740.

t-b added 4 commits August 28, 2020 12:33
In 4791f0d (Rework static/shared variants into a configure-time
build-switch (tango-controls#688), 2020-05-28) the option TANGO_BUILD_SHARED was added
to select a shared or static library.

Internally BUILD_SHARED_LIBS was already set to the same value.

Switching to BUILD_SHARED_LIBS and dropping TANGO_BUILD_SHARED allows us
to replace a specialized option with the default one [1].

[1]: https://cmake.org/cmake/help/v3.18/command/add_library.html#command:add_library
It does not make sense to check

if(A)
...
elseif(A)
...
endif()

so let's change the elseif to an else.
This is confusing and legacy according to [1]:

Per legacy, the else() and endif() commands admit an optional
<condition> argument. If used, it must be a verbatim repeat of the
argument of the opening if command.

[1]: https://cmake.org/cmake/help/v3.18/command/if.html#command:if
Remove trailing whitespace and empty lines at the front and back of the
files.
Copy link
Collaborator

@mliszcz mliszcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change! I added one comment regarding the tests, could you please have a look?

mliszcz
mliszcz previously approved these changes Aug 31, 2020
@mliszcz
Copy link
Collaborator

mliszcz commented Aug 31, 2020

Maybe we should have a CI job for static build on Linux?

t-b added 2 commits September 1, 2020 16:01
In af72afb (Generate static library and fix compilation definitions
(tango-controls#17) (tango-controls#437), 2018-05-15) support was added for building a static
library next to the dynamic one.

As most users want to have only either library we use the newly
introduced option BUILD_SHARED_LIBS to build either one. This also
solves issues when cross-compiling where you might not have shared
libraries for the target architecture.
@t-b t-b force-pushed the allow-turning-shared-library-building-off branch from ec13356 to 998a008 Compare September 1, 2020 14:10
@t-b
Copy link
Collaborator Author

t-b commented Sep 1, 2020

@mliszcz I've added a travis job.

@mliszcz @bourtemb Any opinions about backporting? I would think that having that in 9.3-backports would be good. IMHO only the last two commits are needed.

@t-b t-b mentioned this pull request Sep 1, 2020
Copy link
Collaborator

@mliszcz mliszcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

As for the backport, I do not have any opinion here. Maybe just ask the users if they need this.

@JeanLucPons
Copy link

Hello,
Thanks for this. I tried but am I doing something wrong ?
Thanks for help.

cmake .. -DCMAKE_CXX_COMPILER:FILEPATH=/segfs/linux/xilinx_sdk/arm-toolchain/bin/arm-xilinx-linux-gnueabi-g++ -DIDL_BASE=/users/pons/tango/tango-idl/install -DOMNI_BASE=/segfs/tango/ORB/omniORB4.2.1_p1/arm_xilinx -DZMQ_BASE=/segfs/tango/transport/zmq4.0.5/arm_xilinx -DIDL_BASE=/users/pons/tango/tango-idl -DTANGO_JPEG_MMX=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/segfs/tango/release/arm_xilinx/PR758
- CMake: version 3.7.2
-- Target platform: Linux 32-bit
-- C++ Compiler: GNU with version 4.7.3
-- C Compiler: GNU with version 6.3.0
-- Build type: Release
-- Environment: TANGO_HOST=acudebian7:10000
Using IDL_BASEIDL_BASE=/users/pons/tango/tango-idl
Using OMNI_BASE=/segfs/tango/ORB/omniORB4.2.1_p1/arm_xilinx
Using ZMQ_BASE=/segfs/tango/transport/zmq4.0.5/arm_xilinx
-- Looking for C++ include zmq.hpp
-- Looking for C++ include zmq.hpp - found
-- Check if zmq::socket has a disconnect method: FALSE
Verifying /segfs/tango/ORB/omniORB4.2.1_p1/arm_xilinx/bin/omniidl
omniidl version 1.0
found GNU compiler ...
setup for release build ...
-- Check if the compiler supports C++14 relaxed constexpr: FALSE
Generate tango.h, tangoSK.cpp and tangoDynSK.cpp from idl
Using OMNIIDL_PATH=/segfs/tango/ORB/omniORB4.2.1_p1/arm_xilinx/bin/
Using IDL=/users/pons/tango/tango-idl/include
-- Configuring done
CMake Error in CMakeLists.txt:
  Target "tango-static" requires the language dialect "CXX14" , but CMake
  does not know the compile flags to use to enable it.

@t-b
Copy link
Collaborator Author

t-b commented Sep 3, 2020

@JeanLucPons CI passes, and it has a new job with static configuration, see 1.

  • You are using different compilers for C and C++, this does look odd.
  • I think cmake tries to tell you that your compiler is too old. You can try passing -DCMAKE_CXX_STANDARD=11 which might still work, but we will be moving towards C++14. So using something newer than g++ 4.7 is definitly more future proof.

@JeanLucPons
Copy link

Unfortunately I cannot update the compiler. The toolchain has been built by a manufacturer for a specific hardware and cannot be updated. I tried to use -DCMAKE_CXX_STANDARD=11 and the cmake ended successfully. However the make wants to build MMX although it was disabled (-DTANGO_JPEG_MMX=OFF).

[debian9-devel.pons] > cmake .. -DCMAKE_CXX_COMPILER:FILEPATH=/segfs/linux/xilinx_sdk/arm-toolchain/bin/arm-xilinx-linux-gnueabi-g++ -DIDL_BASE=/users/pons/tango/tango-idl/install -DOMNI_BASE=/segfs/tango/ORB/omniORB4.2.1_p1/arm_xilinx -DZMQ_BASE=/segfs/tango/transport/zmq4.0.5/arm_xilinx -DIDL_BASE=/users/pons/tango/tango-idl -DTANGO_JPEG_MMX=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX=/segfs/tango/release/arm_xilinx/PR758-- CMake: version 3.7.2
-- Target platform: Linux 32-bit
-- C++ Compiler: GNU with version 4.7.3
-- C Compiler: GNU with version 6.3.0
-- Build type: Release
-- Environment: TANGO_HOST=acudebian7:10000
Using IDL_BASEIDL_BASE=/users/pons/tango/tango-idl
Using OMNI_BASE=/segfs/tango/ORB/omniORB4.2.1_p1/arm_xilinx
Using ZMQ_BASE=/segfs/tango/transport/zmq4.0.5/arm_xilinx
-- Looking for C++ include zmq.hpp
-- Looking for C++ include zmq.hpp - found
-- Check if zmq::socket has a disconnect method: FALSE
Verifying /segfs/tango/ORB/omniORB4.2.1_p1/arm_xilinx/bin/omniidl
omniidl version 1.0
found GNU compiler ...
setup for release build ...
-- Check if the compiler supports C++14 relaxed constexpr: FALSE
Generate tango.h, tangoSK.cpp and tangoDynSK.cpp from idl
Using OMNIIDL_PATH=/segfs/tango/ORB/omniORB4.2.1_p1/arm_xilinx/bin/
Using IDL=/users/pons/tango/tango-idl/include
-- Configuring done
-- Generating done
-- Build files have been written to: /users/pons/tango/cppTango.PR758/build
[debian9-devel.pons] > 
[debian9-devel.pons] > make
[  0%] Building CXX object cppapi/server/jpeg_mmx/CMakeFiles/jpeg_mmx_objects.dir/jpeg_color_mmx.cpp.o
arm-xilinx-linux-gnueabi-g++: error: unrecognized command line option '-fstack-protector-strong'
cppapi/server/jpeg_mmx/CMakeFiles/jpeg_mmx_objects.dir/build.make:62: recipe for target 'cppapi/server/jpeg_mmx/CMakeFiles/jpeg_mmx_objects.dir/jpeg_color_mmx.cpp.o' failed

@mliszcz
Copy link
Collaborator

mliszcz commented Sep 8, 2020

Hi @JeanLucPons, let me clarify a few points here:

  • cppTango (tango-9-lts branch and also this PR) requires C++14. CMAKE_CXX_STANDARD is here to allow compiling with newer C++ standard versions. Things generally won't work if you pass C++11 there. With your compiler you should use one of 9.3.x releases.

  • The flag TANGO_JPEG_MMX if for disabling use of MMX extensions in our internal jpeg_mmx library. This basically disables -mmmx switch. The library is still compiled, as you noticed.

  • The compilation is failing due to your compiler not supporting -fstack-protector-strong flag. In GCC this flag is only available since 4.9.0 release. We do not support older GCC releases as they do not support most of C++14 features (see first bullet). As of today, the oldest supported and tested in CI version of GCC is 4.9.2. To work around this particular problem, you may try building in Debug mode which should not include any hardening flags (-DCMAKE_BUILD_TYPE=Debug).

@JeanLucPons
Copy link

JeanLucPons commented Sep 8, 2020

OK thanks.
There is no interest for me to compile in debug mode as I search maximum performance for running server on small embedded devices (Spark BPM). For the moment the 9.3.4-rc6 is working well and I hope it will work for the next years... We have at the ESRF lots of BPM (and BLM) spark devices that require embedded Tango.

@t-b t-b added the Candidate For Backport Requires a backport to the release branches label Sep 8, 2020
@t-b
Copy link
Collaborator Author

t-b commented Sep 8, 2020

@JeanLucPons Will make a backport PR available.

@t-b
Copy link
Collaborator Author

t-b commented Sep 10, 2020

@JeanLucPons See #763 for the backport PR.

@t-b t-b removed the Candidate For Backport Requires a backport to the release branches label Sep 10, 2020
Copy link
Member

@bourtemb bourtemb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
Thanks!

@t-b t-b merged commit ce78115 into tango-controls:tango-9-lts Sep 15, 2020
@t-b t-b deleted the allow-turning-shared-library-building-off branch September 15, 2020 10:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems when cross compiling for ARM
4 participants