Skip to content

Raise minimum CMake version to 3.16 - #1968

Merged
keithw merged 1 commit into
WebAssembly:mainfrom
alexreinking:cmake/halide-fixes-1
Aug 26, 2022
Merged

keithw merged 1 commit into
WebAssembly:mainfrom
alexreinking:cmake/halide-fixes-1

Conversation

@alexreinking

@alexreinking alexreinking commented Aug 25, 2022 •

Copy link
Copy Markdown
Contributor

The stated minimum, 3.1, was released on Dec 17, 2014 and did not support a value of 17 for CMAKE_CXX_STANDARD. The first version to do so was 3.8. In fact, attempting to build with CMake 3.7 fails with errors like:

CMake Error in CMakeLists.txt:
  Target "wasm-strip" requires the language dialect "CXX17" , but CMake does
  not know the compile flags to use to enable it.

So we might as well take this chance to raise the minimum to something more recent. I propose 3.16 here because of the following features:

  • CMP0077 (v3.13) makes the lives of FetchContent users easier by allowing option() to be overridden.
  • CMP0082 (v3.14) corrects the semantics of install() rules, which is relevant for FetchContent users.
  • CMake 3.12 allows the namelink of a shared library on Linux to be installed separately (i.e. in a dev package)
  • CMake 3.14 integrates the standard install destination variables from GNUInstallDirs with the install() command.
  • CMake 3.15 introduced the CMAKE_MSVC_RUNTIME_LIBRARY variable for controlling the selection of the runtime library from the outside.
  • CMake 3.16 gained support for generator expressions in RPATH properties, which will make it easier to ship shared libraries.

This version is quite conservative and I would even suggest upgrading further. Windows and macOS users enjoy frequent updates from Homebrew and Microsoft Visual Studio. Ubuntu Linux 20.04 LTS ships 3.16 and the newest LTS ships 3.22. Linux users can always install the latest version through PIP, even on ARM, PowerPC, and s390x, and even without sudo.

I have also added a GHA job to the CI workflow to test that WABT builds under its stated minimum version. This should prevent unintentional compatibility issues from creeping in. The other workflows can use newer CMake versions to catch issues there.

Fixes #1568

@alexreinking

alexreinking commented Aug 25, 2022 •

Copy link
Copy Markdown
Contributor Author

Bumping up to 3.15 would: Since we're going to 3.16 we additionally get:

  1. Provide an immediate solution to Statically link Visual C++ runtime when releasing on Windows #1568 in the form of CMAKE_MSVC_RUNTIME_LIBRARY
  2. Let us write build and installation instructions that use the nicer cmake --install ... command instead of cmake ... -P build/cmake_install.cmake. c.f. Makefile behaves differently on different systems #1558 and More docs for building/using libwabt? #1267

This was referenced Aug 25, 2022
@steven-johnson

steven-johnson commented Aug 25, 2022 •

Copy link
Copy Markdown
Collaborator

I have to no LGTM power here, but I endorse this PR :-)

@keithw

keithw commented Aug 25, 2022

Copy link
Copy Markdown
Member

Thanks! If you think 3.15 would be helpful for these various issues, maybe we should just bump to 3.15? Debian packages 3.16 in stretch-backports, and CentOS 8 "AppStream" seems to have 3.20, so given that this is only a build-dep, it doesn't seem that aggressive if it would help.

Would this also help us with #1602?

Comment thread .github/workflows/build.yml Resolved
@alexreinking

Copy link
Copy Markdown
Contributor Author

@keithw - absolutely it would help. I strongly favor being aggressive with CMake version updates. Halide just upgraded to 3.22. Why not just bump to 3.16 since that's the lower of the two baselines you mentioned?

@keithw

keithw commented Aug 25, 2022

Copy link
Copy Markdown
Member

3.16 sgtm

@alexreinking alexreinking changed the title Raise minimum CMake version to 3.14 Raise minimum CMake version to 3.16 Aug 25, 2022
@alexreinking

