dongjunduo added a comment.

@jamieschmeiser @Whitney

For now, the time-trace file's name is corresponding to the output file's name 
([demo].o => [demo].json).

The only fly in the ointment is that when the user hasn't given the object 
file's name by "-o", 
the object file may be stored in `/tmp` and its name may be append a random 
string.
The main logic of storing it to a temporary file is here: link 
<https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/Driver.cpp#L5502>.
The random string is created by createUniquePath 
<https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/Path.cpp#L796>.

It has guaranteed the object files' name is unique in the `/tmp`.
If the time-trace file's name follows its corresponding object file's name, it 
may also be unique.
But if the time-trace file's name follows its corresponding source file's name, 
it will cause a naming conflict.

Think about a demo common case:

  $ clang++ -ftime-trace dir1/source.cpp dir2/source.cpp main.cpp

The object files'name of `dir1/source.cpp` and `dir2/source.cpp` must be 
different, but...

1. If the time-trace file's name follows the object file, 
"source-[random-string-1].json" and "source-[random-string-2].json" may be 
created independently.
2. If the time-trace file's name follows the source file, "source.json" will be 
created twice and the first one may be overwritten.

I **prefer** the first one, which is implemented now.
While this method adds an annoying random string, it is guaranteed not to cause 
data overwrites in normal use.

So do we need to change it to the second approach?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131469/new/

https://reviews.llvm.org/D131469

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to