[libc] Fix `nvptx_options` variable not being reset in CMake
authorJoseph Huber <jhuber6@vols.utk.edu>
Wed, 19 Apr 2023 20:27:33 +0000 (15:27 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 19 Apr 2023 20:28:26 +0000 (15:28 -0500)
Summary:
This variable was not being reset, which caused the options to be
compounded when building multiple architectures. This was very
problematic as the architectures are not compatible.

libc/cmake/modules/LLVMLibCObjectRules.cmake

index 5a9fdc6..b62a799 100644 (file)
@@ -66,11 +66,12 @@ endfunction()
 
 # Obtains NVPTX specific arguments for compilation.
 # The PTX feature is primarily based on the CUDA toolchain version. We want to
-# be able to target NVPTX without an existing architecture, so we need to set
-# this manually. This simply sets the PTX feature to the minimum required for
-# the features we wish to use on that target.
+# be able to target NVPTX without an existing CUDA installation, so we need to
+# set this manually. This simply sets the PTX feature to the minimum required
+# for the features we wish to use on that target.
 # Adjust as needed for desired PTX features.
 function(get_nvptx_compile_options output_var gpu_arch)
+  set(nvptx_options "")
   list(APPEND nvptx_options "-march=${gpu_arch}")
   if(${gpu_arch} STREQUAL "sm_35")
     list(APPEND nvptx_options "--cuda-feature=+ptx42")