[libc-commits] [PATCH] D153637: [libc] Fix installing GPU headers

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Jun 23 08:44:29 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: sivachandra, aidengrossman, phosek.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
jhuber6 requested review of this revision.

The patch in D152592 <https://reviews.llvm.org/D152592> changed the logic for this. We could never check if
we were on the GPU as this was before the variable was defined so I
moved it later. Secondly, we cannot use the `LLVM_BINARY_DIR` here, and
I do not know if that works in general. The problem is that it will
isntall the headers under a normal path outside of the
`LLVM_ENABLE_RUNTIMES` build. I don't know if that's correct for the
other targets, but for the GPU I need to set it back to the
CMAKE_BINARY_DIR so it works.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153637

Files:
  libc/CMakeLists.txt


Index: libc/CMakeLists.txt
===================================================================
--- libc/CMakeLists.txt
+++ libc/CMakeLists.txt
@@ -19,28 +19,6 @@
 
 set(LIBC_ENABLE_USE_BY_CLANG OFF CACHE BOOL "Whether or not to place libc in a build directory findable by a just built clang")
 
-if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
-  set(LIBC_INCLUDE_DIR ${LLVM_BINARY_DIR}/include/gpu-none-llvm)
-  set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/gpu-none-llvm)
-  set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/gnu-none-llvm)
-elseif(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND LIBC_ENABLE_USE_BY_CLANG)
-  set(LIBC_INCLUDE_DIR ${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE})
-  set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
-  set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
-else()
-  if(NOT LIBC_ENABLE_USE_BY_CLANG)
-    set(LIBC_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
-    set(LIBC_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/lib)
-  elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
-    set(LIBC_INCLUDE_DIR ${LLVM_BINARY_DIR}/include)
-    set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
-  else()
-    set(LIBC_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
-    set(LIBC_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
-  endif()
-  set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
-endif()
-
 if(LLVM_LIBC_FULL_BUILD OR LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES)
   if(NOT LIBC_HDRGEN_EXE)
     # We need to set up hdrgen first since other targets depend on it.
@@ -106,6 +84,28 @@
 # Defines LIBC_TARGET_ARCHITECTURE and associated macros.
 include(LLVMLibCArchitectures)
 
+if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
+  set(LIBC_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/gpu-none-llvm)
+  set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/gpu-none-llvm)
+  set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/gnu-none-llvm)
+elseif(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND LIBC_ENABLE_USE_BY_CLANG)
+  set(LIBC_INCLUDE_DIR ${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE})
+  set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+  set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE})
+else()
+  if(NOT LIBC_ENABLE_USE_BY_CLANG)
+    set(LIBC_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
+    set(LIBC_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/lib)
+  elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
+    set(LIBC_INCLUDE_DIR ${LLVM_BINARY_DIR}/include)
+    set(LIBC_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
+  else()
+    set(LIBC_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
+    set(LIBC_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+  endif()
+  set(LIBC_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
+endif()
+
 if(LIBC_TARGET_ARCHITECTURE_IS_GPU)
   include(prepare_libc_gpu_build)
   set(LIBC_ENABLE_UNITTESTS OFF)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153637.533974.patch
Type: text/x-patch
Size: 2910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230623/b20f8b9e/attachment.bin>


More information about the libc-commits mailing list