Skip to content

Fix build compatibility with macOS 26 and Apple Clang 21#4295

Open
ikkoham wants to merge 7 commits intoNVIDIA:mainfrom
ikkoham:fix/macos-26-apple-clang-21-compat
Open

Fix build compatibility with macOS 26 and Apple Clang 21#4295
ikkoham wants to merge 7 commits intoNVIDIA:mainfrom
ikkoham:fix/macos-26-apple-clang-21-compat

Conversation

@ikkoham
Copy link
Copy Markdown
Collaborator

@ikkoham ikkoham commented Apr 10, 2026

Summary

macOS 26 (Tahoe) SDK removed __has_builtin guards from libc++ headers (e.g., __builtin_ctzg, __is_nothrow_convertible), making them incompatible with LLVM 16's clang. Additionally, Apple Clang 21 introduced new warnings that break the build under -Werror.

This PR fixes both issues so that CUDA-Q builds and passes all tests on macOS 26 with Apple Clang 21.

LLVM libc++ runtimes (SDK 26+)

  • set_env_defaults.sh: Auto-detect active SDK version via xcrun --show-sdk-version. When SDK >= 26, include runtimes in LLVM_PROJECTS to build LLVM's own libc++.
  • cudaq-quake.cpp: Use -nostdinc++ to suppress SDK C++ headers when LLVM's libc++ is available, while keeping -isysroot for C standard headers.
  • nvq++.in: Add -Wl,-syslibroot for ld64.lld to find libSystem in the SDK. Add -lc++abi during final link when LLVM's libc++abi is present.
  • build_llvm.sh: Do not bake SDK sysroot paths into clang++.cfg on macOS (they become stale after Xcode updates). Sysroot is resolved at runtime by nvq++.

Relocatable linking

  • nvq++.in: LLVM 16's ld64.lld does not implement -r (relocatable linking). Probe the configured linker and fall back to system ld for the object merge step if needed.
  • device_call.cpp: Update FileCheck pattern to match both Apple ld and ld64.lld error formats.

Apple Clang 21 warnings

  • CMakeLists.txt: Add -Wno-character-conversion for gtest (third-party).
  • server_impl/CMakeLists.txt: Add -Wno-deprecated-literal-operator for Crow (third-party).
  • cudaq.cpp: Fix -Wnontrivial-memcall on memset with std::vector<bool>.
  • vqe_tester.cpp: Add missing #pragma to suppress -Wdeprecated-declarations for backward-compatibility test (matching existing pattern in builder_tester.cpp).

Signed-off-by: ikkoham <ikkoham@users.noreply.github.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Apr 10, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@sacpis
Copy link
Copy Markdown
Collaborator

sacpis commented Apr 10, 2026

/ok to test d9566e7

Command Bot: Processing...

github-actions Bot pushed a commit that referenced this pull request Apr 10, 2026
@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@sacpis
Copy link
Copy Markdown
Collaborator

sacpis commented Apr 20, 2026

/ok to test b53ad52

Command Bot: Processing...

github-actions Bot pushed a commit that referenced this pull request Apr 20, 2026
@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Signed-off-by: ikkoham <ikkoham@users.noreply.github.com>
@taalexander
Copy link
Copy Markdown
Collaborator

Thanks for putting this together Ikko. I don't have my macOS machine with me this week but will test and review next week.

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.

3 participants