diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 13280ed0cec22..7b39e24660091 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -13,8 +13,6 @@ #include "Config.h" #include "InputFiles.h" #include "LinkerScript.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/Path.h" #include "MapFile.h" #include "OutputSections.h" #include "Relocations.h" @@ -2800,15 +2798,6 @@ template void Writer::writeHeader() { sec->writeHeaderTo(++sHdrs); } -static StringRef parentPathOrDot(StringRef path) { - auto parent_path = sys::path::parent_path(path); - if (parent_path.empty() && !path.empty() && !sys::path::is_absolute(path)) { - return "."; - } else { - return parent_path; - } -} - // Open a result file. template void Writer::openFile() { uint64_t maxSize = config->is64 ? INT64_MAX : UINT32_MAX; @@ -2829,18 +2818,6 @@ template void Writer::openFile() { flags |= FileOutputBuffer::F_executable; if (!config->mmapOutputFile) flags |= FileOutputBuffer::F_no_mmap; - if (config->mmapOutputFile) { - // LLD relies on [fallocate] to mmap the output. - // In case there's no space left on the device - // it will error with SIGBUS, which is confusing - // for users - auto ErrOrSpaceInfo = sys::fs::disk_space(parentPathOrDot(config->outputFile)); - if (!ErrOrSpaceInfo) - error("Can't get remaining size on disk"); - if (ErrOrSpaceInfo.get().free < fileSize) - error("failed to open " + config->outputFile + ": " + - "No Space Left on Device"); - } Expected> bufferOrErr = FileOutputBuffer::create(config->outputFile, fileSize, flags);