Copy link
Copy Markdown
Contributor Author

@keithw - done! I think I need you to re-start the workflows.

@alexreinking

alexreinking commented Aug 25, 2022 •

Copy link
Copy Markdown
Contributor Author

@keithw - and we're green! Anything left for me to do here? I'm ready to rebase my other two PRs when this one is merged.

Comment thread .github/workflows/build.yml Resolved
The stated minimum, 3.1, was released on Dec 17, 2014 and did not
support a value of 17 for CMAKE_CXX_STANDARD. The first version to do so
was 3.8. In fact, attempting to build with CMake 3.7 fails with errors
like:

CMake Error in CMakeLists.txt:
  Target "wasm-strip" requires the language dialect "CXX17" , but CMake does
  not know the compile flags to use to enable it.

So we might as well take this chance to raise the minimum to something
more recent. I propose 3.16 here because of the following features:

* CMP0077 (v3.13) makes the lives of FetchContent users easier by
  allowing option() to be overridden.
* CMP0082 (v3.14) corrects the semantics of install() rules, which is
  relevant for FetchContent users.
* CMake 3.12 allows the namelink of a shared library on Linux to be
  installed separately (i.e. in a dev package)
* CMake 3.14 integrates the standard install destination variables from
  GNUInstallDirs with the install() command.
* CMake 3.15 introduced the CMAKE_MSVC_RUNTIME_LIBRARY variable for
  controlling the selection of the runtime library from the outside.
* CMake 3.16 gained support for generator expressions in RPATH
  properties, which will make it easier to ship shared libraries.

This version is quite conservative and I would even suggest upgrading
further. Windows and macOS users enjoy frequent updates from Homebrew
and Microsoft Visual Studio. Ubuntu Linux 20.04 LTS ships 3.16 and the
newest LTS ships 3.22. Linux users can always install the latest version
through PIP, even on ARM, PowerPC, and s390x, and even without sudo.

Fixes #1568
@keithw
keithw enabled auto-merge (squash) August 26, 2022 01:08
@keithw
keithw merged commit 5abf3c2 into WebAssembly:main Aug 26, 2022
@sbc100

sbc100 commented Aug 30, 2022

Copy link
Copy Markdown
Member

In the past we have tried to avoid bumping this to a version higher than is needed by the two peer projects binaryen (currently on 3.10.2) and llvm (currently on 3.13.4). However, less relevant today since we don't build wabt on emscripten-releases waterfall (normally the limiting factor) anymore.

I do like the new test, but i would have rather we did a minimal bump to 3.8 (or 3.10 to match binaryen).

@alexreinking

alexreinking commented Aug 30, 2022 •

Copy link
Copy Markdown
Contributor Author

In our experience on Halide, telling users that pip install --user cmake will install the latest version on every Linux imaginable (s390x with musl libc? yep.) without root permissions adequately addresses their concerns. Yet, I doubt users will complain about this change in the first place since even CentOS ships 3.20 now.

For another point of reference, the official x86 binaries require only glibc 2.12, which was released in 2010, four years before CMake 3.0 was released. The arm binaries require glibc 2.17, released in 2012, still predating CMake 3.0. Even if Python (which is a requirement for testing) is too much of a burden, one can still run:

$ curl -L https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-linux-x86_64.tar.gz | tar xzf -
$ export PATH="$PWD/cmake-3.24.1-linux-x86_64/bin:$PATH"
$ cmake --version
cmake version 3.24.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

LLVM is a massive project and taking advantage of newer CMake features is an endeavor in itself. I'm not sure why binaryen doesn't upgrade more frequently. A comment in their code says they based their version off of the one in Ubuntu bionic. Maybe now that there are two LTS releases ahead of it, they would consider upgrading, too.

And then there are the several clear benefits to upgrading that I outlined above...

@alexreinking
alexreinking deleted the cmake/halide-fixes-1 branch August 30, 2022 14:21
@keithw

