[llvm] [Support] Better error msg when cache dir can't be created. (PR #69575)
Tobias Hieta via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 19 02:34:57 PDT 2023
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/69575
>From c66936964c514b12e97be747d7f4384278cfd260 Mon Sep 17 00:00:00 2001
From: Tobias Hieta <tobias.hieta at ubisoft.com>
Date: Thu, 19 Oct 2023 11:10:35 +0200
Subject: [PATCH 1/2] [Support] Better error msg when cache dir can't be
created.
On windows if you passed /lldltocache:D:\tmp to lld and you didn't have
D: mounted it fail to create the cache dir D:\tmp, but the error message
is pretty hard to understand:
```
c:\code\llvm\llvm-project\out\debug>bin\lld-link.exe /lldltocache:D:\tmp
hello.obj
LLVM ERROR: no such file or directory
PLEASE submit a bug report to
https://github.com/llvm/llvm-project/issues/ and include the crash
backtrace.
Exception Code: 0xC000001D
```
Which lead one of our users to report this as a crash. I have just added
a bit better message so it now says:
```
c:\code\llvm\llvm-project\out\debug>bin\lld-link.exe /lldltocache:D:\tmp
hello.obj
LLVM ERROR: Can't create cache directory: D:\tmp
PLEASE submit a bug report to
https://github.com/llvm/llvm-project/issues/ and include the crash
backtrace.
```
I am not sure this is a fatal error because it's not something that
really should be reported as a bug to LLVM. But at least this gives a
bit more visibility on what to change.
---
llvm/lib/Support/Caching.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Support/Caching.cpp b/llvm/lib/Support/Caching.cpp
index f20f08a865c76ff..722746e7b440390 100644
--- a/llvm/lib/Support/Caching.cpp
+++ b/llvm/lib/Support/Caching.cpp
@@ -145,7 +145,7 @@ Expected<FileCache> llvm::localCache(const Twine &CacheNameRef,
// ensures the filesystem isn't mutated until the cache is.
if (std::error_code EC = sys::fs::create_directories(
CacheDirectoryPath, /*IgnoreExisting=*/true))
- return errorCodeToError(EC);
+ return createStringError(EC, Twine("Can't create cache directory: ") + CacheDirectoryPath);
// Write to a temporary to avoid race condition
SmallString<64> TempFilenameModel;
>From 0ac14c549cf6ad0250a47789b3a6167b4c5b014b Mon Sep 17 00:00:00 2001
From: Tobias Hieta <tobias.hieta at ubisoft.com>
Date: Thu, 19 Oct 2023 11:34:38 +0200
Subject: [PATCH 2/2] Fix formatting
---
llvm/lib/Support/Caching.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Support/Caching.cpp b/llvm/lib/Support/Caching.cpp
index 722746e7b440390..c13957ba849387d 100644
--- a/llvm/lib/Support/Caching.cpp
+++ b/llvm/lib/Support/Caching.cpp
@@ -145,7 +145,8 @@ Expected<FileCache> llvm::localCache(const Twine &CacheNameRef,
// ensures the filesystem isn't mutated until the cache is.
if (std::error_code EC = sys::fs::create_directories(
CacheDirectoryPath, /*IgnoreExisting=*/true))
- return createStringError(EC, Twine("Can't create cache directory: ") + CacheDirectoryPath);
+ return createStringError(EC, Twine("Can't create cache directory: ") +
+ CacheDirectoryPath);
// Write to a temporary to avoid race condition
SmallString<64> TempFilenameModel;
More information about the llvm-commits
mailing list