Fix temp-path bug.

In some cases, the path of the cling temp folder contains some non printable chars at the end.
Change the handling of the path string, to solve this problem.
This commit is contained in:
Simeon Ehrig 2018-04-18 11:14:10 +02:00 committed by sftnight
parent b87dfcf9b1
commit 2b61966c0d

View File

@ -241,21 +241,25 @@ namespace cling {
if(!isInSyntaxOnlyMode() && m_Opts.CompilerOpts.CUDA){
// Create temporary folder for all files, which the CUDA device compiler
// will generate.
llvm::SmallVector<char, 256> TmpFolder;
llvm::SmallString<256> TmpPath;
llvm::StringRef sep = llvm::sys::path::get_separator().data();
llvm::sys::path::system_temp_directory(false, TmpFolder);
llvm::sys::fs::createUniqueFile(std::string(TmpFolder.data())
+ sep + "cling-%%%%" + sep , TmpFolder);
llvm::sys::path::system_temp_directory(false, TmpPath);
TmpPath.append(sep.data());
TmpPath.append("cling-%%%%");
TmpPath.append(sep.data());
llvm::SmallString<256> TmpFolder;
llvm::sys::fs::createUniqueFile(TmpPath.c_str(), TmpFolder);
llvm::sys::fs::create_directory(TmpFolder);
// The CUDA fatbin file is the connection beetween the CUDA device
// compiler and the CodeGen of cling. The file will every time reused.
if(getCI()->getCodeGenOpts().CudaGpuBinaryFileNames.empty())
getCI()->getCodeGenOpts().CudaGpuBinaryFileNames.push_back(
std::string(TmpFolder.data()) + "cling.fatbin");
std::string(TmpFolder.c_str()) + "cling.fatbin");
m_CUDACompiler.reset(
new IncrementalCUDADeviceCompiler(TmpFolder.data(),
new IncrementalCUDADeviceCompiler(TmpFolder.c_str(),
m_OptLevel,
m_Opts,
getCI()));