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

CMake scripts cleanups #680

Merged
merged 8 commits into from
May 11, 2021
Merged

CMake scripts cleanups #680

merged 8 commits into from
May 11, 2021

Conversation

pcercuei
Copy link
Contributor

@pcercuei pcercuei commented May 5, 2021

A set of patches to cleanup the CMake scripts.

This change is a bit more invasive than usual, as it changes the behaviour of the script. For that reason, it is possible that the autobuilders will fail, as their scripts may have to be enabled.

Instead of auto-enabling functions according to the environment (available libraries etc), the options are now never auto-selected, and the environment is probed according to the enabled options.

The goal of this is to make the builds reproductible: now, using the same configuration on two systems will result in the same features being enabled in the library.

The scripts have also been updated to use the 3.x CMake features.

The code already checked for the WITH_AIO macro, and almost all
configurable options in libiio and IIOD use the "WITH" prefix.

Signed-off-by: Paul Cercueil <[email protected]>
@rgetz
Copy link
Contributor

rgetz commented May 6, 2021

The scripts have also been updated to use the 3.x CMake features.

yeah, the still shipping Zynq Images use old cmake - this would break too many boards in the field.

The new Kuiper images that we are moving to use 3.13; I don't think that's the default image yet.

root@analog:~# cmake --version
cmake version 3.13.4

plus it causes all CI builds to fail. Centos like this:

CMake Error at cmake/Install.cmake:177 (include):
  include could not find load file:

    LinuxPackaging.cmake
Call Stack (most recent call first):
  CMakeLists.txt:425 (include)

@nunojsa
Copy link
Contributor

nunojsa commented May 6, 2021

yeah, the still shipping Zynq Images use old cmake - this would break too many boards in the field.

FWIW, cmake 3.20.2 is already complaining about the used version...

CMake Deprecation Warning at tests/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

Copy link
Contributor

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Apart from the cmake version bump question, looks a very good cleanup to me

@@ -17,9 +17,9 @@
#cmakedefine01 WITH_NETWORK_EVENTFD
#cmakedefine01 WITH_IIOD_USBD
#cmakedefine01 WITH_LOCAL_CONFIG
#cmakedefine01 WITH_AIO
Copy link
Contributor

@nunojsa nunojsa May 6, 2021

Choose a reason for hiding this comment

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

Just a comment which has noting to do with this... We should definitely consider about replacing aio for io_uring and liburing for libiio2 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will definitely have a look at io_uring. I want to see if it can help us with zero-copy.

Copy link
Contributor

Choose a reason for hiding this comment

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

It has both ring buffers shared between kernel and userspace so that's something already in the right way... Another neat thing is that we can potential reduce a lot the number of syscalls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I assume the IIO subsystem needs to support it (does it?).

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think so. At least for normal reads/writes on sysfs stuff. Now for ioctl (not sure if that stuff was merged; and yes, it seems io_uring is also allowing to re-implement ioctl), the last time I checked I think IIO would have to support it...

Copy link
Contributor

Choose a reason for hiding this comment

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

https://lwn.net/Articles/844875/ - not idea the outcome of the RFC

@@ -24,7 +24,7 @@ find_library(LIBAIO_LIBRARIES aio)
find_path(LIBAIO_INCLUDE_DIR libaio.h)

if (LIBAIO_LIBRARIES AND LIBAIO_INCLUDE_DIR)
option(ENABLE_AIO "Build IIOD with async. I/O support" ON)
option(WITH_AIO "Build IIOD with async. I/O support" ON)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that we only provide the option if the libraries are installed in the system? If so, I'm not sure if it would not be better to always provide the option and look for the libraries if the option is enabled. Then make it explicit that dependencies are needed (cmake failure)... Otherwise, users might not even be aware that this feature is possible...

message(SEND_ERROR "Unable to find libusb-1.0 dependency.\n"
"If you want to disable the USB backend, set WITH_USB_BACKEND=OFF.")
endif()

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, you can disregard my previous comment 👍

@pcercuei
Copy link
Contributor Author

pcercuei commented May 6, 2021

The scripts have also been updated to use the 3.x CMake features.

yeah, the still shipping Zynq Images use old cmake - this would break too many boards in the field.

Isn't there a "backports" feature like on Ubuntu/Debian?

@pcercuei
Copy link
Contributor Author

pcercuei commented May 6, 2021

@rgetz Now would maybe be a good time to branch libiio2. Then we can up the CMake requirements in the libiio2 branch.

@pcercuei pcercuei force-pushed the clean-cmake branch 6 times, most recently from d20077e to b6d4eea Compare May 6, 2021 11:54
@rgetz
Copy link
Contributor

