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

CMake fix for Mac building #1181

Open
MirceaS opened this issue Dec 9, 2024 · 3 comments
Open

CMake fix for Mac building #1181

MirceaS opened this issue Dec 9, 2024 · 3 comments

Comments

@MirceaS
Copy link

MirceaS commented Dec 9, 2024

When I try to build the LLVM backend on my M1 Mac I keep running into issues due to how CMake handles the versioning of LLVM.
In particular, the issue is with the lines below:

find_package(LLVM 18.1 QUIET CONFIG)
if (NOT LLVM_FOUND)
find_package(LLVM 17 QUIET CONFIG)
endif()
if (NOT LLVM_FOUND)
find_package(LLVM 16 QUIET CONFIG)
endif()
if (NOT LLVM_FOUND)
find_package(LLVM 15 QUIET CONFIG)
endif()

I have LLVM version 15.0.7 installed but for some reason this is not found by find_package(LLVM 15 QUIET CONFIG). I also tried to change it to find_package(LLVM 15...<16 QUIET CONFIG) but this also failed.
If I simply replace all of these lines by find_package(LLVM REQUIRED CONFIG) then everything works fine, so I would propose doing this change (I would have opened a PR but I don't seem to have permission to do so). Lines 15-18 will still make sure that an appropriate llvm version was selected so it feels like trying out all of these higher versions in hopes of finding the right one seems redundant. I figured this might be in place to make sure that the highest version gets selected in multiple are installed, but as far as I could tell reading online, if no version is specified the highest one will be selected by default anyway.

@Robertorosmaninho
Copy link
Collaborator

Hey @MirceaS, I believe the issue here is that:

  1. We need to have a constraint on the LLVM version we find, that is, we need to enforce that 15 <= LLVM Version <= 18.1. And find_package(LLVM REQUIRED CONFIG) doesn't guarantee that.
  2. The REQUIRED option is also very useful! However, I believe the problem with it is the error message not very useful, that's why we silence the find_package's errors, and we emit our own useful error message here

@MirceaS
Copy link
Author

MirceaS commented Dec 11, 2024

Well, we don't actually check that the version that we get is less than 18.1. We only check that it is above 15. Maybe we should also add that to the check then.

@Robertorosmaninho
Copy link
Collaborator

We check that it's 18.1, 17, 16 or 15. That's enough for this purpose...

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

No branches or pull requests

2 participants