[llvm-dev] Experiment on how to improve our temporary file handing.

Rafael Avila de Espindola via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 13 09:42:21 PST 2017


>> Without special permissions and have instead to depend on proc:
>>
>> linkat(AT_FDCWD, "/proc/self/fd/<num>", AT_FDCWD, "destination",
>>        AT_SYMLINK_FOLLOW)
>>
>
> I often execute lld in a chroot environment in which /proc is not mounted,
> and I expect lld would work just fine in that environment. So the presence
> of /proc should be considered optional even on Linux.

I agree. We would have to check if proc is present before using O_TMPFILE.

> Another annoyance is that linkat will not replace the destination and
>> renameat2 doesn't support AT_EMPTY_PATH. The result is that we have to
>> use unlink+linkat and loop.
>>
>
> I think you can avoid unlink+linkat. You can instead give a temporary file
> name to an unnamed file and then rename the temporary file the destination
> file. There's a small chance between linkat and rename, but that race
> condition is probably better than unlink+linkat.

True. I feels silly that we still need to create a temporary name with
O_TMPFILE, but that is a possibility.

In any case. I will focus on the windows case first as it seems to be
the more generally available API.

Cheers,
Rafael


More information about the llvm-dev mailing list