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

Investigate Meson build system #205

Closed
shoogle opened this issue Aug 2, 2016 · 25 comments
Closed

Investigate Meson build system #205

shoogle opened this issue Aug 2, 2016 · 25 comments
Labels

Comments

@shoogle
Copy link

shoogle commented Aug 2, 2016

Meson is a build system which is designed to solve the problems with existing build tools like make, automake, Cmake, qmake, etc. It is designed to be fast and simple to use. It has an interesting dependency management system that might make it ideally suited for building AppImages - either through scripts or by adding native AppImage support directly to Meson.

https://github.com/mesonbuild/meson
http://mesonbuild.com/
http://www.admin-magazine.com/HPC/Articles/The-Meson-Build-System

Highlights from Meson presentation video on YouTube:

Native AppImage support could take the form of an --AppImage command line option for Meson which would not only build the application, but would also locate all of the necessary libraries and components and copy them into the build directory (i.e. it would create the AppDir).

@probonopd
Copy link
Member

Very interesting indeed!

@shoogle
Copy link
Author

shoogle commented Aug 3, 2016

It looks like the Meson developer had a similar idea!

Summary:

  • Just pass an option and an environment variable to Meson and it will statically link all the libraries it can link statically, and copy in the lib.so files for all the libraries that can't be linked statically.
  • Obviously, this requires the libraries to be present on the build system already, and this might involve building some of them from source. The Wrap dependency system makes this relatively easy.

@probonopd
Copy link
Member

probonopd commented Aug 4, 2016

Sounds intriguing.

This directory shows how you can build redistributable binaries. On OSX this menans building an app bundle and a .dmg installer. On Linux it means building a binary that bundles its dependencies. (...) On Linux you must build the package on the oldest distribution you plan to support (Debian stable/oldstable and old CentOS are the common choice here).

I think we should contact the author and ask him whether he would be interested in AppImage as a target. Since he writes "a binary that bundles its dependencies" but actually the script seems to generate an "archive"...

@shoogle
Copy link
Author

shoogle commented Aug 5, 2016

Yes it's probably worth talking to him. I'm really busy at the moment - won't be available until the end of the month - but feel free to start a discussion without me. It would probably be a good idea to have a quick go with Meson first, maybe copy his example project, and see whether his tools can locate and bundle indirect dependencies. The next step would be to implement a blacklist of system libraries.

@jpakkane
Copy link

jpakkane commented Aug 8, 2016

Hi, I'm the main Meson developer. Our goal is to make it easily build to any package format, whether it be AppImage, msi installer, dmg or flatpak. I have not looked too deeply into how AppImage organizes itself, but presumably it is mostly a question of setting up paths correctly when doing install and building all dependencies that are not provided by the base system. The former is done with command line arguments to Meson and the latter by having said deps available as wraps.

@probonopd
Copy link
Member

probonopd commented Aug 8, 2016

Hi @jpakkane and welcome to AppImage; glad you found here. I would roughly compare an AppImage to what is an .app inside a .dmg on the macOS platform. It would be great if you could help by making Meson capable of outputting AppImages.

For an introduction see our wiki, especially the part of how to create portable AppImages.

When in doubt, consult the AppImageSpec.

Key to AppImages that run on not just the most recent but also on older distributions is that the part of the dependency graph which is not supposed to be bundled, starting from glibc, is not more recent than what can be expected to be part of the target system(s). I recommend library versions from the debian oldstable or CentOS 6 era for this reason. Of course, those dependencies that will be bundled inside the AppImage may be more recent than that. A rule-of-thumb for what should be bundled: "Everything that cannot be reasonably expected to be part of each target system in a recent enough version" - namely, everything except these libraries.

Please let me know here if something is unclear, doesn't make sense, or if you get stuck.

Again, welcome!

@jpakkane
Copy link

jpakkane commented Aug 8, 2016

From what I can tell of the documentation, all a project needs to do to support AppImages is to install the AppRun shell script and the PNG image (+ maybe help and the rest). This is quite straightforward and requires no changes in Meson, it can stage an appdir just fine.

@shoogle
Copy link
Author

shoogle commented Aug 8, 2016

@jpakkane Thanks for checking in on AppImages!

Your assessment is pretty accurate. AppImageKit is a very capable tool for making AppImages, and making a _(very basic)_ AppImage is just a case of adding the AppRun script, icon and .desktop file.

There's no changes needed to Meson there, but here is where you might be able to help us:

1. Detect (and bundle) indirect dependencies:

Where it gets tricky is making the AppImage truly portable, as this involves bundling not only the program's direct dependencies, but also it's dependencies' dependencies and so on. It is already possible to detect these dependencies using ldd, but copying them into the container currently requires writing a pretty complicated script. It would be great if Meson could do this automatically.

2. Detect (and bundle) runtime dependencies:

A major problem is where some dependencies are loaded dynamically at runtime and are not detectable using the usual ldd tricks. This is true in particular for many Qt plugins and QML. Since Meson appears to be "aware" of Qt and it's various components it would also be great if it was "aware" of their runtime dependencies and could also copy those in. Again, these must currently be specified manually by running the app and testing features until something breaks, adding the missing library (and its dependencies), and then trying again, and again, and then doing the same on every other distribution.

2. Excluding dependencies provided by the base-system

It is desirable to exclude all libraries that can be guaranteed present on any Linux system to prevent the AppImage becoming too large. Since there is no standard Linux base system this means developers currently have to use trial and error to see what they can get away with not including.

