aaronmondal added a comment.

Fun fact I now know that libxml2 also struggles with this 😆

The following would roughly be how zlib and others handle it:

  if (CLANG_ENABLE_HSA)
  
    if (CLANG_ENABLE_HSA STREQUAL FORCE_ON)
      find_package(hsa-runtime... REQUIRED)
    else()
      find_package (hsa-runtime...)
    endif()
  
    if (hsa-runtime_FOUND)
      # TODO: Some hsa sanity check, executed during configuration.
      # If check passes, `HAVE_HSA` is set.
      if (CLANG_ENABLE_HSA STREQUAL FORCE_ON AND NOT HAVE_HSA)
        message(FATAL_ERROR "Failed to configure HSA.")
      endif()
    endif()
  
    set(CLANG_ENABLE_HSA "${HAVE_HSA}")
  
  else()
    set(CLANG_ENABLE_HSA 0)
  endif()

Then we could remove `__have_include` and could directly check for 
`CLANG_ENABLE_HSA` during compile time.

  #ifdef CLANG_HAVE_HSA
  #include "hsa/hsa.h"
  #endif

Since HSA is used by both OpenMP and the amdgpu-arch plugin, I think it would 
make sense to not call it `CLANG_ENABLE_HSA` but instead use `LLVM_ENABLE_HSA` 
and just put it `llvm/cmake/config-ix.cmake` (where I took the above code from).

@jhuber6 This doesn't consider the "DYNAMIC_..." macros. Do you think an 
approach like this, if worked out a bit more, could work?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143768/new/

https://reviews.llvm.org/D143768

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to