@@ -303,16 +303,16 @@ static int CeedCompileCore_Cuda(Ceed ceed, const char *source, const bool throw_
303303 Ceed_Cuda *ceed_data;
304304
305305 CeedCallBackend (CeedGetData (ceed, &ceed_data));
306- char *llvm_command = ceed_data->llvm_command ;
306+ char *llvm_cxx = ceed_data->llvm_cxx ;
307307
308308 // First check for user LLVM version
309- if (!llvm_command ) {
309+ if (!llvm_cxx ) {
310310 const char *user_cxx = getenv (" CEED_CLANG_CUDA_CXX" );
311311 CeedDebug (ceed, " Attempting to detect user specified LLVM compiler\n User LLVM compiler: %s\n " , user_cxx);
312312
313313 // Check if valid Clang
314- bool is_valid = true ;
315- {
314+ bool is_valid = false ;
315+ if (user_cxx) {
316316 std::string command = std::string (user_cxx) + " --version 2>&1" ;
317317
318318 CeedDebug (ceed, " Checking user LLVM compiler..." );
@@ -321,14 +321,14 @@ static int CeedCompileCore_Cuda(Ceed ceed, const char *source, const bool throw_
321321
322322 if (is_valid) {
323323 CeedDebug (ceed, " User specified LLVM compiler is valid\n " );
324- CeedCall (CeedStringAllocCopy (user_cxx, &ceed_data->llvm_command ));
325- llvm_command = ceed_data->llvm_command ;
324+ CeedCall (CeedStringAllocCopy (user_cxx, &ceed_data->llvm_cxx ));
325+ llvm_cxx = ceed_data->llvm_cxx ;
326326 } else {
327327 CeedDebug (ceed, " Could not invoke user specified LLVM compiler\n " );
328328 }
329329 }
330330 // Next query Rust for LLVM version
331- if (!llvm_command ) {
331+ if (!llvm_cxx ) {
332332 command = " $(find $(rustup run " + std::string (rust_toolchain) + " rustc --print sysroot) -name llvm-link) --version" ;
333333 CeedDebug (ceed, " Attempting to detect Rust LLVM version\n command:\n $ %s" , command.c_str ());
334334 FILE *output_stream = popen ((command + std::string (" 2>&1" )).c_str (), " r" );
@@ -355,7 +355,7 @@ static int CeedCompileCore_Cuda(Ceed ceed, const char *source, const bool throw_
355355 CeedDebug (ceed, " Detected Rust LLVM version: %d" , llvm_version);
356356
357357 // Check if valid Clang
358- bool is_valid = true ;
358+ bool is_valid = false ;
359359 std::string rust_cxx = std::string (" clang++-" ) + std::to_string (llvm_version);
360360 {
361361 std::string command = std::string (rust_cxx) + " --version 2>&1" ;
@@ -366,19 +366,19 @@ static int CeedCompileCore_Cuda(Ceed ceed, const char *source, const bool throw_
366366
367367 if (is_valid) {
368368 CeedDebug (ceed, " Detected Rust LLVM compiler: %s\n " , rust_cxx.c_str ());
369- CeedCall (CeedStringAllocCopy (rust_cxx.c_str (), &ceed_data->llvm_command ));
370- llvm_command = ceed_data->llvm_command ;
369+ CeedCall (CeedStringAllocCopy (rust_cxx.c_str (), &ceed_data->llvm_cxx ));
370+ llvm_cxx = ceed_data->llvm_cxx ;
371371 }
372372 }
373- if (!llvm_command ) CeedDebug (ceed, " Could not invoke detected Rust LLVM compiler\n " );
373+ if (!llvm_cxx ) CeedDebug (ceed, " Could not invoke detected Rust LLVM compiler\n " );
374374 }
375375 // Default to clang++
376- if (!llvm_command ) {
376+ if (!llvm_cxx ) {
377377 CeedDebug (ceed, " Default LLVM compiler: clang++\n " );
378- CeedCall (CeedStringAllocCopy (" clang++" , &ceed_data->llvm_command ));
379- llvm_command = ceed_data->llvm_command ;
378+ CeedCall (CeedStringAllocCopy (" clang++" , &ceed_data->llvm_cxx ));
379+ llvm_cxx = ceed_data->llvm_cxx ;
380380 {
381- std::string command = std::string (llvm_command ) + " --version 2>&1" ;
381+ std::string command = std::string (llvm_cxx ) + " --version 2>&1" ;
382382
383383 CeedDebug (ceed, " Checking default LLVM compiler..." );
384384 CeedCallSystem_Unchecked (ceed, command.c_str (), " checking default LLVM compiler" , NULL );
@@ -387,9 +387,9 @@ static int CeedCompileCore_Cuda(Ceed ceed, const char *source, const bool throw_
387387
388388 // Compile wrapper kernel
389389 CeedCallCuda (ceed, cudaGetDeviceProperties (&prop, ceed_data->device_id ));
390- command = (llvm_command ? std::string (llvm_command) : std::string ( " clang++ " )) + " -flto=thin --cuda-gpu-arch=sm_" + std::to_string (prop.major ) +
391- std::to_string (prop. minor ) + " --cuda-device-only -emit-llvm -S temp/kernel_" + std::to_string (build_id) +
392- " _0_source.cu -o temp/kernel_ " + std::to_string (build_id) + " _1_wrapped.ll " ;
390+ command = std::string (llvm_cxx) + " -flto=thin --cuda-gpu-arch=sm_" + std::to_string (prop.major ) + std::to_string (prop. minor ) +
391+ " --cuda-device-only -emit-llvm -S temp/kernel_" + std::to_string (build_id) + " _0_source.cu -o temp/kernel_ " +
392+ std::to_string (build_id) + " _1_wrapped.ll " ;
393393 command += opts[4 ];
394394 CeedCallSystem (ceed, command.c_str (), " JiT kernel source" );
395395 CeedCallSystem (ceed, (" chmod 0777 temp/kernel_" + std::to_string (build_id) + " _1_wrapped.ll" ).c_str (), " update JiT file permissions" );
0 commit comments