Skip to content

Commit 369c409

Browse files
authored
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: #139836
1 parent 99e8d22 commit 369c409

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

lld/ELF/Arch/ARM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ template <typename ELFT> void elf::writeARMCmseImportLib(Ctx &ctx) {
14891489
const uint64_t fileSize =
14901490
sectionHeaderOff + shnum * sizeof(typename ELFT::Shdr);
14911491
const unsigned flags =
1492-
ctx.arg.mmapOutputFile ? 0 : (unsigned)FileOutputBuffer::F_no_mmap;
1492+
ctx.arg.mmapOutputFile ? (unsigned)FileOutputBuffer::F_mmap : 0;
14931493
unlinkAsync(ctx.arg.cmseOutputLib);
14941494
Expected<std::unique_ptr<FileOutputBuffer>> bufferOrErr =
14951495
FileOutputBuffer::create(ctx.arg.cmseOutputLib, fileSize, flags);

lld/ELF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
14211421
ctx.arg.mergeArmExidx =
14221422
args.hasFlag(OPT_merge_exidx_entries, OPT_no_merge_exidx_entries, true);
14231423
ctx.arg.mmapOutputFile =
1424-
args.hasFlag(OPT_mmap_output_file, OPT_no_mmap_output_file, true);
1424+
args.hasFlag(OPT_mmap_output_file, OPT_no_mmap_output_file, false);
14251425
ctx.arg.nmagic = args.hasFlag(OPT_nmagic, OPT_no_nmagic, false);
14261426
ctx.arg.noinhibitExec = args.hasArg(OPT_noinhibit_exec);
14271427
ctx.arg.nostdlib = args.hasArg(OPT_nostdlib);

lld/ELF/Writer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,8 +2908,8 @@ template <class ELFT> void Writer<ELFT>::openFile() {
29082908
unsigned flags = 0;
29092909
if (!ctx.arg.relocatable)
29102910
flags |= FileOutputBuffer::F_executable;
2911-
if (!ctx.arg.mmapOutputFile)
2912-
flags |= FileOutputBuffer::F_no_mmap;
2911+
if (ctx.arg.mmapOutputFile)
2912+
flags |= FileOutputBuffer::F_mmap;
29132913
Expected<std::unique_ptr<FileOutputBuffer>> bufferOrErr =
29142914
FileOutputBuffer::create(ctx.arg.outputFile, fileSize, flags);
29152915

llvm/include/llvm/Support/FileOutputBuffer.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ class FileOutputBuffer {
3232
/// Set the 'x' bit on the resulting file.
3333
F_executable = 1,
3434

35-
/// Don't use mmap and instead write an in-memory buffer to a file when this
36-
/// buffer is closed.
37-
F_no_mmap = 2,
35+
/// Use mmap for in-memory file buffer.
36+
F_mmap = 2,
3837
};
3938

4039
/// Factory method to create an OutputBuffer object which manages a read/write

llvm/lib/Support/FileOutputBuffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ FileOutputBuffer::create(StringRef Path, size_t Size, unsigned Flags) {
186186
case fs::file_type::regular_file:
187187
case fs::file_type::file_not_found:
188188
case fs::file_type::status_error:
189-
if (Flags & F_no_mmap)
189+
if (Flags & F_mmap)
190190
return createInMemoryBuffer(Path, Size, Mode);
191191
else
192192
return createOnDiskBuffer(Path, Size, Mode);

llvm/unittests/Support/FileOutputBufferTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ TEST(FileOutputBuffer, Test) {
123123
File5.append("/file5");
124124
{
125125
Expected<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
126-
FileOutputBuffer::create(File5, 8000, FileOutputBuffer::F_no_mmap);
126+
FileOutputBuffer::create(File5, 8000, FileOutputBuffer::F_mmap);
127127
ASSERT_NO_ERROR(errorToErrorCode(BufferOrErr.takeError()));
128128
std::unique_ptr<FileOutputBuffer> &Buffer = *BufferOrErr;
129129
// Start buffer with special header.

0 commit comments

Comments
 (0)