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

[RFC] CMake buildsystem QoL improvements ? #4284

Closed
LebedevRI opened this issue Sep 28, 2019 · 14 comments · Fixed by #4644
Closed

[RFC] CMake buildsystem QoL improvements ? #4284

LebedevRI opened this issue Sep 28, 2019 · 14 comments · Fixed by #4644
Assignees
Labels
build Issues related to building Halide and with CI

Comments

@LebedevRI
Copy link
Contributor

Hello.
To preface, i will understand if this isn't something that is wanted for the project..

I'd like to try using halide in some my future toy project.
As it stands now, halide is largely not packaged in distributions,
certainly not in debian; and this is a dealbreaker for me :/

After looking around, i understand why that might be the case - the cmake build system
is, uhm, making some very unusual and interesting choices.

The question is: is there any interest in trying to straighten out the cmake build,
make it more likely to be packaged, and easier to use in cmake-based projects?

Right now i see 3 main issues:

  1. There should be a switch to OPTIONALLY link to shared LLVM libraries (trivial, i already have a patch)
  2. The installation destinations need to be fixed, the current install directory structure is not ideal. (Likely simple. Should the defaults (that are likely in-parity with other build systems?) be fixed, or should the defaults remain?)
  3. A proper Halide-Config.cmake magic needs to be added, so it can be found with simple find_package(halide).
@abadams
Copy link
Member

abadams commented Sep 28, 2019

These sorts of improvements are generally welcome, provided they don't break existing usage. @steven-johnson is the person who knows the most about the existing cmake-based build. I generally avoid it and just use the makefiles.

@BachiLi
Copy link
Contributor

BachiLi commented Sep 29, 2019

A related issue is that the Python bindings also need a CMake file (especially important for Windows users).

LebedevRI added a commit to LebedevRI/Halide that referenced this issue Sep 30, 2019
As discussed in halide#4284
one important thing is to be able to link to shared versions
of LLVM libraries. This is off-by-default.

The important [existing] caveat to note is that i don't see
where those llvm libraries-to-be-linked are specified anywhere
in the halide_config.cmake, so as long as you are
a. building static halide
and
b. not building halide as a cmake sub-project (via add_subdirectory)
i don't see how the linking can succeed, both either with
old static llvm libraries, and now with shared llvm library.

The best i can tell `llvm-config --system-libs` is only needed
when linking to static libraries, to propagate their deps,
so let's not do that for shared llvm libs.

And the switch to `llvm_config()` is the main thing here,
it internally handles `USE_SHARED`, and does `target_link_libraries()`.

Since this is opt-in, i don't believe this should have any impact
on existing users.
@steven-johnson
Copy link
Contributor

Improvements of the sort you describe would be quite welcome. We have historically used CMake primarily for Windows testing, but as you can see, it often lags behind; getting it to 100% parity with Makefile would be a highly desirable goal in my opinion. Contributions in this vein would be great, especially because none of the core contributors use CMake much outside of this project and thus things like the installation options are easy for us to overlook.

@LebedevRI
Copy link
Contributor Author

provided they don't break existing usage

Yeah, that's the fun part i suppose.
Do i understand correctly that if one needs to opt-in into new behavior explicitly,
for example via a CMake option that you'd pass when building Halide itself,
then the existing usage would not be considered broken?

@zvookin
Copy link
Member

zvookin commented Oct 1, 2019

We're totally into helping to make stuff like this better. The main thing I'll add to the discussion so far is that future success rides on making sure the things you care about are covered by tests somehow so that if anything breaks it gets caught before it gets checked in.

I'd also like to see us have regular packaging for various environments as part of our release process.

@LebedevRI
Copy link
Contributor Author

LebedevRI commented Oct 1, 2019

provided they don't break existing usage

Yeah, that's the fun part i suppose.
Do i understand correctly that if one needs to opt-in into new behavior explicitly,
for example via a CMake option that you'd pass when building Halide itself,
then the existing usage would not be considered broken?

I.e. what i'm saying is, would it be acceptable to diverge into two incompatible layouts:

  • the currently-distributed tarball with current halide_config.cmake and it's usage scenarios
  • and a proper CMake config, proper installation directories, etc

via a CMake option at Halide configuration time?
Or should the halide_config.cmake continue working even when the installation paths are fixed?

I'd also like to see us have regular packaging for various environments as part of our release process.

Can be done. As the end result i do plan to end up with debian package files,
so at the very least we can rope https://build.opensuse.org/ into producing
continuous builds for debian-like distros. After that it should be trivial to also
add packages for suse/redhat. So that should cover reasonable chunk of usebase :)
A webhook will need to be configured in github repo settings to auto-trigger builds.

So don't worry about that part.

The main thing I'll add to the discussion so far is that future success rides on making sure the things you care about are covered by tests somehow so that if anything breaks it gets caught before it gets checked in.

I'm sorry, i'm not sure how this could look.

@steven-johnson
Copy link
Contributor

I suspect (without evidence) that the current tarball + usage has limited usage, because (as you've pointed out) it has various serious drawbacks. We'd want to take a straw poll on the mailing list, Gitter room, etc, to see if there are users with nontrivial dependence on the status quo, but I really don't want to fork our build system even more than it already is; making breaking changes to CMake that are a net improvement to people used to that ecosystem is a win IMHO.

@abadams
Copy link
Member

abadams commented Oct 1, 2019

By not breaking the status quo I really just meant that it has to still be tested and work to the same extent that it currently does on all the platforms we support. I.e. don't break the build bots.

@alexreinking
Copy link
Member

alexreinking commented Oct 15, 2019

I am also very interested in improving and modernizing the CMake build. In particular, I don't see any reason we couldn't depend on a very recent version of CMake (like 3.13, the version available by default in Debian Buster) instead of 3.3. The main advantage here being that there are many new features available only in 3.12+ that would greatly improve the simplicity and maintainability of our build.

Adding Halide to Nuget (for Windows), Homebrew (for macOS), a Debian/Ubuntu-compatible PPA, and Pip/Conda (for everyone else), would absolutely ease the installation burden for new users.

@steven-johnson
Copy link
Contributor

steven-johnson commented Oct 15, 2019 via email

@alexreinking alexreinking added the build Issues related to building Halide and with CI label Oct 21, 2019
@alexreinking alexreinking self-assigned this Dec 9, 2019
@alexreinking
Copy link
Member

Most of this has been handled in #4644 -- still need to create deb packages.

@LebedevRI
Copy link
Contributor Author

Oh, nice!
I did the initial deb packaging work, let me see if i can resurrect it.

@alexreinking alexreinking linked a pull request May 2, 2020 that will close this issue
alexreinking added a commit that referenced this issue May 12, 2020
Fixes #870
Fixes #2643
Fixes #2821
Fixes #2852
Fixes #2942
Fixes #3658
Fixes #4009
Fixes #4284
Fixes #4476
Fixes #4581
Fixes #4893
Fixes #4895
alexreinking added a commit that referenced this issue May 12, 2020
Fixes #870
Fixes #2643
Fixes #2821
Fixes #2852
Fixes #2942
Fixes #3658
Fixes #4009
Fixes #4284
Fixes #4476
Fixes #4581
Fixes #4893
Fixes #4895
@LebedevRI
Copy link
Contributor Author

Whoa, huge congrats to everyone involved!

@alexreinking
Copy link
Member

Thanks @LebedevRI -- I took the lead on this and @steven-johnson was invaluable getting our build infrastructure up to date and finding bugs in my work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues related to building Halide and with CI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants