From d14ab2daecfee509706a5ccec3882ad35ceae908 Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Wed, 18 Apr 2018 13:48:49 +0200 Subject: [PATCH] Improve the search of the clang instance for CUDA. Before, it was not possible to find the clang++, which is contained in the cling, if we don't start the clang from the bin folder ('./cling -xcuda'). Now, for example it is possible to start the cling with 'bin/cling -xcuda' . Fix a Bug, which avoid to start './cling -xcuda -fsyntax-only'. --- lib/Interpreter/IncrementalCUDADeviceCompiler.cpp | 7 ++++++- lib/Interpreter/IncrementalParser.cpp | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Interpreter/IncrementalCUDADeviceCompiler.cpp b/lib/Interpreter/IncrementalCUDADeviceCompiler.cpp index b1dc6ca1..288cdf0e 100644 --- a/lib/Interpreter/IncrementalCUDADeviceCompiler.cpp +++ b/lib/Interpreter/IncrementalCUDADeviceCompiler.cpp @@ -125,7 +125,12 @@ namespace cling { cling::InvocationOptions & invocationOptions){ // Search after clang in the folder of cling. llvm::SmallString<128> cwd; - llvm::sys::fs::current_path(cwd); + // get folder of the cling executable to find the clang which is contained + // in cling + // nullptr is ok, if we are the main and not a shared library + cwd.append(llvm::sys::path::parent_path( + llvm::sys::fs::getMainExecutable( + invocationOptions.CompilerOpts.Remaining[0], (void *) &cwd))); cwd.append(llvm::sys::path::get_separator()); cwd.append("clang++"); m_ClangPath = cwd.c_str(); diff --git a/lib/Interpreter/IncrementalParser.cpp b/lib/Interpreter/IncrementalParser.cpp index e5e477ac..c07f446c 100644 --- a/lib/Interpreter/IncrementalParser.cpp +++ b/lib/Interpreter/IncrementalParser.cpp @@ -793,8 +793,9 @@ namespace cling { else if (Diags.getNumWarnings()) return kSuccessWithWarnings; - if(m_CI->getLangOpts().CUDA ) - m_Interpreter->getCUDADeviceCompiler().generateFatbinary(input, m_Consumer->getTransaction()); + if(!m_Interpreter->isInSyntaxOnlyMode() && m_CI->getLangOpts().CUDA ) + m_Interpreter->getCUDADeviceCompiler() + .generateFatbinary(input, m_Consumer->getTransaction()); return kSuccess; }