keithw commented Aug 31, 2022

Copy link
Copy Markdown
Member

FWIW, I guess I wouldn't be thrilled for us to bump the required cmake version beyond what can be built for a recent version of Debian or other major Linux distribution of recent vintage. I recognize that Halide is a different story, but I don't think the pip availability of binaries for later cmake versions really helps when we're talking about something we want packaged by the major distributors -- they want to be building packages in their hermetic/reproducible build environments, with build-deps that are available in the build environment.

@alexreinking

alexreinking commented Aug 31, 2022 •

Copy link
Copy Markdown
Contributor Author

I wouldn't be thrilled for us to bump the required cmake version beyond what can be built for a recent version of Debian or other major Linux distribution of recent vintage.

@keithw - Well, I don't think that's an issue either since, as you previously observed, all the distros of recent vintage have at least CMake 3.16. The older distros aren't going to upgrade WABT beyond what they already packaged. Debian stable (bullseye) has 3.18. We got Halide packaged in Debian when it had a 3.16 requirement.

matthias-blume pushed a commit to matthias-blume/wabt that referenced this pull request Dec 16, 2022
The stated minimum, 3.1, was released on Dec 17, 2014 and did not
support a value of 17 for CMAKE_CXX_STANDARD. The first version to do so
was 3.8. In fact, attempting to build with CMake 3.7 fails with errors
like:

CMake Error in CMakeLists.txt:
  Target "wasm-strip" requires the language dialect "CXX17" , but CMake does
  not know the compile flags to use to enable it.

So we might as well take this chance to raise the minimum to something
more recent. I propose 3.16 here because of the following features:

* CMP0077 (v3.13) makes the lives of FetchContent users easier by
  allowing option() to be overridden.
* CMP0082 (v3.14) corrects the semantics of install() rules, which is
  relevant for FetchContent users.
* CMake 3.12 allows the namelink of a shared library on Linux to be
  installed separately (i.e. in a dev package)
* CMake 3.14 integrates the standard install destination variables from
  GNUInstallDirs with the install() command.
* CMake 3.15 introduced the CMAKE_MSVC_RUNTIME_LIBRARY variable for
  controlling the selection of the runtime library from the outside.
* CMake 3.16 gained support for generator expressions in RPATH
  properties, which will make it easier to ship shared libraries.

This version is quite conservative and I would even suggest upgrading
further. Windows and macOS users enjoy frequent updates from Homebrew
and Microsoft Visual Studio. Ubuntu Linux 20.04 LTS ships 3.16 and the
newest LTS ships 3.22. Linux users can always install the latest version
through PIP, even on ARM, PowerPC, and s390x, and even without sudo.

Fixes WebAssembly#1568
@penzn

penzn commented Apr 6, 2023

Copy link
Copy Markdown
Contributor

I wouldn't be thrilled for us to bump the required cmake version beyond what can be built for a recent version of Debian or other major Linux distribution of recent vintage.

@keithw - Well, I don't think that's an issue either since, as you previously observed, all the distros of recent vintage have at least CMake 3.16. The older distros aren't going to upgrade WABT beyond what they already packaged. Debian stable (bullseye) has 3.18. We got Halide packaged in Debian when it had a 3.16 requirement.

This PR disabled building on latest LTS Ubuntu (22.04), it only has 3.14 at the moment.

@alexreinking

alexreinking commented Apr 6, 2023 •

Copy link
Copy Markdown
Contributor Author

This PR disabled building on latest LTS Ubuntu (22.04), it only has 3.14 at the moment.

@penzn - That is incorrect. The latest Ubuntu LTS (jammy) ships with CMake 3.22. Your environment is broken, somehow.

@penzn

penzn commented Apr 6, 2023

Copy link
Copy Markdown
Contributor

Yeah, I found a rogue CMake on my system...

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.

Statically link Visual C++ runtime when releasing on Windows

5 participants