NVIDIA / NVIDIA/cuda-quantum

[CMake] `find_package` call destroys `LLVM_DIR` variable

Open
#2,959 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build dependencies stale-notified
Dominant language
C++
Stars
1.1k
Forks
456
Avg merge
1d 22h
Merged PRs (30d)
165

Description

Required prerequisites
  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!
Describe the bug

Hi,

I've set the LLVM_DIR variable to specify a (custom/local) LLVM build and I noticed two issues:

  • The call find_package(LLVM ${CUDAQ_LLVM_VERSION} CONFIG QUIET) destroys the variable and shows as not found in later stages.
  • The QUIET in the previous call actually suppressed any underlying cause of failure and should probably be more user friendly. In fact, if the initial attempt at LLVM resolution fails, the build needs to put a warning so that the user is made aware.

Best,

Steps to reproduce the bug
  • Simply surround the call find_package() with status messages:
message(STATUS "LLVM_DIR Before the call: ${LLVM_DIR}")
find_package(LLVM ${CUDAQ_LLVM_VERSION} CONFIG QUIET)
message(STATUS "LLVM_DIR After the call: ${LLVM_DIR}")
  • Run CMake config with -DLLVM_DIR="/some/path" or via a preset file (I use the latter)
Expected behavior

I expect the LLVM_DIR variable to remain intact after the call find_project() as it's gonna be needed for later stages

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment
  • CUDA-Q version: main branch
  • Python version: 3.11
  • C++ compiler: Clang
  • Operating system: Arch Linux
Suggestions

Maybe reorder LLVM resolution steps. Definitely revisit the call find_package(). I don't think it should be QUIET. LLVM resolution is really painful, I have a feeling it's too overfit. I would make it simple: be explicit about expected versions and support custom builds (of those expected versions)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the CMake entry point containing find_package(LLVM ${CUDAQ_LLVM_VERSION} CONFIG QUIET) and inspect the surrounding LLVM resolution steps. Reproduce with CMake configured using -DLLVM_DIR="/some/path" or a preset, then verify that LLVM_DIR remains available afterward and that an unsuccessful initial resolution gives a visible warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.