Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions lld/test/COFF/lto-cache-errors.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; REQUIRES: x86
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://maskray.me/blog/2021-08-08-toolchain-testing#the-test-checks-at-the-wrong-layer

A better test is llvm-lto2 --cache-dir in llvm/test/ThinLTO/X86

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first iteration was there - but it doesn't seem to follow the same code path, I never got the error message that I got from lld-link.

I will merge this now, since a test is better than no test - but I might follow up with a test in the llvm layer when I do the changes to report_fatal_error if people think that's a good change.

;; Not supported on windows since we use permissions to deny the creation
; UNSUPPORTED: system-windows

; RUN: opt -module-hash -module-summary %s -o %t.o
; RUN: opt -module-hash -module-summary %p/Inputs/lto-cache.ll -o %t2.o
; RUN: rm -Rf %t.cache && mkdir %t.cache
; RUN: chmod 444 %t.cache

;; Check emit warnings when we can't create the cache dir
; RUN: not --crash lld-link /lldltocache:%t.cache/nonexistant/ /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s
; CHECK: LLVM ERROR: can't create cache directory {{.*}}/nonexistant/: Permission denied

target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"

define void @globalfunc() #0 {
entry:
ret void
}
4 changes: 3 additions & 1 deletion llvm/lib/Support/Caching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ 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 + ": " +
EC.message());

// Write to a temporary to avoid race condition
SmallString<64> TempFilenameModel;
Expand Down