I think that (1) can be automated within Meson, but (2) and (3) probably require lists to be manually defined. It would be great to be able to have these lists defined centrally somewhere and then have Meson use them to determine what needs to be bundled. The lists would look something like this:

# Qt Plugins dependencies:
libfoo
libbar
libbaz
...
# Linux base system:
libfoo
libbar
libbaz
...

If Meson was used to package an application that depends on Qt Plugins then it would include everything on the first list and exclude everything on the second list.

@probonopd
Copy link
Member

It would be great to be able to have these lists defined centrally somewhere

For the list of libraries that are expected to come with the base system and hence should not be bundled, this list can be used.

@probonopd probonopd added the idea label Aug 19, 2016
@probonopd
Copy link
Member

probonopd commented Jun 5, 2017

Whoever does the work decides which tools to use 💯

@TheAssassin
Copy link
Member

I'd go for CMake (see #408). Most IDEs and other tool sets support it, it's widely spread and well tested. Although it might not be as elegant as meson, it's probably the better decision to go for CMake.

@TheAssassin
Copy link
Member

Transitioning to CMake in the near future. Partial implementation is available already. Closing this issue.

@probonopd
Copy link
Member

Why I absolutely dislike Meson:
openzim/libzim#212

@shoogle
Copy link
Author

shoogle commented May 26, 2019

Why I absolutely dislike Meson: openzim/libzim#212

TLDR: Meson appears not to work on Ubuntu 14.04 LTS despite the fact that 14.04 is still supported by Canonical (or was until the 25th of April this year). This is apparantly because Meson depends on a newer version of Python than is provided for that distribution.

However, Meson's CI tests run on Ubuntu 14.04, so the above conclusion may not be entirely accurate. Anyway, Ubuntu 16.04 is now the oldest supported Ubuntu LTS, and there are good reasons to consider switching to it.

@jpakkane
Copy link

However, Meson's CI tests run on Ubuntu 14.04

This is not entirely accurate. The CI uses a Docker image that is based on Ubuntu 18/10.

@shoogle
Copy link
Author

shoogle commented May 27, 2019

The CI uses a Docker image that is based on Ubuntu 18/10.

Thanks for the clarification @jpakkane. Perhaps you would consider switching to something a bit older in future because most people use whatever Travis currently uses.

@probonopd
Copy link
Member

Hi @jpakkane. In this project, we care about building applications for the oldest still-supported long term stable distributions, e.g., CentOS 6, Ubuntu LTS, and so on. Hence, to make it feasible to use Meson for this purpose, it would be good if Meson was developed on say, CentOS 6 and accept no dependencies that are newer than what is shipped with it.

I realize that our demands are a bit special, so if building on the oldest still-supported long term stable distributions is not in the scope of Meson, then Meson is not a good fit for our purpose but may still be fine for other use cases.

@TheAssassin
Copy link
Member

Well, meson as a build system wouldn't be problematic strictly in terms of dependencies; we can build additional ones. But then again, that's annoying work to do. So I agree with @probonopd.

@probonopd
Copy link
Member

That being said, an AppImage that would contain Python, Meson, and ninja and that could run on all still-supported LTS distributions might be beneficial for the Meson project to have - it would allow users to use Meson without having to worry about incompatible Python versions and such, which currently makes using it cumbersome.

@shoogle
Copy link
Author

shoogle commented May 30, 2019

As a build system, Meson should really target the oldest distribution possible. This should be by default, for CI Tests and everything, not just as an optional AppImage build for those that want it. Application developers sometimes have to choose between supporting older systems or gaining access to features only provided on newer systems, but they don't expect this decision to be made for them by their build system.

While Meson builds against Ubuntu 18.10 there is a genuine risk that it might not work with Ubuntu 18.04, which is the latest LTS. Most users and developers use LTS releases, so at the very least Meson should support the latest LTS, and preferably the one before that too.

@jpakkane
Copy link

We do our best to support things, but our test matrix is really big. Running tests is already fairly slow. Adding even more platforms will quickly become unfeasible. The only "real" dependency we have is Python 3 and we do have 3.5 in our test setup (on Windows IIRC, but it's there nevertheless). Thus far we have not received many (or any?) bug reports about things breaking in old LTS versions.

The version of Python required is the oldest that is available from the system in Debian Stable, latest Ubuntu LTS and in the future probably also the latest RHEL.

@probonopd
Copy link
Member

probonopd commented May 30, 2019

What we are asking for is to go for the oldest still-supported rather than the newest LTS. It should not increase the test matrix because what runs on old systems is supposed to also run on newer systems.

@shoogle
Copy link
Author

shoogle commented May 31, 2019

In other words, if you can only support one platform, pick the oldest one and you get the newer ones for free. That's what Qt and everybody else does.

@Calinou
Copy link

Calinou commented May 31, 2019

In other words, if you can only support one platform, pick the oldest one and you get the newer ones for free.

Newer Python versions can sometimes break in subtle ways, so that's not always true. That said, if you have to choose between testing on an old and a new version, it's probably better to test on the old version.

@shoogle
Copy link
Author

shoogle commented May 31, 2019

Newer Python versions can sometimes break in subtle ways

That's true, but that's arguably a Python bug so not something you'd have to worry about. In any case, you can rely on experienced users to test and fix bugs on new systems whereas people on older systems tend to be less experienced (though not always), and the bugs on newer systems are likely to be smaller and easier to fix than if a dependency is completely missing on an old system.

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

No branches or pull requests

5 participants