Support,lld: Rename misnamed F_no_mmap to F_mmap

`F_no_mmap` introduced by https://reviews.llvm.org/D69294 is misnamed.
It oughts to be `F_mmap`

When the output is a regular file or do not exist,
`--no-mmap-output-file` is the default. Relands #134787 by fixing the
lld option default. Note: changing the default to --map-output-file
would likely fail on llvm-clang-x86_64-sie-win
(https://lab.llvm.org/buildbot/#/builders/46/builds/14847)

Pull Request: https://github.com/llvm/llvm-project/pull/139836
This commit is contained in:
Fangrui Song
2025-05-14 21:00:49 -07:00
committed by GitHub
parent 99e8d22d69
commit 369c409348
6 changed files with 8 additions and 9 deletions

View File

@@ -1489,7 +1489,7 @@ template <typename ELFT> void elf::writeARMCmseImportLib(Ctx &ctx) {
const uint64_t fileSize =
sectionHeaderOff + shnum * sizeof(typename ELFT::Shdr);
const unsigned flags =
ctx.arg.mmapOutputFile ? 0 : (unsigned)FileOutputBuffer::F_no_mmap;
ctx.arg.mmapOutputFile ? (unsigned)FileOutputBuffer::F_mmap : 0;
unlinkAsync(ctx.arg.cmseOutputLib);
Expected<std::unique_ptr<FileOutputBuffer>> bufferOrErr =
FileOutputBuffer::create(ctx.arg.cmseOutputLib, fileSize, flags);

View File

@@ -1421,7 +1421,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
ctx.arg.mergeArmExidx =
args.hasFlag(OPT_merge_exidx_entries, OPT_no_merge_exidx_entries, true);
ctx.arg.mmapOutputFile =
args.hasFlag(OPT_mmap_output_file, OPT_no_mmap_output_file, true);
args.hasFlag(OPT_mmap_output_file, OPT_no_mmap_output_file, false);
ctx.arg.nmagic = args.hasFlag(OPT_nmagic, OPT_no_nmagic, false);
ctx.arg.noinhibitExec = args.hasArg(OPT_noinhibit_exec);
ctx.arg.nostdlib = args.hasArg(OPT_nostdlib);

View File

@@ -2908,8 +2908,8 @@ template <class ELFT> void Writer<ELFT>::openFile() {
unsigned flags = 0;
if (!ctx.arg.relocatable)
flags |= FileOutputBuffer::F_executable;
if (!ctx.arg.mmapOutputFile)
flags |= FileOutputBuffer::F_no_mmap;
if (ctx.arg.mmapOutputFile)
flags |= FileOutputBuffer::F_mmap;
Expected<std::unique_ptr<FileOutputBuffer>> bufferOrErr =
FileOutputBuffer::create(ctx.arg.outputFile, fileSize, flags);

View File

@@ -32,9 +32,8 @@ public:
/// Set the 'x' bit on the resulting file.
F_executable = 1,
/// Don't use mmap and instead write an in-memory buffer to a file when this
/// buffer is closed.
F_no_mmap = 2,
/// Use mmap for in-memory file buffer.
F_mmap = 2,
};
/// Factory method to create an OutputBuffer object which manages a read/write

View File

@@ -186,7 +186,7 @@ FileOutputBuffer::create(StringRef Path, size_t Size, unsigned Flags) {
case fs::file_type::regular_file:
case fs::file_type::file_not_found:
case fs::file_type::status_error:
if (Flags & F_no_mmap)
if (Flags & F_mmap)
return createInMemoryBuffer(Path, Size, Mode);
else
return createOnDiskBuffer(Path, Size, Mode);

View File

@@ -123,7 +123,7 @@ TEST(FileOutputBuffer, Test) {
File5.append("/file5");
{
Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
FileOutputBuffer::create(File5, 8000, FileOutputBuffer::F_no_mmap);
FileOutputBuffer::create(File5, 8000, FileOutputBuffer::F_mmap);
ASSERT_NO_ERROR(errorToErrorCode(BufferOrErr.takeError()));
std::unique_ptr<FileOutputBuffer> &Buffer = *BufferOrErr;
// Start buffer with special header.