[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Nov 24 13:50:40 PST 2024


================
@@ -50,43 +42,28 @@ macro(enable_cuda_compilation name files)
       "${CUDA_COMPILE_OPTIONS}"
       )
 
-    if (EXISTS "${FLANG_LIBCUDACXX_PATH}/include")
+    if (EXISTS "${FLANG_RT_LIBCUDACXX_PATH}/include")
       # When using libcudacxx headers files, we have to use them
       # for all files of F18 runtime.
-      include_directories(AFTER ${FLANG_LIBCUDACXX_PATH}/include)
+      include_directories(AFTER ${FLANG_RT_LIBCUDACXX_PATH}/include)
       add_compile_definitions(RT_USE_LIBCUDACXX=1)
     endif()
 
     # Add an OBJECT library consisting of CUDA PTX.
-    llvm_add_library(${name}PTX OBJECT PARTIAL_SOURCES_INTENDED ${files})
-    set_property(TARGET obj.${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
-    if (FLANG_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
-      target_compile_definitions(obj.${name}PTX
-        PRIVATE FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
+    add_flangrt_library(${name}PTX OBJECT ${files})
----------------
Meinersbur wrote:

Either I was confused by the `OBJECT` argument[^1] or had the impression that only the `*.ptx` files are the ones needed here. In any case, I wasn't aware that the `.a` files consists of those `*.ptx` files. Fixed in the last PR push.

`CUDA_PTX_COMPILATION` can only be applied to object libraries. There seems to be no way in CMake to include those `.ptx` files into a static library without an intermediate object library. The usual tools such as `nm`, `objdump`, or `strip` don't like `.a` files built this way. I wonder whether this is sound.

[^1]: The semantics of `SHARED`/`STATIC`/`OBJECT` are pairwise different in `llvm_add_library`, `add_flang_library`, and CMake's `add_library`, a mistake I don't want to repeat for `add_flangrt_library`. Whether `llvm_add_library` actually creates a `obj.${name}` is present depends on not only function arguments, but also e.g. globals such as `BUILD_SHARED_LIBS`. `OBJECT` does NOT imply `STATIC`, but can also be a `SHARED` library if `BUILD_SHARED_LIBS=ON`. At least creating a shared library out of `.ptx` files does not work.

https://github.com/llvm/llvm-project/pull/110217


More information about the llvm-branch-commits mailing list