<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - lld-created binaries do not end up in disk cache (?)"
   href="https://bugs.llvm.org/show_bug.cgi?id=32718">32718</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lld-created binaries do not end up in disk cache (?)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>After linking Clang with ld.bfd or ld.gold, if I run the binary, it starts
~instantly. If I instead link with ld.lld, I incur a several second startup
time the first time I run the Clang binary, and 'perf' indicates the time is
spent paging in the binary.

Here's what ld.bfd does to create its output binary (when the output file
already exists):

stat("x", {st_mode=S_IFREG|0750, st_size=1079, ...}) = 0
lstat("x", {st_mode=S_IFREG|0750, st_size=1079, ...}) = 0
unlink("x")                             = 0
open("x", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3
fcntl(3, F_GETFD)                       = 0
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0640, st_size=0, ...}) = 0
lseek(3, 0, SEEK_SET)                   = 0
read(3, "", 64)                         = 0
lseek(3, 64, SEEK_CUR)                  = 64
write(3, "\1\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0"...,
120) = 120
# ... lots more seeking, reading, and writing on fd 3
write(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
448) = 448
close(3)                                = 0
stat("x", {st_mode=S_IFREG|0640, st_size=1079, ...}) = 0
umask(0)                                = 027
umask(027)                              = 0
chmod("x", 0750)                        = 0

Here's what ld.gold does:

stat("x", {st_mode=S_IFREG|0750, st_size=1079, ...}) = 0 
unlink("x")                             = 0
open("x", O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC, 0777) = 4
fstat(4, {st_mode=S_IFREG|0750, st_size=0, ...}) = 0
fallocate(4, 0, 0, 1072)                = 0
mmap(NULL, 1072, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = 0x7fdfec2db000
munmap(0x7fdfec2db000, 1072)            = 0
close(4)                                = 0

Here's what ld.lld does:

access("x", F_OK)                       = 0
access("xtmp5181559f", F_OK)            = -1 ENOENT (No such file or directory)
rename("x", "xtmp5181559f")             = 0
stat("x", 0x7ffd9649e180)               = -1 ENOENT (No such file or directory)
lstat("x", 0x7ffd9649e220)              = -1 ENOENT (No such file or directory)
open("x.tmp3566de2", O_RDWR|O_CREAT|O_EXCL|O_TRUNC|O_CLOEXEC, 0777) = 3
fallocate(3, 0, 0, 4736)                = 0
mmap(NULL, 4736, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x7fd09a5bf000
close(3)                                = 0
munmap(0x7fd09a5bf000, 4736)            = 0
rename("x.tmp3566de2", "x")             = 0


There are a few odd things here. Using temporary files (which sometimes get
left behind!) seems unnecessary and error-prone, and stat'ing a file we just
renamed seems pointless. But I suspect the slowness is caused either by the
rename or by the relative order of the close and munmap calls.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>