Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LSP]: fix cmake cxx standard required (chapel-lang#23531)
This PR changes how `chpldef` sets the required minimum `c++` version with `cmake`. When testing locally with cmake version `v3.22.1`, I was experiencing different behavior than on `chapdl` or `chapcs`, both of which have different versions of `cmake`. After some digging, it appears there's a behavior change in `cmake 3.22.0` that introduced a bug causing the standard not to be set in this case. The bug was later fixed in `v3.22.2`. See https://cmake.org/cmake/help/git-stage/release/3.22.html#cmake-3-22-release-notes. Using a different strategy to set the required version (the same one we use everywhere else) allows `chpldef` to be built with the required standard on `cmake` `v3.22.0` and `v3.22.1`, in addition to the previous and later versions. Also discovered that `cmake` `v3.26` changed the behavior of adding compiler flags and setting the `c++` standard such that it reordered the flags, putting the language standard flag near the beginning instead of near the end. This creates inconsistent behavior between `cmake` versions because our build script passes the `c++` std flag in multiple locations, and earlier versions of `cmake` just happened to work because the `cmake` generated flag was added after all those. Now, in new versions, it comes before and it breaks the builds. The solution should be to use a `cmake` policy to opt out of the new behavior, but the devs didn't include a policy for this change because...well...they didn't. see https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7931 So to work around this new limitation, I started parsing the flags passed from `make` to remove the `-std=c++14` flag as it's redundant to all the `cmake` targets, which have logic to specify the correct standard already. A different option would be to adjust the `Makefile` to strip the flag, or possibly just adjust the `chpl_llvm.py` script to stop appending the flag.
- Loading branch information