llvm-objcopy has a test that creates a non-writable file. This file
is causing the clang-with-thin-lto-windows bot to fail because it
cannot clean its build directory. This change makes util.clean_dir()
try harder to remove directory trees, which should allow the bot
to succeed.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
This looks like an improvement, but it still might not work on Windows, because there you're racing the file system--deleting a file on Windows is not an atomic, instantaneous operation. Tune in to https://www.youtube.com/watch?v=uhRWMGBjlO8 at 7:30 for details.
Doesn't shutil.rmtree handle this? I believe it's implemented as SHFileOperation. In any case, it's better to not try and re-invent robust directory tree deletion and just use the tools available.
Doesn't shutil.rmtree handle this?
No. That's the code that's currently running. See here for the error: http://lab.llvm.org:8011/builders/clang-with-thin-lto-windows/builds/8570/steps/stage%202%20clean/logs/stdio
I tested the code on the affected machine. shutil.rmtree fails with the permissions error. The rmtree implementation I wrote succeeds.
I was talking about Adrian’s comment. I know it won’t clear the read only
flag, but Adrian’s comment was about something different.
I don’t think it’s worth the trouble doing anything better though, let the
OS handle it to the best of its ability (which your patch does)
Ah, my bad. Thanks for clarifying, @zturner.
@amccarth, point about possible incorrect directory tree removal semantics well taken, but I'd still like to ship this change as-is if that's ok with you. The reason is that it fixes a problem that is currently causing essentially every build to fail. Hopefully zturner is right and shutil actually does the right thing on Windows, and if not, I'll be happy to cook up a new patch if we find out it's causing problems.
Yes, by all means. My intent was not to block this but to point out that it might still suffer from an already existent problem.
If Zach's right that it uses SHFileOperation under the hood, that goes a long way toward solving the problem.