Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Protect against path with space #2318

Merged
merged 1 commit into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions taichi/llvm/llvm_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ void compile_runtime_bitcode(Arch arch) {

std::string arch_macro = fmt::format(" -D ARCH_{}", arch_name(arch));
auto cmd = fmt::format(
"{} -S {}runtime.cpp -o {}runtime.ll -fno-exceptions "
"-emit-llvm -std=c++17 {} -I {}",
"{} -S \"{}runtime.cpp\" -o \"{}runtime.ll\" -fno-exceptions "
"-emit-llvm -std=c++17 {} -I \"{}\"",
clang, runtime_src_folder, runtime_folder, arch_macro, get_repo_dir());
int ret = std::system(cmd.c_str());
if (ret) {
TI_ERROR("LLVMRuntime compilation failed.");
}
cmd = fmt::format("llvm-as {}runtime.ll -o {}", runtime_folder,
cmd = fmt::format("llvm-as \"{}runtime.ll\" -o \"{}\"", runtime_folder,
dst_runtime_bc);
std::system(cmd.c_str());
TI_TRACE("Runtime module bitcode compiled.");
Expand All @@ -214,7 +214,8 @@ void compile_runtime_bitcode(Arch arch) {
auto ret = fs::copy_file(dst_runtime_bc, src_runtime_bc,
fs::copy_options::overwrite_existing);
#else
auto ret = (system(fmt::format("cp {} {}", dst_runtime_bc, src_runtime_bc)
auto ret = (system(fmt::format("cp \"{}\" \"{}\"", dst_runtime_bc,
src_runtime_bc)
.c_str()) &
255) == 0;
#endif
Expand Down