rgetz commented May 6, 2021

@rgetz Now would maybe be a good time to branch libiio2. Then we can up the CMake requirements in the libiio2 branch.

that makes total sense to me.

@rgetz
Copy link
Contributor

rgetz commented May 6, 2021

but the CI failures still should be fixed, or you won't have much test coverage going forward...

@pcercuei
Copy link
Contributor Author

pcercuei commented May 7, 2021

@rgetz yes. Don't worry ;)

@pcercuei pcercuei force-pushed the clean-cmake branch 6 times, most recently from 9707c35 to 73ec11b Compare May 7, 2021 10:16
Old OSes (CentOS 7, Ubuntu 16.04) require s6_addr32 to be defined for
the IN6_IS_ADDR_LINKLOCAL() macro to work.

Signed-off-by: Paul Cercueil <[email protected]>
This function is not used in libiio, but is used by IIOD.

Signed-off-by: Paul Cercueil <[email protected]>
We do not want to compile with GNU-specific extensions, as we want the
code to be as portable as possible.

Thanksfully we don't actually need _GNU_SOURCE to be defined, removing
it only triggers an error in network-unix.c about an undefined
structure, which we can fix by including the right header.

Signed-off-by: Paul Cercueil <[email protected]>
Instead of making build options available according to whether or not a
library is found, only search for the library if the option has been
enabled.

This change may temporarily break the auto-builders (which will need to
be updated), but it makes the build *reproductible*, and that's very
important.

Signed-off-by: Paul Cercueil <[email protected]>
Disable serial backend, enable ZSTD support.

Signed-off-by: Paul Cercueil <[email protected]>
Disable serial and USB backends.

Signed-off-by: Paul Cercueil <[email protected]>
Enable ZSTD support, except on Ubuntu 16.04 where it doesn't build, and
explicitely set the build options as it is required now.

Note that the serial backend is disabled on Ubuntu 16.04 as its version
of libserialport is too old, and USB support in IIOD is disabled in
CentOS 7 as its kernel headers are too old.

Signed-off-by: Paul Cercueil <[email protected]>
@pcercuei
Copy link
Contributor Author

pcercuei commented May 7, 2021

Alright, it should be ready for merging now.

Note that USB support in IIOD is disabled in CentOS 7, and UART support and ZSTD compression are disabled on Ubuntu 16.04, as the corresponding dependencies are too old on these OSes.

@pcercuei pcercuei merged commit c32fab4 into master May 11, 2021
@pcercuei pcercuei deleted the clean-cmake branch May 11, 2021 12:03
nunojsa added a commit to analogdevicesinc/meta-adi that referenced this pull request May 17, 2021
With the changes introduced in [1], libiio now looks for system
dependencies depending on enabled options. Hence, as the serial backend
is enabled by default, libserialport has to be set as DEPENDS. This patch
adds the SERIAL_BACKEND to the list of PACKAGECONFIG for libiio.

[1]: analogdevicesinc/libiio#680
Signed-off-by: Nuno Sá <[email protected]>
nunojsa added a commit to analogdevicesinc/meta-adi that referenced this pull request May 20, 2021
With the changes introduced in [1], libiio now looks for system
dependencies depending on enabled options. Hence, as the serial backend
is enabled by default, libserialport has to be set as DEPENDS. This patch
adds the SERIAL_BACKEND to the list of PACKAGECONFIG for libiio.

[1]: analogdevicesinc/libiio#680
Signed-off-by: Nuno Sá <[email protected]>
nunojsa added a commit to analogdevicesinc/meta-adi that referenced this pull request May 26, 2021
This fix is still related with the changes introduced by [1]. If
'HAVE_DNS_SD' is ON, we need to have the correspondent avahi dependencies
set... However, for microblaze builds, zeroconf is not part of the
petalinux 'DISTRO_FEATURES'. Hence, we disable 'DHAVE_DNS_SD' if zeroconf
is not present.

[1]: analogdevicesinc/libiio#680
Signed-off-by: Nuno Sá <[email protected]>
nunojsa added a commit to analogdevicesinc/meta-adi that referenced this pull request Jun 7, 2021
This fix is still related with the changes introduced by [1]. If
'HAVE_DNS_SD' is ON, we need to have the correspondent avahi dependencies
set... However, for microblaze builds, zeroconf is not part of the
petalinux 'DISTRO_FEATURES'. Hence, we disable 'DHAVE_DNS_SD' if zeroconf
is not present.

[1]: analogdevicesinc/libiio#680
Signed-off-by: Nuno Sá <[email protected]>
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 this pull request may close these issues.

3 participants