[all-commits] [llvm/llvm-project] 6730b4: [HIP] Fix HIP include path

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Wed Mar 9 17:57:55 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6730b44480fcce18bfbbae0c46719250e9eae425
      https://github.com/llvm/llvm-project/commit/6730b44480fcce18bfbbae0c46719250e9eae425
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2022-03-09 (Wed, 09 Mar 2022)

  Changed paths:
    M clang/lib/Driver/ToolChains/AMDGPU.cpp
    M clang/test/Driver/hip-include-path.hip
    M clang/test/Driver/rocm-detect.hip

  Log Message:
  -----------
  [HIP] Fix HIP include path

The clang compiler prepends the HIP header include paths to the search
list using -internal-isystem when building for the HIP language. This
prevents warnings related to things like reserved identifiers when
including the HIP headers even when ROCm is installed in a non-system
directory, such as /opt/rocm.

However, when HIP is installed in /usr, then the prepended include
path would be /usr/include. That is a problem, because the C standard
library headers are stored in /usr/include and the C++ standard
library headers must come before the C library headers in the search
path list (because the C++ standard library headers use #include_next
to include the C standard library headers).

While the HIP wrapper headers _do_ need to be earlier in the search
than the C++ headers, those headers get their own subdirectory and
their own explicit -internal-isystem argument. This include path is for
<hip/hip_runtime_api.h> and <hip/hip_runtime.h>, which do not require a
particular search ordering with respect to the C or C++ headers. Thus,
HIP include path is added after other system include paths.

With contribution from Cordell Bloor.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D120132




More information about the All-commits mailing list