Skip to content

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Sep 2, 2025

Backport 63195d3 3e6ec47

Requested by: @amy-kwan

A CMake change included in CMake 4.0 makes `AIX` into a variable
(similar to `APPLE`, etc.)
https://gitlab.kitware.com/cmake/cmake/-/commit/ff03db6657c38c8cf992877ea66174c33d0bcb0b

However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to
`AIX` and `if` auto-expands variable names in CMake. That means you get
a double expansion if you write:

`if (${CMAKE_SYSTEM_NAME}  MATCHES "AIX")`
which becomes:
`if (AIX  MATCHES "AIX")`
which is as if you wrote:
`if (ON MATCHES "AIX")`

You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}",
due to policy
[CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054)
which is on by default in 4.0+. Most of the LLVM CMake already does
this, but this PR fixes the remaining cases where we do not.

(cherry picked from commit 63195d3)
This is a follow on to llvm#154537, which quoted the CMAKE_SYSTEM_NAME to avoid expanding it again when that CMAKE_SYSTEM_NAME expands to AIX.

But by the same logic, we also need to quote the plain string AIX as well.

(cherry picked from commit 3e6ec47)
@llvmbot
Copy link
Member Author

llvmbot commented Sep 2, 2025

@hubert-reinterpretcast What do you think about merging this PR to the release branch?

@tru tru moved this from Needs Triage to Needs Review in LLVM Release Status Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

2 participants