[PATCH] D125439: Ensure that the MRI CREATE/CREATETHIN commands overwrite the output file appropriately

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 19:05:27 PDT 2022


bd1976llvm created this revision.
Herald added a subscriber: rupprecht.
Herald added a project: All.
bd1976llvm requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

The CREATE/CREATETHIN commands should overwrite the output file appropriately: https://sourceware.org/binutils/docs/binutils/ar-scripts.html.

This fixes a regression for MRI scripts introduced in: https://reviews.llvm.org/D123142 which put logic into performWriteOperation. performWriteOperation is called for all MRI commands that write an archive out (one's with a SAVE command). performWriteOperation is unaware of MRI semantics and loads an existing archive if present. If an existing archive is loaded, llvm-ar checks the properties of the existing archive for decisions about the output archive (for example making the output archive thin if the existing one was). https://reviews.llvm.org/D123142 adds the following logic...

  if (OldArchive) {
    if (Thin && !OldArchive->isThin())
      fail("cannot convert a regular archive to a thin one");
  
    if (OldArchive->isThin())
      Thin = true;
  }

... which errors for a script with CREATETHIN in effect if there is an existing regular archive, and causes CREATE to output a thin archive if there is an existing thin archive.


https://reviews.llvm.org/D125439

Files:
  llvm/test/tools/llvm-ar/mri-create-overwrite.test
  llvm/tools/llvm-ar/llvm-ar.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125439.428835.patch
Type: text/x-patch
Size: 4378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220512/9e846549/attachment.bin>


More information about the llvm-commits mailing list