[all-commits] [llvm/llvm-project] 01d393: [Clang][HIP] Include `__clang_cuda_math_forward_de...

Juan Manuel Martinez Caamaño via All-commits all-commits at lists.llvm.org
Tue Jun 9 03:20:27 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 01d3932364bee33f8e861d5664c2983cc855124f
      https://github.com/llvm/llvm-project/commit/01d3932364bee33f8e861d5664c2983cc855124f
  Author: Juan Manuel Martinez Caamaño <jmartinezcaamao at gmail.com>
  Date:   2026-06-09 (Tue, 09 Jun 2026)

  Changed paths:
    M clang/lib/Headers/__clang_hip_runtime_wrapper.h
    A clang/test/Headers/hip-constexpr-cmath.hip

  Log Message:
  -----------
  [Clang][HIP] Include `__clang_cuda_math_forward_declares.h` before `<cmath>` (#201563)

In HIP, `constexpr` functions are treated as both `__host__` and
`__device__`.

A new version of the MS STL shipped with the build tools version
14.51.36231 has `constexpr` definitions for some `cmath` functions when
the
compiler in use is Clang (this gets worse when C++23 is in use).

These definitions conflict with the `__device__` declarations we provide
in the header wrappers.

There is a workaround for this: We do not mark `constexpr`
functions [_that are defined in a system
header_](https://github.com/llvm/llvm-project/blob/03127a03860b9d8cb440fe8f51c00647f45eb8be/clang/lib/Sema/SemaCUDA.cpp#L877)
as
`__host__` and `__device__` if there is a previous `__device__`
 declaration.

By moving `__clang_cuda_math_forward_declares.h` before `<cmath>` is
included we're able to benefit from this behavior.

This fixes error like this one
https://github.com/ggml-org/llama.cpp/issues/22570
even for recent versions of C++.

This patch should address C++23 concerns where more functions are marked
as `constexpr`.
However, we should still figure out how to provide `__device__
constexpr` versions for those functions, or not provide ours and use the
system's if they exist.

This patch replaces https://github.com/llvm/llvm-project/pull/200395



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list