[libc] Fix CMake deduplication `-Xclang` arguments
authorJoseph Huber <jhuber6@vols.utk.edu>
Tue, 14 Mar 2023 20:03:22 +0000 (15:03 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Tue, 14 Mar 2023 20:04:37 +0000 (15:04 -0500)
Summary:
We use `-Xclang` to pass the GPU binary to be embedded. In the case of
multi-source objects this will be passed more than once, but CMake
implicitly deduplicates arguments. Use the special generator to prevent
this from happening.

libc/cmake/modules/LLVMLibCObjectRules.cmake

index 0630cf5..e97a6a4 100644 (file)
@@ -173,9 +173,11 @@ function(_build_gpu_objects fq_target_name internal_target_name)
   target_compile_options(${fq_target_name} BEFORE PRIVATE
                          ${common_compile_options} -nostdlib)
   foreach(packaged_gpu_binary ${packaged_gpu_binaries})
+    message(STATUS ${packaged_gpu_binary})
     target_compile_options(${fq_target_name} PRIVATE
-                           -Xclang -fembed-offload-object=${packaged_gpu_binary})
+                           "SHELL:-Xclang -fembed-offload-object=${packaged_gpu_binary}")
   endforeach()
+    message(STATUS "\n")
   target_include_directories(${fq_target_name} PRIVATE ${include_dirs})
   add_dependencies(${fq_target_name}
                    ${full_deps_list} ${packaged_gpu_names} ${stub_target_name})